Reputation: 626
I tried to select an item from a combo box through selenium driver with java, but it didn't work.
This is my code...
combo box list = {NIC, NAME, AGE};
driver.findElement(By.xpath("//div[@id='views/div/select']/label")).sendKeys("NIC");
Upvotes: 3
Views: 21935
Reputation: 5667
In WebDriver there is separate Class (Select) is there to deal with Combo lists.
Use below logic to select options from pick list fields
Select select=new Select(driver.findElement(By.xpath("//div[@id='views/div/select']"));
select.selectByVisibleText("NIC");
or
select.selectByIndex(0);
or
select.selectByValue("value");
Refer this post for more info regarding Select class.
Upvotes: 6