Stop loading page watir-webdriver

后端 未结 3 561
走了就别回头了
走了就别回头了 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条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-17 07:47

    You can use the Timeout class to force it to give up after waiting a reasonable amount of time (and this is internally how Watir performs it's waits as well)

    begin
      Timeout::timeout(10) do
        # perform actions that may hang here
      end
    rescue Timeout::Error => msg
      put "Recovered from Timeout"
    end
    

提交回复
热议问题