Reputation: 11
URL : http://demos.telerik.com/aspnet-ajax/dropdownlist/examples/overview/defaultcs.aspx
Question : How to select dropdown value?
My Code:
Select dropdown = new Select(driver.findElement(By.xpath("//a[@class='rddlSlide']//span")));
dropdown.selectByVisibleText("Chai");
Upvotes: 1
Views: 526
Reputation: 23825
How to select dropdown value?
Actually target element is not proper <select>
element, Hence you can't handle is using Select
class.
Try as below :-
driver.get("http://demos.telerik.com/aspnet-ajax/dropdownlist/examples/overview/defaultcs.aspx");
driver.manage().window().maximize();
WebDriverWait wait = new WebDriverWait(driver, 60);
//This line would find the dropdown element and open the options
wait.until(ExpectedConditions.elementToBeClickable(By.id("ctl00_ContentPlaceholder1_RadDropDownProducts"))).click();
//This line would select the desire option using their text
wait.until(ExpectedConditions.elementToBeClickable(By.xpath("//li[text() = 'Chai']"))).click();
Upvotes: 1