gpt4 book ai didi

ruby - 切换到 cucumber , capybara 中的弹出窗口

转载 作者:数据小太阳 更新时间:2023-10-29 06:55:16 24 4
gpt4 key购买 nike

在 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

最佳答案

您可以使用 Capybara在与弹出窗口交互的 Cucumber 步骤中:

login_window = window_opened_by do
click_button 'Open Login Window'
end
within_window(login_window) do
fill_in :email, with: "email@example.com"
fill_in :password, with: "password"
click_button 'Log In'
end

关于ruby - 切换到 cucumber , capybara 中的弹出窗口,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18983684/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com