Skip to content

[🐛 Bug]: dotnet Execute Script stopped working on few use cases on 4.24 and above #14720

@omer-za

Description

@omer-za

What happened?

I’m trying to perform a request using JS with the following script.
driver.ExecuteScript(script);
it doesn’t throw any error but also doesn’t perform the request like it was before upgrading selenium version from 4.23 to 4.24

How can we reproduce the issue?

Try to run the following JS on using driver and see if a request is sent.

chrome.webRequest.onHeadersReceived.addListener(
    function(details) {
        var responseHeaders = details.responseHeaders.filter(header => header.name !== 'X-Response-Body-Signature');
        return { responseHeaders };
    },
    {
        urls: ['https://something/vendors/*'],
    },
    ['blocking', 'responseHeaders', 'extraHeaders']
);

function makeRequest (method, url) {
    return new Promise(function (resolve, reject) {
        var xhr = new XMLHttpRequest();
        xhr.open(method, url);
        xhr.addEventListener('load', function () {
            if (xhr.status >= 200 && xhr.status < 300) {
                resolve(xhr.response);
            } else {
                reject({
                    status: xhr.status,
                    statusText: xhr.statusText
                });
            }
        });
        xhr.onerror = function () {
            reject({
                status: xhr.status,
                statusText: xhr.statusText
            });
        };
        xhr.send();
    });
}
makeRequest('GET', 'https://something');


### Relevant log output

```shell
[1730883100.030][INFO]: [86c0407fa12f100431895d5ac7101aa5] COMMAND ExecuteScript {
   "args": [  ],
   "script": "\nchrome.webRequest.onHeadersReceived.addListener(\n    function(details) {\n        var responseHeaders = details.responseHeaders.map(\n            (header) => {\n                if (header.name === 'X-Context-Signature')\n                    header.value = 'bLrAdZ9t6/D/0DnirIq6S452y4OxuUiOFSeQPjsdZn4t3J21TgILC94rXOWsgHNseI91o2vLS007QIKxzQTPfCG046LF191jgysoGPbr2g0LeKacO1RYSCyM8W4SZfSlDfQQIZzT4zb40JiFFtJCltiiWD1arHQjXxgfPGiRAi+5Bwu9fOKS9CVrvNZclrHRinEq2NZctNfCHg4LJIEh/dLdYcXdEe8vdn05a/AqsWBfzeDvQ==';\n                return header;\n        });\n        return { responseHeaders };\n    },\n    {\n        urls: ['https://something'],\n    },\n    ['blocking', 'responseHeaders', 'extraHeaders']\n);\n \nfunction makeRequest (method, url) {\n    return new Promise(function (resolve, reject) {\n        var xhr = new XMLHttpRequest();\n        xhr.open(method, url);\n        xhr.addEventListener('load', function () {\n            if (xhr.status >= 200 && xhr.status \u003C 300) {\n                resolve(xhr.response);\n            } else {\n                reject({\n                    status: xhr.status,\n                    statusText: xhr.statusText\n                });\n            }\n        });\n        xhr.onerror = function () {\n            reject({\n                status: xhr.status,\n                statusText: xhr.statusText\n            });\n        };\n        xhr.send();\n    });\n};\nmakeRequest('GET', 'https://something');\n;"
}
[1730883100.030][INFO]: Waiting for pending navigations...
[1730883100.030][DEBUG]: DevTools WebSocket Command: Runtime.evaluate (id=160) (session_id=2B156A8482D74E7FDB1FFDE9CBAE77BD) 7F3D768072D4CD0BFA0A08FF8A09CA94 {
   "expression": "1"
}
[1730883100.030][DEBUG]: DevTools WebSocket Response: Runtime.evaluate (id=160) (session_id=2B156A8482D74E7FDB1FFDE9CBAE77BD) 7F3D768072D4CD0BFA0A08FF8A09CA94 {
   "result": {
      "description": "1",
      "type": "number",
      "value": 1
   }
}
[1730883100.030][INFO]: Done waiting for pending navigations. Status: ok
[1730883100.030][DEBUG]: DevTools WebSocket Command: Page.getNavigationHistory (id=161) (session_id=2B156A8482D74E7FDB1FFDE9CBAE77BD) 7F3D768072D4CD0BFA0A08FF8A09CA94 {
}
[1730883100.030][DEBUG]: DevTools WebSocket Response: Page.getNavigationHistory (id=161) (session_id=2B156A8482D74E7FDB1FFDE9CBAE77BD) 7F3D768072D4CD0BFA0A08FF8A09CA94 {
   "currentIndex": 0,
   "entries": [ {
      "id": 4,
      "title": "",
      "transitionType": "link",
      "url": "chrome-extension://bdgmpdloimlbdpofeojcfgjdjaelhlcm/_generated_background_page.html",
      "userTypedURL": "chrome-extension://bdgmpdloimlbdpofeojcfgjdjaelhlcm/_generated_background_page.html"
   } ]
}
[1730883100.031][DEBUG]: DevTools WebSocket Command: Runtime.evaluate (id=162) (session_id=2B156A8482D74E7FDB1FFDE9CBAE77BD) 7F3D768072D4CD0BFA0A08FF8A09CA94 {
   "awaitPromise": true,
   "expression": "(function() { // Copyright 2012 The Chromium Authors\n// Use of this source code is governed by a BSD-style license that can be\n// found in the LICENSE file.\n\n/**\n * Enum for WebDriver status codes....",
   "returnByValue": true
}
[1730883100.033][DEBUG]: DevTools WebSocket Response: Runtime.evaluate (id=162) (session_id=2B156A8482D74E7FDB1FFDE9CBAE77BD) 7F3D768072D4CD0BFA0A08FF8A09CA94 {
   "result": {
      "type": "object",
      "value": {
         "status": 0,
         "value": null
      }
   }
}
[1730883100.033][INFO]: Waiting for pending navigations...
[1730883100.033][DEBUG]: DevTools WebSocket Command: Runtime.evaluate (id=163) (session_id=2B156A8482D74E7FDB1FFDE9CBAE77BD) 7F3D768072D4CD0BFA0A08FF8A09CA94 {
   "expression": "1"
}
[1730883100.034][DEBUG]: DevTools WebSocket Response: Runtime.evaluate (id=163) (session_id=2B156A8482D74E7FDB1FFDE9CBAE77BD) 7F3D768072D4CD0BFA0A08FF8A09CA94 {
   "result": {
      "description": "1",
      "type": "number",
      "value": 1
   }
}
[1730883100.034][INFO]: Done waiting for pending navigations. Status: ok
[1730883100.034][INFO]: [86c0407fa12f100431895d5ac7101aa5] RESPONSE ExecuteScript null

Operating System

Mac

Selenium version

4.24

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

Chrome latest

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

Latest

Are you using Selenium Grid?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-needs-triagingA Selenium member will evaluate this soon!I-defectSomething is not working as intendedJ-awaiting answerQuestion asked of user; a reply moves it to triage again

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions