I am working on automation, while automating a form with number of drop-down's.

The problem with me is, when run the code in maximize mode of window it gives me an Error:

org.openqa.selenium.NoSuchElementException: Cannot locate element with text: Computers

Build info: version: '2.44.0', revision: '76d78cf', time: '2014-10-23 20:03:00' System info: host: 'Rajesh-PC', ip: '', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.8.0_31' Driver info: driver.version: unknown

It touches the drop-down but the value is not being clicked.

But when I run same code in minimized window it execute all code successfully without any error, please go-through code of one drop-drown.

new Select(driver.findElement(By.name("industrySectorsector"))). selectByVisibleText("Computer Software");
driver.findElement(By.cssSelector("select[name=\"industrySector-sector\"] > option[value=\"Computer Software\"]")).click();

HTML code:

<div id="industrySectorFilter" class="custom-select select-width" name="select-type">
<select class="" name="industrySector-sector">
    <option value="0">Industry Sector * </option>
    <option data-type="43" data-id="1" value="Accounting - Finance">Accounting - Finance</option>
    <option data-type="43" data-id="2" value="Advertising">Advertising</option>
    <option data-type="43" data-id="3" value="Agriculture">Agriculture</option>
    <option data-type="43" data-id="4" value="Airline - Aviation">Airline - Aviation</option>
    <option data-type="43" data-id="5" value="Appliance">Appliance</option>
    <option data-type="43" data-id="7" value="Architecture - Building">Architecture - Building</option>
    <option data-type="43" data-id="8" value="Art - Photography - Journalism">Art - Photography - Journalism</option>
  • Add your HTML code also with question. Mar 2, 2015 at 10:11
  • That's not HTML :( Mar 2, 2015 at 21:49
  • It was HTML code, but it was not in a code block and thus most was stripped away. Mar 3, 2015 at 9:32
  • Can you check the webelement is visible on the page maximize?
    – saikrishna
    Mar 3, 2015 at 9:33
  • the web element are visible,it goes to the drop down selects it then goes to desired option highlights it. but doesn't get select.but the same code works in minimized screen Mar 3, 2015 at 11:05

3 Answers 3


Its very hard to answers questions like this, without being able to debug and run the test code it self, but here is a try going over your code top to bottom:

  1. Why are you using a sleep?


Here you want to wait for the element to be visible as describe in the post: http://software-testing-tutorials-automation.blogspot.nl/2014/02/selenium-webdriver-how-to-wait-till.html

WebDriverWait wait = new WebDriverWait(driver, 15);

Because maybe waiting 4 seconds is not enough when the screen is maximized, while it is when its minimized?

  1. The select the dropdown works a bit simpler according to this post: https://stackoverflow.com/questions/12940592/how-to-select-an-item-from-a-dropdown-list-using-selenium-webdriver-with-java

You only need the following code:

Select dropdown = new Select(driver.findElement(By.name("industrySector-sector")));
dropdown.selectByVisibleText("Computer Software");

There is a - missing in the By.Name in your example code

I think you do not even need to click it to open, unless the onClick triggers an event to populate it.

  1. You don't need to click on the dropdown element again afterwards, this is what the selectByVisibleText function is for

  2. Also I do not see a option Computer Software in your HTML snippet, maybe its correct this option is missing?

  • Hi Niels,Thanks for your response 1>I used Thread.sleep(1000*4); basically to see execution steps are working step by step in proper way no other operation is perform during that time. 2>As suggested it tried the given code i.e Select dropdown = new Select(driver.findElement(By.name("industrySector-sector"))); dropdown.selectByVisibleText("Computer Software"); but am using same issue,i.e it works in minimize mode..( 3>option Computer software is missing, but its the same drop-down list was huge so ,I put part of code. Mar 4, 2015 at 6:06
  • I am also bit confused about this situation,how does a runs successfully in minimized mode of window and fails in maximize. Thinks which ,I think would cause error may be, 1> customize Drop-down. 2> When the page loads their a small bar which gets loaded after few seconds when the operation is stared. but again the same question,that the bar also runs in minimized mode that time the code works fine, also in maximized mode the bar gets loaded, the code gets executed,selects drop-down goes to option,but option doesn't get selected on click. Mar 4, 2015 at 6:06
new Select(driver.findElement(By.name("industrySectorsector"))). selectByVisibleText("Computer Software");

I don't see "Computer Software" in your HTML file.

Maybe try "div + select > option" for your selector. So...

Driver.FindElements(By.CssSelector("div + select > option")); 

to get all option elements, and then you can iterate through them calling getAttribute("value") to get the text.


@Rajesh, Below solution works for me:

var myDropdownOption = driver.findElements(By.name("industrySector-sector")).Where(x => x.GetProperty("value").ToString().Contains("Computer Software")).First();*


Give a try !

Not the answer you're looking for? Browse other questions tagged or ask your own question.