What happened?
When calling Network.setCookie, any value set for expires is serialized as a string
INFO: -> {
"id": 5,
"method": "Network.setCookie",
"params": {
"name": "test",
"value": "test",
"domain": ".example.com",
"expires": "-1"
},
"sessionId": "BBD81B244C0A68D25C798704C7C340E2"
}
Response is an error
{"id":5,"error":{"code":-32602,"message":"Invalid parameters","data":"Failed to deserialize params.expires - BINDINGS: double value expected at position 56"},"sessionId":"BBD81B244C0A68D25C798704C7C340E2"}
Seems like it should be serialized as a double, eg: "expires": -1 not "expires": "-1"
How can we reproduce the issue?
Unit test to reproduce issue --
Test setCookieDoesNotWork will fail
`import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;
import org.openqa.selenium.devtools.DevTools;
import org.openqa.selenium.devtools.v85.network.Network;
import org.openqa.selenium.devtools.v85.network.model.TimeSinceEpoch;
import java.util.Optional;
public class SetCookieTest {
private ChromeDriver chromeDriver = null;
private DevTools devTools = null;
@Before
public void setup() {
ChromeOptions chromeOptions = new ChromeOptions();
chromeOptions.setHeadless(true);
chromeDriver = new ChromeDriver(chromeOptions);
devTools = chromeDriver.getDevTools();
devTools.createSession();
}
@After
public void cleanup() {
chromeDriver.quit();
}
@Test
public void setCookieWorks() {
devTools.send(Network.setCookie(
"test",
"test",
Optional.empty(),
Optional.of(".example.com"),
Optional.empty(),
Optional.empty(),
Optional.empty(),
Optional.empty(),
Optional.empty(),
Optional.empty()));
}
@Test
public void setCookieDoesNotWork() {
// this fails with error:
// {"id":6,"error":{"code":-32602,"message":"Invalid parameters","data":"Failed to deserialize params.expires - BINDINGS: double value expected at position 56"},"sessionId":"D99E2349D88F4D799EC526BCCE31B9EF"}
devTools.send(Network.setCookie(
"test",
"test",
Optional.empty(),
Optional.of(".example.com"),
Optional.empty(),
Optional.empty(),
Optional.empty(),
Optional.empty(),
// when TimeSinceEpoch fails
Optional.of(new TimeSinceEpoch(-1)),
Optional.empty()));
}
}
`
Relevant log output
Exception message --
org.openqa.selenium.devtools.DevToolsException: {"id":5,"error":{"code":-32602,"message":"Invalid parameters","data":"Failed to deserialize params.expires - BINDINGS: double value expected at position 56"},"sessionId":"69A350CDD71F711A42EE71A1266FCC76"}
Build info: version: '4.1.0', revision: '87802e897b'
System info: host: 'rhart-rmac.local', ip: '192.168.1.116', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '11.6', java.version: '17'
Driver info: driver.version: unknown
at org.openqa.selenium.devtools.Connection.sendAndWait(Connection.java:159)
at org.openqa.selenium.devtools.DevTools.send(DevTools.java:70)
at SetCookieTest.setCookieDoesNotWork(SetCookieTest.java:55)
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:568)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:59)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:56)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)
at org.junit.runners.BlockJUnit4ClassRunner$1.evaluate(BlockJUnit4ClassRunner.java:100)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:366)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:103)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:63)
at org.junit.runners.ParentRunner$4.run(ParentRunner.java:331)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:79)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:329)
at org.junit.runners.ParentRunner.access$100(ParentRunner.java:66)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:293)
at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)
at org.junit.runners.ParentRunner.run(ParentRunner.java:413)
at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:69)
at com.intellij.rt.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:33)
at com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:235)
at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:54)
Caused by: org.openqa.selenium.WebDriverException: {"id":5,"error":{"code":-32602,"message":"Invalid parameters","data":"Failed to deserialize params.expires - BINDINGS: double value expected at position 56"},"sessionId":"69A350CDD71F711A42EE71A1266FCC76"}
Build info: version: '4.1.0', revision: '87802e897b'
System info: host: 'rhart-rmac.local', ip: '192.168.1.116', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '11.6', java.version: '17'
Driver info: driver.version: unknown
at org.openqa.selenium.devtools.Connection.handle(Connection.java:234)
at org.openqa.selenium.devtools.Connection.access$200(Connection.java:58)
at org.openqa.selenium.devtools.Connection$Listener.lambda$onText$0(Connection.java:199)
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:833)
Operating System
macOS Big Sur
Selenium version
Java 4.1.0/4.0.0
What are the browser(s) and version(s) where you see this issue?
Chrome 96
What are the browser driver(s) and version(s) where you see this issue?
ChromeDriver 96
Are you using Selenium Grid?
Not applicable
What happened?
When calling Network.setCookie, any value set for expires is serialized as a string
Response is an error
{"id":5,"error":{"code":-32602,"message":"Invalid parameters","data":"Failed to deserialize params.expires - BINDINGS: double value expected at position 56"},"sessionId":"BBD81B244C0A68D25C798704C7C340E2"}Seems like it should be serialized as a double, eg:
"expires": -1not"expires": "-1"How can we reproduce the issue?
Relevant log output
Exception message -- org.openqa.selenium.devtools.DevToolsException: {"id":5,"error":{"code":-32602,"message":"Invalid parameters","data":"Failed to deserialize params.expires - BINDINGS: double value expected at position 56"},"sessionId":"69A350CDD71F711A42EE71A1266FCC76"} Build info: version: '4.1.0', revision: '87802e897b' System info: host: 'rhart-rmac.local', ip: '192.168.1.116', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '11.6', java.version: '17' Driver info: driver.version: unknown at org.openqa.selenium.devtools.Connection.sendAndWait(Connection.java:159) at org.openqa.selenium.devtools.DevTools.send(DevTools.java:70) at SetCookieTest.setCookieDoesNotWork(SetCookieTest.java:55) 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:568) at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:59) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:56) at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17) at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26) at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27) at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306) at org.junit.runners.BlockJUnit4ClassRunner$1.evaluate(BlockJUnit4ClassRunner.java:100) at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:366) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:103) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:63) at org.junit.runners.ParentRunner$4.run(ParentRunner.java:331) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:79) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:329) at org.junit.runners.ParentRunner.access$100(ParentRunner.java:66) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:293) at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306) at org.junit.runners.ParentRunner.run(ParentRunner.java:413) at org.junit.runner.JUnitCore.run(JUnitCore.java:137) at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:69) at com.intellij.rt.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:33) at com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:235) at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:54) Caused by: org.openqa.selenium.WebDriverException: {"id":5,"error":{"code":-32602,"message":"Invalid parameters","data":"Failed to deserialize params.expires - BINDINGS: double value expected at position 56"},"sessionId":"69A350CDD71F711A42EE71A1266FCC76"} Build info: version: '4.1.0', revision: '87802e897b' System info: host: 'rhart-rmac.local', ip: '192.168.1.116', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '11.6', java.version: '17' Driver info: driver.version: unknown at org.openqa.selenium.devtools.Connection.handle(Connection.java:234) at org.openqa.selenium.devtools.Connection.access$200(Connection.java:58) at org.openqa.selenium.devtools.Connection$Listener.lambda$onText$0(Connection.java:199) 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:833)Operating System
macOS Big Sur
Selenium version
Java 4.1.0/4.0.0
What are the browser(s) and version(s) where you see this issue?
Chrome 96
What are the browser driver(s) and version(s) where you see this issue?
ChromeDriver 96
Are you using Selenium Grid?
Not applicable