gpt4 book ai didi

ruby - 初始化' : rack-test requires a rack application, 但没有给出 (ArgumentError)

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

从 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

最佳答案

Capybara.javascript_driver = :poltergeist 不切换驱动程序。如果您想切换驱动程序,请改用 Capybara.current_driver。那就是:Capybara.current_driver = :poltergeist

关于ruby - 初始化' : rack-test requires a rack application, 但没有给出 (ArgumentError),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27851659/

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