gpt4 book ai didi

Ruby selenium 无法加载此类文件 -- selenium-webdriver (LoadError)

转载 作者:行者123 更新时间:2023-12-05 01:20:28 24 4
gpt4 key购买 nike

我正在尝试使用 ruby​​ 和 Selenium WebDriver 和 Eclipse 来利用 BrowserStack 的自动化测试。

这是我试图运行的代码:

require 'rubygems'
require 'selenium-webdriver'

# Input capabilities
caps = Selenium::WebDriver::Remote::Capabilities.new
caps["browser"] = "IE"
caps["browser_version"] = "7.0"
caps["os"] = "Windows"
caps["os_version"] = "XP"
caps["browserstack.debug"] = "true"
caps[:name] = "Testing Selenium 2 with Ruby on BrowserStack"

driver = Selenium::WebDriver.for(:remote,
:url => "http://xxxxxxxxxxxxx:xxxxxxxxxxxxxx@hub.browserstack.com/wd/hub",
:desired_capabilities => caps)
driver.navigate.to "http://www.google.com/ncr"
element = driver.find_element(:name, 'q')
element.send_keys "BrowserStack"
element.submit
puts driver.title

driver.quit

这是我遇到的错误:
/Users/user/.rvm/rubies/ruby-1.9.3-p392/lib/ruby/site_ruby/1.9.1/rubygems/core_ext/kernel_require.rb:55:in `require': cannot load such file -- selenium-webdriver (LoadError)
from /Users/user/.rvm/rubies/ruby-1.9.3-p392/lib/ruby/site_ruby/1.9.1/rubygems/core_ext/kernel_require.rb:55:in `require'
from /Users/user/Documents/workspace/Lowfares/ie/wintest.rb:2:in `<main>'

最佳答案

就我而言,它有助于将以下内容添加到我的 Gemfile

# in test group
gem 'selenium-webdriver'

然后运行 ​​ bundle install

关于Ruby selenium 无法加载此类文件 -- selenium-webdriver (LoadError),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22952022/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com