Хабр Курсы для всех
РЕКЛАМА
Практикум, Хекслет, SkyPro, авторские курсы — собрали всех и попросили скидки. Осталось выбрать!
int timeoutIC = 5; //max number of iterations
Boolean flg = true; //success flag
int h = 0;
WebElement win = null;
while ((flg)&&(h < timeoutIC))
{
win = attachN(_webDriver,winName);//_webDriver - current attached driver, winName - Name of the target window
if (win == null)
{
log("Window was not found, waiting further");
//optional - Thread.sleep(...) here, but not necessary
h++;
}
else
{
log("Window found");
flg = false;
}
}
if (flg){
throw new Exception("The window was not appeared in time");
}
/* the rest of your code*/
public static WebElement attachN(WebDriver _driver, String _name){
log("Attaching to element ...");
try{
WebElement res = _driver.findElement(By.name(_name)); //will wait for window to appear for predefined time, will throw exception if window was not found
return res;
}
catch(Exception ex){
log("... window was not found");
return null;
}
}
Автоматизация тестирования Windows-приложений с использованием Winium