Giter VIP home page Giter VIP logo

cuprite's People

Contributors

botandrose avatar botandrose-machine avatar dreyks avatar esergion avatar iainbeeston avatar ianks avatar krisleech avatar kzkn avatar lacostej avatar lindagruenwald avatar lstanden avatar mifrill avatar nherzing avatar niezbop avatar norman avatar nwallace avatar odlp avatar olleolleolle avatar phikes avatar phylor avatar route avatar ryanong avatar seanpdoyle avatar sigmike avatar singhprd avatar swanson avatar trobrock avatar wojtha avatar ximus avatar y-yagi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

cuprite's Issues

Status?

Hi! I stumbled upon this gem and wanted to try it, but it's not available from rubygems.org yet, so just wanted to ask if it will be up any time soon?

Chrome process did not produce websocket url within 1 seconds (RuntimeError)

Even after updating the cuprite declaration (as seen below) we still get the error Chrome process did not produce websocket url within 1 seconds (RuntimeError)

Capybara.register_driver :cuprite do |app|
  Capybara::Cuprite::Driver.new(app, {
  headless: true,
  inspector: true,
  process_timeout: 5,
  url_blacklist: [
    'blacklisted_url'
  ],
  browser_options: {
    'ignore-certificate-errors' => true
  },
  timeout: 120
})
end

Is there some configuration missing?

rspec fails with Capybara::Cuprite::NoSuchWindowError on CI

cuprite version 0.6.0
google-chrome-stable version 73
docker container

during rspec tests run I've execution expired on some feature test
after that all other feature tests fail with Capybara::Cuprite::NoSuchWindowError
as result CI hangs for more than a hour and worker just kills it, so I don't have detailed logs about what's happened there. I on CI it fails randomly (aproximately once per 20 runs) and I can't reproduce it on my local machine.

Did someone encountered with such problem? Maybe any suggestions how to debug it?

Non-HTML response not being handled properly

Hi!

I've been running into an issue where a button, a link or a form in my Rails application makes an Ajax request to the server and expects a JS response (a form remote: true). The problem is that when the response reaches the browser, the JS code is not being executed, it's being displayed on the screen as if it was HTML.

I was expecting rails-ujs to handle the response, but apparently cuprite is intercepting it and rendering on the page. This test passes with capybara-webkit.

Here's a sample app: https://github.com/mateusg/cuprite_bug_sample

Great work with this gem! ๐Ÿ‘ ๐Ÿ‘ ๐Ÿ‘ I'm getting rid of capybara-webkit and I liked it.

"set_proxy" doesn't seem to have an effect for external resources

Similarly to what's happening on the apparition driver (twalpole/apparition#2), and I presume for the same reasons (both use CDP afaik), if one uses set_proxy, and a given page includes external resources (e.g. a <script>, but probably also JSONP calls etc), these calls won't go through the proxy.

This can be problematic for instance if someone is using puffing-billy, a rewriting web proxy which is very useful to e.g. mock out javascript calls to external payment systems (Stripe/Recurly etc).

