How to use --remote-debugging-port with chromedriver

1,272 views
Skip to first unread message

Julie Silvestri

unread,
Feb 27, 2018, 9:47:33 PM2/27/18
to Selenium Users
I am using Selenium to run headless Chrome with Capybara, which works great, except I cannot figure out how to use remote debugging.  When I add `--remote-debugging-port=4444` or `--remote-debugging-port=9222` or `--remote-debugging-port=9521`, Selenium no longer connects to the browser to run the test -- I get a Net::ReadTimeout.

How do I get remote debugging to work?  Here is my code for reference:

Capybara.register_driver :selenium do |app|
     capabilities = Selenium::WebDriver::Remote::Capabilities.chrome(loggingPrefs: {browser: 'ALL'})
     options = Selenium::WebDriver::Chrome::Options.new
     options.add_argument '--disable-infobars' # hide info bar about chrome automating test
     # if we don't use this flag, every selenium test will die with the error:
     # "unknown error: Chrome failed to start: exited abnormally"
     options.add_argument '--no-sandbox'
     port = 9521
   options.add_preference 'debuggerAddress', "127.0.0.1:#{port}"
   # BREAKS THINGS if uncommented
   # options.add_argument "--remote-debugging-port=#{port}"
     options.add_argument '--headless'
     options.add_argument '--window-size=1600,2400'
     options.add_preference('profile.default_content_settings.popups', 0)
     options.add_preference('download.default_directory', DownloadHelpers::PATH.to_s)
     Capybara::Selenium::Driver.new(
       app,
       clear_local_storage: true,
       clear_session_storage: true,
       browser: :chrome,
       options: options,
       desired_capabilities: capabilities,
     )
   end


    

Roger Sillito

unread,
Mar 2, 2018, 2:58:23 AM3/2/18
to Selenium Users
I found this issue on the Chromium bug tracker which sheds some light - I'm currently pursuing the crmux idea: https://bugs.chromium.org/p/chromedriver/issues/detail?id=878

Julie Silvestri

unread,
Mar 6, 2018, 10:44:55 AM3/6/18
to Selenium Users
Thanks!  I have tried crmux, but Selenium seems to connect to a different port (e.g. 9531 or 9532), so it is still not working.  I tried hard-coding in my gem for it to connect to 9522, but then I get the error:

Selenium::WebDriver::Error::WebDriverError:
            unable to bind to locking port 9522 within 45 seconds

I will also post on the link you sent.
Reply all
Reply to author
Forward
0 new messages