我已经使用puppet设置了Watir环境,模块适用于:
现在,如果我运行基本测试:
basic_headless.rb
require 'watir-webdriver'
require 'headless'
headless = Headless.new
headless.start
b = Watir::Browser.start 'www.google.com'
puts b.title
b.close
headless.destroy
打印“Google”
以及以下内容:
#!/usr/bin/ruby
require 'rubygems'
require 'watir-webdriver'
require 'headless'
require 'bacon'
apache_auth = 'https://l_backup:ke0' + vm_name + '/cgi-bin/administrator/customer.cgi'
user_login = 'sales_test'
user_password = 'sst'
puts "Logging into " + vm_name + " with " + user_password
Bacon.extend Bacon.const_get(format) rescue abort "No such formatter: #{format}"
browser = Watir::Browser.new :chrome
browser.window.resize_to(1450, 750)
browser.window.move_to(0, 0)
describe "UI Testing for Coder-Workspace" do
it "Login" do
browser.goto apache_auth
browser.text_field(:id => 'login_input').set user_login
browser.text_field(:id => 'pw_input').set user_password
browser.form(:name => 'loginform').submit
browser.frame(:index => 1).html.should.include 'superuser'
end
显示错误:
/usr/local/rvm/gems/ruby-2.1.1@global/gems/selenium-webdriver-2.40.0/lib/selenium/webdriver/chrome/service.rb:50:in `start': unable to connect to chromedriver http://127.0.0.1:9515 (Selenium::WebDriver::Error::WebDriverError)
from /usr/local/rvm/gems/ruby-2.1.1@global/gems/selenium-webdriver-2.40.0/lib/selenium/webdriver/chrome/bridge.rb:15:in `initialize'
from /usr/local/rvm/gems/ruby-2.1.1@global/gems/selenium-webdriver-2.40.0/lib/selenium/webdriver/common/driver.rb:37:in `new'
from /usr/local/rvm/gems/ruby-2.1.1@global/gems/selenium-webdriver-2.40.0/lib/selenium/webdriver/common/driver.rb:37:in `for'
from /usr/local/rvm/gems/ruby-2.1.1@global/gems/selenium-webdriver-2.40.0/lib/selenium/webdriver.rb:67:in `for'
from /usr/local/rvm/gems/ruby-2.1.1@global/gems/watir-webdriver-0.6.8/lib/watir-webdriver/browser.rb:46:in `initialize'
from code_lookup.rb:34:in `new'
from code_lookup.rb:34:in `<main>'
现在,我应该连接到selenium服务器吗?还是一个watir Grid?作为运行测试的代理?
为什么要尝试连接到chromedriver http://127.0.0.1:9515
我已经在/ usr / bin中手动安装了chromedriver,而在chmod 777中安装了
答案 0 :(得分:1)
(我从错误消息中假设code_lookup.rb
中的第34行是行browser = Watir::Browser.new :chrome
。如果这不正确,则答案可能也是如此。)
你的第一个脚本工作原因是因为Watir-Webdriver中的默认浏览器是Firefox:
# From line 28 in https://github.com/watir/watir-webdriver/blob/master/lib/watir-webdriver/browser.rb
def start(url, browser = :firefox, *args)
在第二个脚本中,您具体:chrome
。如果您的目标是通用浏览,则很容易解决:移除:chrome
browser = Watir::Browser.new # <= same as :firefox
如果您想特别使用Chrome,则会遇到困难。不可能正确地#39;在Centos 6.x上安装Chrome和chromedriver,因为谷歌(实际上)不支持它。 I've writen about this here,虽然我使用的是32位系统,所以希望你比我更幸运。
我在StackOverflow问题上获得的具有相同内容的最佳答案(没有链接 - 它被投票并随后自动删除)是安装GLIBCXX_3.4.15作为依赖项的东西。我仍然无法让chromedriver认识到它已经安装完毕。