简体   繁体   English

如何使用Selenium WebDriver选择多个下拉菜单

[英]How to Select Multiple dropdowns using selenium webdriver

Currently am working on selenium webdriver . 目前正在开发selenium webdriver I am trying select the multiple dropdowns and it is the filter selection. 我正在尝试选择多个下拉列表,这是过滤器选择。 once i selected multiple dropdown i will click on Apply Filter button then i will produce the result based on the selected filter section. 一旦选择了多个下拉菜单,我将单击“ 应用过滤器”按钮,然后将基于所选过滤器部分产生结果。 so i am getting problem to select multiple drop down and can't able to click on Apply filter dropdown. 所以我在选择多个下拉列表时遇到问题,无法单击“ 应用过滤器”下拉列表。 Could you please help me to figure out how to use the code. 您能否帮助我找出如何使用代码。 am using java 我正在使用Java

Here is my sample code: 这是我的示例代码:

driver.findElement(By.id("ext-new-prs")).click();
new Select(driver.findElement(By.id("visualizationId"))).selectByVisibleText("Center");
new Select(driver.findElement(By.id("periodId"))).selectByVisibleText("Last 52 Weeks");
new Select(driver.findElement(By.id("topographyId"))).selectByVisibleText("Center");
driver.findElement(By.cssSelector("#topographyId > option[value=\"center\"]")).click();
new Select(driver.findElement(By.id("centerId"))).selectByVisibleText("OAB");
new Select(driver.findElement(By.id("featureRequestId"))).selectByVisibleText("Include");
driver.findElement(By.id("kpiFilterSubmit")).click();

Something like below:- 如下所示:

Actions actions = new Actions(driver);
WebElement dBox1= (new WebDriverWait(driver,10)).until(ExpectedConditions.elementToBeClickable(By.id("visualizationId"))).selectByVisibleText("Center");
actions.moveToElement(dBox1);
actions.click();
actions.perform();
public static void waitforElement (WebDriver driver , int Seconds , String Locator )
{
WebDriverWait wait=new WebDriverWait(driver, Seconds);
wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath(Locator)));
}
use this method
waitforElement(driver,30,"//div[@id='divGrid']");
call like this
By sundar
www.mjksundar.weebly.com

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM