简体   繁体   English

Ruby on Rails硒Cloud9

[英]Ruby on Rails Selenium Cloud9

I am using Cloud9 to develop a Ruby on Rails Application. 我正在使用Cloud9开发Ruby on Rails应用程序。 In the application, I am using Rspec and Selenium. 在应用程序中,我正在使用Rspec和Selenium。 However, when I run my tests I get the following error: 但是,当我运行测试时,出现以下错误:

An error occurred in an after hook
Selenium::WebDriver::Error::WebDriverError: unable to obtain stable firefox connection in   60 seconds (127.0.0.1:7055) occurred at /usr/local/rvm/gems/ruby-2.1.4@rails4/gems/selenium-webdriver-2.44.0/lib/selenium/webdriver/firefox/launcher.rb:79:in `connect_until_stable'

I have tried installing firefox and xvfb but these applications were up to date. 我曾尝试安装firefox和xvfb,但这些应用程序是最新的。

How can I run the tests in Cloud9? 如何在Cloud9中运行测试?

I can't speak to your use of Rspec but I know Cloud9 has a good integration with Sauce Labs that allows for extensive browser testing with Selenium. 我不能说您对Rspec的使用,但是我知道Cloud9与Sauce Labs有很好的集成,可以使用Selenium进行广泛的浏览器测试。 You can use this if you: 您可以在以下情况下使用此功能:

  1. Preview your desired file or page 预览所需的文件或页面
  2. Click "Browser" or the word shown in the dropdown in the top right side of the preview 点击“浏览器”或预览右上角下拉菜单中显示的单词
  3. Click "Desktop Browser" or "Mobile Browser" 点击“桌面浏览器”或“移动浏览器”
  4. Select the browser you want to test 选择您要测试的浏览器

I too couldn't get Selenium working in Cloud9. 我也无法让Selenium在Cloud9中工作。 When I tried launching a Selenium webdriver - either by running tests or in IRB with Selenium::WebDriver.for :firefox - I got the 'unable to obtain stable Firefox connection' error. 当我尝试通过运行测试或在带有Selenium::WebDriver.for :firefox IRB中启动Selenium Webdriver时,出现“无法获得稳定的Firefox连接”错误。 What finally worked was installing Firefox xvfb (rather than just Firefox) and running tests with xvfb-run: 最终可行的方法是安装Firefox xvfb(而不只是Firefox)并使用xvfb-run运行测试:

sudo apt-get install firefox xvfb

Then 然后

xvfb-run rake

I don't really understand why this works but Selenium wouldn't launch with Firefox normally. 我真的不明白为什么这行得通,但是Selenium通常不会在Firefox中启动。 If anyone can explain that would be great! 如果有人可以解释的话,那太好了!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM