【问题标题】:Command to open new console with ruby script after running selenium server运行 selenium 服务器后使用 ruby​​ 脚本打开新控制台的命令
【发布时间】:2013-02-18 06:35:36
【问题描述】:

我正在尝试运行由不同命令组成的脚本:

1) 系统“bundle exec rails s -e test -d”

2) 系统“bundle exec selenium-rc”

3) 系统“bundle exec rspec test/selenium/*_sel.rb”

现在当第 1 行执行时,服务器运行并且控制台的控制权被转移回来。但是在执行第 2 行后,硒服务器运行,但控制台的控制权没有被转回,因为没有执行第 3 行。

所以我的问题是我们如何同时运行所有三个命令。

【问题讨论】:

    标签: selenium ruby-on-rails-3.1 console selenium-rc rails-console


    【解决方案1】:

    我通过一些研究而不是第 2 行找到了解决方案,现在我正在使用以下代码运行 selenium 服务器

    require 'selenium/rake/tasks'
    JAR_FILE_PATTERN = "vendor/selenium-remote-control/selenium-server-*.jar"    
    @port = 4444      
    @jar_file = "YOUR_PROJECT_PATH/vendor/selenium-server-standalone-2.28.0.jar"   
    @background = true   
    @timeout_in_seconds = 3 * 60   
    @wait_until_up_and_running = true  
    @additional_args = []  
    @additional_args << "-singleWindow"   
    
    raise "Could not find jar file '#{@jar_file}'. Expected it under     #{JAR_FILE_PATTERN}"      unless @jar_file && File.exists?(@jar_file)    
    remote_control = Selenium::RemoteControl::RemoteControl.new("0.0.0.0", @port, :timeout => @timeout_in_seconds)   
    remote_control.jar_file = @jar_file    
    remote_control.additional_args = @additional_args   
    remote_control.log_to = @log_to   
    remote_control.start :background => true       
    if @background && @wait_until_up_and_running       
      TCPSocket.wait_for_service :host => @host, :port => @port     
    end      
    

    3) # 现在第 3 行来了

    4) remote_control.stop #这条线停在那里服务器

    【讨论】:

      猜你喜欢
      • 2014-02-08
      • 1970-01-01
      • 1970-01-01
      • 2013-04-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多