在RSpec我可以使用这样的代码切换到弹出窗口,link,我怎么能在Cucumber步骤中做这样的事情?
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
解决方法
我不认为有这样做的黄瓜/水豚方式.
但您仍然可以使用selenium驱动程序命令更改窗口,如下所示:@H_301_9@
#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更改以来,安德鲁斯在下面的回答是正确答案.@H_301_9@