Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't connect to running Chrome browser session #48

Closed
Dark-Sun opened this issue Feb 4, 2019 · 20 comments
Closed

Can't connect to running Chrome browser session #48

Dark-Sun opened this issue Feb 4, 2019 · 20 comments

Comments

@Dark-Sun
Copy link

Dark-Sun commented Feb 4, 2019

Environment:
macOS 10.13.6
Google Chrome 71.0.3578.98
cuprite 0.4.0
ruby 2.5.0

When running with the following options and already launched Google Chrome:

Capybara.register_driver :cuprite_head do |app|
  Capybara::Cuprite::Driver.new(app, {
    headless: false
  })
end

it raises

RuntimeError:
    Chrome process did not produce websocket url within 1 seconds

It seems Cuprite can't connect to running Chrome instance, since it outputs Opening in existing browser session instead valid ws url that could be connected to

@route
Copy link
Member

route commented Feb 5, 2019

Yea seems like there's some issue when Chrome is already running. I have to take a look, but PRs are always welcome ;)

@gregoryduckworth
Copy link

gregoryduckworth commented Feb 12, 2019

I'm getting the same issue when running through a docker container.
Chrome process did not produce websocket url within 1 seconds (RuntimeError)

@route
Copy link
Member

route commented Feb 12, 2019

@gregoryduckworth that's because in docker as root you have to pass no-sandbox option:

Capybara.register_driver :cuprite do |app|
  Capybara::Cuprite::Driver.new(
    app,
    browser_options: {
      'no-sandbox': nil
    }
  )
end

@gregoryduckworth
Copy link

gregoryduckworth commented Feb 12, 2019

Thanks for the reply @route, however when I add in the browser_options, I seem to be unable to run the tests and get the following error: no implicit conversion of Array into Hash (TypeError)

Capybara.register_driver :cuprite do |app|
  options = {
    headless: true,
    timeout: 30,
    browser_options: [
      'no-sandbox': nil
    ],
    url_blacklist: [
      'https://example.com'
    ]
  }
  Capybara::Cuprite::Driver.new(app, options)
end

@gregoryduckworth
Copy link

gregoryduckworth commented Feb 12, 2019

Sorted it, just checked and noticed you mentioned {} instead of [].

Although now have the error Chrome is dead (Capybara::Cuprite::DeadBrowser) or Broken pipe (Errno::EPIPE)

@gvinicius
Copy link

I'm facing the same problem. I do know what to do in order to solve this.

@route
Copy link
Member

route commented Feb 12, 2019

I need more information other than that, browser version, full backtrace, options you are passing etc

@gregoryduckworth
Copy link

Environment:

macOS 10.12.6
Google Chrome 71.0.3578.80
cuprite 0.4.0
ruby 2.5.3

Driver:

Capybara.default_driver = :cuprite
Capybara.register_driver :cuprite do |app|
  options = {
    browser_options: {
      'no-sandbox': nil
    },
    url_blacklist: [
      # Stop the EDR Survey from popping up
      'https://edigitalsurvey.com'
    ]
  }
  Capybara::Cuprite::Driver.new(app, options)
end

Capybara.javascript_driver = :cuprite

Then it is failing after running a test and the after hook, so struggling to provide a stack trace.

@gvinicius
Copy link

Environment:

Ubuntu 16.04
Google Chrome 50.0.2661.102 
Cuprite 0.4.0
Ruby 2.5.0

Configs in spec_helper

require 'capybara/cuprite'
Capybara.javascript_driver = :cuprite
Capybara.server = :webrick

Full stack of the error:


Failures:

1) Login GENERATED
Got 0 failures and 2 other errors:

1.1) Failure/Error: visit '/signin'

RuntimeError:
Chrome process did not produce websocket url within 1 seconds
# /home/gesteira/.rvm/gems/ruby-2.5.0@project/gems/cuprite-0.4.0/lib/capybara/cuprite/browser/process.rb:179:in `parse_ws_url'
# /home/gesteira/.rvm/gems/ruby-2.5.0@project/gems/cuprite-0.4.0/lib/capybara/cuprite/browser/process.rb:93:in `start'
# /home/gesteira/.rvm/gems/ruby-2.5.0@project/gems/cuprite-0.4.0/lib/capybara/cuprite/browser/process.rb:31:in `tap'
# /home/gesteira/.rvm/gems/ruby-2.5.0@project/gems/cuprite-0.4.0/lib/capybara/cuprite/browser/process.rb:31:in `start'
# /home/gesteira/.rvm/gems/ruby-2.5.0@project/gems/cuprite-0.4.0/lib/capybara/cuprite/browser.rb:236:in `start'
# /home/gesteira/.rvm/gems/ruby-2.5.0@project/gems/cuprite-0.4.0/lib/capybara/cuprite/browser.rb:50:in `initialize'
# /home/gesteira/.rvm/gems/ruby-2.5.0@project/gems/cuprite-0.4.0/lib/capybara/cuprite/browser.rb:22:in `new'
# /home/gesteira/.rvm/gems/ruby-2.5.0@project/gems/cuprite-0.4.0/lib/capybara/cuprite/browser.rb:22:in `start'
# /home/gesteira/.rvm/gems/ruby-2.5.0@project/gems/cuprite-0.4.0/lib/capybara/cuprite/driver.rb:26:in `browser'
# /home/gesteira/.rvm/gems/ruby-2.5.0@project/gems/cuprite-0.4.0/lib/capybara/cuprite/driver.rb:31:in `visit'
# /home/gesteira/.rvm/gems/ruby-2.5.0@project/gems/capybara-3.13.2/lib/capybara/session.rb:277:in `visit'
# /home/gesteira/.rvm/gems/ruby-2.5.0@project/gems/capybara-3.13.2/lib/capybara/dsl.rb:51:in `block (2 levels) in <module:DSL>'
# ./spec/features/login_spec.rb:5:in `block (2 levels) in <top (required)>'

