Rubyの一般的な新機能です。私は会社のウェブサイトのテストを行うためにセレンを使ってカピバラを学びたいと思っています。記述ブロックでCapybara rspecスクリプトが実行されない
ブロックを記述する前に私のコードが動作していました。しかし、私はログイン後にページが読み込まれるまで待つ必要がありました。私はいくつかの研究を行い、期待する方法が行く方法であることを発見しました。今、ruby testscript.rbを実行すると、ブラウザが開かなくなってしまいます。以下はコードです:
require 'timeout'
require 'capybara'
require 'capybara/dsl'
require 'capybara/rspec'
require 'capybara/rspec/matchers'
require 'capybara/session/matchers'
require 'capybara/node/matchers'
Capybara.default_driver = :selenium
session = Capybara::Session.new(:selenium)
describe 'login process', :type => :feature do
it 'signs me in' do
visit 'https://testwebsite.com'
find_by_id('login_form')
fill_in('username', with: 'testuser')
fill_in('password', with: 'testpw')
find_by_id('Login').click
expect(page).to have_content('phSearchInput')
end
end
describe 'search install product', :type => :feature do
it 'searches product' do
fill_in('phSearchInput', with: '6109302')
find_by_id('phSearchButton').click
within "SVMXC__Installed_Product__c_body" do
click_on "6109302"
end
end
end
何か助けていただければ幸いです。ページロードの待ち時間の問題を解決するための代替手段を提供してください。私は睡眠を使いたくない。ありがとう!
ありがとうございました!今は走っている。しかし、私は期待通りにNoMethodErrorを得ています。私はすべての必要を追加したと思う。何か案は?これは次の行です:expect(page).to have_field( 'phSearchInput') – shen
@shen現代のRSpecを実行しているとすれば、 'rspec'または 'rspec/expectations'の前に 'capybara/rspec 'とRSpecも設定してください。 –
私は昨日すべてをインストールしたので、すべてが現代的でなければならないと思います。私は 'rspec'または 'rspec/expectation'を持っていません。私は 'capybara/rspec/matchers'を持っています。それは 'capybara/rspec'の前ですが、まだ動作していません。あなたはなにか考えはありますか?ありがとう! – shen