4

I am trying to select a particular values from 2 Ajax drop down fields.First drop down option list getting open but doesn't select option, that's why second drop down list is not binding and error occurred as

org.openqa.selenium.NoSuchElementException: Unable to locate element: option[value="111"].

Please help me.. I am new on selenium

Here is my code..

Code

HTML Block:

HTML block

3
  • what is the error are you getting when try using selectByVisibleText???CommentedAug 26, 2016 at 2:41
  • Hi Swa, and welcome to Stack Overflow. Rather than posting your html code and webdriver code as screenshots, your question would be better if you pasted the code - just the relevant bits - into your question using markdown.CommentedAug 26, 2016 at 9:05
  • @swa as you have solved this, add it as solution and mark it as answer. it will help other users to debug on it. also do add more clarification on the versions you have used in the environment. :)
    – jit
    CommentedSep 18, 2016 at 9:20

2 Answers 2

3

This issue occurred because of Firefox browser(version 45) compatibility issue. I am using selenium 3.0.0-beta2 and test against Firefox 45.0.2

When tried geckodriver (version 0.10.0)for OS windows 10 -64 bit, it seems something not work. It only works with Firefox 48 or onwards. It successfully working on chromedriver

    0

    You can try a more specific way to interact with dropdowns in selenium. Try something like this:

    Select dropdown = new Select(driver.findElement(By.id("cmbJob"))); dropdown.selectByValue("111"); 

    You can even define a function for working with dropdwns:

    protected void chooseOptionInSelectByValue(String selectId, String valueString) { Select dropdown = new Select(driver.findElement(By.id(selectId))); dropdown.selectByValue(valueString); } 

    So you can use the function like this

    chooseOptionInSelectByValue("cmbJob","111"); 

    Selenium dropdown object has many other options like selectByText, etc. Check it in the API here: https://seleniumhq.github.io/selenium/docs/api/java/org/openqa/selenium/support/ui/Select.html

    10
    • tried above solution .and selectByVisibleText, by using Xpath too but still same error occurred...Please suggest me
      – Swa
      CommentedAug 24, 2016 at 8:18
    • @ Ricardo..Thank you so much for reply.. There is a one hidden div before 'first drop down' div. Is there any problem because of that hidden div?
      – Swa
      CommentedAug 24, 2016 at 9:49
    • @Swa this should not be a problem. But check your html because i can see two select with name="cmbJob". You can check if new Select(driver.findElement(By.id(selectId))) finds the right dropdown printing to a log or system.out its elements with 'dropdown.getOptions()'. see seleniumhq.github.io/selenium/docs/api/java/org/openqa/selenium/…CommentedAug 24, 2016 at 13:34
    • @ Ricardo..tried lots of solutions..still unable to select drop down values..i am stuck on this..Please help me...
      – Swa
      CommentedAug 25, 2016 at 9:51
    • @Swa Did you check if new Select(driver.findElement(By.id(selectId))) finds the right dropdown?CommentedAug 25, 2016 at 9:54

    Start asking to get answers

    Find the answer to your question by asking.

    Ask question

    Explore related questions

    See similar questions with these tags.