SeleniumHQ / selenium

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

[🐛 Bug]: [java17] Encountered JsonException while using selenium versions higher than 4.13.0 , unable to connect to remote WebDriver #14727

Open mantrishruti opened 2 weeks ago

mantrishruti commented 2 weeks ago

What happened?

Automation framework with same set up works for selenium 4.13.0 but fails as we upgrade selenium version Code using as below - please note - there is no issue with local browser testing , this is happening only for remote grid which is set up on aws cloud . ChromeOptions opt = new ChromeOptions(); driver = new RemoteWebDriver(gridurl);

Error as below - Caused by: org.openqa.selenium.json.JsonException: Expected to read a START_MAP but instead have: NUMBER. Last 0 characters read: , next 19 characters to read: 404 page not found

Grid is up and running as 4.13.0 works fine chrome version used : v.130.0.6723.69

How can we reproduce the issue?

set up selenium grid on aws cloud 
and try to access url using remotewebdriver

 ChromeOptions opt = new ChromeOptions();
  driver = new RemoteWebDriver(gridurl);

Relevant log output

[main] INFO org.testng.internal.Utils - [TestNG] Running:
  C:\Users\shruti.mantri\AppData\Local\JetBrains\IdeaIC2024.2\temp-testng-customsuite.xml

Nov 08, 2024 12:40:14 PM org.openqa.selenium.remote.tracing.opentelemetry.OpenTelemetryTracer createTracer
INFO: Using OpenTelemetry for tracing

org.openqa.selenium.SessionNotCreatedException: Could not start a new session. Unable to parse remote response: 404 page not found

Host info: host: 'AP-BPU94NHAXTMS', ip: '192.168.1.10'

    at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:126)
    at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:96)
    at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:68)
    at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:163)
    at org.openqa.selenium.remote.TracedCommandExecutor.execute(TracedCommandExecutor.java:51)
    at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:523)
    at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:237)
    at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:164)
    at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:144)
    at com.ptsmc.utils.WebDriverManager.setUp(WebDriverManager.java:51)
    at com.ptsmc.utils.WebDriverManager.getDriver(WebDriverManager.java:29)
    at com.ptsmc.utils.TestContextSetUp.<init>(TestContextSetUp.java:18)
    at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:77)
    at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:500)
    at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:481)
    at org.picocontainer.injectors.AbstractInjector.newInstance(AbstractInjector.java:145)
    at org.picocontainer.injectors.ConstructorInjector$1.run(ConstructorInjector.java:342)
    at org.picocontainer.injectors.AbstractInjector$ThreadLocalCyclicDependencyGuard.observe(AbstractInjector.java:270)
    at org.picocontainer.injectors.ConstructorInjector.getComponentInstance(ConstructorInjector.java:364)
    at org.picocontainer.injectors.AbstractInjectionFactory$LifecycleAdapter.getComponentInstance(AbstractInjectionFactory.java:56)
    at org.picocontainer.behaviors.AbstractBehavior.getComponentInstance(AbstractBehavior.java:64)
    at org.picocontainer.behaviors.Stored.getComponentInstance(Stored.java:91)
    at org.picocontainer.DefaultPicoContainer.getInstance(DefaultPicoContainer.java:699)
    at org.picocontainer.DefaultPicoContainer.getComponent(DefaultPicoContainer.java:647)
    at org.picocontainer.DefaultPicoContainer.getComponent(DefaultPicoContainer.java:632)
    at org.picocontainer.parameters.BasicComponentParameter$1.resolveInstance(BasicComponentParameter.java:118)
    at org.picocontainer.parameters.ComponentParameter$1.resolveInstance(ComponentParameter.java:136)
    at org.picocontainer.injectors.SingleMemberInjector.getParameter(SingleMemberInjector.java:78)
    at org.picocontainer.injectors.ConstructorInjector$CtorAndAdapters.getParameterArguments(ConstructorInjector.java:309)
    at org.picocontainer.injectors.ConstructorInjector$1.run(ConstructorInjector.java:335)
    at org.picocontainer.injectors.AbstractInjector$ThreadLocalCyclicDependencyGuard.observe(AbstractInjector.java:270)
    at org.picocontainer.injectors.ConstructorInjector.getComponentInstance(ConstructorInjector.java:364)
    at org.picocontainer.injectors.AbstractInjectionFactory$LifecycleAdapter.getComponentInstance(AbstractInjectionFactory.java:56)
    at org.picocontainer.behaviors.AbstractBehavior.getComponentInstance(AbstractBehavior.java:64)
    at org.picocontainer.behaviors.Stored.getComponentInstance(Stored.java:91)
    at org.picocontainer.DefaultPicoContainer.getInstance(DefaultPicoContainer.java:699)
    at org.picocontainer.DefaultPicoContainer.getComponent(DefaultPicoContainer.java:647)
    at org.picocontainer.DefaultPicoContainer.getComponent(DefaultPicoContainer.java:678)
    at io.cucumber.picocontainer.PicoFactory.getInstance(PicoFactory.java:64)
    at io.cucumber.java.AbstractGlueDefinition.invokeMethod(AbstractGlueDefinition.java:47)
    at io.cucumber.java.JavaStepDefinition.execute(JavaStepDefinition.java:29)
    at io.cucumber.core.runner.CoreStepDefinition.execute(CoreStepDefinition.java:66)
    at io.cucumber.core.runner.PickleStepDefinitionMatch.runStep(PickleStepDefinitionMatch.java:62)
    at io.cucumber.core.runner.ExecutionMode$1.execute(ExecutionMode.java:10)
    at io.cucumber.core.runner.TestStep.executeStep(TestStep.java:81)
    at io.cucumber.core.runner.TestStep.run(TestStep.java:53)
    at io.cucumber.core.runner.PickleStepTestStep.run(PickleStepTestStep.java:51)
    at io.cucumber.core.runner.TestCase.run(TestCase.java:84)
    at io.cucumber.core.runner.Runner.runPickle(Runner.java:75)
    at io.cucumber.testng.TestNGCucumberRunner.lambda$runScenario$1(TestNGCucumberRunner.java:135)
    at io.cucumber.core.runtime.CucumberExecutionContext.lambda$runTestCase$5(CucumberExecutionContext.java:136)
    at io.cucumber.core.runtime.RethrowingThrowableCollector.executeAndThrow(RethrowingThrowableCollector.java:23)
    at io.cucumber.core.runtime.CucumberExecutionContext.runTestCase(CucumberExecutionContext.java:136)
    at io.cucumber.testng.TestNGCucumberRunner.runScenario(TestNGCucumberRunner.java:132)
    at io.cucumber.testng.AbstractTestNGCucumberTests.runScenario(AbstractTestNGCucumberTests.java:35)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:569)
    at org.testng.internal.invokers.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:141)
    at org.testng.internal.invokers.TestInvoker.invokeMethod(TestInvoker.java:686)
    at org.testng.internal.invokers.TestInvoker.invokeTestMethod(TestInvoker.java:230)
    at org.testng.internal.invokers.TestMethodWithDataProviderMethodWorker.call(TestMethodWithDataProviderMethodWorker.java:81)
    at org.testng.internal.thread.Async$AsyncTask.run(Async.java:34)
    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
    at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
    at java.base/java.lang.Thread.run(Thread.java:840)
