WinAppDriver icon indicating copy to clipboard operation
WinAppDriver copied to clipboard

SelectElement method is not available in WinAppDriver

Open dillibabu123 opened this issue 7 years ago • 4 comments

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. SelectElement

dillibabu123 avatar Sep 23 '19 15:09 dillibabu123

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);
        }

    }

VijayHugar avatar Oct 01 '19 13:10 VijayHugar

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();

dillibabu123 avatar Dec 21 '19 09:12 dillibabu123

For the above solution , I received classcastException in Java. How can we initiate windowsElement in Java?

ssaravanak avatar May 26 '21 21:05 ssaravanak

@ssaravanak Please share your code

Shakevg avatar May 28 '21 18:05 Shakevg