0
votes

Hi I am trying to create automated test with selenium webdriver using Nodejs I am having problem selecting value from drop down menu My code to select value from drop down is

   await driver.findElement(By.name('state')).getText(5).cllick();

Basically there is a dropdown of all the states and I am trying to read the 5th state in the drop down. When I run this I can see dropdown to expand but nothing happens after that. Please let me know how I can read the state value from dropdown.

The code for drop down is select AK .......

1
Can you show the HTML? - Buaban
Please add the HTML code for dropdown. - Pradeep hebbar
Added the drop down code - J. Davidson

1 Answers

-1
votes

Try this -

Select dd = new Select(driver.findElement(By.id("your identifier")));
dd.selectByVisibleText("5");

You can also choose by index or value.