Caused by: org.openqa.selenium.json.JsonException: Unable to parse: 404 page not found

    at org.openqa.selenium.json.Json.toType(Json.java:169)
    at org.openqa.selenium.json.Json.toType(Json.java:152)
    at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:122)
    ... 68 more
Caused by: org.openqa.selenium.json.JsonException: Expected to read a START_MAP but instead have: NUMBER. Last 0 characters read: , next 19 characters to read: 404 page not found

Build info: version: '4.16.0', revision: '15400459dd*'
System info: os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '17.0.13'
Driver info: driver.version: RemoteWebDriver
    at org.openqa.selenium.json.JsonInput.expect(JsonInput.java:467)
    at org.openqa.selenium.json.JsonInput.beginObject(JsonInput.java:333)
    at org.openqa.selenium.json.MapCoercer.lambda$apply$1(MapCoercer.java:64)
    at org.openqa.selenium.json.JsonTypeCoercer.lambda$buildCoercer$6(JsonTypeCoercer.java:171)
    at org.openqa.selenium.json.JsonTypeCoercer.coerce(JsonTypeCoercer.java:146)
    at org.openqa.selenium.json.Json.toType(Json.java:206)
    at org.openqa.selenium.json.Json.toType(Json.java:167)
    ... 70 more

Nov 08, 2024 12:40:18 PM tech.grasshopper.pdf.PDFCucumberReport collectReportConfiguration
INFO: PDF report configuration YAML file not found. Using default settings.

===============================================
Default Suite
Total tests run: 1, Passes: 0, Failures: 1, Skips: 0
===============================================

Process finished with exit code 0

Operating System

windows 11

Selenium version

Java selenium 4.25.0

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

chrome 130

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

v.130.0.6723.69

Are you using Selenium Grid?

yes 4.25.0

github-actions[bot] commented 2 weeks ago

@mantrishruti, 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!

github-actions[bot] commented 1 week ago

Hi, @mantrishruti. Please follow the issue template, we need more information to reproduce the issue.

Either a complete code snippet and URL/HTML (if more than one file is needed, provide a GitHub repo and instructions to run the code), the specific versions used, or a more detailed description to help us understand the issue.

Note: If you cannot share your code and URL/HTML, any complete code snippet and URL/HTML that reproduces the issue is good enough.

Reply to this issue when all information is provided, thank you.

VietND96 commented 4 days ago

Unable to parse remote response: 404 page not found

What is Grid URL given, can you try to access it with endpoint /status to see any response?