Stop loading page watir-webdriver

后端 未结 3 566
走了就别回头了
走了就别回头了 2020-12-17 06:58

Is there a way to stop loading a page with watir-webdriver on firefox? Or is there a way to force something in my script even if the page is still loading? At a point in my

3条回答
  •  难免孤独
    2020-12-17 07:43

    If the website hangs, you should be able to use a wait method to timeout the script if an element does not appear. These are mainly used as an answer to AJAX, but they should work for this condition as well. For example, if the script hangs after you click a link, and you expect the next page to have a specific title or text:

    @browser.link(:name => "Let's Hang!").click
    Watir::Wait.until(30) { @browser.title == "new page" }
    

    or

    Watir::Wait.until(30) { @browser.text.include? ("confirmation text") }
    

    or

    @browser.image(:src => "awesome.jpg").wait_until_present(30)
    

    Each of these will wait 30 seconds for the condition to be met before exiting with an error. You can change the time (30) to exit within your app's hang window.

提交回复
热议问题