I'm writing a functional automated test framework against a windows application using Typescript / selenium-appium / WinAppDriver. I've run into an issue where I need to perform a get all elements (findElements), and select a specific one based on the element's index. The issue I'm running into here is with passing the index of the element into a custom function I've written to select a dropdown element.
I must have the type incorrectly defined, or I'm passing the web element incorrectly, because I've tried several combinations of types:
Promise<WebElement[]>
WebElement[]>
Array<WebElement>
etc
Here's the function I wrote...
/**
* Standard function to handle selecting a dropdown item
*
* @param dropdown - The dropdown to expand
* @param dropdownItem - The actual item from the open dropdown
*
*/
async selectDropdownItem(dropdown: Promise<WebElement[]>, dropdownItem: string) {
if (dropdown instanceof WebElement) {
await dropdown.click;
}
await this.openButton.click();
await driver.findElement(By2.nativeName(dropdownItem)).click();
}
Here's the locator for the element I'm trying to pass into this function
async dropDowns() { return await this.driver.findElements(By2.nativeClassName('WindowsForms10.COMBOBOX.app.0.37504c8_r8_ad1')); }
Here's where I pass the element into the selectDropdownItem()
function I wrote above
await MainPage.selectDropdownItem(this.dropDowns[0],'Test Scenario 1');
The error is always the same, the type I pass into the function can't be resolved with the type I defined in the function. Anyone have any ideas?
I've tried using several different types for the parameter in the function definition, and I can't seem to land on one that can be resolved. I need to target specific indexes of the findElements returned array and pass those into my function to handle selecting the item from the dropdown.