#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就行了。
Ruby是编辑语言,Rails是基于Ruby来实现的一个用于网站开发的MVC框架,全称为Ruby on Rails。学习Rails需要一些Ruby的基础知识,先学Ruby。 Ruby是一种脚本语言,如果有脚本语言的基础最好,没有也可以直接演习。