[英]ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require': cannot load such file -- selenium-webdriver (LoadError)
I am trying to run this below code, then I got code error:
ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require': cannot load such file -- selenium-webdriver (LoadError)
ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require': 无法加载此类文件 -- selenium-webdriver (LoadError)
I am not able to find what I am missing please help me with this我无法找到我缺少的东西,请帮我解决这个问题
require "selenium-webdriver"
# Firefox browser instantiation
driver = Selenium::WebDriver.for :firefox
#Loading the assertselenium URL
driver.navigate.to "http://www.assertselenium.com"
#Clicking on the Follow link present on the assertselenium home page
FollowButton = driver.find_element(:link, "Follow")
FollowButton.click
#Typing the UserName
LoginButton = driver.find_element(:id, "user_login")
LoginButton.send_keys "sampleuser77dff27"
#Typing the Email-Id
EmailId = driver.find_element(:id, "user_email")
EmailId.send_keys "sampleuser7f7df27@gmail.com"
#Clicking on the Submit Button
SubmitButton = driver.find_element(:id, "wp-submit")
SubmitButton.click
#Asserting whether the registration success message is diaplyed
SuccessMessage = driver.find_element(:css, "p.message")
"Registration complete. Please check your e-mail.".eql? SuccessMessage.text
puts "Successfully completed the user registration and validated the Success message"
#Quitting the browser
driver.quit
Try add:尝试添加:
require 'rubygems'
on top of this script.在这个脚本之上。 If you still get the same error, then install the gem:
如果您仍然遇到相同的错误,请安装 gem:
gem install selenium-webdriver
Hope it helps.希望能帮助到你。
I resolved that issue, but my condition in that time was the project didn't run any command related to install or update gems, and throw a message complain me to update new version of an installed gem (sprockets).我解决了这个问题,但当时我的情况是该项目没有运行任何与安装或更新 gems 相关的命令,并抛出一条消息抱怨我更新已安装 gem (sprockets) 的新版本。 So, next are the steps I followed:
所以,接下来是我遵循的步骤:
Uninstall bundler with the actual version that ruby you are using by using: gem uninstall bundler
使用您正在使用的 ruby 的实际版本
gem uninstall bundler
: gem uninstall bundler
Install bundler, this will make install the newest version bundler, using : gem install bundler
安装 bundler,这将使安装最新版本的 bundler,使用:
gem install bundler
Update all your installed gems of the project by using: bundle update
使用以下命令
bundle update
项目的所有已安装 gem: bundle update
And for just in case: bundle install
以防万一:
bundle install
I had opened multiple projects when I got "Kernel-require" error.当我收到“Kernel-require”错误时,我打开了多个项目。 Then I opened my project in a separate window and I used the require statement again.
然后我在一个单独的窗口中打开了我的项目,我再次使用了 require 语句。 It worked for me.
它对我有用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.