Trying to select a word inside a dropdown menu.
In Webdriver IDE appear this to click the dropdown (which Id is "p" and the to click the word "Barcelona" inside the dropdown.:
I just can open the dropdown menu using:
driver.FindElement(By.Id("p")).Click();
Now I'm trying to select a word inside this dropdown menu, using "selectelement" and "select visibleText" but does not work in C# Webdriver for me.
SelectElement selector = new SelectElement.selectByVisibleText("Barcelona");
Any helps please?
Using C# Webdriver and not java.
I think the problem is in the SelectElement initialization. You can try the following code:
If you are new in the C# WebDriver API, you can find the following article useful: http://automatetheplanet.com/getting-started-webdriver-c-10-minutes/
In WebDriver.Support.dll Version: 3.1.0 we have SelectElement class. SelectElement mainly three methods.
Please find the methods:
Code samples: SelectByIndex
Code samples: SelectByText
Code samples: SelectByValue
Please find attached photo for your reference Sample Image
Further clarification and other methods Refer