红宝石 – 切换到黄瓜,水豚的弹出窗口
发布时间:2020-12-16 20:50:28 所属栏目:百科 来源:网络整理
导读:在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
在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驱动程序命令更改窗口,如下所示: #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更改以来,安德鲁斯在下面的回答是正确答案. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |