SeleniumHQ / selenium

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

[🐛 Bug]: Error in making the API request POST /session/:sessionId/se/log #10399

Closed ankur-lt closed 2 years ago

ankur-lt commented 2 years ago

What happened?

I am trying to get the logs from POST /session/:sessionId/se/log API, but facing errors in it. Following are the steps I followed:

How can we reproduce the issue?

  1. Start Selenium 4 session with the following command
    
    java -Dwebdriver.chrome.driver="/Users/ankur/chromedriver" -jar selenium-server-4.1.1.jar standalone  --driver-configuration display-name="Chrome"   stereotype='{"browserName": "chrome", "browserVersion": "95", "goog:chromeOptions":{"binary":"/Applications/Google Chrome.app/Contents/MacOS/Google Chrome"}}'
2. Start a session with the following request:

```jsx
curl --location --request POST 'localhost:4444/wd/hub/session' \
--header 'Content-Type: application/json; charset=utf-8' \
--data-raw '{
    "desiredCapabilities": {
        "browserName": "chrome",
        "goog:chromeOptions": {
            "args": [
                "--remote-debugging-port=9225"
            ]
        },
        "goog:loggingPrefs": {
            "browser": "ALL",
            "driver": "ALL",
            "server": "ALL"
        }
    },
    "capabilities": {
        "browserName": "chrome"
    }
}'
  1. Get logs with the following request:
curl --location --request GET 'localhost:4444/session/30b9b9b2b29ff8bfeedfd5c27a418c23/se/log' \
--header 'Content-Type: application/json; charset=utf-8' \
--data-raw ''

Getting the error:

{
    "value": {
        "error": "script timeout",
        "message": "Unable to execute request for an existing session: GET /session/30b9b9b2b29ff8bfeedfd5c27a418c23/se/log\nBuild info: version: '4.1.1', revision: 'e8fcc2cecf'\nSystem info: host: 'MacBook-Pro.local', ip: 'fe80:0:0:0:18df:a1f9:77fb:d522%en0', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.16', java.version: '1.8.0_311'\nDriver info: driver.version: unknown",
        "stacktrace": "java.lang.RuntimeException: Unable to execute request for an existing session: GET /session/30b9b9b2b29ff8bfeedfd5c27a418c23/se/log\nBuild info: version: '4.1.1', revision: 'e8fcc2cecf'\nSystem info: host: 'MacBook-Pro.local', ip: 'fe80:0:0:0:18df:a1f9:77fb:d522%en0', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.16', java.version: '1.8.0_311'\nDriver info: driver.version: unknown\n\tat org.openqa.selenium.grid.router.HandleSession.execute(HandleSession.java:139)\n\tat org.openqa.selenium.remote.http.Route$PredicatedRoute.handle(Route.java:373)\n\tat org.openqa.selenium.remote.http.Route.execute(Route.java:68)\n\tat org.openqa.selenium.remote.http.Route$CombinedRoute.handle(Route.java:336)\n\tat org.openqa.selenium.remote.http.Route.execute(Route.java:68)\n\tat org.openqa.selenium.grid.router.Router.execute(Router.java:91)\n\tat org.openqa.selenium.grid.web.CheckOriginHeader.lambda$apply$0(CheckOriginHeader.java:66)\n\tat org.openqa.selenium.grid.web.CheckContentTypeHeader.lambda$apply$0(CheckContentTypeHeader.java:70)\n\tat org.openqa.selenium.grid.web.EnsureSpecCompliantResponseHeaders.lambda$apply$0(EnsureSpecCompliantResponseHeaders.java:34)\n\tat org.openqa.selenium.remote.http.Filter$1.execute(Filter.java:64)\n\tat org.openqa.selenium.remote.http.Route$CombinedRoute.handle(Route.java:336)\n\tat org.openqa.selenium.remote.http.Route.execute(Route.java:68)\n\tat org.openqa.selenium.remote.http.Route$CombinedRoute.handle(Route.java:336)\n\tat org.openqa.selenium.remote.http.Route.execute(Route.java:68)\n\tat org.openqa.selenium.remote.AddWebDriverSpecHeaders.lambda$apply$0(AddWebDriverSpecHeaders.java:35)\n\tat org.openqa.selenium.remote.ErrorFilter.lambda$apply$0(ErrorFilter.java:44)\n\tat org.openqa.selenium.remote.http.Filter$1.execute(Filter.java:64)\n\tat org.openqa.selenium.remote.ErrorFilter.lambda$apply$0(ErrorFilter.java:44)\n\tat org.openqa.selenium.remote.http.Filter$1.execute(Filter.java:64)\n\tat org.openqa.selenium.netty.server.SeleniumHandler.lambda$channelRead0$0(SeleniumHandler.java:44)\n\tat java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)\n\tat java.util.concurrent.FutureTask.run(FutureTask.java:266)\n\tat java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)\n\tat java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)\n\tat java.lang.Thread.run(Thread.java:748)\n"
    }
}

How can I get the logs here?


### Relevant log output

```shell
{
    "value": {
        "error": "script timeout",
        "message": "Unable to execute request for an existing session: GET /session/30b9b9b2b29ff8bfeedfd5c27a418c23/se/log\nBuild info: version: '4.1.1', revision: 'e8fcc2cecf'\nSystem info: host: 'MacBook-Pro.local', ip: 'fe80:0:0:0:18df:a1f9:77fb:d522%en0', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.16', java.version: '1.8.0_311'\nDriver info: driver.version: unknown",
        "stacktrace": "java.lang.RuntimeException: Unable to execute request for an existing session: GET /session/30b9b9b2b29ff8bfeedfd5c27a418c23/se/log\nBuild info: version: '4.1.1', revision: 'e8fcc2cecf'\nSystem info: host: 'MacBook-Pro.local', ip: 'fe80:0:0:0:18df:a1f9:77fb:d522%en0', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.16', java.version: '1.8.0_311'\nDriver info: driver.version: unknown\n\tat org.openqa.selenium.grid.router.HandleSession.execute(HandleSession.java:139)\n\tat org.openqa.selenium.remote.http.Route$PredicatedRoute.handle(Route.java:373)\n\tat org.openqa.selenium.remote.http.Route.execute(Route.java:68)\n\tat org.openqa.selenium.remote.http.Route$CombinedRoute.handle(Route.java:336)\n\tat org.openqa.selenium.remote.http.Route.execute(Route.java:68)\n\tat org.openqa.selenium.grid.router.Router.execute(Router.java:91)\n\tat org.openqa.selenium.grid.web.CheckOriginHeader.lambda$apply$0(CheckOriginHeader.java:66)\n\tat org.openqa.selenium.grid.web.CheckContentTypeHeader.lambda$apply$0(CheckContentTypeHeader.java:70)\n\tat org.openqa.selenium.grid.web.EnsureSpecCompliantResponseHeaders.lambda$apply$0(EnsureSpecCompliantResponseHeaders.java:34)\n\tat org.openqa.selenium.remote.http.Filter$1.execute(Filter.java:64)\n\tat org.openqa.selenium.remote.http.Route$CombinedRoute.handle(Route.java:336)\n\tat org.openqa.selenium.remote.http.Route.execute(Route.java:68)\n\tat org.openqa.selenium.remote.http.Route$CombinedRoute.handle(Route.java:336)\n\tat org.openqa.selenium.remote.http.Route.execute(Route.java:68)\n\tat org.openqa.selenium.remote.AddWebDriverSpecHeaders.lambda$apply$0(AddWebDriverSpecHeaders.java:35)\n\tat org.openqa.selenium.remote.ErrorFilter.lambda$apply$0(ErrorFilter.java:44)\n\tat org.openqa.selenium.remote.http.Filter$1.execute(Filter.java:64)\n\tat org.openqa.selenium.remote.ErrorFilter.lambda$apply$0(ErrorFilter.java:44)\n\tat org.openqa.selenium.remote.http.Filter$1.execute(Filter.java:64)\n\tat org.openqa.selenium.netty.server.SeleniumHandler.lambda$channelRead0$0(SeleniumHandler.java:44)\n\tat java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)\n\tat java.util.concurrent.FutureTask.run(FutureTask.java:266)\n\tat java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)\n\tat java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)\n\tat java.lang.Thread.run(Thread.java:748)\n"
    }
}

Operating System

MacOS Monterey

Selenium version

4.1.1

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?

Chromedriver

Are you using Selenium Grid?

4.1.1

github-actions[bot] commented 2 years ago

@ankur-lt, 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, 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!

titusfortner commented 2 years ago

Not sure why it's giving that error, but usually the bindings manage things better than curl will. Also the server is going to ignore everything in desired capabilities in favor of what's in capabilities, so only send that one.

titusfortner commented 2 years ago

If you are going to use CURL, you need to make sure you are reading the w3c spec.

here's an example of starting with capabilities, pay attention to firstMatch vs alwaysMatch syntax: https://w3c.github.io/webdriver/#example-7

Logging was not agreed on in w3c meetings, so the logging is a selenium specific implementation brought over from JSON Wire Protocol: https://www.selenium.dev/documentation/legacy/json_wire_protocol/#sessionsessionidlog

Note that you need to use GET se/log/types in order to see what are available

Then you need to POST se/log with {"type": logType}

github-actions[bot] commented 2 years ago

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