The poltergeist driver (from which I'm migrating off, because phantomjs is EOL), was working differently & all externals calls were going through the proxy, hence allowing to stub out those calls.

I'm raising this point since we'll see more people migrating off phantomjs in the next few months!

I've created a self-contained reproduction (which also shows the behaviour of poltergeist) here:

https://github.com/thbar/repro-bug-proxy

Capybara::Cuprite::BrowserError: "Invalid parameteres"

I've updated to latest ref and suddenly my full spec suite fails with an exception.

 GIT
   remote: git://github.com/machinio/cuprite.git
-  revision: 00d3b2874066715be11d28a6e342209afd28398c
+  revision: 43d3bbdec34f9be70a82856725c030dd215a558d

I've double checked going back to 00d3b2874066715be11d28a6e342209afd28398c solves the issue. Tried to spot the problematic commit but no luck.

        Capybara::Cuprite::BrowserError:
            Invalid parameters
          # /Users/pablo/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/bundler/gems/cuprite-9b1041dd6cd9/lib/capybara/cuprite/browser/client.rb:43:in `wait'
          # /Users/pablo/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/bundler/gems/cuprite-9b1041dd6cd9/lib/capybara/cuprite/browser/page.rb:191:in `command'
          # /Users/pablo/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/bundler/gems/cuprite-9b1041dd6cd9/lib/capybara/cuprite/browser/page.rb:296:in `prepare_page'
          # /Users/pablo/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/bundler/gems/cuprite-9b1041dd6cd9/lib/capybara/cuprite/browser/page.rb:65:in `initialize'
          # /Users/pablo/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/bundler/gems/cuprite-9b1041dd6cd9/lib/capybara/cuprite/browser/targets.rb:90:in `new'
          # /Users/pablo/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/bundler/gems/cuprite-9b1041dd6cd9/lib/capybara/cuprite/browser/targets.rb:90:in `reset'
          # /Users/pablo/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/bundler/gems/cuprite-9b1041dd6cd9/lib/capybara/cuprite/browser/targets.rb:16:in `initialize'
          # /Users/pablo/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/bundler/gems/cuprite-9b1041dd6cd9/lib/capybara/cuprite/browser.rb:220:in `new'
          # /Users/pablo/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/bundler/gems/cuprite-9b1041dd6cd9/lib/capybara/cuprite/browser.rb:220:in `targets'
          # /Users/pablo/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/bundler/gems/cuprite-9b1041dd6cd9/lib/capybara/cuprite/browser.rb:189:in `reset'
          # /Users/pablo/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/bundler/gems/cuprite-9b1041dd6cd9/lib/capybara/cuprite/driver.rb:131:in `reset!'
          # /Users/pablo/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/capybara-2.18.0/lib/capybara/session.rb:127:in `reset!'
          # /Users/pablo/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/capybara-2.18.0/lib/capybara.rb:314:in `block in reset_sessions!'
          # /Users/pablo/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/capybara-2.18.0/lib/capybara.rb:314:in `reverse_each'
          # /Users/pablo/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/capybara-2.18.0/lib/capybara.rb:314:in `reset_sessions!'
          # /Users/pablo/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/capybara-2.18.0/lib/capybara/rspec.rb:22:in `block (2 levels) in <top (required)>'
          # /Users/pablo/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/rspec-core-3.4.4/lib/rspec/core/example.rb:425:in `instance_exec'
          # /Users/pablo/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/rspec-core-3.4.4/lib/rspec/core/example.rb:425:in `instance_exec'
          # /Users/pablo/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/rspec-core-3.4.4/lib/rspec/core/hooks.rb:364:in `run'
          # /Users/pablo/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/rspec-core-3.4.4/lib/rspec/core/hooks.rb:521:in `block in run_owned_hooks_for'
          # /Users/pablo/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/rspec-core-3.4.4/lib/rspec/core/hooks.rb:520:in `each'
          # /Users/pablo/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/rspec-core-3.4.4/lib/rspec/core/hooks.rb:520:in `run_owned_hooks_for'
          # /Users/pablo/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/rspec-core-3.4.4/lib/rspec/core/hooks.rb:607:in `block in run_example_hooks_for'
          # /Users/pablo/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/rspec-core-3.4.4/lib/rspec/core/hooks.rb:606:in `each'
          # /Users/pablo/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/rspec-core-3.4.4/lib/rspec/core/hooks.rb:606:in `run_example_hooks_for'
          # /Users/pablo/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/rspec-core-3.4.4/lib/rspec/core/hooks.rb:477:in `run'
          # /Users/pablo/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/rspec-core-3.4.4/lib/rspec/core/example.rb:485:in `run_after_example'
          # /Users/pablo/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/rspec-core-3.4.4/lib/rspec/core/example.rb:251:in `block in run'
          # /Users/pablo/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/rspec-core-3.4.4/lib/rspec/core/example.rb:478:in `block in with_around_and_singleton_context_hooks'
          # /Users/pablo/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/rspec-core-3.4.4/lib/rspec/core/example.rb:435:in `block in with_around_example_hooks'
          # /Users/pablo/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/rspec-core-3.4.4/lib/rspec/core/hooks.rb:478:in `block in run'
          # /Users/pablo/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/rspec-core-3.4.4/lib/rspec/core/hooks.rb:618:in `block in run_around_example_hooks_for'
          # /Users/pablo/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/rspec-core-3.4.4/lib/rspec/core/example.rb:320:in `call'
          # /Users/pablo/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/rspec-rails-3.4.2/lib/rspec/rails/adapters.rb:127:in `block (2 levels) in <module:MinitestLifecycleAdapter>'
          # /Users/pablo/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/rspec-core-3.4.4/lib/rspec/core/example.rb:425:in `instance_exec'
          # /Users/pablo/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/rspec-core-3.4.4/lib/rspec/core/example.rb:425:in `instance_exec'
          # /Users/pablo/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/rspec-core-3.4.4/lib/rspec/core/hooks.rb:389:in `execute_with'
          # /Users/pablo/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/rspec-core-3.4.4/lib/rspec/core/hooks.rb:620:in `block (2 levels) in run_around_example_hooks_for'
          # /Users/pablo/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/rspec-core-3.4.4/lib/rspec/core/example.rb:320:in `call'
          # /Users/pablo/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/rspec-core-3.4.4/lib/rspec/core/hooks.rb:621:in `run_around_example_hooks_for'
          # /Users/pablo/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/rspec-core-3.4.4/lib/rspec/core/hooks.rb:478:in `run'
          # /Users/pablo/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/rspec-core-3.4.4/lib/rspec/core/example.rb:435:in `with_around_example_hooks'
          # /Users/pablo/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/rspec-core-3.4.4/lib/rspec/core/example.rb:478:in `with_around_and_singleton_context_hooks'
          # /Users/pablo/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/rspec-core-3.4.4/lib/rspec/core/example.rb:233:in `run'
          # /Users/pablo/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/rspec-core-3.4.4/lib/rspec/core/example_group.rb:581:in `block in run_examples'
          # /Users/pablo/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/rspec-core-3.4.4/lib/rspec/core/example_group.rb:577:in `map'
          # /Users/pablo/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/rspec-core-3.4.4/lib/rspec/core/example_group.rb:577:in `run_examples'
          # /Users/pablo/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/rspec-core-3.4.4/lib/rspec/core/example_group.rb:543:in `run'
          # /Users/pablo/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/rspec-core-3.4.4/lib/rspec/core/runner.rb:119:in `block (3 levels) in run_specs'
          # /Users/pablo/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/rspec-core-3.4.4/lib/rspec/core/runner.rb:119:in `map'
          # /Users/pablo/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/rspec-core-3.4.4/lib/rspec/core/runner.rb:119:in `block (2 levels) in run_specs'
          # /Users/pablo/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/rspec-core-3.4.4/lib/rspec/core/configuration.rb:1680:in `with_suite_hooks'
          # /Users/pablo/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/rspec-core-3.4.4/lib/rspec/core/runner.rb:118:in `block in run_specs'
          # /Users/pablo/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/rspec-core-3.4.4/lib/rspec/core/reporter.rb:77:in `report'
          # /Users/pablo/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/rspec-core-3.4.4/lib/rspec/core/runner.rb:117:in `run_specs'
          # /Users/pablo/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/rspec-core-3.4.4/lib/rspec/core/runner.rb:93:in `run'
          # /Users/pablo/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/rspec-core-3.4.4/lib/rspec/core/runner.rb:78:in `run'
          # /Users/pablo/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/rspec-core-3.4.4/lib/rspec/core/runner.rb:45:in `invoke'
          # /Users/pablo/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/rspec-core-3.4.4/exe/rspec:4:in `<top (required)>'
          # /Users/pablo/.rbenv/versions/2.3.3/bin/rspec:22:in `load'
          # /Users/pablo/.rbenv/versions/2.3.3/bin/rspec:22:in `<top (required)>'

#send_keys is failing when passing a symbol

According to capybara docs (https://www.rubydoc.info/github/jnicklas/capybara/Capybara%2FNode%2FElement:send_keys), it should allowed to send a key event in the form of element.send_keys :tab. It looks like is only expecting a string:

     NoMethodError:
       undefined method `each_char' for :tab:Symbol

     # /Users/pablo/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/bundler/gems/cuprite-0efa3f9ffbd4/lib/capybara/cuprite/browser/input.rb:64:in `send_keys'
     # /Users/pablo/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/bundler/gems/cuprite-0efa3f9ffbd4/lib/capybara/cuprite/node.rb:17:in `command'
     # /Users/pablo/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/bundler/gems/cuprite-0efa3f9ffbd4/lib/capybara/cuprite/node.rb:179:in `send_keys'
     # /Users/pablo/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/capybara-2.18.0/lib/capybara/node/element.rb:239:in `block in send_keys'
     # /Users/pablo/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/capybara-2.18.0/lib/capybara/node/base.rb:85:in `synchronize'
     # /Users/pablo/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/capybara-2.18.0/lib/capybara/node/element.rb:239:in `send_keys'
     # ./spec/features/presupuesto/editor/detalles_spec.rb:22:in `block (3 levels) in <top (required)>'
     # /Users/pablo/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/capybara-2.18.0/lib/capybara/session.rb:341:in `within'
     # /Users/pablo/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/capybara-2.18.0/lib/capybara/dsl.rb:50:in `block (2 levels) in <module:DSL>'
     # /Users/pablo/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/capybara-2.18.0/lib/capybara/rspec/matcher_proxies.rb:14:in `within'

Browser hang when running single test file

For example:

When running bundle exec rspec spec/system/back_office tests run

but when running bundle exec rspec spec/system/back_office/customers_spec.rb it runs the first test then it hangs forever.

Possible to use it for non-headless?

Heya,

This is a pretty cool gem, I was wondering if the same protocol can be used for "classic", non-headless mode as well. The readme kinda makes it clear that this gem is for headless chrome but sometimes it's handy to be able to run a test with the full browser on, but as it is, I have to keep selenium and the whole shebang in the project just for that.

I know it's in an early stage, is it planned to support "headed" mode too?

Screenshot raise exception

Got this when attempting to screenshot. A quick look at the code seems like this is indeed referring to a variable that doesn't exist.

WARN: Screenshot could not be saved. `page.current_path` raised exception: #<NameError: undefined local variable or method `exe' for #<Capybara::Cuprite::Browser::Process:0x00007fbc12bb70f8>
Did you mean?  exec>.

Auto-discover Google Chrome on macOS

It would be nice if cuprite discovered my locally installed Google Chrome in the default location on macOS, like selenium etc.

$ rspec
Cliver::Dependency::NotFound:
  Could not find an executable `chrome`. Try to make it available on the PATH or set environment varible for example BROWSER_PATH="/Applications/Chromium.app/Contents/MacOS/Chromium"

$ BROWSER_PATH=/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome rspec ...
... rspec output ...

drag support?

I can see the skipped specs so it's definitely on the radar. Any specific plans/drafts? I might take a stab at this if time allows

Chrome process did not produce websocket url within 1 seconds (RuntimeError)

I am trying to run Cucumber tests using cuprite for Capybara with the following set up

Capybara.register_driver :cuprite do |app|
  options = {js_errors: true, browser_options: {headless: true, "disable-gpu": true, "no-sandbox": true}}
  Capybara::Cuprite::Driver.new(app, options)
end

However I get the error

Chrome process did not produce websocket url within 1 seconds (RuntimeError)

I first tried to work around this by setting process_timeout to 30 seconds, but recevied another error (in less than 30 seconds)

Timed out waiting for response. It's possible that this happened because something took a very long time (for example a page load was slow). If so, setting the Cuprite :timeout option to a higher value might help. (Capybara::Cuprite::TimeoutError)

So i set the timeout option to 30 (supposedly the default) and everything works correctly.

So i'm not sure if this is a problem with defaults or setup.

Mac OSX: 10.14.4
Chrome version: 75.0.3770.100

Capybara::Cuprite::BrowserError: "Cannot find context with specified id"

I have another set of tests that is failing always with the same structure, for example:

      scenario 'generates report filtered by client name match' do
        visit business_payment_report_path(test_business)
        fill_in 'since date', with: input_date('01/01/2017')
        fill_in 'to date', with: input_date('10/01/2017')
        click_on 'Filter client'
        fill_in 'name', with: 'Smith'
        click_on 'Confirm'
        click_on 'Generate'
        #save_and_open_page or sleep 1
        expect(page).to have_content "Client: 2 - John Smith"
      end

When starting to debug, first I tried to watch in which state was the page with save_and_open_page and to my suprise the test started passing (the same with sleep 1). Now the strange thing it that the report generation inside the spec is not that slow actually.

Anyway I've tried:

expect(page).to have_content "Client: 2 - John Smith", wait: 10

And is raising the same exception, so I think this is not a case where the expectation is timing-out at all.

     # /Users/pablo/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/bundler/gems/cuprite-00d3b2874066/lib/capybara/cuprite/browser/client.rb:43:in `wait'
     # /Users/pablo/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/bundler/gems/cuprite-00d3b2874066/lib/capybara/cuprite/browser/page.rb:185:in `command'
     # /Users/pablo/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/bundler/gems/cuprite-00d3b2874066/lib/capybara/cuprite/browser/runtime.rb:159:in `cyclic?'
     # /Users/pablo/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/bundler/gems/cuprite-00d3b2874066/lib/capybara/cuprite/browser/runtime.rb:147:in `reduce_props'
     # /Users/pablo/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/bundler/gems/cuprite-00d3b2874066/lib/capybara/cuprite/browser/runtime.rb:128:in `handle'
     # /Users/pablo/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/bundler/gems/cuprite-00d3b2874066/lib/capybara/cuprite/browser/runtime.rb:33:in `evaluate'
     # /Users/pablo/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/bundler/gems/cuprite-00d3b2874066/lib/capybara/cuprite/browser.rb:237:in `find_all'
     # /Users/pablo/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/bundler/gems/cuprite-00d3b2874066/lib/capybara/cuprite/browser.rb:72:in `find'
     # /Users/pablo/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/bundler/gems/cuprite-00d3b2874066/lib/capybara/cuprite/driver.rb:68:in `find'
     # /Users/pablo/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/bundler/gems/cuprite-00d3b2874066/lib/capybara/cuprite/driver.rb:72:in `find_xpath'
     # /Users/pablo/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/capybara-2.18.0/lib/capybara/node/base.rb:108:in `find_xpath'
     # /Users/pablo/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/capybara-2.18.0/lib/capybara/queries/selector_query.rb:149:in `block in resolve_for'
     # /Users/pablo/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/capybara-2.18.0/lib/capybara/node/base.rb:81:in `synchronize'
     # /Users/pablo/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/capybara-2.18.0/lib/capybara/queries/selector_query.rb:145:in `resolve_for'
     # /Users/pablo/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/capybara-2.18.0/lib/capybara/node/finders.rb:304:in `block in synced_resolve'
     # /Users/pablo/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/capybara-2.18.0/lib/capybara/node/base.rb:81:in `synchronize'
     # /Users/pablo/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/capybara-2.18.0/lib/capybara/node/finders.rb:302:in `synced_resolve'
     # /Users/pablo/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/capybara-2.18.0/lib/capybara/node/finders.rb:37:in `find'
     # /Users/pablo/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/capybara-2.18.0/lib/capybara/node/document.rb:24:in `text'
     # /Users/pablo/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/capybara-2.18.0/lib/capybara/queries/text_query.rb:94:in `text'
     # /Users/pablo/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/capybara-2.18.0/lib/capybara/queries/text_query.rb:25:in `resolve_for'
     # /Users/pablo/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/capybara-2.18.0/lib/capybara/node/matchers.rb:707:in `block in _verify_text'
     # /Users/pablo/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/capybara-2.18.0/lib/capybara/node/base.rb:85:in `synchronize'
     # /Users/pablo/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/capybara-2.18.0/lib/capybara/node/matchers.rb:706:in `_verify_text'
     # /Users/pablo/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/capybara-2.18.0/lib/capybara/node/matchers.rb:615:in `assert_text'
     # /Users/pablo/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/capybara-2.18.0/lib/capybara/session.rb:808:in `block (2 levels) in <class:Session>'
     # /Users/pablo/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/capybara-2.18.0/lib/capybara/rspec/matchers.rb:153:in `block in matches?'
     # /Users/pablo/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/capybara-2.18.0/lib/capybara/rspec/matchers.rb:27:in `wrap_matches?'
     # /Users/pablo/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/capybara-2.18.0/lib/capybara/rspec/matchers.rb:153:in `matches?'
     # /Users/pablo/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/rspec-expectations-3.4.0/lib/rspec/expectations/handler.rb:50:in `block in handle_matcher'
     # /Users/pablo/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/rspec-expectations-3.4.0/lib/rspec/expectations/handler.rb:27:in `with_matcher'
     # /Users/pablo/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/rspec-expectations-3.4.0/lib/rspec/expectations/handler.rb:48:in `handle_matcher'
     # /Users/pablo/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/rspec-expectations-3.4.0/lib/rspec/expectations/expectation_target.rb:54:in `to'

Any ideas?

Capybara.default_host and Capybara.app_host don't set the Host header

Hi Machinio - thanks for a great driver!

In switching from Selenium I note that I can't use Capybara.default_host or Capybara.app_host to ensure the Host header is set correctly. My app responds differently depending on which hostname is used so it misbehaves with the cuprite driver.

Are there plans to introduce this feature? I could have a go at fixing it myself but I've had a browse of the cuprite code and I'm not sure I understand the best way to do this.

Thanks for your help!

Implement log access

I use this to check for JS errors:

  # Browser error = test fail
  config.after(:each, type: :system) do
    errors = page.driver.browser.manage.logs.get(:browser)
    aggregate_failures 'browser errors' do
      errors.reject do |error|
        IGNORED_BROWSER_ERRORS.any? do |ignored_error|
          Array(ignored_error).all? { |message| error.message.include?(message) }
        end
      end.each do |error|
        expect(false).to eq(true), error.message
      end
    end
  end

This results in:

     NoMethodError:
       undefined method `manage' for #<Capybara::Cuprite::Browser:0x00007f9148fb44e8>

Capybara::Cuprite::BrowserError Cannot find context with specified id

Getting intermittent BrowserError with cannot find context with specified id.

Some searches led me down a similar issue in puppeteer which was solved by adding a waitFor networkidle2 (network almost finished requests). I'm wondering if this error is caused by attempting to interact with the page too early, and we should wait for this networkidle2 event.

Is remote access to chrome supported?

I can't find any roadmap so decided to ask this question. I want to separate a main application and chrome to different docker containers therefor it is required a remote control under chrome, but I can't understand how to set up cuprite's configuration.
Could you please give me advice may be I something miss?

rspec fails on Windows

Hey!

Ran rspec on Windows (mingw64) and a few test broke:

Failures:

  1) Capybara::Cuprite::Driver supports a custom path
     Failure/Error: @pid = ::Process.spawn(*@cmd, process_options)

     Errno::ENOEXEC:
       Exec format error - C:/Users/pniez/Documents/cuprite/spec/support/custom_chrome
     # ./lib/capybara/cuprite/browser/process.rb:104:in `spawn'
     # ./lib/capybara/cuprite/browser/process.rb:104:in `block in start'
     # ./lib/capybara/cuprite/browser/process.rb:153:in `redirect_stdout'
     # ./lib/capybara/cuprite/browser/process.rb:99:in `start'
     # ./lib/capybara/cuprite/browser/process.rb:39:in `tap'
     # ./lib/capybara/cuprite/browser/process.rb:39:in `start'
     # ./lib/capybara/cuprite/browser.rb:252:in `start'
     # ./lib/capybara/cuprite/browser.rb:60:in `initialize'
     # ./lib/capybara/cuprite/browser.rb:23:in `new'
     # ./lib/capybara/cuprite/browser.rb:23:in `start'
     # ./lib/capybara/cuprite/driver.rb:26:in `browser'
     # ./spec/integration/driver_spec.rb:49:in `ensure in block (2 levels) in <module:Cuprite>'
     # ./spec/integration/driver_spec.rb:49:in `block (2 levels) in <module:Cuprite>'
     # ./spec/integration/driver_spec.rb:14:in `block (2 levels) in <module:Cuprite>'
     # ------------------
     # --- Caused by: ---
     # Errno::ENOEXEC:
     #   Exec format error - C:/Users/pniez/Documents/cuprite/spec/support/custom_chrome
     #   ./lib/capybara/cuprite/browser/process.rb:104:in `spawn'

  2) Capybara::Cuprite::Driver raises an error and restarts the client if the client dies while executing a command
     Failure/Error: expect { driver.browser.crash }.to raise_error(DeadBrowser)

       expected Capybara::Cuprite::DeadBrowser, got #<Errno::ECONNRESET: Une connexion existante a dยน ร›tre fermรše par lร†hยถte distant.> with backtrace:
         # ./lib/capybara/cuprite/browser/web_socket.rb:61:in `write'
         # ./lib/capybara/cuprite/browser/web_socket.rb:61:in `write'
         # ./lib/capybara/cuprite/browser/web_socket.rb:65:in `close'
         # ./lib/capybara/cuprite/browser/client.rb:56:in `close'
         # ./lib/capybara/cuprite/browser.rb:218:in `quit'
         # ./lib/capybara/cuprite/browser.rb:213:in `restart'
         # ./lib/capybara/cuprite/browser.rb:240:in `rescue in command'
         # ./lib/capybara/cuprite/browser.rb:236:in `command'
         # ./lib/capybara/cuprite/browser.rb:224:in `crash'
         # ./spec/integration/driver_spec.rb:73:in `block (3 levels) in <module:Cuprite>'
         # ./spec/integration/driver_spec.rb:73:in `block (2 levels) in <module:Cuprite>'
         # ./spec/integration/driver_spec.rb:14:in `block (2 levels) in <module:Cuprite>'
     # ./spec/integration/driver_spec.rb:73:in `block (2 levels) in <module:Cuprite>'
     # ./spec/integration/driver_spec.rb:14:in `block (2 levels) in <module:Cuprite>'

Finished in 8 minutes 15 seconds (files took 3.96 seconds to load)
1553 examples, 2 failures, 27 pending

Failed examples:

rspec ./spec/integration/driver_spec.rb:25 # Capybara::Cuprite::Driver supports a custom path
rspec ./spec/integration/driver_spec.rb:71 # Capybara::Cuprite::Driver raises an error and restarts the client if the client dies while executing a command

undefined method `map' for "(cyclic structure)":String

I have code in a capybara feature spec that looks like this:

find('header', match: :first)

and I'm calling it on a page with html like this:

<html>
  <body>
  ย  <header>
    ย  <h1>Enter details</h1>
  ย  </header>
  </body>
</html>

It should return "Enter details", but instead it's raising an error in cuprite (I'm using master):

NoMethodError:
       undefined method `map' for "(cyclic structure)":String
       Did you mean?  tap
     # /Users/iain/.gem/ruby/2.5.3/bundler/gems/cuprite-be6d0412614a/lib/capybara/cuprite/browser.rb:253:in `find_all'
     # /Users/iain/.gem/ruby/2.5.3/bundler/gems/cuprite-be6d0412614a/lib/capybara/cuprite/browser.rb:72:in `find'
     # /Users/iain/.gem/ruby/2.5.3/bundler/gems/cuprite-be6d0412614a/lib/capybara/cuprite/driver.rb:68:in `find'
     # /Users/iain/.gem/ruby/2.5.3/bundler/gems/cuprite-be6d0412614a/lib/capybara/cuprite/driver.rb:76:in `find_css'
     # /Users/iain/.gem/ruby/2.5.3/gems/capybara-3.7.1/lib/capybara/node/base.rb:98:in `find_css'
     # /Users/iain/.gem/ruby/2.5.3/gems/capybara-3.7.1/lib/capybara/queries/selector_query.rb:137:in `find_nodes_by_selector_format'
     # /Users/iain/.gem/ruby/2.5.3/gems/capybara-3.7.1/lib/capybara/queries/selector_query.rb:102:in `block in resolve_for'
     # /Users/iain/.gem/ruby/2.5.3/gems/capybara-3.7.1/lib/capybara/node/base.rb:77:in `synchronize'
     # /Users/iain/.gem/ruby/2.5.3/gems/capybara-3.7.1/lib/capybara/queries/selector_query.rb:101:in `resolve_for'
     # /Users/iain/.gem/ruby/2.5.3/gems/capybara-3.7.1/lib/capybara/node/finders.rb:291:in `block in synced_resolve'
     # /Users/iain/.gem/ruby/2.5.3/gems/capybara-3.7.1/lib/capybara/node/base.rb:82:in `synchronize'
     # /Users/iain/.gem/ruby/2.5.3/gems/capybara-3.7.1/lib/capybara/node/finders.rb:286:in `synced_resolve'
     # /Users/iain/.gem/ruby/2.5.3/gems/capybara-3.7.1/lib/capybara/node/finders.rb:33:in `find'
     # /Users/iain/.gem/ruby/2.5.3/gems/capybara-3.7.1/lib/capybara/session.rb:728:in `block (2 levels) in <class:Session>'
     # /Users/iain/.gem/ruby/2.5.3/gems/capybara-3.7.1/lib/capybara/dsl.rb:51:in `block (2 levels) in <module:DSL>'
     # ./spec/support/capybara_helpers.rb:166:in `first_header'
     # ./spec/features/my_spec.rb:259:in `block (2 levels) in <top (required)>'

This is failing on Browser#find_all, which is being passed :css to the method param, and "header" to the selector param (within is nil). What is being returned from the call to evaluate is the string "(cyclic structure)", but the code seems to expect an enumerable object.

rspec fail if CUPRITE_DEBUG is on

Platform: Mac
Ruby 2.5.0
Chrome

bundle exec rspec spec/unit/

Failures:

  1) Capybara::Cuprite::Browser logs requests and responses
     Failure/Error: expect(logger.string).to include("<html><head></head><body></body></html>")
       expected "" to include "<html><head></head><body></body></html>"
     # ./spec/unit/browser_spec.rb:15:in `block (2 levels) in <module:Cuprite>'

