切换到黄瓜,水豚的弹出窗口 [英] Switch to popup windows in cucumber, capybara
本文介绍了切换到黄瓜,水豚的弹出窗口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在RSpec中,我可以使用这样的代码切换到弹出窗口, link ,如何在黄瓜步骤中执行此操作?
In RSpec i can use such code switch to popup window, link, How can i do such thing in Cucumber steps?
login_window = page.driver.find_window('PPA_identity_window')
main_window = page.driver.find_window('')
# We use this to execute the next instructions in the popup window
page.within_window(login_window) do
#Normally fill in the form and log in
fill_in 'email', :with => "<your paypal sandbox username>"
fill_in 'password', :with => "<your paypal sandbox password>"
click_button 'Log In'
end
推荐答案
我认为没有黄瓜/水豚这样的方法.
I don't think there is a cucumber/capybara way to do this as such.
但是您仍然可以使用硒驱动程序命令更改窗口,如下所示:
But you can still change the window using selenium driver commands like this:
#Get the main window handle
main = page.driver.browser.window_handles.first
#Get the popup window handle
popup = page.driver.browser.window_handles.last
#Then switch control between the windows
page.driver.browser.switch_to.window(popup)
由于实施了新的DSL更改,因此下面的安德鲁斯答案是正确的答案.
Andrews answer below is the correct answer now since new DSL changes were implemented.
这篇关于切换到黄瓜,水豚的弹出窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文