【问题标题】: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)
【发布时间】:2017-07-09 14:53:35
【问题描述】:
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': 无法加载此类文件 -- 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

【问题讨论】:

    标签: ruby-on-rails ruby selenium


    【解决方案1】:

    尝试添加:

    require 'rubygems'
    

    在此脚本之上。如果仍然出现同样的错误,请安装 gem:

    gem install selenium-webdriver
    

    希望对你有帮助。

    【讨论】:

      【解决方案2】:

      我解决了这个问题,但我当时的情况是该项目没有运行任何与安装或更新 gems 相关的命令,并抛出一条消息,抱怨我更新已安装 gem(sprockets)的新版本。所以,接下来是我遵循的步骤:

      1. 使用您正在使用的 ruby​​ 的实际版本卸载 bundler:gem uninstall bundler

      2. 安装捆绑器,这将安装最新版本的捆绑器,使用:gem install bundler

      3. 使用以下命令更新项目的所有已安装 gem:bundle update

      4. 以防万一:bundle install

      【讨论】:

        【解决方案3】:

        当我收到“需要内核”错误时,我打开了多个项目。然后我在一个单独的窗口中打开了我的项目,并再次使用了 require 语句。 它对我有用。

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 2014-03-16
          • 1970-01-01
          • 1970-01-01
          • 2015-03-25
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2023-01-12
          相关资源
          最近更新 更多