#
# Waits until the element is present.
#
# @example
# browser.button(:id =>'foo').wait_until_present
#
# @param [Fixnum] timeout seconds to wait before timing out
#
# @see Watir::Wait
# @see Watir::Element#present?
#
def wait_until_present(timeout = 30)
message = "waiting for #{selector_string} to become present"
Watir::Wait.until(timeout, message) { present? }
end
def until(timeout = 30, message = nil, &block)
end_time = ::Time.now + timeout
until ::Time.now >end_time
result = yield(self)
return result if result
sleep INTERVAL
end
raise TimeoutError, message_for(timeout, message)
end
希望对你有帮助
如果是弹出窗口页的话需要先把焦点转到这个窗口。###Ahelpermethodtowaitthepopupwindowtobeclosed#defwait_close_popup_windowi=0whilepage.driver.browser.window_handles.size>1sleep0.3i=i+0.3ifi>3breakend