【问题标题】:Automated Browser Testing with Capybara and Sauce Connect. GET "__identify__" routing error使用 Capybara 和 Sauce Connect 进行自动浏览器测试。 GET "__identify__" 路由错误
【发布时间】:2013-05-31 21:15:21
【问题描述】:

我正在尝试使用 Sauce Connect 设置 Capybara,以便对我编写的 gem 进行一些自动化测试。我正在使用Combustion 在 localhost:9000 启动服务器以在浏览器中进行测试。

我的spec_helper.rb 看起来像这样:

require 'rubygems'
require 'bundler'

Bundler.require :development

require 'rspec/rails'
require 'capybara/rails'
require 'capybara/rspec'
require 'sauce/capybara'
require 'sauce/parallel'

Combustion.initialize!

# Engine config initializer
require 'setup_credentials.rb'

RSpec.configure do |config|
  #config.use_transactional_fixtures = true
end



Capybara.default_driver = :sauce
Capybara.server_port = 9000

BROWSERS = [
  ["Mac", "Firefox", "17"]
]

index = ENV["TEST_ENV_NUMBER"] != "" ? (ENV["TEST_ENV_NUMBER"].to_i - 1) : 0
platform = BROWSERS[index]
Sauce.config do |config|
  config[:os] = platform[0]
  config[:browser] = platform[1]
  config[:version] = platform[2]
end

在我正在运行的另一个终端中:

java -jar Sauce-Connect.jar MY-USERNAME MY-API-KEY -p localhost:9000

我有一个名为 miso_spec.rb 的规范,看起来像这样:

require "spec_helper"

describe "File upload", :sauce => true do
  it "should go through locally" do
    visit "http://localhost:9000"
    fill_in 'search', :with => "platform"
    click_button "searchButton"
    page.should have_content "Screencasts"
  end
end

我通过执行这个命令来运行它:

rspec -P "spec/features/miso_spec.rb"

启动此命令几秒钟后,我的服务器被下面的 GET 请求淹没并无限期地继续。

Started GET "/__identify__" for 127.0.0.1 at 2013-05-31 13:51:05 +0200
** [Raven] User excluded error: #<ActionController::RoutingError: No route matches [GET] "/__identify__">

ActionController::RoutingError (No route matches [GET] "/__identify__"):

当我在 Saucelabs.com 上查看视频时,我可以看到浏览器从未访问过 http://localhost:9000。然而,奇怪的是,当我控制测试会话时(您可以在浏览器测试运行时单击 Sauce Labs 上的视频来控制),手动导航到该地址会打开本地托管页面.

我相当肯定我已经排除了燃烧是问题的根源。在此端口上启动标准 Rails 服务器仍然会出现上面发布的路由错误。我不确定如何进行。谢谢。

【问题讨论】:

    标签: gem capybara automated-tests saucelabs


    【解决方案1】:

    想通了。我意识到我不止一次需要几件事,所以我在spec_helper.rb 中注释掉了第 6-8 行。

    【讨论】:

    • 第 6-8 行不是一个好的答案,因为文件在各处都不同
    • 为什么投反对票?上述spec_helper.rb的6-8。我认为这很清楚。
    • 最好指定哪些文件不需要,这样读者就不用计算行数了。
    猜你喜欢
    • 1970-01-01
    • 2021-03-11
    • 2013-01-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-12-31
    • 2021-01-14
    • 1970-01-01
    相关资源
    最近更新 更多