Do we have any generic function to check if page has completely loaded in Selenium

前端 未结 5 1209
清歌不尽
清歌不尽 2020-11-21 22:56

I am trying to check if web page is loaded completed or not (i.e. checking that all the control is loaded) in selenium.

I tried below code:

new WebDr         


        
5条回答
  •  感情败类
    2020-11-21 23:40

    Something like this should work (please excuse the python in a java answer):

    idle = driver.execute_async_script("""
      window.requestIdleCallback(() => {
        arguments[0](true)
      })
    """)
    

    This should block until the event loop is idle which means all assets should be loaded.

提交回复
热议问题