Not able to select value from drop down menu



  • https://demo.guru99.com/test/newtours/register.php

    I was trying to automate the drop down country menu on this page but am unable to select any value from the drop down.

    code used

    Eclipse is throwing the following error:

    Exception in thread "main" java.lang.NoSuchMethodError: 'java.lang.String org.openqa.selenium.WebElement.getDomAttribute(java.lang.String)' at org.openqa.selenium.support.ui.Select.(Select.java:54) at ui.DropDown1.main(DropDown1.java:23)

    I can click on the drop down menu but it does not select any value. neither does it print the values of drop down menu stored in List.



  • The way you have created the Select object will need change

    Select countrySel=new Select(driver.findElement(By.name("country")));
    countrySel.selectByValue("Antarctica");
    

    I hope this should help.




Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2