Error: org.openqa.selenium.ScriptTimeoutException: 脚本超时

huangapple go评论61阅读模式
英文:

Error : org.openqa.selenium.ScriptTimeoutException: script timeout

问题

我正在使用带有Java的Selenium WebDriver。在10次中,有7次我的脚本失败并显示以下错误:

org.openqa.selenium.ScriptTimeoutException: 脚本超时

我尝试了很多选项:

  1. 增加等待时间
  2. 尝试了方法jsWaitForPageToLoad并验证js.executeScript("return document.readyState").toString().equals("complete")
  3. 等待元素可见
  4. 等待元素可点击
  5. 等待最后一个元素加载

但是没有任何作用。

解决方法:如果我手动在浏览器上微调鼠标,那么脚本就可以正常运行。

根据上述解决方法,我还尝试了使用Action类来移动鼠标,但没有起作用。

环境:Chrome版本:85.0.4183.83(官方版本)(64位)
Selenium WebDriver:3.141.59
应用程序:使用Angularjs开发

我还使用了ngwebdriver(1.1.5)用于AngularJs。

非常感谢任何帮助。

英文:

I am using selenium webdriver with Java. 7/10 times my script failed with error:

org.openqa.selenium.ScriptTimeoutException: script timeout

I tried so many option :

  1. increase wait time
  2. tried method jsWaitForPageToLoad and verified js.executeScript(""return document.readyState"").toString().equals("complete")
  3. Wait for element to visible
  4. wait for element to be Clickable
  5. Wait last element to load

but nothing worked.

Workaround : If I manually move my mouse little bit on browser then script work without issue.

As per above workaround, I tried Action class to move mouse also , but its not worked.

Env : Chrome : Version 85.0.4183.83 (Official Build) (64-bit)
Selenium Webdriver : 3.141.59
Application : Developed in Angularjs

I also used ngwebdriver (1.1.5) for angularJs

Any help is highly appreciated

答案1

得分: 1

问题已解决。问题出在ngDriver的waitForAngularRequestsToFinish()方法上。

一旦我使用如下方式:

ngDriver.withRootSelector("root-app").waitForAngularRequestsToFinish();

它就正常工作了。

英文:

Issue got fixed. The issue was with waitForAngularRequestsToFinish() method of ngDriver.

Once I used as below :

ngDriver.withRootSelector(""root-app"").waitForAngularRequestsToFinish();

It worked well

答案2

得分: -1

你的问题是因为使用了前端技术(AngularJS)而变得不稳定。

自动化测试Angular Web应用的最佳工具是Protractor。

英文:

Your problem is a flaky one because of the front end technology used (angular js).

The best tool to automate agular web app is Protractor.

huangapple
  • 本文由 发表于 2020年9月9日 01:27:06
  • 转载请务必保留本文链接:https://go.coder-hub.com/63798832.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定