GithubHelp home page GithubHelp logo

Comments (14)

booch avatar booch commented on June 30, 2024 1

OK, I got it working. Oddly, I had to change chromeOptions: in the Thoughtbot example code to 'chromeOptions' => to get it to work.

I still think it's worth mentioning how to get this working in the docs.

from chromedriver-helper.

rantler avatar rantler commented on June 30, 2024 1

I love Ruby more than most (it is by far my favorite programming language), but I gotta say the "symbol vs. string" hash key issue is one of the biggest warts on the language. 😭

from chromedriver-helper.

weedySeaDragon avatar weedySeaDragon commented on June 30, 2024 1

I was not able to get this to work with chromedriver version 2.28. When I updated to 2.31, it worked. Note that the path for the chromedriver bin is set by chromedriver-helper and is in your gem path. I'd forgotten about this at first and so was inadvertently checking the version of chromedriver I had installed elsewhere.

Here is the code that I'm using in my cucumber features/support/env.rb file that is working:


# Headless chrome browser.
# Use @selenium
Capybara.register_driver :selenium do |app|

  options = Selenium::WebDriver::Chrome::Options.new(args: ['headless', 'disable-gpu'])

  Capybara::Selenium::Driver.new(
      app,
      browser: :chrome,
      options: options
  )
end

chromedriver-helper v. 1.1.0
selenium-webdriver 3.4.4

from chromedriver-helper.

booch avatar booch commented on June 30, 2024

I found this article from Thoughtbot and tried following the instructions there. I verified that I'm using chromedriver 2.30 and Chrome 59, but the browser window appears, and when I go to chrome://version/, I don't see --headless in the list.

Also worth mentioning is the Getting Started with Headless Chrome article from Google and the ChromeDriver Capabilities docs.

from chromedriver-helper.

seanriordan08 avatar seanriordan08 commented on June 30, 2024

If you're running on OSX - make sure to avoid the remote-debugging-port=9222 option, which causes chrome to hang, resulting in a Net::ReadTimeout. (chrome 59.0.30, chromedriver 2.3)

from chromedriver-helper.

eugen0329 avatar eugen0329 commented on June 30, 2024

@booch

Can you share your driver config, please?

I followed https://robots.thoughtbot.com/headless-feature-specs-with-chrome instructions along with converting chromeOptions key to string as you suggested and nothing happened. Capybara stucks without any log information.

PS My version is:

Chromium 59.0.3071.109 Built on Ubuntu , running on Ubuntu 16.04

from chromedriver-helper.

Petercopter avatar Petercopter commented on June 30, 2024

Hey guys. I'm in the same boat as the others here. I've got Chromedriver working with Capybara, but I cannot, for the life of me, get the options working. Anytime I try to introduce the desired_capabilities key, everything falls apart. I've tried changing symbols to keys, different options, chanting, yelling... nothing has worked yet.

Capybara.register_driver :selenium do |app|
  Capybara::Selenium::Driver.new(
    app,
    browser: :chrome,
    desired_capabilities: Selenium::WebDriver::Remote::Capabilities.chrome(
      chromeOptions: {
        args: %w(headless disable-gpu)
      }
    )
  )
end

I've got Chromedriver 2.3 and selenium-webdriver in the gemfile.

from chromedriver-helper.

Petercopter avatar Petercopter commented on June 30, 2024

@weedySeaDragon Your config works for me! I've got headless chrome running. Now I have all kinds of problems related to changing from Poltergeist to Chrome, but progress is being made.

🍺 🌮 🎉 Thanks very much.

from chromedriver-helper.

Petercopter avatar Petercopter commented on June 30, 2024

It appears that when running headless, JavaScript is disabled. Has anyone else had this problem?

from chromedriver-helper.

flavorjones avatar flavorjones commented on June 30, 2024

Thanks for opening this issue, and apologies for not responding earlier.

Honestly, I'm not sure it's within the ability of chromedriver-helper to opt into headless mode. All this gem does is download the correct executable for your platform and run it -- configuration needs to be done within your testing framework (e.g., Capybara).

I'm going to close this; though if I'm wrong and there's a PR that can be submitted to do this, I'm open to it.

from chromedriver-helper.

Petercopter avatar Petercopter commented on June 30, 2024

@flavorjones No problem at all, this is absolutely unrelated to your work. I'm going to go bark up the right tree now. Thanks very much for the gem!

from chromedriver-helper.

cseelus avatar cseelus commented on June 30, 2024

Thanks @weedySeaDragon, your config works. Did try ~ a dozen different config variants, to no avail.

@flavorjones Maybe how to pass options to the Driver (for example to run it headless) could be added to the Readme. I could open a PR, if desired.

from chromedriver-helper.

metaskills avatar metaskills commented on June 30, 2024

I had to downgrade selenium-webdriver to v 3.4.4. My system test config looks like this. Note how I am forcing a version downloaded by the helper too. I found there is no class level property to set for future binstub run to take advantage of. This seemed like a good way to be consistent.

require 'test_helper'

driver = Chromedriver::Helper.new
driver.update('2.30')

Selenium::WebDriver::Chrome.driver_path = driver.binary_path

class ApplicationSystemTestCase < ActionDispatch::SystemTestCase
  Capybara.register_driver :headless_chrome do |app|
    Capybara::Selenium::Driver.new(
      app,
      browser: :chrome,
      desired_capabilities: Selenium::WebDriver::Remote::Capabilities.chrome(
        'chromeOptions' => {
          'args' => ['headless', 'disable-gpu', 'no-sandbox', 'window-size=1280,1024'],
          'binary' => ENV['GOOGLE_CHROME_SHIM']
        }.reject { |_k, v| v.nil? }
      )
    )
  end

  driven_by :headless_chrome
end

from chromedriver-helper.

metaskills avatar metaskills commented on June 30, 2024

Ah, I am using latest selenium-webdriver gem now and driver.update('2.36') version now.

from chromedriver-helper.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.