Ruby on rails 为selenium remote设置Rails环境url

Ruby on rails 为selenium remote设置Rails环境url,ruby-on-rails,selenium,capybara,minitest,Ruby On Rails,Selenium,Capybara,Minitest,我已配置并运行selenium remote。我可以使用测试方法(如使用minitest在capybara上的“访问根路径”)从我的计算机访问在“192.168.1.23:3000”上部署了“rails s”的开发服务器 然而,当我关闭我的开发服务器时,我无法在测试时访问我的测试服务器,我只是得到一个chrome错误,页面未找到 测试文件: require "test_helper" feature "dashboard" do scenario "test1", :js => tru

我已配置并运行selenium remote。我可以使用测试方法(如使用minitest在capybara上的“访问根路径”)从我的计算机访问在“192.168.1.23:3000”上部署了“rails s”的开发服务器

然而,当我关闭我的开发服务器时,我无法在测试时访问我的测试服务器,我只是得到一个chrome错误,页面未找到

测试文件:

require "test_helper"
feature "dashboard" do
  scenario "test1", :js => true  do
  #Rails.application.routes.default_url_options[:host]= 'http://192.168.1.23:3000' 
  visit root_path
end 
注意:当运行访问根路径时,激活第4行将显示为零

test_helper.rb

Capybara.configure do |config| 
  config.default_host = 'http://192.168.1.23:3000'
  config.app_host   = 'http://192.168.1.23:3000'
end
我也 测试环境,test.rb

Rails.application.default_url_options = {:host => "http://192.168.1.23:3000" }
Rails.application.routes.default_url_options = {:host => "http://192.168.1.23:3000" }
编辑: 我已将rails服务器配置为侦听外部地址:

boot.rb

#this lets listen to some interfaces,
#https://fullstacknotes.com/make-rails-4-2-listen-to-all-interface/
require 'rubygems'  
require 'rails/commands/server'

module Rails  
  class Server
    alias :default_options_bk :default_options
    def default_options
      default_options_bk.merge!(Host: '192.168.1.23')
    end
  end
end  

默认情况下,Capybara在随机端口上运行应用程序,但您已将app_host设置为仅在端口3000上连接,这是dev服务器的默认设置。而不是在app_主机集中设置固定端口

Capybara.always_include_port = true
Capybara.app_host = 'http://192.168.1.23`
然后,如果由于selenium远程计算机和本地计算机之间的防火墙问题导致随机端口分配不起作用,则可以设置

Capybara.server_port = <some fixed port number the test app will get run on>

没用。我无法连接,甚至无法分配服务器端口当您分配服务器端口时,您可以从192.168.1.23上的计算机访问它吗??您是否注释掉了默认的\u url\u选项设置?另一件需要检查的事情是,您是否需要设置Capybara.server\u主机默认情况下,它会将服务器绑定到127.0.0.1-您可能需要更改它以绑定到另一个接口,无论192.168.1.23路由到哪个接口,我假设它是127.0.0.1,因为您说rails s工作。另外,您还没有将Capybara.run\u server=false设置为对吗?我已经删除了:“Rails.application.default\u url\u options…”和“Rails.application.routes.default\u url\u options…”。在rake测试期间,我无法从任何一台pc访问192.168.1.23:3000。现在我有了:'Capybara.always\u include\u port=true''Capybara.server\u port=3000'Capybara.server\u host='=false'AH-所以设置Capybara.server\u host='192.168.1.23',您需要使用Capybara来运行服务器,所以不要设置run\u server=false-然后您应该能够删除Capybara.server\u port=3000或将其设置为其他值,否则,您将无法同时运行dev服务器time@Gaston-始终包含端口=真-很高兴听到它在工作