appium: Sometimes 'An error occurred while executing user supplied JavaScript' error happens
Test 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.
About this issue
- Original URL
- State: closed
- Created 11 years ago
- Comments: 19 (11 by maintainers)
Commits related to this issue
- update appium-uiauto to 1.6.3 with sendkeys changes (fix #1567) — committed to jlipps/appium by jlipps 10 years ago
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.