从Selenium切换到PhantomJs/Poltergeist
时,我一直收到此错误消息。
谁知道我做错了什么?如果我将驱动程序切换到selenium,脚本可以正常工作。每当我发表评论default_driver = :selenium
并替换为javascript_driver = :poltergeist
时,我都会遇到此错误。
initialize': rack-test requires a rack application, but none was given (ArgumentError)
这都是ruby文件,没有rails。
require 'rubygems'
require 'capybara'
require 'capybara/dsl'
require "open-uri"
# require "date"
# require 'active_support/core_ext/integer/inflections'
require 'capybara/poltergeist'
# require 'selenium-webdriver'
require 'pry'
require 'phantomjs'
# require 'database_cleaner'
Capybara.run_server = false
Capybara.javascript_driver = :poltergeist
# Capybara.default_driver = :selenium
Capybara.app_host = 'https://www.sameplsite.com'
module MyCapybaraTest
class Test
include Capybara::DSL
def login_site
visit('https://www.sameplsite.com')
# binding.pry
click_link('Log in')
fill_in('email', :with => 'joefrank@sharklasers.com')
fill_in('password', :with => 'passwordpassword')
check('checkbox_remember')
click_button('Log in')
end
def click_right_game
click_link('Create Contest')
all('.boxed')[1].click
check('Free practice')
click_link('Create 1 Head-to-Head')
save_and_open_page
end
def output_game_link
url = URI.parse(current_url)
puts url
end
end
end
t = MyCapybaraTest::Test.new
t.login_fanduel
t.click_right_game
t.output_game_link
答案 0 :(得分:5)
Capybara.javascript_driver = :poltergeist
不会切换驱动程序。如果要切换驱动程序,请改用Capybara.current_driver
。
这说:Capybara.current_driver = :poltergeist