Selenium - don't wait until all elements are presented

天大地大妈咪最大 提交于 2019-12-07 13:29:00

问题


Selenium by default is waiting for all elements to be loaded. Is there any way for waiting for a specific element and then to proceed on? On my test, selenium is waiting with the wait() function for a page to be loaded. sometimes, some images couldn't be loaded from a remote server, while all others element on the page loaded successfully. How can I ask Selenium to ignore waiting all elements except a specific one?


回答1:


Selenium works on a copy of the page's source so it try to wait until the DOM represents what will be the page's full source. For this to work correctly selenium is bases on the document.readyState:

  • uninitialized, loading, loaded (waiting)
  • interactive, complete (working).

this behavior is mandatory for work, otherwise the next scenarios might occur and break tests:

  1. Ajax requests that do not return.
  2. Accessing unready elements might cause stale element exceptions.


来源:https://stackoverflow.com/questions/25018868/selenium-dont-wait-until-all-elements-are-presented

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!