Finished in 2.7 seconds (files took 0.79745 seconds to load)
6 examples, 1 failure

Failed examples:

rspec ./spec/unit/browser_spec.rb:8 # Capybara::Cuprite::Browser logs requests and responses

url does not seem to pass through to Ferrum process

Not sure if I'm doing something wrong here, but I've tried passing through the url parameter to Cuprite, and it still spawns the Chrome process. If there's an error occurring, I can't see any output related to the said error, and it simply seems to just not respect the parameter.

Can't start on macOS

Trying this out on macOS with BROWSER_PATH=/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome I get:

     1.1) Failure/Error: visit "/"

          URI::InvalidURIError:
            bad URI(is not URI?):
          # /usr/local/rbenv/versions/2.5.0/lib/ruby/2.5.0/uri/rfc3986_parser.rb:18:in `rescue in split'
          # /usr/local/rbenv/versions/2.5.0/lib/ruby/2.5.0/uri/rfc3986_parser.rb:15:in `split'
          # /usr/local/rbenv/versions/2.5.0/lib/ruby/2.5.0/uri/rfc3986_parser.rb:73:in `parse'
          # /usr/local/rbenv/versions/2.5.0/lib/ruby/2.5.0/uri/common.rb:237:in `parse'
          # /usr/local/rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/cuprite-0.2.1/lib/capybara/cuprite/browser/web_socket.rb:21:in `initialize'
          # /usr/local/rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/cuprite-0.2.1/lib/capybara/cuprite/browser/client.rb:16:in `new'
          # /usr/local/rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/cuprite-0.2.1/lib/capybara/cuprite/browser/client.rb:16:in `initialize'
          # /usr/local/rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/cuprite-0.2.1/lib/capybara/cuprite/browser.rb:255:in `new'
          # /usr/local/rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/cuprite-0.2.1/lib/capybara/cuprite/browser.rb:255:in `start'
          # /usr/local/rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/cuprite-0.2.1/lib/capybara/cuprite/browser.rb:48:in `initialize'
          # /usr/local/rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/cuprite-0.2.1/lib/capybara/cuprite/browser.rb:22:in `new'
          # /usr/local/rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/cuprite-0.2.1/lib/capybara/cuprite/browser.rb:22:in `start'
          # /usr/local/rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/cuprite-0.2.1/lib/capybara/cuprite/driver.rb:26:in `browser'
          # /usr/local/rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/cuprite-0.2.1/lib/capybara/cuprite/driver.rb:31:in `visit'
          # /usr/local/rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/capybara-3.9.0/lib/capybara/session.rb:265:in `visit'
          # /usr/local/rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/capybara-3.9.0/lib/capybara/dsl.rb:51:in `block (2 levels) in <module:DSL>'
