org.openqa.selenium.WebDriverException: unknown error: Runtime.callFunctionOn threw exception: TypeError: JSON.stringify is not a function at buildError (<anonymous>:323:18)

591 views
Skip to first unread message

Bhagyashree

unread,
Jun 19, 2023, 10:28:26 AM6/19/23
to Selenium Users
I am trying to identify and webelement with xpath "@FindBy(xpath="(//*[contains(text(),'Crew')])[4]")

WebElement crew;".

It is inside a frame, when trying to click on the element am getting the below exception .

org.openqa.selenium.WebDriverException: unknown error: Runtime.callFunctionOn threw exception: TypeError: JSON.stringify is not a function
    at buildError (<anonymous>:323:18)
  (Session info: MicrosoftEdge=114.0.1823.51)
Build info: version: '4.9.1', revision: 'eb2032df7f'
System info: os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '17.0.5'
Driver info: org.openqa.selenium.edge.EdgeDriver
Command: [416cd93099e568c474ceed26e34f15cc, findElement {using=xpath, value=//dt[contains(text(),'Crew')]}]
Capabilities {acceptInsecureCerts: false, browserName: msedge, browserVersion: 114.0.1823.51, ms:edgeOptions: {debuggerAddress: localhost:59975}, msedge: {msedgedriverVersion: 114.0.1823.51 (ab4ec67361d1..., userDataDir: C:\Users\HP\AppData\Local\T...}, networkConnectionEnabled: false, pageLoadStrategy: normal, platformName: windows, proxy: Proxy(), se:cdp: ws://localhost:59975/devtoo..., se:cdpVersion: 114.0.1823.51, setWindowRect: true, strictFileInteractability: false, timeouts: {implicit: 0, pageLoad: 300000, script: 30000}, unhandledPromptBehavior: dismiss and notify, webauthn:extension:credBlob: true, webauthn:extension:largeBlob: true, webauthn:extension:minPinLength: true, webauthn:extension:prf: true, webauthn:virtualAuthenticators: true}
Session ID: 416cd93099e568c474ceed26e34f15cc
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:499)
at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:480)
at org.openqa.selenium.remote.codec.w3c.W3CHttpResponseCodec.createException(W3CHttpResponseCodec.java:200)
at org.openqa.selenium.remote.codec.w3c.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:133)
at org.openqa.selenium.remote.codec.w3c.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:53)
at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:193)
at org.openqa.selenium.remote.service.DriverCommandExecutor.invokeExecute(DriverCommandExecutor.java:183)
at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:158)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:543)
at org.openqa.selenium.remote.ElementLocation$ElementFinder$2.findElement(ElementLocation.java:162)
at org.openqa.selenium.remote.ElementLocation.findElement(ElementLocation.java:60)
at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:352)
at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:344)
at org.openqa.selenium.support.pagefactory.DefaultElementLocator.findElement(DefaultElementLocator.java:70)
at org.openqa.selenium.support.pagefactory.internal.LocatingElementHandler.invoke(LocatingElementHandler.java:39)
at jdk.proxy2/jdk.proxy2.$Proxy21.getWrappedElement(Unknown Source)
at org.openqa.selenium.remote.internal.WebElementToJsonConverter.apply(WebElementToJsonConverter.java:51)
at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197)
at java.base/java.util.Spliterators$ArraySpliterator.forEachRemaining(Spliterators.java:992)
at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509)
at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499)
at java.base/java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:921)
at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
at java.base/java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:682)
at org.openqa.selenium.remote.RemoteWebDriver.executeScript(RemoteWebDriver.java:477)
at com.compass.pages.SP100_CMP16526_Story.verifyAccomodationOnboardCrewList(SP100_CMP16526_Story.java:97)
at com.compass.testcases.SP100_CMP16526.TC_05_verifyAccomodationOnboardCrewList(SP100_CMP16526.java:221)
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.testng.internal.invokers.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:139)
at org.testng.internal.invokers.TestInvoker.invokeMethod(TestInvoker.java:677)
at org.testng.internal.invokers.TestInvoker.invokeTestMethod(TestInvoker.java:221)
at org.testng.internal.invokers.MethodRunner.runInSequence(MethodRunner.java:50)
at org.testng.internal.invokers.TestInvoker$MethodInvocationAgent.invoke(TestInvoker.java:969)
at org.testng.internal.invokers.TestInvoker.invokeTestMethods(TestInvoker.java:194)
at org.testng.internal.invokers.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:148)
at org.testng.internal.invokers.TestMethodWorker.run(TestMethodWorker.java:128)
at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
at org.testng.TestRunner.privateRun(TestRunner.java:829)
at org.testng.TestRunner.run(TestRunner.java:602)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:437)
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:431)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:391)
at org.testng.SuiteRunner.run(SuiteRunner.java:330)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:95)
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1256)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1176)
at org.testng.TestNG.runSuites(TestNG.java:1099)
at org.testng.TestNG.run(TestNG.java:1067)
at org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:115)
at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:251)
at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:77)

