2013-11-15 87 views
0

目前正在selenium webdriver工作。我正在嘗試選擇多個下拉菜單,並且它是篩選器選擇。一旦我選擇了多個下拉列表,我將點擊應用濾鏡按鈕,然後我將根據所選濾鏡部分產生結果。所以我越來越難以選擇多個下拉菜單,並且無法點擊應用過濾器下拉菜單。你能幫我弄清楚如何使用代碼。我用java如何選擇使用硒webdriver多個下拉

這裏是我的示例代碼:

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

我們需要知道你做了什麼錯誤,也可能是HTML –

+0

org.openqa.selenium.ElementNotVisibleException:元素當前不可見,因此可能不會與 交互命令持續時間o r timeout:16毫秒 – Amirdha

+0

如果添加driver.manage()。timeouts()。implicitlyWait(30,TimeUnit.SECONDS); – Amirdha

回答

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

我在我的代碼中使用了上述代碼,但遇到了如下錯誤,等待元素可點擊10秒後超時:By.id:visualizationId – Amirdha

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 
相關問題