はここに私の問題です:私はサイトクリックに接続するために、セレンwebdriverをを使用するアプリケーションを書いていますカピバラでセレンのアプリケーションをテストするにはどうすればよいですか?
/物事の束を埋めます。
明らかに、私は私のコードをテストします ...これは難しいです!これはどうすればいいですか?ここで
は私のテストである:ここでは
require 'spec_helper'
require 'capybara/rspec'
module MyModule
Capybara.run_server = false
describe "the method", :type => :request do
it "should open a browser and go to the site" do
MyClass.open_site("http://google.com")
page.has_content? "Google"
end
end
end
はコードです:ここでは
require 'selenium-webdriver'
module MyModule
class MyClass
def self.open_site(url)
@driver = Selenium::WebDriver.for :firefox
@driver.navigate.to url
end
end
end
は、私が取得していますエラーです:
Failures:
1) the method should open a browser and go to the site
Failure/Error: page.has_content? "Google"
ArgumentError:
rack-test requires a rack application, but none was given
# (eval):2:in `has_content?'
# ./spec/integration/myclass_spec.rb:10
私はテストが混乱して理解することができます通常Capybaraはサイトを参照し、すべてがうまく見えることを確認するためにSeleniumを実行するためです。しかし、ここではSeleniumはコードの一部として独自に実行されています。
実行中のSeleniumをそのアプリケーションとして使用するには、どのようにしてラックテストを行うことができますか?
カピバラはこのコードをテストする正しい解決策でもありますか?
ありがとうございました!