Euller Campagnollo
Euller Campagnollo

Reputation: 35

Bad URI(is not URI?) while trying to use Capybara Apparition driver

it's my first time trying a webdriver different than selenium with capybara.

I've made this very small script below just to see it running but invalid uri error is thrown.

require 'capybara'
require 'capybara/DSL'
require 'capybara/apparition'

include Capybara::DSL

Capybara.javascript_driver = :apparition
Capybara.default_driver = :apparition

visit('https://github.com/twalpole/apparition')

The error thrown is:

> ruby test.rb
Traceback (most recent call last):
        15: from test.rb:9:in `<main>'
        14: from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/capybara-3.34.0/lib/capybara/DSL.rb:58:in `block (2 levels) in <module:DSL>'
        13: from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/capybara-3.34.0/lib/capybara/session.rb:278:in `visit'
        11: from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/apparition-0.6.0/lib/capybara/apparition/driver.rb:50:in `browser'
        10: from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/apparition-0.6.0/lib/capybara/apparition/driver.rb:69:in `client'
         9: from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/apparition-0.6.0/lib/capybara/apparition/driver/chrome_client.rb:16:in `client'
         8: from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/apparition-0.6.0/lib/capybara/apparition/driver/chrome_client.rb:16:in `new'
         7: from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/apparition-0.6.0/lib/capybara/apparition/driver/chrome_client.rb:33:in `initialize'
         6: from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/apparition-0.6.0/lib/capybara/apparition/driver/chrome_client.rb:33:in `new'
         5: from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/apparition-0.6.0/lib/capybara/apparition/driver/web_socket_client.rb:10:in `initialize'
         4: from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/apparition-0.6.0/lib/capybara/apparition/driver/web_socket_client.rb:10:in `new'
         3: from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/apparition-0.6.0/lib/capybara/apparition/driver/web_socket_client.rb:69:in `initialize'
         2: from C:/Ruby26-x64/lib/ruby/2.6.0/uri/common.rb:234:in `parse'
         1: from C:/Ruby26-x64/lib/ruby/2.6.0/uri/rfc3986_parser.rb:73:in `parse'
C:/Ruby26-x64/lib/ruby/2.6.0/uri/rfc3986_parser.rb:67:in `split': bad URI(is not URI?): "ws://127.0.0.1:65515/devtools/browser/1c053b9f-60e6-4cef-822f-4d336aac7fad\r" (URI::InvalidURIError)

Am I missing something?

I've these versions installed: capybara (3.34.0), apparition (0.6.0) and chrome (91.0.4472.77) in windows 10 pro 20H2.

Upvotes: 0

Views: 258

Answers (1)

Darshan Shah
Darshan Shah

Reputation: 346

I had the same issue while running Apparition driver.

It seems the issue is present while instantiating new TCP Socket done by the Socket Class defined in Apparition/driver/web_socket_client

The URL passed in the initialize of Socket Class seems to have trailing white space .

Workaround

Navigate to the following path Ruby26-x64\lib\ruby\gems\2.6.0\gems\apparition-0.6.0\lib\capybara\apparition\driver

Note:- The location of Ruby26-x64 depends on where you installed ruby on your system for me it was in C drive

Modify the web_socket_client.rb file present in the above path as shown in the below image

Web_Socket_Client Change

This fixed the issue for me

Upvotes: 1

Related Questions