Sometimes 'An error occurred while executing user supplied JavaScript' error happens
See original GitHub issueTest case:
- Start app
- Type text to the UIATextField element
- Stop app
- Repeat 1-3 steps in cycle (100 iterations)
selenium.webdriver.remote.remote_connection: POST http://127.0.0.1:4723/wd/hub/session/aad3f7fb-fca5-493f-96b9-07b0525858e9/element/0/value {"sessionId": "aad3f7fb-fca5-493f-96b9-07b0525858e9", "id": "0", "value": ["t", "s", "o", "_", "u", "s", "e", "r", "_", "0", "0", "3", "0"]}
AppiumServer: [90mdebug[39m: Appium request initiated at /wd/hub/session/aad3f7fb-fca5-493f-96b9-07b0525858e9/element/0/value
AppiumServer: [90mdebug[39m: Request received with params: {"sessionId":"aad3f7fb-fca5-493f-96b9-07b0525858e9","id":"0","value":["t","s","o","_","u","s","e","r","_","0","0","3","0"]}
AppiumServer: [36minfo[39m: Pushing command to appium work queue: "au.getElement('0').setValueByType('tso_user_0030')"
AppiumServer: [90mdebug[39m: Sending command to instruments: au.getElement('0').setValueByType('tso_user_0030')
AppiumServer: [36minfo[39m: [90m[INSTSERVER] Sending command to instruments: au.getElement('0').setValueByType('tso_user_0030')[39m
AppiumServer: [36minfo[39m: [32m[INST] 2013-12-03 12:20:04 +0000 Default: Got new command 7 from instruments: au.getElement('0').setValueByType('tso_user_0030')[39m
AppiumServer: [36minfo[39m: [90m[INSTSERVER] Socket data received (153 bytes)[39m
AppiumServer: [36minfo[39m: [90m[INSTSERVER] Socket data being routed for 'cmd' event[39m
AppiumServer: [36minfo[39m: [90m[INSTSERVER] Got result from instruments: {"status":17,"value":"Cannot set value on invalid element: UIATextField from target.frontMostApp().elements()[0].elements()[4]"}[39m
Message: u'An error occurred while executing user supplied JavaScript.'
Traceback (most recent call last):
....
File "/Library/Python/2.7/site-packages/selenium-2.35.0-py2.7.egg/selenium/webdriver/remote/webdriver.py", line 165, in execute
self.error_handler.check_response(response)
File "/Library/Python/2.7/site-packages/selenium-2.35.0-py2.7.egg/selenium/webdriver/remote/errorhandler.py", line 164, in check_response
raise exception_class(message, screen, stacktrace)
WebDriverException: Message: u'An error occurred while executing user supplied JavaScript.'
Note: Xcode 5.0.2, iOS simulator 7.0.3, Appium 0.12.0 Appium in pre-lauched mode.
Issue Analytics
- State:
- Created 10 years ago
- Comments:19 (11 by maintainers)
Top Results From Across the Web
An error occurred while executing user supplied JavaScript
Exception in thread "main" org.openqa.selenium.WebDriverException: An > error occurred while executing user supplied JavaScript.
Read more >JavaScript error - WebDriver - MDN Web Docs
The JavaScript error is a WebDriver error that occurs when a script the supplied by the user fails to execute.
Read more >5 Common Causes of JavaScript Errors (and How to Avoid ...
The error is thrown because JavaScript code is usually executed according to the order it appears on a document. As such, the browser...
Read more >JavaScript errors in Dreamweaver - Adobe Support
Common causes of JavaScript errors in Dreamweaver include a conflicting Dreamweaver extension, a conflict with code on a page, or a bad ...
Read more >Introducing: Click Errors and JavaScript Error Details
Not all JavaScript errors are the same—they can vary greatly based on user details (like browser, OS, country), different parts of your script, ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I just ran into this issue and the following debug logs from the appium server gave me a clue for a workaround:
This is happening in an embedded webview on iOS only.
I solved it by adding my own click actions using the same locator (xpath) that I gave to sendKeys. When I use my own click actions then the keyboard does appear and sendKeys is able to type the text.
It seems that there is a problem with Appium’s sendKeys method and clicking on the text field in embedded web views.
Tested using Appium version 1.4.13 and java-client 3.0.0
NB I was lucky I saw those server error logs. The ‘invalid javascript’ error message that the client receives is not very clear in this case.
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.