Dropdown selection | Selenium Forum
M
Posted on 02/11/2016
I want to select the value "COSTCO_SUMNER_SL_002" from the below drop down by using the value "COSTCO_SUMNER_SL_002".

<div>
<select class="form-control" id="scanStationId" name="scanStationId"><option value="493">COSTCO_SUMNER_RFScan</option>
<option value="491">COSTCO_SUMNER_SL_001</option>
<option value="492">COSTCO_SUMNER_SL_002</option>
<option value="496">COSTCO_SUMNER_SL_010</option>
</select>
</div>

The below code is working .But i want to use COSTCO_SUMNER_SL_002 instead of 492
Select dropdown = new Select(driver.findElement(By.xpath("//*[@id='scanStationId']")));
dropdown.selectByValue("492");

Please help

Thanks,
Kannan C
kanna C

M
Replied on 02/11/2016

have you tried this option??

Select dropdown = new Select(driver.findElement(By.xpath("//*[@id='scanStationId']")));

[u:l2xh4xil][b:l2xh4xil]dropdown.selectByVisibleText("COSTCO_SUMNER_SL_002");[/b:l2xh4xil][/u:l2xh4xil]


M
Replied on 02/11/2016

I just tried and worked. Thanks a lot