#
# 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
希望对你有帮助
如果是弹出窗口页的话需要先把焦点转到这个窗口。
###A helper method to wait the popup window to be closed
#
def wait_close_popup_window
i=0
while page.driver.browser.window_handles.size > 1
sleep 0.3
i = i+0.3
if i > 3
break
end
end
end
##
#A helper method to wait the popup window to be opened
#
def wait_open_popup_window
i=0
while page.driver.browser.window_handles.size < 2
sleep 0.3
i = i+0.3
if i > 3
break
end
end
end
##
#A helper method to simplify the operation of popup window
# AdminBase.popup_window{
# page.execute_script "window.close()"
# }
#
def popup_window
wait_open_popup_window
popup = page.driver.browser.window_handles.last
within_window(popup) do
yield
wait_close_popup_window
end
end
把你需要在弹窗也处理的代码块替换yield就行了。
make的时候需要调用ruby很多编译前的参数.一些信息make不知道的话会不知道如何建库.我个人的建议是根据你安装的ruby路径和版本信息把配置选项补充全.下面是我电脑上面的配置,你可以借鉴一下.据我分析应该能解决你的问题.
Provided configuration options:
--with-opt-dir
--with-opt-include
--without-opt-include=${opt-dir}/include
--with-opt-lib
--without-opt-lib=${opt-dir}/usr/lib
--with-make-prog
--without-make-prog
--srcdir=.
--curdir
--ruby=/usr/local/ruby-2.1.2/rubies/ruby-2.1.2/bin/ruby