How do I make use of selenium select dropdown?

379    Asked by RickNovak in QA Testing , Asked on Oct 20, 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 Stacy Reed

I'm assuming you're using Firefox? Right-click the drop-down list and select "Inspect Element" for the selenium select dropdown. 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