如何使用selenium webdriver选择多个下拉列表

时间:2013-11-15 04:20:52

标签: java jquery selenium selenium-webdriver

目前正致力于selenium webdriver。我正在尝试选择多个下拉列表,它是过滤器选择。一旦我选择了多个下拉列表,我将点击应用过滤器按钮,然后我将根据所选过滤器部分生成结果。所以我有问题选择多个下拉菜单,无法点击应用过滤器下拉列表。你能帮我弄清楚如何使用代码吗?我正在使用java

以下是我的示例代码:

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();

2 个答案:

答案 0 :(得分:0)

如下所示: -

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();

答案 1 :(得分:0)

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