2013-07-30 50 views

回答

0

這可能意味着您的元素可見性被設置爲隱藏。或者它也可能意味着該元素當前不在視圖中,並且必須滾動到視圖中。

0

如果它是不可見的,而webdriver的期待與下拉然後互動:

一號通)你應該增加隱含等待時間,直到任何控制器出現在UI:

public Accesor(WebDriver driver,String url){ 
    this.driver = driver; 
    this.driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS); 
    driver.get(url); 
} 

2nd-)嘗試等待,直到該特定元素出現(但我wouldnt推薦): WebElement cBoxOverlay = wait.until(ExpectedConditions.visibilityOf(driver.findElement(By.id(「cboxOverlay」))));

3rd-)如果它是應用程序的真正bug並且UI沒有顯示您正在查找的下拉列表,那麼請嘗試處理這些類型的異常,方法是截取屏幕截圖並嘗試下一個測試用例或測試套件:

public void takePicture(){ 
    File scrFile = ((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE); 
    // Now you can do whatever you need to do with it, for example copy somewhere 
    try { 
     FileUtils.copyFile(scrFile, new File("c:\\tmp\\"+ getClass().getName().substring("com.automation.testsuite.".lastIndexOf(".")+1) + ""+new Date().toString().substring(0,10) +".png")); 
    } catch (IOException e) { 

     e.printStackTrace(); 
    } 
相關問題