Skip to content

[🐛 Bug]: Selenium interception Response body is getting mocked but not response code #15422

Closed as not planned

Description

@Mohanram3012

What happened?

driver.intercept do |request, &continue|
end
can perfectly replace the response body but not the response code.
With the code below, I can get the intercepted body, but the response code is still 404 (I hope it to be 200)

How can we reproduce the issue?

require 'selenium-webdriver'

driver = Selenium::WebDriver.for :remote, url: "http://localhost:4444/wd/hub", capabilities: :chrome
driver.intercept do |request, &continue|
    uri = URI(request.url)
    if uri.path.end_with?('/not_exist.html')
        continue.call(request) do |r|
            r.code = 200
            r.body = "intercepted"
        end
    else
        continue.call(request)
    end
end

sleep 20
driver.navigate.to "http://www.google.com/not_exist.html"
sleep 20

driver.quit

Relevant log output

NA

Operating System

Mac

Selenium version

4.10

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

chrome133

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

chromedriver133

Are you using Selenium Grid?

NO

Activity

  1. added
    I-defectSomething is not working as intended
    A-needs-triagingA Selenium member will evaluate this soon!
    on Mar 14, 2025
  2. github-actions commented on Mar 14, 2025

    @github-actions
    Contributor

    @Mohanram3012, thank you for creating this issue. We will troubleshoot it as soon as we can.


    Info for maintainers

    Triage this issue by using labels.

    If information is missing, add a helpful comment and then I-issue-template label.

    If the issue is a question, add the I-question label.

    If the issue is valid but there is no time to troubleshoot it, consider adding the help wanted label.

    If the issue requires changes or fixes from an external project (e.g., ChromeDriver, GeckoDriver, MSEdgeDriver, W3C), add the applicable G-* label, and it will provide the correct link and auto-close the issue.

    After troubleshooting the issue, please add the R-awaiting answer label.

    Thank you!

  3. Mohanram3012 commented on Mar 14, 2025

    @Mohanram3012
    Author

    The issue is already reported but couldn't get proper resolution out of it -> #11332

  4. github-actions commented on Sep 15, 2025

    @github-actions
    Contributor

    This issue is stale because it has been open 180 days with no activity. Remove stale label or comment or this will be closed in 14 days.

  5. added
    J-staleApplied to issues that become stale, and eventually closed.
    on Sep 15, 2025
  6. github-actions commented on Sep 30, 2025

    @github-actions
    Contributor

    This issue was closed because it has been stalled for 14 days with no activity.

  7. github-actions commented on Oct 30, 2025

    @github-actions
    Contributor

    This issue has been automatically locked since there has not been any recent activity since it was closed. Please open a new issue for related bugs.

  8. locked and limited conversation to collaborators on Oct 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-needs-triagingA Selenium member will evaluate this soon!C-rbRuby BindingsI-defectSomething is not working as intendedJ-staleApplied to issues that become stale, and eventually closed.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions