How to use watir-webdriver to wait for page load

后端 未结 7 1880
后悔当初
后悔当初 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:18

    The best summary is found in "Waiting".

    This is it in a nutshell:

    require 'watir-webdriver'
    b = Watir::Browser.start 'bit.ly/watir-webdriver-demo'
    b.select_list(:id => 'entry_1').wait_until_present
    b.text_field(:id => 'entry_0').when_present.set 'your name'
    b.button(:value => 'Submit').click
    b.button(:value => 'Submit').wait_while_present
    Watir::Wait.until { b.text.include? 'Thank you' }
    

提交回复
热议问题