Continuing my Appium adventure with the latest Appium.app 1.3.5, Appium-Python-Client 0.13, Xcode 6.1.1, iOS 8.x simulator.
Happily, when attempting to execute an element.click()
against a native object that is out of view, Appium automatically scrolls it into view prior to clicking on it. No brain power or extra code required.
However, I’m finally venturing into hybrid webviews and am finding that the same simple element.click()
fails horribly if the element physically exists, but is not visible / currently in view.
I’ve tried the following code to scroll to the element:
el = self.driver.find_element_by_xpath('//UIAWebView/UIALink[contains(@name,"Physical Security Services")]') self.driver.execute_script("mobile: scrollTo", {"element": el.id}) el.click()
I see the vertical scroll bar indicator flash in the right margin indicating something is attempting to scroll, but the webview itself never physically moves (is never scrolled).
What am I doing wrong?
What is the appropriate path to success?
Here is the pertinent logging which shows the successful element discovery, attempted scrollTo, then attempted and failed click (which appears to also automatically attempt a scrollTo).
2015-02-12 18:02:50:004 - info: [debug] [INST] 2015-02-12 18:02:49 +0000 Debug: Lookup returned [object UIALink] with the name "Physical Security Services" (id: 14). 2015-02-12 18:02:50:018 - info: [debug] [INST] 2015-02-12 18:02:49 +0000 Debug: responding with: 2015-02-12 18:02:50:031 - info: [debug] [INST] 2015-02-12 18:02:49 +0000 Debug: Running system command #59: /Applications/Appium.app/Contents/Resources/node/bin/node /Applications/Appium.app/Contents/Resources/node_modules/appium/node_modules/appium-uiauto/bin/command-proxy-client.js /tmp/instruments_sock 2,{"status":0,"value":{"ELEMENT":"14"}}... 2015-02-12 18:02:50:053 - info: [debug] Socket data received (39 bytes) 2015-02-12 18:02:50:053 - info: [debug] Socket data being routed. 2015-02-12 18:02:50:053 - info: [debug] Got result from instruments: {"status":0,"value":{"ELEMENT":"14"}} 2015-02-12 18:02:50:053 - info: [debug] Responding to client with success: {"status":0,"value":{"ELEMENT":"14"},"sessionId":"ced8e825-4fb5-4a04-b5aa-9762ae3a13ed"} 2015-02-12 18:02:50:054 - info: <-- POST /wd/hub/session/ced8e825-4fb5-4a04-b5aa-9762ae3a13ed/element 200 865.261 ms - 88 {"status":0,"value":{"ELEMENT":"14"},"sessionId":"ced8e825-4fb5-4a04-b5aa-9762ae3a13ed"} 2015-02-12 18:02:50:055 - info: --> POST /wd/hub/session/ced8e825-4fb5-4a04-b5aa-9762ae3a13ed/execute {"sessionId":"ced8e825-4fb5-4a04-b5aa-9762ae3a13ed","args":[{"element":"14"}],"script":"mobile: scrollTo"} 2015-02-12 18:02:50:057 - warn: scrollTo will be removed in a future version of appium 2015-02-12 18:02:50:057 - info: [debug] Pushing command to appium work queue: "au.getElement('14').scrollToVisible()" 2015-02-12 18:02:50:057 - info: [debug] Sending command to instruments: au.getElement('14').scrollToVisible() 2015-02-12 18:02:50:095 - info: [debug] [INST] 2015-02-12 18:02:50 +0000 Debug: Got new command 59 from instruments: au.getElement('14').scrollToVisible() 2015-02-12 18:02:50:109 - info: [debug] [INST] 2015-02-12 18:02:50 +0000 Debug: evaluating au.getElement('14').scrollToVisible() 2015-02-12 18:02:50:122 - info: [debug] [INST] 2015-02-12 18:02:50 +0000 Debug: target.frontMostApp().elements()[1].elements()[1].elements()[0].elements()[48].scrollToVisible() 2015-02-12 18:02:50:412 - info: [IOS_SYSLOG_ROW ] Feb 12 13:02:50 --- last message repeated 13 times --- 2015-02-12 18:02:50:412 - info: [IOS_SYSLOG_ROW ] Feb 12 13:02:50 CHRIGRAH-M-2038 lsd[68230]: LaunchServices: Currently 0 installed placeholders: ( 2015-02-12 18:02:50:412 - info: [IOS_SYSLOG_ROW ] ) 2015-02-12 18:02:50:779 - info: [IOS_SYSLOG_ROW ] Feb 12 13:02:50 CHRIGRAH-M-2038 assertiond[68218]: assertion failed: 14C109 12B411: assertiond + 11523 [3F572A0B-7E12-378D-AFEE-EA491BAF2C36]: 0x1 2015-02-12 18:02:52:708 - info: --> GET /wd/hub/status {} 2015-02-12 18:02:52:708 - info: [debug] Responding to client with success: {"status":0,"value":{"build":{"version":"1.3.5","revision":"a124a15677e26b33db16e81c4b3b34d9c6b8cac9"},"isShuttingDown":false},"sessionId":"ced8e825-4fb5-4a04-b5aa-9762ae3a13ed"} 2015-02-12 18:02:52:709 - info: <-- GET /wd/hub/status 200 1.108 ms - 178 {"status":0,"value":{"build":{"version":"1.3.5","revision":"a124a15677e26b33db16e81c4b3b34d9c6b8cac9"},"isShuttingDown":false},"sessionId":"ced8e825-4fb5-4a04-b5aa-9762ae3a13ed"} 2015-02-12 18:02:55:733 - info: [debug] Socket data received (39 bytes) 2015-02-12 18:02:55:734 - info: [debug] Socket data being routed. 2015-02-12 18:02:55:734 - info: [debug] Got result from instruments: {"status":0,"value":{"ELEMENT":"15"}} 2015-02-12 18:02:55:734 - info: [debug] Responding to client with success: {"status":0,"value":{"ELEMENT":"15"},"sessionId":"ced8e825-4fb5-4a04-b5aa-9762ae3a13ed"} 2015-02-12 18:02:55:734 - info: <-- POST /wd/hub/session/ced8e825-4fb5-4a04-b5aa-9762ae3a13ed/execute 200 5679.216 ms - 88 {"status":0,"value":{"ELEMENT":"15"},"sessionId":"ced8e825-4fb5-4a04-b5aa-9762ae3a13ed"} 2015-02-12 18:02:55:768 - info: [debug] [INST] 2015-02-12 18:02:55 +0000 Debug: evaluation finished 2015-02-12 18:02:55:783 - info: [debug] [INST] 2015-02-12 18:02:55 +0000 Debug: Lookup returned [object UIALink] with the name "Physical Security Services" (id: 15). 2015-02-12 18:02:55:796 - info: [debug] [INST] 2015-02-12 18:02:55 +0000 Debug: responding with: 2015-02-12 18:02:55:810 - info: [debug] [INST] 2015-02-12 18:02:55 +0000 Debug: Running system command #60: /Applications/Appium.app/Contents/Resources/node/bin/node /Applications/Appium.app/Contents/Resources/node_modules/appium/node_modules/appium-uiauto/bin/command-proxy-client.js /tmp/instruments_sock 2,{"status":0,"value":{"ELEMENT":"15"}}... 2015-02-12 18:03:01:323 - info: [IOS_SYSLOG_ROW ] Feb 12 13:03:01 --- last message repeated 15 times --- 2015-02-12 18:03:01:323 - info: [IOS_SYSLOG_ROW ] Feb 12 13:03:01 CHRIGRAH-M-2038 mstreamd[68209]: (Note ) PS: Media stream daemon stopping. 2015-02-12 18:03:01:324 - info: [IOS_SYSLOG_ROW ] Feb 12 13:03:01 CHRIGRAH-M-2038 mstreamd[68209]: (Note ) AS: <MSIOSAlbumSharingDaemon: 0x7f7f53b069b0>: Shared Streams daemon has shut down. 2015-02-12 18:03:01:324 - info: [IOS_SYSLOG_ROW ] Feb 12 13:03:01 CHRIGRAH-M-2038 mstreamd[68209]: (Warn ) mstreamd: mstreamd shutting down. 2015-02-12 18:03:01:994 - info: [IOS_SYSLOG_ROW ] Feb 12 13:03:01 CHRIGRAH-M-2038 assertiond[68218]: assertion failed: 14C109 12B411: assertiond + 11523 [3F572A0B-7E12-378D-AFEE-EA491BAF2C36]: 0x1 2015-02-12 18:03:05:739 - info: --> POST /wd/hub/session/ced8e825-4fb5-4a04-b5aa-9762ae3a13ed/element/14/click {"sessionId":"ced8e825-4fb5-4a04-b5aa-9762ae3a13ed","id":"14"} 2015-02-12 18:03:05:739 - info: [debug] Pushing command to appium work queue: "au.tapById('14')" 2015-02-12 18:03:05:739 - info: [debug] Sending command to instruments: au.tapById('14') 2015-02-12 18:03:05:866 - info: [debug] [INST] 2015-02-12 18:03:05 +0000 Debug: Got new command 60 from instruments: au.tapById('14') 2015-02-12 18:03:05:881 - info: [debug] [INST] 2015-02-12 18:03:05 +0000 Debug: evaluating au.tapById('14') 2015-02-12 18:03:05:896 - info: [debug] [INST] 2015-02-12 18:03:05 +0000 Debug: target.frontMostApp().elements()[1].elements()[1].elements()[0].elements()[48].tap() 2015-02-12 18:03:05:911 - info: [debug] [INST] 2015-02-12 18:03:05 +0000 Debug: target.frontMostApp().elements()[1].elements()[1].elements()[0].elements()[48].scrollToVisible() 2015-02-12 18:03:11:377 - info: [debug] [INST] 2015-02-12 18:03:11 +0000 Debug: target.frontMostApp().elements()[1].elements()[1].elements()[0].elements()[48] could not be tapped 2015-02-12 18:03:11:483 - info: [debug] [INST] 2015-02-12 18:03:11 +0000 Error: VerboseError: elementId 14 could not be tapped 2015-02-12 18:03:11:493 - info: [debug] Socket data received (58 bytes) 2015-02-12 18:03:11:494 - info: [debug] Socket data being routed. 2015-02-12 18:03:11:494 - info: [debug] Got result from instruments: {"status":13,"value":"elementId 14 could not be tapped"} 2015-02-12 18:03:11:494 - info: [debug] Responding to client with error: {"status":13,"value":{"message":"An unknown server-side error occurred while processing the command.","origValue":"elementId 14 could not be tapped"},"sessionId":"ced8e825-4fb5-4a04-b5aa-9762ae3a13ed"}