通过RSpec使用selenium测试Javascript元素会导致RSpec测试的其他部分失败
我正在尝试将Stripe集成到我正在构建的web应用程序中。然而,当我尝试测试“用卡支付”按钮时,我遇到了一个小问题。无论我做什么,rspec都会抛出一个ElementNotFound错误 经过一些搜索,我发现这是因为默认的驱动程序,rack\u test,不支持Javascript。然后我参考了一些文档:并将:js=>true添加到我的一个RSpec场景中,并将selenium webdrivergem添加到我的gemfile中 然而,这又带来了另一系列问题。现在,每当我运行测试时,我都会被告知我使用的用户名/密码组合无效,我无法进入测试的下一部分,以查看是否可以单击该死的按钮!Selenium似乎没有识别和/或使我的用户工厂无效 举起手来 任何帮助都将不胜感激 规格/功能/用户\u升级\u高级\u规格.rb:通过RSpec使用selenium测试Javascript元素会导致RSpec测试的其他部分失败,javascript,ruby-on-rails,ruby,selenium,rspec,Javascript,Ruby On Rails,Ruby,Selenium,Rspec,我正在尝试将Stripe集成到我正在构建的web应用程序中。然而,当我尝试测试“用卡支付”按钮时,我遇到了一个小问题。无论我做什么,rspec都会抛出一个ElementNotFound错误 经过一些搜索,我发现这是因为默认的驱动程序,rack\u test,不支持Javascript。然后我参考了一些文档:并将:js=>true添加到我的一个RSpec场景中,并将selenium webdrivergem添加到我的gemfile中 然而,这又带来了另一系列问题。现在,每当我运行测试时,我都会被告
require 'rails_helper'
describe "Upgrade from Standard to Premium Plan" do
before do
@user = create(:user)
visit root_path
click_link "Sign In"
fill_in 'Email', with: @user.email
fill_in 'Password', with: @user.password
click_button "Sign In"
expect(page).to have_content "Signed in successfully."
end
scenario "Successfully", :js => true do
click_link "My Account"
click_link "Upgrade Account"
click_button "Pay with Card"
end
end
spec/factories/user.rb
FactoryGirl.define do
factory :user do
name "User One"
sequence(:email, 100) { |n| "person#{n}@example.com" }
password "helloworld"
password_confirmation "helloworld"
confirmed_at Time.now
end
end
在超时类别下尝试
script\u timeout
,例如implicit\u wait
和page\u load
;在全球范围内声明它,让我们看看它在我们的案例中是如何工作的
@driver.manage.timeouts.script_timeout = 15
您正在使用页面对象模式吗?用RSpec替换描述“从标准升级到高级计划”do。描述“从标准升级到高级计划”do