How can I select the option of selenium select drop down?

509    Asked by AndrewJenkins in QA Testing , Asked on Apr 25, 2022

I'm using the Selenium IDE to record my initial tests and then export them to c# and then use the webdriver. Some things that I do from the IDE don't export.


I am trying to select a State from a drop-down text list. I don't have much background in HTML and am kind of new to C# also (I've programmed for a couple semesters in Java so far, c# for about a month.) How would I go about selecting a specific state from the dropdown list?

Answered by Andrew Jenkins

I'm assuming you're using Firefox? Right-click the selenium select drop down list and select "Inspect Element". Get the tag from the information (everything in green following the pound sign). Then add this to your code where you need to select the element


new SelectElement(driver.FindElement(By.Id("{put your tag information here}"))).SelectByText("{State here}");

Your Answer

Interviews

Parent Categories