SelectElement method is not available in WinAppDriver
In Selenium Webdriver we have in built SelectElement() method and using this we can call SelectByText(), SelectByValue(), SelectByIndex() methods. Please find the below screenshot. This methods will work for IWebElement. How can i use same methods for WindowElement. When i try to use this i am getting an error for combobox selection.
WinAppDriver team provided Click, SendKeys, Clear, Text, Displayed methods like we have in Selenium webdriver but i don't see any method like SelectElement() in WinAppdriver. If this method is available then we can easily select items from list.
Please find the below Selenium Webdriver code screenshot.
Here is the code to work with combo boxes.
comboBoxElement1.Click(); //Click on Combo Box
comboBoxElement1.FindElementByName("Yellow").Click(); // Select 'Yellow' value from comboBox
Assert.AreEqual("Yellow", comboBoxElement1.Text);
In my project, I used following code under library class.
public static void SetDropDownValue(WindowsElement windowsElement, string dropDownValue) { try {
windowsElement.SendKeys(Keys.F4); //F4 is default key to expand combo boxes for any win application
Thread.Sleep(500);
windowsElement.FindElementByName(dropDownValue).FindElementByClassName("ListBoxItem").Click();
//Assert.AreEqual(dropDownValue, windowsElement.Text);
}
catch (Exception err)
{
Assert.Fail($"Unable to select text value {dropDownValue} in the dropdown {windowsElement}" + err.Message);
}
}
Thanks VijayHugar.
I tried similar way and I am able to handle the drop downs using below code. Closing this issue.
WindowsElement ServiceType = App_Session.FindElementByAccessibilityId("SubdividedMap");
ServiceType.Click();
App_Session.FindElementByXPath("/Pane[@ClassName="#32769"][@Name="Desktop 1"]/List[@ClassName="Internet Explorer_Server"]/ListItem[@Name="Map Book"]").Click();
For the above solution , I received classcastException in Java. How can we initiate windowsElement in Java?
@ssaravanak Please share your code