...

I popped open the gem and made Process.start dump output while looking for websockets and found:

[0118/045325.644206:ERROR:xattr.cc(64)] setxattr org.chromium.crashpad.database.initialized on file /var/folders/sv/kt7w98jx5zj16c4whzrwmx9m0000gn/T/: Operation not permitted (1)
[0118/045325.644206:ERROR:xattr.cc(64)] setxattr org.chromium.crashpad.database.initialized on file /var/folders/sv/kt7w98jx5zj16c4whzrwmx9m0000gn/T/: Operation not permitted (1)
[0118/045325.646487:ERROR:file_io.cc(89)] ReadExactly: expected 8, observed 0
[0118/045325.703505:ERROR:xattr.cc(64)] setxattr org.chromium.crashpad.database.initialized on file /var/folders/sv/kt7w98jx5zj16c4whzrwmx9m0000gn/T/: Operation not permitted (1)
[0118/045325.703505:ERROR:xattr.cc(64)] setxattr org.chromium.crashpad.database.initialized on file /var/folders/sv/kt7w98jx5zj16c4whzrwmx9m0000gn/T/: Operation not permitted (1)
[0118/045325.705365:ERROR:file_io.cc(89)] ReadExactly: expected 8, observed 0

Would be nice if the browser output were piped to the logger when CUPRITE_DEBUG=1 or something.

