How do I use Watir::Waiter::wait_until to force Chrome to wait?

前端 未结 3 1385
南笙
南笙 2020-12-14 03:01

I\'m trying to tell my watir script to wait for an ajax-injected login box to open up. I am using watir-webdriver, and testing in Chrome. I cannot get wait_until

相关标签:
3条回答
  • 2020-12-14 03:26

    I run into the same issue few weeks ago. The point is that Watir::Wait.until{} waits ONLY for the main page to load (tested mainly on Firefox). If you have some JavaScript code loading other components, these are not waited for.

    So, the only solution is to pick and element and explicitly wait for it to appear (using methods 2 & 3).

    0 讨论(0)
  • 2020-12-14 03:31

    You can also set timeout with browser.it will wait for it 700 seconds, like this.

    client = Selenium::WebDriver::Remote::Http::Default.new
    client.timeout = 700 # seconds � default is 60 second
    ie=Watir::Browser.new:firefox, :http_client => client
    
    0 讨论(0)
  • 2020-12-14 03:40

    Do this first:

    require "watir-webdriver/wait"
    

    Then try these:

    1

    Watir::Wait.until { ... }
    

    2

    browser.text_field(:id => 'username').when_present.set("name")
    

    3

    browser.text_field(:id => 'username').wait_until_present
    

    Note that "present" here means "the element both exists and is visible".

    0 讨论(0)
提交回复
热议问题