Skip to content

[🐛 Bug]: Ruby Selenium Header Injection fails on POST requests - Failed to deserialize params.postData #11256

@KevinTran00

Description

@KevinTran00

What happened?

I would like to inject some headers into all network requests during my tests. This was originally working about 7 months ago. I used this logic of injecting headers for about a month after that and haven't had a need to run this logic since then until this week.

The script throws this exception of -32602: Invalid parameters: Failed to deserialize params.postData - BINDINGS: inv alid base64 string at position 119 (Selenium::WebDriver::Error::WebDriverError) [Number may vary slightly depending on the POST request] whenever it runs into a POST type of network request and thus fails to inject the new headers.

To reproduce this issue, you can execute the provided example reproduction code in irb or standalone ruby.

How can we reproduce the issue?

Example Reproduction Code:


require 'selenium-webdriver'
require 'selenium/devtools'
driver = Selenium::WebDriver.for :chrome
driver.intercept do |request, &continue|
  request.headers['my_test_header'] = 'header_value_123456'
  continue.call(request)
end
driver.navigate.to 'https://www.google.com'


### Relevant log output

```shell
## Note: This output is from the above example reproduction code executed in ruby irb but same behavior is observed when executed via ruby (non-irb debugging)

[20408:15280:1111/155519.306:ERROR:device_event_log_impl.cc(215)] [15:55:19.306] USB: usb_service_win.cc:415 Could not read device interface GUIDs: The system cannot find the file specified. (0x2)
[20408:15280:1111/155519.309:ERROR:device_event_log_impl.cc(215)] [15:55:19.313] USB: usb_device_handle_win.cc:1048 Failed to read descriptor from node connection: A device attached to the system is not functioning. (0x1F)
[20408:15280:1111/155519.309:ERROR:usb_descriptors.cc(141)] Failed to read length for configuration 1.
[20408:15280:1111/155519.309:ERROR:usb_descriptors.cc(100)] Failed to read all configuration descriptors. Expected 2, got 1.
[20408:15280:1111/155519.309:ERROR:device_event_log_impl.cc(215)] [15:55:19.313] USB: usb_device_win.cc:96 Failed to read descriptors from \\?\usb#vid_0bda&pid_8153#000001#{a5dcbf10-6530-11d2-901f-00c04fb951ed}.
[20408:15280:1111/155519.309:ERROR:device_event_log_impl.cc(215)] [15:55:19.314] USB: usb_device_handle_win.cc:1048 Failed to read descriptor from node connection: A device attached to the system is not functioning. (0x1F)
[20408:15280:1111/155519.323:ERROR:device_event_log_impl.cc(215)] [15:55:19.322] USB: usb_device_handle_win.cc:1048 Failed to read descriptor from node connection: A device attached to the system is not functioning. (0x1F)
[20408:15280:1111/155519.329:ERROR:device_event_log_impl.cc(215)] [15:55:19.328] USB: usb_device_handle_win.cc:1048 Failed to read descriptor from node connection: A device attached to the system is not functioning. (0x1F)
[20408:15280:1111/155519.329:ERROR:device_event_log_impl.cc(215)] [15:55:19.329] USB: usb_device_handle_win.cc:1048 Failed to read descriptor from node connection: A device attached to the system is not functioning. (0x1F)
[20408:34160:1111/155616.893:ERROR:util.cc(129)] Can't create base directory: C:\Program Files\Google\GoogleUpdater=> nil

irb(main):009:0> #<Thread:0x067a1aec C:/Ruby31/lib/ruby/gems/3.1.0/gems/selenium-webdriver-4.6.1/lib/selenium/webdriver/common/websocket_connection.rb:114 run> terminated with exception (report_
on_exception is true):
C:/Ruby31/lib/ruby/gems/3.1.0/gems/selenium-webdriver-4.6.1/lib/selenium/webdriver/devtools.rb:49:in `send_cmd': -32602: Invalid parameters: Failed to deserialize params.postData - BINDINGS: inv
alid base64 string at position 119 (Selenium::WebDriver::Error::WebDriverError)
        from C:/Ruby31/lib/ruby/gems/3.1.0/gems/selenium-devtools-0.107.0/lib/selenium/devtools/v107/fetch.rb:66:in `continue_request'
        from C:/Ruby31/lib/ruby/gems/3.1.0/gems/selenium-webdriver-4.6.1/lib/selenium/webdriver/devtools/network_interceptor.rb:135:in `mutate_request'
        from C:/Ruby31/lib/ruby/gems/3.1.0/gems/selenium-webdriver-4.6.1/lib/selenium/webdriver/devtools/network_interceptor.rb:109:in `block in intercept_request'
        from (irb):6:in `block in <top (required)>'
        from C:/Ruby31/lib/ruby/gems/3.1.0/gems/selenium-webdriver-4.6.1/lib/selenium/webdriver/devtools/network_interceptor.rb:103:in `intercept_request'
        from C:/Ruby31/lib/ruby/gems/3.1.0/gems/selenium-webdriver-4.6.1/lib/selenium/webdriver/devtools/network_interceptor.rb:88:in `block in request_paused'
        from C:/Ruby31/lib/ruby/gems/3.1.0/gems/selenium-webdriver-4.6.1/lib/selenium/webdriver/devtools/network_interceptor.rb:164:in `with_cancellable_request'
        from C:/Ruby31/lib/ruby/gems/3.1.0/gems/selenium-webdriver-4.6.1/lib/selenium/webdriver/devtools/network_interceptor.rb:83:in `request_paused'
        from C:/Ruby31/lib/ruby/gems/3.1.0/gems/selenium-webdriver-4.6.1/lib/selenium/webdriver/devtools/network_interceptor.rb:50:in `block in intercept'
        from C:/Ruby31/lib/ruby/gems/3.1.0/gems/selenium-webdriver-4.6.1/lib/selenium/webdriver/common/websocket_connection.rb:124:in `block in callback_thread'