No test coverage badge

You don't seem to have a test coverage badge and it's unclear if specs are all green and if it's safe to use your project.

Benchmarks are misleading

After looking at the reason for the speed improvements the benchmarks are misleading/invalid. The majority of the speedup comes because cuprite is set Capybara.default_max_wait_time to 0 for a large part of the Capybara specs, which means a large number of them aren't actually testing anything and makes the timing non-comparable to Selenium headless Chrome. If Selenium headless Chrome is run with the same modified wait times on Travis it's time drops from around 14 minutes to under 10 (but again it's not valid to do so since it means a large number of tests aren't actually doing anything). Assuming a similar percentage speedup for the invalid tests, running Selenium headless Chrome on the hardware you benchmarked it on should be in the 7 minute range just like cuprite

Version bump?

Is it possible to get a version bump, so we can pull down the PROCESS_TIMEOUT changes? Without having to reference github.

rspec fails with 2 errors on Mac :)

Failures:

  1) Capybara::Cuprite::Driver has ability to send keys sends sequences with modifiers and symbols
     Failure/Error: expect(input.value).to eq("string")
     
       expected: "string"
            got: "trings"
     
       (compared using ==)
     # ./spec/integration/driver_spec.rb:1303:in `block (3 levels) in <module:Cuprite>'
     # ./spec/integration/driver_spec.rb:14:in `block (2 levels) in <module:Cuprite>'

  2) Capybara::Cuprite::Driver has ability to send keys sends sequences with multiple modifiers and symbols
     Failure/Error: expect(input.value).to eq("s")
     
       expected: "s"
            got: "trings"
     
       (compared using ==)
     # ./spec/integration/driver_spec.rb:1311:in `block (3 levels) in <module:Cuprite>'
     # ./spec/integration/driver_spec.rb:14:in `block (2 levels) in <module:Cuprite>'

