Manmit Shelar
Manmit Shelar

Reputation: 11

How to locate Telerik controls in Selenium?

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

Answers (1)

Saurabh Gaur
Saurabh Gaur

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

Related Questions