我有一个正在测试的应用程序,它有一个iFrame,注入了Angular应用程序。我的测试套件在Java Selenium中,我发现很难操纵角度应用程序中的控件。
我已经单独使用了量角器和硒,但是这种情况下,我发现很难找到解决方案。
我的问题是:
非常感谢任何帮助。
答案 0 :(得分:1)
我们还使用Selenium& amp ;;自动化Angularjs应用程序。 java的。我们编写了自己的同步并等待加载功能如下:
public void Sync()
{
//waitForLoading();
try
{
JavascriptExecutor js = (JavascriptExecutor)driver;
WebDriverWait wait = new WebDriverWait(webDriver, 300);//timeoutInSeconds
wait.Until(js.executeScript("return document.readyState").toString().equals("complete"));
Thread.sleep(4000);
}
catch
{
Thread.sleep(16000);
}
}
//Another version of the same function based on time based polling to make it more dynamic
public void checkPageIsReady() {
JavascriptExecutor js = (JavascriptExecutor)driver;
//Initially bellow given if condition will check ready state of page.
if (js.executeScript("return document.readyState").toString().equals("complete")){
System.out.println("Page Is loaded.");
return;
}
//This loop will rotate for 25 times to check If page Is ready after every 1 second.
//You can replace your value with 25 If you wants to Increase or decrease wait time.
for (int i=0; i<25; i++){
try {
Thread.sleep(1000);
}catch (InterruptedException e) {}
//To check page ready state.
if (js.executeScript("return document.readyState").toString().equals("complete")){
break;
}
}
}