Finished in 8 minutes 28 seconds (files took 1.14 seconds to load)
1555 examples, 2 failures, 26 pending

Failed examples:

rspec ./spec/integration/driver_spec.rb:1298 # Capybara::Cuprite::Driver has ability to send keys sends sequences with modifiers and symbols
rspec ./spec/integration/driver_spec.rb:1306 # Capybara::Cuprite::Driver has ability to send keys sends sequences with multiple modifiers and symbols

Bringing back the "no-sandbox" process option

I have had errors when running with a non parametrized user because of the no-sanbox option. Because we do not necessarily want to run with a configured user, I'm trying to get this implemented in the codebase, but I'd like your advise. Would it be good if it was an opt-out parameter in the process constructor?

Strange field reset issue

Trying to find a good way to create a test case for this, but thought I'd ask for suggestions since I got a bit stuck.

I have a test which does something like:

visit some_page
click 'submit'
assert_equal 'Some error message', find('.some-element').text

fill_in 'name', with: 'some test'
fill_in 'body', with: 'some message'
click 'submit'
assert_equal 'Success', find('.some-element').text

The line with fill_in 'name' is not throwing any kind of error, but the form field is blank when the submit button is clicked.

For context, I'm attempting to covert an entire test suite from poltergeist to cuprite.

Any suggestions?

Docker + cuprite

Whenever I try to run chrome inside of a docker container, I get this:

Failure/Error: page.driver.browser.url_whitelist = ["fonts.googleapis.com"]
--
ย  | ย 
ย  | Errno::EACCES:
ย  | Permission denied - /opt/chrome-linux

It says permission denied. I gave executable permissions to this folder and their files in it. I can start chrome myself. It works. However, cuprite is unable to spawn a process.

Dou you have a working example for docker? How do you start your docker? (I simply start dockerd with tcp socket thats all) What kind of permission do we need to give docker or docker user/group?

Having issues trying to get CORS working

When trying to get a test working which creates a request across two domains, the status received from the other domain is a 403, however setting the browser options to disable-web-security doesn't resolve the issue and performing the same test in a browser manual works without any issues.

Is there something radically different in the way Cuprite handles CORS?

Capybara::Node::Element#click not working

I have a bunch of tests (~25) that depend on this functionality (working flawlessly with Geckodriver, Chromedriver and PhantomJS), and are failing with:

Capybara::Cuprite::TimeoutError:
Timed out waiting for response. It's possible that this happened because something took a very long time (for example a page load was slow). If so, setting the Cuprite :timeout option to a higher value might help.

But has nothing to do with a timeout, looks like the#click method is not working because If I debug before the failing line and do find('#elemet_id') or find('.element_class') the node is returned.

For example this happens with this helper:

  def force_blur_focus
    page.find('body').click
  end

That I use to force the blur of the focus in the current input.

