0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

NoMethodError: undefined method `chrome' for Selenium::WebDriver::Remote::Capabilities:Class ってなエラーが出た場合

Posted at

6.1のサポートがぁぁぁあということで、7.0へ引っ越し作業中に

NoMethodError: undefined method `chrome' for Selenium::WebDriver::Remote::Capabilities:Class 

ってエラーが発生

Capybara.register_driver :chrome_as_pc do |app|
  caps = Selenium::WebDriver::Remote::Capabilities.chrome(
    loggingPrefs: { browser: "ALL" },
    chromeOptions: {
      w3c: false,
      args: [
        "no-sandbox",
        "headless",
        "disable-gpu",
        "window-size=1200,800",
        "user-agent=Mozilla/5.0 (Windows NT 5.1) AppleWebKit/535.11 (KHTML, like Gecko) Chrome/17.0.963.79 Safari/535.11",
        "disable-dev-shm-usage",
        "lang=ja",
      ],
    }
  )
  Capybara::Selenium::Driver.new(app, browser: :chrome, desired_capabilities: caps)
end

↓↓↓↓↓↓↓

Capybara.register_driver :chrome_as_pc do |app|
  options = Selenium::WebDriver::Chrome::Options.new
  options.add_argument("--headless")
  options.add_argument("--no-sandbox")
  options.add_argument("--disable-gpu")
  options.add_argument("--disable-dev-shm-usage")
  options.add_argument("--window-size=1200,800")
  options.add_argument("--user-agent=Mozilla/5.0 (Windows NT 5.1) AppleWebKit/535.11 (KHTML, like Gecko) Chrome/17.0.963.79 Safari/535.11")
  options.add_argument("--lang=ja")
  Capybara::Selenium::Driver.new(app, browser: :chrome, options:)
end

でとりあえず動きました。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?