-1

There are three dropdowns Pool,category,material

options in category dropdown loads when a pool is selected options in material dropdown loads when a category is selected

can seem to select a value on category

<div class="col-sm-4">
<select name="ctl00$body$txtCategory" onchange="javascript:setTimeout('__doPostBack(\'ctl00$body$txtCategory\',\'\')', 0)" id="body_txtCategory" class="form-control">
<option selected="selected" value="-1">-- Select Item --</option>
<option value="56">Poultry</option>
</select>
</div>

1 Answers1

1

You can select values from drop down using select in selenium web driver. senkeys not working for dropdown.

First you need to identify the drop down using select.You can select/deselect drop down value by using this.

SelectByVisibleText()/deselectByVisibleText() : selects/deselects an option by its displayed text

selectByValue()/ deselectByValue() : selects/deselects an option by the value of its "value" attribute

selectByIndex()/ deselectByIndex() : selects/deselects an option by its index

Select drpCountry = new Select(driver.findElement(By.id("body_txtCategory")));
drpCountry.selectByVisibleText("Poultry"); 
Dhru 'soni
  • 1,024
  • 7
  • 23