Complete backtrace:

     # /Users/pablo/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/bundler/gems/cuprite-960e1b481492/lib/capybara/cuprite/browser/client.rb:39:in `pop'
     # /Users/pablo/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/bundler/gems/cuprite-960e1b481492/lib/capybara/cuprite/browser/client.rb:39:in `block in wait'
     # /Users/pablo/.rbenv/versions/2.3.3/lib/ruby/2.3.0/timeout.rb:101:in `timeout'
     # /Users/pablo/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/bundler/gems/cuprite-960e1b481492/lib/capybara/cuprite/browser/client.rb:39:in `wait'
     # /Users/pablo/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/bundler/gems/cuprite-960e1b481492/lib/capybara/cuprite/browser/page.rb:185:in `command'
     # /Users/pablo/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/bundler/gems/cuprite-960e1b481492/lib/capybara/cuprite/browser/runtime.rb:159:in `cyclic?'
     # /Users/pablo/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/bundler/gems/cuprite-960e1b481492/lib/capybara/cuprite/browser/runtime.rb:147:in `reduce_props'
     # /Users/pablo/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/bundler/gems/cuprite-960e1b481492/lib/capybara/cuprite/browser/runtime.rb:128:in `handle'
     # /Users/pablo/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/bundler/gems/cuprite-960e1b481492/lib/capybara/cuprite/browser/runtime.rb:33:in `evaluate'
     # /Users/pablo/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/bundler/gems/cuprite-960e1b481492/lib/capybara/cuprite/browser.rb:248:in `find_all'
     # /Users/pablo/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/bundler/gems/cuprite-960e1b481492/lib/capybara/cuprite/browser.rb:78:in `find_within'
     # /Users/pablo/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/bundler/gems/cuprite-960e1b481492/lib/capybara/cuprite/node.rb:17:in `command'
     # /Users/pablo/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/bundler/gems/cuprite-960e1b481492/lib/capybara/cuprite/node.rb:36:in `find'
     # /Users/pablo/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/bundler/gems/cuprite-960e1b481492/lib/capybara/cuprite/node.rb:42:in `find_xpath'
     # /Users/pablo/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/capybara-2.18.0/lib/capybara/node/base.rb:108:in `find_xpath'
     # /Users/pablo/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/capybara-2.18.0/lib/capybara/queries/selector_query.rb:149:in `block in resolve_for'
     # /Users/pablo/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/capybara-2.18.0/lib/capybara/node/base.rb:81:in `synchronize'
     # /Users/pablo/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/capybara-2.18.0/lib/capybara/queries/selector_query.rb:145:in `resolve_for'
     # /Users/pablo/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/capybara-2.18.0/lib/capybara/node/matchers.rb:687:in `block in _verify_selector_result'
     # /Users/pablo/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/capybara-2.18.0/lib/capybara/node/base.rb:85:in `synchronize'
     # /Users/pablo/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/capybara-2.18.0/lib/capybara/node/matchers.rb:686:in `_verify_selector_result'
     # /Users/pablo/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/capybara-2.18.0/lib/capybara/node/matchers.rb:93:in `assert_selector'
     # /Users/pablo/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/capybara-2.18.0/lib/capybara/session.rb:808:in `block (2 levels) in <class:Session>'
     # /Users/pablo/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/capybara-2.18.0/lib/capybara/rspec/matchers.rb:68:in `block in matches?'
     # /Users/pablo/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/capybara-2.18.0/lib/capybara/rspec/matchers.rb:27:in `wrap_matches?'
     # /Users/pablo/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/capybara-2.18.0/lib/capybara/rspec/matchers.rb:68:in `matches?'
     # /Users/pablo/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/rspec-expectations-3.4.0/lib/rspec/expectations/handler.rb:50:in `block in handle_matcher'
     # /Users/pablo/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/rspec-expectations-3.4.0/lib/rspec/expectations/handler.rb:27:in `with_matcher'
     # /Users/pablo/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/rspec-expectations-3.4.0/lib/rspec/expectations/handler.rb:48:in `handle_matcher'
     # /Users/pablo/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/rspec-expectations-3.4.0/lib/rspec/expectations/expectation_target.rb:54:in `to'

Capybara::Cuprite::Browser::Targets#targets is sometimes empty during Browser init

Hello!

We are experiencing flaky tests on at least 2 local dev machines because of Capybara::Cuprite::Browser::Targets#targets being empty. However we are not experiencing this on our CI server (Codeship). (So perhaps it could be somehow environment / Chrome version related...)

It blows up during first touch with page.browser. Previously we have had page.driver.browser.url_whitelist = ['127.0.0.1'] in the config. So it usually exploded there. After we placed this to driver config it explodes later in the test execution - e.g. during first visit command within the example.

macOS 10.14.4
Cuprite ver 0b985fa
Chrome version 74.0.3729.157
cuprite_debug_20190523.txt

Setup

Capybara.register_driver :cuprite_debug do |app|
  options = {
    headless: true,
    inspector: true,
    process_timeout: 5,
    browser_options: {
      'ignore-certificate-errors' => true
    },
    timeout: 120,
    url_whitelist: ['127.0.0.1'],
  }
  Capybara::Cuprite::Driver.new(app, options)
end

Stack trace

NoMethodError: undefined method `first' for nil:NilClass
/Users/wojtha/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/bundler/gems/cuprite-0b985fa6a8e5/lib/capybara/cuprite/browser/targets.rb:9:in `initialize'
/Users/wojtha/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/bundler/gems/cuprite-0b985fa6a8e5/lib/capybara/cuprite/browser.rb:241:in `new'
/Users/wojtha/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/bundler/gems/cuprite-0b985fa6a8e5/lib/capybara/cuprite/browser.rb:241:in `targets'
/Users/wojtha/.rbenv/versions/2.5.3/lib/ruby/2.5.0/forwardable.rb:223:in `page'
/Users/wojtha/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/bundler/gems/cuprite-0b985fa6a8e5/lib/capybara/cuprite/browser.rb:189:in `url_whitelist='
/Users/wojtha/Code/inm/portal/spec/support/config/capybara.rb:228:in `block (2 levels) in <main>'

Non replicable test failure

Heyo!

Related to #52 I'm running tests on my Windows machine to see if tests are still failing, and I have had a test fail, but not always:

4) Capybara::Cuprite::Driver javascript errors propagates a synchronous Javascript error on the page to a ruby exception
     Failure/Error:
       expect do
         driver.execute_script "omg"
       end.to raise_error(JavaScriptError, /ReferenceError.*omg/)

       expected Capybara::Cuprite::JavaScriptError with message matching /ReferenceError.*omg/, got #<NoMethodError: undefined method `first' for nil:NilClass> with backtrace:
         # ./lib/capybara/cuprite/browser/targets.rb:9:in `initialize'
         # ./lib/capybara/cuprite/browser.rb:245:in `new'
         # ./lib/capybara/cuprite/browser.rb:245:in `targets'
         # ./lib/capybara/cuprite/driver.rb:94:in `execute_script'
         # ./spec/integration/driver_spec.rb:594:in `block (4 levels) in <module:Cuprite>'
         # ./spec/integration/driver_spec.rb:593:in `block (3 levels) in <module:Cuprite>'
         # ./spec/integration/driver_spec.rb:14:in `block (2 levels) in <module:Cuprite>'
     # ./spec/integration/driver_spec.rb:593:in `block (3 levels) in <module:Cuprite>'
     # ./spec/integration/driver_spec.rb:14:in `block (2 levels) in <module:Cuprite>'

