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
to work, as commented in the below (simplified) script.
require "rubygems"
require "watir-webdriver"
b = Watir::Browser.new(:chrome)
site = "www.example.com"
b.goto site
puts "Click on Sign In button"
b.link(:id, 'btnLogin').click
puts "Waiting for the username/password dialog to show up"
# Below line does *not* work
# Throws this error: "uninitialized constant Watir::Waiter (NameError)"
Watir::Waiter::wait_until { b.text_field(:id, 'username').exists? }
# Below line does *not* work
# Throws this error: "undefined method `wait_until' for main:Object (NoMethodError)"
wait_until { b.text_field(:id, 'username').exists? }
# Below line *does* work, but I don't want to use it.
sleep 1 until b.text_field(:id, 'username').exists?
Is Watir::Waiter
an IE-only class? Or what am I doing wrong, the sleep 1
wait method works just fine. I am new to Ruby and watir, I literally just picked this up yesterday so I'm half expecting this to be a result of my noobaciousness.
In case it is relevant, I am working on a mac (OSX v. 10.6.5).
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…