What happened?
In Chrome Browser.ExecuteJavaScript<double>("{return performance.timeOrigin ;}"); fails 1 in 10 times because it returns a double truncated to 1 decimal. However when the decimal part is 0 Selenium sees this as a long, which is not IsInstanceOfType double, so it crashes with WebDriverException("Script returned a value, but the result could not be cast to the desired type");.
This means that it is in general not possible to use double for ExecuteJavaScript, even though it often seems correct.
How can we reproduce the issue?
`Browser.ExecuteJavaScript<double>("{return 123.0;}");`
Relevant log output
OpenQA.Selenium.WebDriverException : Script returned a value, but the result could not be cast to the desired type
at OpenQA.Selenium.Support.Extensions.WebDriverExtensions.ExecuteJavaScript[T](IWebDriver driver, String script, Object[] args)
Operating System
Windows 10
Selenium version
.Net 4.8.1
What are the browser(s) and version(s) where you see this issue?
Chrome 111
What are the browser driver(s) and version(s) where you see this issue?
ChromeDriver 111
Are you using Selenium Grid?
No response
What happened?
In Chrome
Browser.ExecuteJavaScript<double>("{return performance.timeOrigin ;}");fails 1 in 10 times because it returns a double truncated to 1 decimal. However when the decimal part is 0 Selenium sees this as a long, which is notIsInstanceOfTypedouble, so it crashes withWebDriverException("Script returned a value, but the result could not be cast to the desired type");.This means that it is in general not possible to use
doubleforExecuteJavaScript, even though it often seems correct.How can we reproduce the issue?
`Browser.ExecuteJavaScript<double>("{return 123.0;}");`Relevant log output
Operating System
Windows 10
Selenium version
.Net 4.8.1
What are the browser(s) and version(s) where you see this issue?
Chrome 111
What are the browser driver(s) and version(s) where you see this issue?
ChromeDriver 111
Are you using Selenium Grid?
No response