Don't know if it's bad luck or something, but I wanted to let you know ๐Ÿ™‚

Shared chromium process / debugging client

Currently, cuprite will spawn a new chrome process on every invocation. Typically, this is perfectly fine. However, when running parallel tests, it begins to become a performance bottleneck, since each process has to spawn a brand new version of chrome.

Since chrome 63, devtools has supported multiple debugging clients. It would be ๐Ÿ˜Ž if cuprite had the ability to detect an already spawned version of chrome, and use that if available.

Capybara::Cuprite::DeadBrowser with a new version of Chrome 73

Hallo,

With a new version of Google Chrome, I have the same issue as here #48

Environment:

  • Debian GNU/Linux 9.8 (stretch)
  • Google Chrome 73.0.3683.75
  • Google Driver 73.0.3683.68
  • cuprite 0.5.0
  • ruby 2.5.3

` Got 0 failures and 3 other errors:

      Capybara::Cuprite::DeadBrowser:
        Chrome is dead
      # /bundle/2.5.3/gems/cuprite-0.5.0/lib/capybara/cuprite/browser/client.rb:41:in `wait'
      # /bundle/2.5.3/gems/cuprite-0.5.0/lib/capybara/cuprite/browser/page.rb:196:in `command'
      # /bundle/2.5.3/gems/cuprite-0.5.0/lib/capybara/cuprite/browser/page.rb:77:in `visit'
      # /bundle/2.5.3/gems/cuprite-0.5.0/lib/capybara/cuprite/driver.rb:31:in `visit'
      # /bundle/2.5.3/gems/capybara-2.18.0/lib/capybara/session.rb:274:in `visit'`

Attempt to unlock a mutex which is locked by another thread

Switched a test suite with a few hundred specs to Cuprite, mostly working fine (well done and thank you!)

There's 1 weird error we get. The spec passes normally, but if we turn on js_errors: true we get this:

Failures:

  1) Enthusiast an enthusiast successfully books an activity that disallows kids
     Failure/Error: dashboard_page.browse_activities.click
     
     ThreadError:
       Attempt to unlock a mutex which is locked by another thread
     # ./spec/features/enthusiasts/books_an_activity_spec.rb:151:in `navigate_to_booking_page'
     # ./spec/features/enthusiasts/books_an_activity_spec.rb:36:in `block (2 levels) in <main>'
     # -e:1:in `<main>'
     # ------------------
     # --- Caused by: ---
     # Capybara::Cuprite::JavaScriptError:
     #   r
     #   ./spec/features/enthusiasts/books_an_activity_spec.rb:151:in `navigate_to_booking_page'

Mutex seems like a Ruby thing not a JS thing, yet a JS error is being raised. And the JS error is just the letter "r"?

The scenario is just logging in, being redirected to the dashboard, then clicking a link. On clicking the link this error happens.

For now I've worked around like so:

begin
  click_on 'Search'
  # visit '/search' # same error
rescue ThreadError
  puts 'Rescuing erroneous Cuprite JS error on search page'
end

Can't connect to running Chrome browser session

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

Parallel specs

Here is my capyabra integration with parallel specs:
it should work out of the box, maybe it's useful for others

test_env_number = ENV["TEST_ENV_NUMBER"].to_i

Capybara.server_port = 9887 + test_env_number

Capybara.register_driver :cuprite do |app|
  Capybara::Cuprite::Driver.new(
      app,
      browser_options: {
          'no-sandbox': nil,
          'disable-gpu': nil,
          'disable-dev-shm-usage': nil,
          'disable-infobars': nil,
          'disable-extensions': nil,
          'disable-popup-blocking': nil,
          'window-size': '1280,1024'
      },
      port: 9515 + test_env_number
  )
end

Capybara.default_driver = :cuprite

Is proxy supported?

I'm trying to configure cuprite in a way that would use puffing-billy as a proxy (this is useful to mock any request, including external ones like Stripe or Recurly).

I attempted to do this:

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

Capybara.register_driver :custom_billy do |app|
  driver = Capybara::Cuprite::Driver.new(app, {})
  driver.set_proxy(Billy.proxy.host, Billy.proxy.port)
  driver
end

Apparently the call to set_proxy raises a NotImplementedError.

Is this expected?

Many thanks!

State that Cuprite requieres Ruby 2.4

It will be useful if is stated on the gemspec or README file this requirement or relaxed. Tried to test it with a big Rails app we are on Ruby 2.3.3 and failed because undefined method "match?" for #<String:0x007fed7b8e30f8> (https://stackoverflow.com/questions/41792348/nomethoderror-undefined-method-match-for-rubystring):

# /Users/pablo/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/bundler/gems/cuprite-85177260d0c0/lib/capybara/cuprite/browser/process.rb:144:in `parse_ws_url'
# /Users/pablo/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/bundler/gems/cuprite-85177260d0c0/lib/capybara/cuprite/browser/process.rb:93:in `start'              
# /Users/pablo/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/bundler/gems/cuprite-85177260d0c0/lib/capybara/cuprite/browser/process.rb:31:in `tap'
# /Users/pablo/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/bundler/gems/cuprite-85177260d0c0/lib/capybara/cuprite/browser/process.rb:31:in `start'              
# /Users/pablo/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/bundler/gems/cuprite-85177260d0c0/lib/capybara/cuprite/browser.rb:235:in `start'
# /Users/pablo/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/bundler/gems/cuprite-85177260d0c0/lib/capybara/cuprite/browser.rb:49:in `initialize'                 
# /Users/pablo/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/bundler/gems/cuprite-85177260d0c0/lib/capybara/cuprite/browser.rb:22:in `new'
# /Users/pablo/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/bundler/gems/cuprite-85177260d0c0/lib/capybara/cuprite/browser.rb:22:in `start'
# /Users/pablo/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/bundler/gems/cuprite-85177260d0c0/lib/capybara/cuprite/driver.rb:26:in `browser'
# /Users/pablo/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/bundler/gems/cuprite-85177260d0c0/lib/capybara/cuprite/driver.rb:135:in `reset!'

I will suggest, if you want a bigger pool of colaborators, relax a little this constraint. The reality of a lot of big Rails apps on production is that we lag behind a little on versions.

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.