How to use watir-webdriver to wait for page load

后端 未结 7 1856
后悔当初
后悔当初 2021-02-01 21:34

Using watir-webdriver, how do I wait for a page to load after I click a link?

At the moment I am using:

sleep n

But this is not ideal a

7条回答
  •  野的像风
    2021-02-01 22:20

    This is how I wait for AJAX in my project:

    ajax_loader = $b.element(:xpath  => "//*[@id='spinner-modal-transparent' and @aria-hidden='true']/div/div/div/div/img[@alt='Ajax transparent loader']")
    
    if ajax_loader.exists?
      ajax_loader.wait_while_present(timeout=350)
    else
      puts "The AJAX loader was not present."
    end
    

提交回复
热议问题