I am trying to run this below code, then I got code error:
ruby / 2.3.0 / rubygems / core_ext / kernel_require.rb:55:在`require':无法加载这样的文件 - selenium-webdriver(LoadError)
我无法找到我所缺少的东西,请帮助我
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
答案 0 :(得分:0)
尝试添加:
require 'rubygems'
在此脚本之上。如果仍然出现相同的错误,请安装gem:
gem install selenium-webdriver
希望它有所帮助。
答案 1 :(得分:0)
我解决了该问题,但是当时的条件是该项目未运行任何与安装或更新gems相关的命令,并发出一条消息,要求我更新已安装gem(链轮)的新版本。因此,接下来是我要执行的步骤:
通过使用gem uninstall bundler
安装捆绑包,这将使用以下命令安装最新版本的捆绑包:gem install bundler
使用以下方法更新项目中所有已安装的gem:bundle update
以防万一:bundle install
答案 2 :(得分:-1)
当我遇到“Kernel-require”错误时,我打开了多个项目。然后我在一个单独的窗口中打开我的项目,然后我再次使用了require语句。 它对我有用。