Open bswhb opened 4 years ago
Hi there, I was trying to simulate a button click with JS in an Android WebView application, and found out the same script can not work on wd. Here's the code:
const js = 'var el=arguments[0];el.click();' await webdriver.execute(js, [clickableElement])
Here's the appium console output:
[HTTP] --> POST /wd/hub/session/8a880501-e737-4241-bd9f-748df49f7cdc/execute [HTTP] {"script":"var el=arguments[0];el.click();","args":[{"ELEMENT":"74f110ed-ff58-4b2f-82b8-933b5d78ff38"}]} [MJSONWP (8a880501)] Driver proxy active, passing request on via HTTP proxy [debug] [WD Proxy] Matched '/wd/hub/session/8a880501-e737-4241-bd9f-748df49f7cdc/execute' to command name 'execute' [Protocol Converter] Rewrote the original URL '/wd/hub/session/8a880501-e737-4241-bd9f-748df49f7cdc/execute' to '/wd/hub/session/8a880501-e737-4241-bd9f-748df49f7cdc/execute/sync' for W3C protocol [debug] [WD Proxy] Proxying [POST /wd/hub/session/8a880501-e737-4241-bd9f-748df49f7cdc/execute/sync] to [POST http://127.0.0.1:8000/wd/hub/session/bb5286b26ad42d34aa736dab637db5de/execute/sync] with body: {"script":"var el=arguments[0];el.click();","args":[{"ELEMENT":"74f110ed-ff58-4b2f-82b8-933b5d78ff38"}]} [WD Proxy] Got an unexpected response with status 500: {"value":{"error":"javascript error","message":"javascript error: el.click is not a function\n (Session info: chrome=80.0.3987.132)","stacktrace":"Backtrace:\n\tOrdinal0 [0x010D0C83+1707139]\n\tOrdinal0 [0x010368F1+1075441]\n\tOrdinal0 [0x00FADFC9+516041]\n\tOrdinal0 [0x00FAFC75+523381]\n\tOrdinal0 [0x00FAFB64+523108]\n\tOrdinal0 [0x00FB022D+524845]\n\tOrdinal0 [0x00F6392B+211243]\n\tOrdinal0 [0x00F59E9D+171677]\n\tOrdinal0 [0x00F630F4+209140]\n\tOrdinal0 [0x00F59D4B+171339]\n\tOrdinal0 [0x00F41D4A+73034]\n\tOrdinal0 [0x00F42DC0+77248]\n\tOrdinal0 [0x00F42D59+77145]\n\tOrdinal0 [0x0104BB67+1162087]\n\tGetHandleVerifier [0x0116A966+508998]\n\tGetHandleVerifier [0x0116A6A4+508292]\n\tGetHandleVerifier [0x0117F7B7+594583]\n\tGetHandleVerifier [0x0116B1D6+511158]\n\tOrdinal0 [0x0104402C+1130540]\n\tOrdinal0 [0x0104D4CB+1168587]\n\tOrdinal0 [0x0104D633+1168947]\n\tOrdinal0 [0x01065B35+1268533]\n\tBaseThreadInitThunk [0x760A6359+25]\n\tRtlGetAppContainerNamedObjectPath [0x77AA7B74+228]\n\tRtlGetAppContainerName... [debug] [MJSONWP (8a880501)] Encountered internal error running command: ProxyRequestError: Could not proxy command to remote server. Original error: 500 - {"value":{"error":"javascript error","message":"javascript error: el.click is not a function\n (Session info: chrome=80.0.3987.132)","stacktrace":"Backtrace:\n\tOrdinal0 [0x010D0C83+1707139]\n\tOrdinal0 [0x010368F1+1075441]\n\tOrdinal0 [0x00FADFC9+516041]\n\tOrdinal0 [0x00FAFC75+523381]\n\tOrdinal0 [0x00FAFB64+523108]\n\tOrdinal0 [0x00FB022D+524845]\n\tOrdinal0 [0x00F6392B+211243]\n\tOrdinal0 [0x00F59E9D+171677]\n\tOrdinal0 [0x00F630F4+209140]\n\tOrdinal0 [0x00F59D4B+171339]\n\tOrdinal0 [0x00F41D4A+73034]\n\tOrdinal0 [0x00F42DC0+77248]\n\tOrdinal0 [0x00F42D59+77145]\n\tOrdinal0 [0x0104BB67+1162087]\n\tGetHandleVerifier [0x0116A966+508998]\n\tGetHandleVerifier [0x0116A6A4+508292]\n\tGetHandleVerifier [0x0117F7B7+594583]\n\tGetHandleVerifier [0x0116B1D6+511158]\n\tOrdinal0 [0x0104402C+1130540]\n\tOrdinal0 [0x0104D4CB+1168587]\n\tOrdinal0 [0x0104D633+1168947]\n\tOrdinal0 [0x01065B35+1268533]\n\tBaseThreadInitThunk [0x760A6359+25]\n\tRtlGetAppContainerNamedObjectPath [0x77AA7B74+228]\n\tRtlGetAppContainerNamedObjectPath [0x77AA7B44+180]\n"}} [debug] [MJSONWP (8a880501)] at JWProxy.proxy (C:\Users\bswhb\AppData\Roaming\npm\node_modules\appium\node_modules\appium-base-driver\lib\jsonwp-proxy\proxy.js:222:13) [debug] [W3C] Matched W3C error code 'javascript error' to JavaScriptError
But the same script can work on the Java client of Appium, and I found the difference is Java will pass two arguments which looks like below:
[HTTP] {"script":"arguments[0].click();","args":[{"ELEMENT":"576bd040-ce6b-4fdf-92d8-072b10e4a599","element-6066-11e4-a52e-4f735466cecf":"576bd040-ce6b-4fdf-92d8-072b10e4a599"}]}
The 2nd argument has the key to the id of the element to click, that is element-6066-11e4-a52e-4f735466cecf.
element-6066-11e4-a52e-4f735466cecf
Kindly please advise why the commands are different, and how to fix it, thanks a lot!
Best regards, Hanbo
Hi there, I was trying to simulate a button click with JS in an Android WebView application, and found out the same script can not work on wd. Here's the code:
Here's the appium console output:
But the same script can work on the Java client of Appium, and I found the difference is Java will pass two arguments which looks like below:
The 2nd argument has the key to the id of the element to click, that is
element-6066-11e4-a52e-4f735466cecf
.Kindly please advise why the commands are different, and how to fix it, thanks a lot!
Best regards, Hanbo