我的時區下午好。不穩定的測試Selenium
我開始使用Selenium來測試我的Web應用程序。我正在使用WebDriver API和IEDriverServer.exe。操作系統 - > Windows XP 主要問題是測試不穩定。有時運行,有時會拋出異常。例如,這是測試不穩定的常見地點。 我必須打開一個新窗口並開始履行一些領域。
driver.findElement(By.xpath("//input[@name='"+button+"' and @type='button']")).click();//BUTTON THAT OPENS THE NEW WINDOW
long initDate = System.currentTimeMillis();
while(driver.getWindowHandles().size() <= numberPopUps){
Thread.sleep(500);
//15 seconds waiting for the pop-up
if((System.currentTimeMillis() - initDate) > 15000){
throw new Exception("Timeout to open popup");
}
}
for(String winHandle : driver.getWindowHandles()){
if(!winHandle.equals(mWindow)){
driver.switchTo().window(winHandle);
break;
}
}
driver.manage().timeouts().pageLoadTimeout(10, TimeUnit.SECONDS);//WAIT THAT THE PAGE COMPLETELY LOAD
wait.until(ExpectedConditions.presenceOfElementLocated(By.xpath("//input[@name='descricaoMov']")));//VERIFY IF THIS INPUT IS ON THE DOM
`driver.findElement(By.xpath("//input[@name='descricaoMov']")).sendKeys("TESTE SELENIUM");`//This is where sometimes the test throws exception saying that is unable to find this element
,我想問這怎麼可能?
預先感謝 問候
有幾件事情映入腦海。你的while循環只是複製'WebDriverWait' /'FluentWait'中的代碼 - 它被設計用於在這種情況下「等待」。其次,什麼版本的IE?第三是什麼版本的IE驅動程序?另外,你會得到什麼錯誤?每次都是一樣的嗎?如果不是,那是什麼?它多久失敗一次?每2次運行?每10次運行?最後,你有沒有正確設置你的保護模式設置? – Arran
版本的IE 8 IE驅動程序版本2.39 錯誤時發生的總是相同的「WebElement‘輸入[@名稱=’descricaoMov‘’」沒有找到 我沒有因爲IEDriver頁面配置任何保護模式設置規範沒有說任何與Windows XP相關的任何內容僅針對高級版本 – tt0686