Java 如何在Selenium中定位Telerik控件?
网址: 问题: 如何选择下拉列表值 我的代码:Java 如何在Selenium中定位Telerik控件?,java,selenium,selenium-webdriver,telerik,Java,Selenium,Selenium Webdriver,Telerik,网址: 问题: 如何选择下拉列表值 我的代码: Select dropdown = new Select(driver.findElement(By.xpath("//a[@class='rddlSlide']//span"))); dropdown.selectByVisibleText("Chai"); 如何选择下拉列表值 实际上,目标元素不是合适的元素,因此您无法处理使用类的情况 请尝试以下操作:- driver.get("http://demos.telerik.com/aspne
Select dropdown = new Select(driver.findElement(By.xpath("//a[@class='rddlSlide']//span")));
dropdown.selectByVisibleText("Chai");
如何选择下拉列表值
实际上,目标元素不是合适的
元素,因此您无法处理使用类的情况
请尝试以下操作:-
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();