C:/Ruby31/lib/ruby/gems/3.1.0/gems/selenium-webdriver-4.6.1/lib/selenium/webdriver/devtools.rb:49:in `send_cmd': -32602: Invalid parameters: Failed to deserialize params.postData - BINDINGS: inv
alid base64 string at position 119 (Selenium::WebDriver::Error::WebDriverError)
        from C:/Ruby31/lib/ruby/gems/3.1.0/gems/selenium-devtools-0.107.0/lib/selenium/devtools/v107/fetch.rb:66:in `continue_request'
        from C:/Ruby31/lib/ruby/gems/3.1.0/gems/selenium-webdriver-4.6.1/lib/selenium/webdriver/devtools/network_interceptor.rb:135:in `mutate_request'
        from C:/Ruby31/lib/ruby/gems/3.1.0/gems/selenium-webdriver-4.6.1/lib/selenium/webdriver/devtools/network_interceptor.rb:109:in `block in intercept_request'
        from (irb):6:in `block in <top (required)>'
        from C:/Ruby31/lib/ruby/gems/3.1.0/gems/selenium-webdriver-4.6.1/lib/selenium/webdriver/devtools/network_interceptor.rb:103:in `intercept_request'
        from C:/Ruby31/lib/ruby/gems/3.1.0/gems/selenium-webdriver-4.6.1/lib/selenium/webdriver/devtools/network_interceptor.rb:88:in `block in request_paused'
        from C:/Ruby31/lib/ruby/gems/3.1.0/gems/selenium-webdriver-4.6.1/lib/selenium/webdriver/devtools/network_interceptor.rb:164:in `with_cancellable_request'
        from C:/Ruby31/lib/ruby/gems/3.1.0/gems/selenium-webdriver-4.6.1/lib/selenium/webdriver/devtools/network_interceptor.rb:83:in `request_paused'
        from C:/Ruby31/lib/ruby/gems/3.1.0/gems/selenium-webdriver-4.6.1/lib/selenium/webdriver/devtools/network_interceptor.rb:50:in `block in intercept'
        from C:/Ruby31/lib/ruby/gems/3.1.0/gems/selenium-webdriver-4.6.1/lib/selenium/webdriver/common/websocket_connection.rb:124:in `block in callback_thread'

Operating System

Windows 11 (x64)

Selenium version

Ruby 3.1.2; Selenium-webdriver 4.6.1; Selenium-devtools 0.107.0

What are the browser(s) and version(s) where you see this issue?

Chrome 107

What are the browser driver(s) and version(s) where you see this issue?

ChromeDriver 107.0.5304.62 (1eec40d3a5764881c92085aaee66d25075c159aa-refs/branch-heads/5304@{#942})

Are you using Selenium Grid?

No, Selenium Grid was not used.

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-rbRuby BindingsG-chromedriverRequires fixes in ChromeDriverI-defectSomething is not working as intended

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions