0
WebDriver driver=new FirefoxDriver();
driver.get("http://192.168.0.133/tiyorelease3");
WebElement ListBox = driver.findElement(By.className("dropdown-toggle"));       Select Select = new Select(ListBox);
Select.selectByVisibleText("Bangalore");
3
  • Add a snippet of your HTML code please. Commented May 31, 2017 at 10:15
  • <a id="supported_city_label" aria-expanded="false" aria-haspopup="true" role="button" data-toggle="dropdown" class="dropdown-toggle">Kolkata<span class="caret"></span></a> Commented May 31, 2017 at 10:21
  • @PremkumarYadav I am unable to connect to http://192.168.0.133/tiyorelease3. Can you please confirm its a public URL? Thanks Commented Jun 2, 2017 at 14:16

1 Answer 1

1

This exception generally occurs when we use Select command to select dropdowns which are not built by using "select" tag.

You can try by using sendkeys to select dropdown, just give displayed text of option in sendkeys.

If above does not work, then go for click on dropdown and again click on required option.

If it is auto complete dropdown, then click on that dropdown input box and go for senkeys char by char with small sleep, so that required option will be displayed.

You can try following code in your case:

WebElement ListBox = driver.findElement(By.className("dropdown-toggle")); 
ListBox.sendKeys("Bangalore");
Sign up to request clarification or add additional context in comments.

1 Comment

Code is added in the answer

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.