selenium implicitly wait doesn't work

元气小坏坏 提交于 2019-11-29 16:06:09

As you mentioned in your question it takes too much time to load the whole page(especially when some resource is unavailable) is pretty much possible if the Application Under Test (AUT) uses JavaScript or AJAX Calls.

  • In your first scenario you have induced both set_page_load_timeout(5) and set_script_timeout(5)

Hence the Application Under Test being dependent on JavaScript or AJAX Calls in presence of both the conditions raises TimeoutException.

WARNING : Do not mix implicit and explicit waits. Doing so can cause unpredictable wait times. For example setting an implicit wait of 10 seconds and an explicit wait of 15 seconds, could cause a timeout to occur after 20 seconds.

Solution :

The best solution would be to remove all the instance of implicitly_wait(time_to_wait) and replace with WebDriverWait() for a stable behavior of the Application Under Test (AUT).


Update

As per your counter question, the current code block looks perfect. The measurement of time which you are seeing as time used: 44.6049938202 s is the time required for the Web Page to load completely and functionally that is the time required for the Client (i.e. the Web Browser) to return back the control to the WebDriver instance once 'document.readyState' equals to "complete" is achieved. Selenium or as an user you have no control on this rendering process. However for a better performance you may follow the best practices as follows :

  • Keep your JDK version updated currently Java SE Development Kit 8u162
  • Keep your Selenium Client version updated currently selenium 3.9.0
  • Keep your WebDriver version updated.
  • Keep your Web Browser version updated.
  • Clean you Project Workspace within your IDE regularly to build your project with required dependencies only.
  • Use CCleaner tool to wipe away the OS chores before and after your Test Suite execution.
  • If your Web Browser base version is too old uninstall the Web Browser through Revo Uninstaller and install a recent GA released version of the Web Browser.
  • Execute your Test.
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!