1.2) Failure/Error: raise "Chrome process did not produce websocket url within #{timeout} seconds"

RuntimeError:
Chrome process did not produce websocket url within 1 seconds
# /home/gesteira/.rvm/gems/ruby-2.5.0@project/gems/cuprite-0.4.0/lib/capybara/cuprite/browser/process.rb:179:in `parse_ws_url'
# /home/gesteira/.rvm/gems/ruby-2.5.0@project/gems/cuprite-0.4.0/lib/capybara/cuprite/browser/process.rb:93:in `start'
# /home/gesteira/.rvm/gems/ruby-2.5.0@project/gems/cuprite-0.4.0/lib/capybara/cuprite/browser/process.rb:31:in `tap'
# /home/gesteira/.rvm/gems/ruby-2.5.0@project/gems/cuprite-0.4.0/lib/capybara/cuprite/browser/process.rb:31:in `start'
# /home/gesteira/.rvm/gems/ruby-2.5.0@project/gems/cuprite-0.4.0/lib/capybara/cuprite/browser.rb:236:in `start'
# /home/gesteira/.rvm/gems/ruby-2.5.0@project/gems/cuprite-0.4.0/lib/capybara/cuprite/browser.rb:50:in `initialize'
# /home/gesteira/.rvm/gems/ruby-2.5.0@project/gems/cuprite-0.4.0/lib/capybara/cuprite/browser.rb:22:in `new'
# /home/gesteira/.rvm/gems/ruby-2.5.0@project/gems/cuprite-0.4.0/lib/capybara/cuprite/browser.rb:22:in `start'
# /home/gesteira/.rvm/gems/ruby-2.5.0@project/gems/cuprite-0.4.0/lib/capybara/cuprite/driver.rb:26:in `browser'
# /home/gesteira/.rvm/gems/ruby-2.5.0@project/gems/cuprite-0.4.0/lib/capybara/cuprite/driver.rb:131:in `reset!'
# /home/gesteira/.rvm/gems/ruby-2.5.0@project/gems/capybara-3.13.2/lib/capybara/session.rb:128:in `reset!'
# /home/gesteira/.rvm/gems/ruby-2.5.0@project/gems/capybara-3.13.2/lib/capybara.rb:315:in `block in reset_sessions!'
# /home/gesteira/.rvm/gems/ruby-2.5.0@project/gems/capybara-3.13.2/lib/capybara.rb:315:in `reverse_each'
# /home/gesteira/.rvm/gems/ruby-2.5.0@project/gems/capybara-3.13.2/lib/capybara.rb:315:in `reset_sessions!'
# /home/gesteira/.rvm/gems/ruby-2.5.0@project/gems/capybara-3.13.2/lib/capybara/rspec.rb:18:in `block (2 levels) in <top (required)>'


@route
Copy link
Member

route commented Feb 12, 2019

@gvinicius Google Chrome 50.0.2661.102 outdated, install >= 71

@route
Copy link
Member

route commented Feb 12, 2019

@gregoryduckworth could you please try to use master branch? gem "cuprite", github: "machinio/cuprite"

@gregoryduckworth
Copy link

@route - still getting the same Chrome is dead or Broken pipe errors

@gvinicius
Copy link

@route , @gregoryduckworth after upgrading chrome to the latest version (72), setting BROWSER_PATH env var correctly, the error is no longer happening to me.

@route
Copy link
Member

route commented Feb 12, 2019

@gregoryduckworth I believe it's env related, does your test suite work without docker?

@gregoryduckworth
Copy link

@route - Yeah it works fine without docker

@route
Copy link
Member

route commented Feb 12, 2019

@gregoryduckworth could you please show all cmd flags you run chrome process on docker, take a look at https://github.com/machinio/cuprite/blob/master/spec/spec_helper.rb#L16

@gregoryduckworth
Copy link

Thanks, I sorted it with the following change in my Dockerfile

RUN wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - \
  && echo "deb http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google-chrome.list \
  && apt-get update -qqy \
  && apt-get -qqy install google-chrome-stable \
  && rm /etc/apt/sources.list.d/google-chrome.list \
  && rm -rf /var/lib/apt/lists/* /var/cache/apt/* \
  && sed -i 's/"$HERE\/chrome"/"$HERE\/chrome" --no-sandbox/g' /opt/google/chrome/google-chrome

@route
Copy link
Member

route commented Feb 13, 2019

@Dark-Sun fixed your original issue. I think it's almost time to release 1.0

@smarquez1
Copy link

@gvinicius Can you give us an example of how to set the BROWSER_PATH ?

@route
Copy link
Member

route commented Apr 6, 2020

@smarquez1

BROWSER_PATH=/path/to/browser bundle exec rspec`

or pass it when instantiating a driver

Capybara::Cuprite::Driver.new(app, browser_path: "/path/to/browser")

saikumar-everest pushed a commit to saikumar-everest/cuprite that referenced this issue Jun 30, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants