【发布时间】:2011-09-02 20:42:09
【问题描述】:
我无法通过 cron 运行 rspec 测试。我正在使用 selenium 访问 Firefox 并测试登录到页面。在 cron 之外执行时,我的所有文件都可以正常工作。根据我的阅读,问题可能是 cron 需要一个显示环境来运行像 firefox 这样的程序。这就是我卡住的地方,如何为 selenium 设置显示环境以从 cron 中启动 firefox。
我已经尝试在 crontab 中设置显示的几种方式..
*/25 * * * * /home/justin/test.sh --display=:0 > testlog
*/25 * * * * DISPLAY=:0; /home/justin/test.sh > testlog;
我也试过在脚本中设置它..
#!/bin/sh
cd /home/justin/widget_ui_testing/
DISPLAY=:0
/home/justin/.rvm/bin/rvm exec /home/justin/.rvm/gems/ruby-1.9.2-p290/bin/rspec
-fdoc /home/justin/widget_ui_testing/spec/requests/log_in_spec.rb
我不断收到的错误消息是
Selenium::WebDriver::Error::WebDriverError:
unable to obtain stable firefox connection in 60 seconds (127.0.0.1:7055)
# ./spec/requests/log_in_spec.rb:22:in `block (2 levels) in <top (required)>'
我想知道是否有一种方法可以更改 selenium 的代码以使用指定的显示运行 firefox。或者,如果我一路上错过了什么。任何帮助将不胜感激。
【问题讨论】:
标签: ruby rspec continuous-integration cron