Shivam Kumar Bhatnagar

unread,
Jun 19, 2023, 10:55:50 AM6/19/23
to seleniu...@googlegroups.com
Hi ,
Please check the Iframe id, if it is in frame so again you will checkNested IFrame as well .


Shivam Kumar Bhatnagar

Test Engineer | EdServices

: www.magicedtech.com

  : +91 9027699186



--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/063086c9-2556-49a9-87b5-558545cc19b5n%40googlegroups.com.

"The content of this email is confidential and intended solely for the use of the individual or entity to whom they are addressed. It is strictly forbidden to share any part of this message with any third party, without the written consent of the sender. If you have received it by mistake, please inform us by an email reply and then delete the message. If you are not the intended recipient, you are notified that disclosing, copying, distributing, or taking any action in reliance on the contents of this information is strictly prohibited".

Harit Yadav

unread,
Jun 24, 2023, 2:12:14 AM6/24/23
to Selenium Users
Any updates? I am facing same error when trying to find elements or executing javascript in python.

Harit Yadav

unread,
Jun 24, 2023, 2:12:14 AM6/24/23
to Selenium Users
Any updates on this? I am using selenium with python and am getting the same issue when trying to find elements or when executing javascript on page.

from selenium.webdriver.chrome.service import Service

service = Service(executable_path="C:/Users/hy84957/git/robot-framework/ERA/v4/chromedriverERA.exe")
driver = webdriver.Chrome(service=service)

driver.maximize_window()  

driver.get("internal link")

driver.execute_script("dummy_obj = {};")


--------------------------------------------------------------------------- WebDriverException Traceback (most recent call last) Input In [5], in <module> ----> 1 driver.execute_script("ola = {};") File C:\Miniconda-4.10.3-py3812\lib\site-packages\selenium\webdriver\remote\webdriver.py:406, in WebDriver.execute_script(self, script, *args) 403 converted_args = list(args) 404 command = Command.W3C_EXECUTE_SCRIPT --> 406 return self.execute(command, {"script": script, "args": converted_args})["value"] File C:\Miniconda-4.10.3-py3812\lib\site-packages\selenium\webdriver\remote\webdriver.py:346, in WebDriver.execute(self, driver_command, params) 344 response = self.command_executor.execute(driver_command, params) 345 if response: --> 346 self.error_handler.check_response(response) 347 response["value"] = self._unwrap_value(response.get("value", None)) 348 return response File C:\Miniconda-4.10.3-py3812\lib\site-packages\selenium\webdriver\remote\errorhandler.py:245, in ErrorHandler.check_response(self, response) 243 alert_text = value["alert"].get("text") 244 raise exception_class(message, screen, stacktrace, alert_text) # type: ignore[call-arg] # mypy is not smart enough here --> 245 raise exception_class(message, screen, stacktrace) WebDriverException: Message: unknown error: Runtime.callFunctionOn threw exception: TypeError: JSON.stringify is not a function at buildError (<anonymous>:323:18) (Session info: chrome=114.0.5735.91) Stacktrace: Backtrace: GetHandleVerifier [0x00246E73+48323] (No symbol) [0x001D9661] (No symbol) [0x000E5308] (No symbol) [0x000E84D6] (No symbol) [0x000EA14B] (No symbol) [0x0013D419] (No symbol) [0x0012A8DC] (No symbol) [0x0013CAC2] (No symbol) [0x0012A6D6] (No symbol) [0x0010847C] (No symbol) [0x0010957D] GetHandleVerifier [0x004AFD5D+2575277] GetHandleVerifier [0x004EF86E+2836158] GetHandleVerifier [0x004E96DC+2811180] GetHandleVerifier [0x002D41B0+626688] (No symbol) [0x001E314C] (No symbol) [0x001DF4B8] (No symbol) [0x001DF59B] (No symbol) [0x001D21B7] BaseThreadInitThunk [0x771000C9+25] RtlGetAppContainerNamedObjectPath [0x77B57B4E+286] RtlGetAppContainerNamedObjectPath [0x77B57B1E+238] (No symbol) [0x00000000]
On Monday, June 19, 2023 at 8:25:50 PM UTC+5:30 shivam.b...@magicedtech.com wrote:
Reply all
Reply to author
Forward
0 new messages