SeleniumHQ / selenium

A browser automation framework and ecosystem.
https://selenium.dev
Apache License 2.0
30.68k stars 8.19k forks source link

[šŸ› Bug]: dotnet Execute Script stopped working on few use cases on 4.24 and above #14720

Open omer-za opened 19 hours ago

omer-za commented 19 hours ago

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

github-actions[bot] commented 19 hours ago

@omer-za, 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!