Mac2Driver - JavaClient - How to perform scroll or swipe action

HI
Using Mac2Driver with Java Client to automate Mac Desktop application.
In one of the test steps, need to perform a scroll action before clicking on the element. Checked the documentation, but did not find a way to implement the scroll using Java client. Any inputs for the same will be much helpful.
Thanks in advance.

can you be a bit more clear. tons of way to swipe:
https://discuss.appium.io/search?q=swipe%20java
http://appium.io/docs/en/writing-running-appium/tutorial/swipe-tutorial/
http://appium.io/docs/en/commands/interactions/actions/
https://appium.io/docs/en/writing-running-appium/touch-actions/

Thanks for the reply.

As told, using the Appium Mac2Driver for Automating Mac Desktop applications.
From their official documentation(https://www.npmjs.com/package/appium-mac2-driver), got the command as - macos: scroll for performing the same.

When I am trying to perform the scroll to an Element not in the viewport, Appium server is showing the following logs -

e[35m[HTTP]e[39m e[37m–>e[39m e[37mPOSTe[39m e[37m/wd/hub/session/96289080-ea7a-4d85-b408-1258713451c2/execute/synce[39m
e[35m[HTTP]e[39m e[90m{“script”:“macos: scroll”,“args”:[{“deltaX”:0,“element”:{“ELEMENT”:“8411FEBD-5B1E-4B2D-9C7C-958FAA661242”,“element-6066-11e4-a52e-4f735466cecf”:“8411FEBD-5B1E-4B2D-9C7C-958FAA661242”},“deltaY”:0}]}e[39m
[debug] e[35m[W3C (96289080)]e[39m Calling AppiumDriver.execute() with args: [“macos: scroll”,[{“deltaX”:0,“element”:{“ELEMENT”:“8411FEBD-5B1E-4B2D-9C7C-958FAA661242”,“element-6066-11e4-a52e-4f735466cecf”:“8411FEBD-5B1E-4B2D-9C7C-958FAA661242”},“deltaY”:0}],“96289080-ea7a-4d85-b408-1258713451c2”]
e[35m[Mac2Driver]e[39m Executing extension command ‘macos: scroll’
[debug] e[35m[WD Proxy]e[39m Proxying [POST /wda/element/8411FEBD-5B1E-4B2D-9C7C-958FAA661242/scroll] to [POST http://127.0.0.1:10100/session/EFCEEA67-4D24-4E68-9EEC-5881C96F0808/wda/element/8411FEBD-5B1E-4B2D-9C7C-958FAA661242/scroll] with body: {“deltaX”:0,“deltaY”:0}
[debug] e[35m[WebDriverAgentMac]e[39m [xcodebuild] t = 243.68s Find the “Email bot” StaticText
[debug] e[35m[WebDriverAgentMac]e[39m [xcodebuild] t = 243.68s Requesting snapshot of accessibility hierarchy for app with pid 86885
[debug] e[35m[WebDriverAgentMac]e[39m [xcodebuild] t = 245.63s Find: Descendants matching type Any
[debug] e[35m[WebDriverAgentMac]e[39m [xcodebuild] t = 245.64s Find: Elements matching predicate ‘BLOCKPREDICATE(0x600000f6f5d0)’
[debug] e[35m[WebDriverAgentMac]e[39m [xcodebuild] t = 245.64s Find: Identity Binding
[debug] e[35m[WebDriverAgentMac]e[39m [xcodebuild] t = 245.66s Scroll “Email bot” StaticText by dx: 0.00, dy: 0.00
[debug] e[35m[WebDriverAgentMac]e[39m [xcodebuild] t = 245.66s Wait for com.Org.ist.MyAppPrime.uat to idle
[debug] e[35m[WebDriverAgentMac]e[39m [xcodebuild] t = 245.66s Find the “Email bot” StaticText
[debug] e[35m[WebDriverAgentMac]e[39m [xcodebuild] t = 245.66s Requesting snapshot of accessibility hierarchy for app with pid 86885
[debug] e[35m[WebDriverAgentMac]e[39m [xcodebuild] t = 247.54s Find: Descendants matching type Any
[debug] e[35m[WebDriverAgentMac]e[39m [xcodebuild] t = 247.54s Find: Elements matching predicate ‘BLOCKPREDICATE(0x600000f6f5d0)’
[debug] e[35m[WebDriverAgentMac]e[39m [xcodebuild] t = 247.55s Find: Identity Binding
[debug] e[35m[WebDriverAgentMac]e[39m [xcodebuild] t = 247.57s Synthesize event
[debug] e[35m[WebDriverAgentMac]e[39m [xcodebuild] /usr/local/lib/node_modules/appium/node_modules/appium-mac2-driver/WebDriverAgentMac/WebDriverAgentRunner/WebDriverAgentRunner.m:48: error: -[UITestingUITests testRunner] : Unable to find hit point for StaticText, {{261.5, 973.0}, {71.0, 19.0}}, label: ‘Email bot’
[debug] e[35m[WebDriverAgentMac]e[39m [xcodebuild] t = 247.99s Wait for com.Org.ist.MyAppPrime.uat to idle
[debug] e[35m[WD Proxy]e[39m Got response with status 200: {“value”:null,“sessionId”:“EFCEEA67-4D24-4E68-9EEC-5881C96F0808”}
[debug] e[35m[W3C (96289080)]e[39m Responding to client with driver.execute() result: null
e[35m[HTTP]e[39m e[37m<-- POST /wd/hub/session/96289080-ea7a-4d85-b408-1258713451c2/execute/sync e[39me[32m200e[39m e[90m4313 ms - 14e[39m
e[35m[HTTP]e[39m e[90me[39m
[debug] e[35m[WebDriverAgentMac]e[39m [xcodebuild] t = 247.99s Tear Down
e[35m[HTTP]e[39m e[37m–>e[39m e[37mPOSTe[39m e[37m/wd/hub/session/96289080-ea7a-4d85-b408-1258713451c2/execute/synce[39m
e[35m[HTTP]e[39m e[90m{“script”:“macos: click”,“args”:[{“element”:{“ELEMENT”:“8411FEBD-5B1E-4B2D-9C7C-958FAA661242”,“element-6066-11e4-a52e-4f735466cecf”:“8411FEBD-5B1E-4B2D-9C7C-958FAA661242”}}]}e[39m
[debug] e[35m[W3C (96289080)]e[39m Calling AppiumDriver.execute() with args: [“macos: click”,[{“element”:{“ELEMENT”:“8411FEBD-5B1E-4B2D-9C7C-958FAA661242”,“element-6066-11e4-a52e-4f735466cecf”:“8411FEBD-5B1E-4B2D-9C7C-958FAA661242”}}],“96289080-ea7a-4d85-b408-1258713451c2”]
e[35m[Mac2Driver]e[39m Executing extension command ‘macos: click’
[debug] e[35m[WD Proxy]e[39m Matched ‘/element/8411FEBD-5B1E-4B2D-9C7C-958FAA661242/click’ to command name ‘click’
[debug] e[35m[WD Proxy]e[39m Proxying [POST /element/8411FEBD-5B1E-4B2D-9C7C-958FAA661242/click] to [POST http://127.0.0.1:10100/session/EFCEEA67-4D24-4E68-9EEC-5881C96F0808/element/8411FEBD-5B1E-4B2D-9C7C-958FAA661242/click] with body: {}
[debug] e[35m[WebDriverAgentMac]e[39m [xcodebuild] t = 248.00s Find the “Email bot” StaticText
[debug] e[35m[WebDriverAgentMac]e[39m [xcodebuild] t = 248.00s Requesting snapshot of accessibility hierarchy for app with pid 86885
[debug] e[35m[WebDriverAgentMac]e[39m [xcodebuild] t = 249.85s Find: Descendants matching type Any
[debug] e[35m[WebDriverAgentMac]e[39m [xcodebuild] t = 249.85s Find: Elements matching predicate ‘BLOCKPREDICATE(0x600000f6f5d0)’
[debug] e[35m[WebDriverAgentMac]e[39m [xcodebuild] t = 249.86s Find: Identity Binding
[debug] e[35m[WebDriverAgentMac]e[39m [xcodebuild] t = 249.88s Click “Email bot” StaticText
[debug] e[35m[WebDriverAgentMac]e[39m [xcodebuild] t = 249.88s Wait for com.Org.ist.MyAppPrime.uat to idle
[debug] e[35m[WebDriverAgentMac]e[39m [xcodebuild] t = 249.88s Find the “Email bot” StaticText
[debug] e[35m[WebDriverAgentMac]e[39m [xcodebuild] t = 249.88s Requesting snapshot of accessibility hierarchy for app with pid 86885
[debug] e[35m[WebDriverAgentMac]e[39m [xcodebuild] t = 249.88s Using snapshot previously cached by query
[debug] e[35m[WebDriverAgentMac]e[39m [xcodebuild] t = 249.88s Find: Descendants matching type Any
[debug] e[35m[WebDriverAgentMac]e[39m [xcodebuild] t = 249.89s Find: Elements matching predicate ‘BLOCKPREDICATE(0x600000f6f5d0)’
[debug] e[35m[WebDriverAgentMac]e[39m [xcodebuild] t = 249.89s Find: Identity Binding
[debug] e[35m[WebDriverAgentMac]e[39m [xcodebuild] t = 249.91s Synthesize event
[debug] e[35m[WebDriverAgentMac]e[39m [xcodebuild] t = 249.92s Scroll element to visible
[debug] e[35m[WebDriverAgentMac]e[39m [xcodebuild] t = 249.92s Scroll Table by dx: 411.56, dy: -532.38
[debug] e[35m[WebDriverAgentMac]e[39m [xcodebuild] t = 249.92s Wait for com.Org.ist.MyAppPrime.uat to idle
[debug] e[35m[WebDriverAgentMac]e[39m [xcodebuild] t = 249.92s App event loop idle notification not received, will attempt to continue.
[debug] e[35m[WebDriverAgentMac]e[39m [xcodebuild] t = 249.92s Find the Table
[debug] e[35m[WebDriverAgentMac]e[39m [xcodebuild] t = 249.92s Find the Table (retry 1)
[debug] e[35m[WebDriverAgentMac]e[39m [xcodebuild] t = 249.92s Find the Table (retry 2)
[debug] e[35m[WebDriverAgentMac]e[39m [xcodebuild] t = 249.92s Collecting extra data to assist test failure triage
[debug] e[35m[WebDriverAgentMac]e[39m [xcodebuild] t = 249.92s Requesting snapshot of accessibility hierarchy for app with pid 86885
[debug] e[35m[WebDriverAgentMac]e[39m [xcodebuild] t = 253.08s Requesting snapshot of accessibility hierarchy for app with pid 86885
[debug] e[35m[WebDriverAgentMac]e[39m [xcodebuild] t = 253.08s Using snapshot previously cached by application
[debug] e[35m[WebDriverAgentMac]e[39m [xcodebuild] t = 253.09s Find: Descendants matching type Any
[debug] e[35m[WebDriverAgentMac]e[39m [xcodebuild] t = 253.09s Find: Identity Binding
[debug] e[35m[WebDriverAgentMac]e[39m [xcodebuild] t = 253.11s Requesting snapshot of accessibility hierarchy for app with pid 86885
[debug] e[35m[WebDriverAgentMac]e[39m [xcodebuild] t = 255.50s Find: Descendants matching type Any
[debug] e[35m[WebDriverAgentMac]e[39m [xcodebuild] t = 255.51s Find: Identity Binding
[debug] e[35m[WebDriverAgentMac]e[39m [xcodebuild] t = 255.52s Requesting snapshot of accessibility hierarchy for app with pid 86885
[debug] e[35m[WebDriverAgentMac]e[39m [xcodebuild] t = 255.52s Using snapshot previously cached by application
[debug] e[35m[WebDriverAgentMac]e[39m [xcodebuild] t = 255.52s Find: Descendants matching type Any
[debug] e[35m[WebDriverAgentMac]e[39m [xcodebuild] t = 255.54s Requesting snapshot of accessibility hierarchy for app with pid 86885
[debug] e[35m[WebDriverAgentMac]e[39m [xcodebuild] t = 255.54s Using snapshot previously cached by application
[debug] e[35m[WebDriverAgentMac]e[39m [xcodebuild] t = 255.56s Synthesize event
[debug] e[35m[WebDriverAgentMac]e[39m [xcodebuild] t = 255.89s Find the “Email bot” StaticText
[debug] e[35m[WebDriverAgentMac]e[39m [xcodebuild] t = 255.89s Requesting snapshot of accessibility hierarchy for app with pid 86885
[debug] e[35m[WebDriverAgentMac]e[39m [xcodebuild] t = 255.89s Using snapshot previously cached by application
[debug] e[35m[WebDriverAgentMac]e[39m [xcodebuild] t = 255.89s Find: Descendants matching type Any
[debug] e[35m[WebDriverAgentMac]e[39m [xcodebuild] t = 255.90s Find: Elements matching predicate ‘BLOCKPREDICATE(0x600000f6f5d0)’
[debug] e[35m[WebDriverAgentMac]e[39m [xcodebuild] t = 255.90s Find: Identity Binding
[debug] e[35m[WebDriverAgentMac]e[39m [xcodebuild] :0: error: -[UITestingUITests testRunner] : Not hittable: StaticText, {{261.5, 973.0}, {71.0, 19.0}}, label: ‘Email bot’
[debug] e[35m[WD Proxy]e[39m Got response with status 200: {“value”:null,“sessionId”:“EFCEEA67-4D24-4E68-9EEC-5881C96F0808”}
[debug] e[35m[W3C (96289080)]e[39m Responding to client with driver.execute() result: null
e[35m[HTTP]e[39m e[37m<-- POST /wd/hub/session/96289080-ea7a-4d85-b408-1258713451c2/execute/sync e[39me[32m200e[39m e[90m7928 ms - 14e[39m
e[35m[HTTP]e[39m e[90me[39m
[debug] e[35m[WebDriverAgentMac]e[39m [xcodebuild] Test Case ‘-[UITestingUITests testRunner]’ failed (255.925 seconds).
[debug] e[35m[WebDriverAgentMac]e[39m Test Suite ‘UITestingUITests’ failed at 2021-06-11 07:23:12.931.
[debug] e[35m[WebDriverAgentMac]e[39m Executed 1 test, with 2 failures (0 unexpected) in 255.925 (255.926) seconds

The execution gets halted after this, without performing the scroll operation.

From the logs, understand that the Element is not hittable.
But why is the operation getting halted ? Can’t scroll operations be done to Elements not in the current view port ?

why not check it code? if element you trying to scroll outside visible screen scroll into needed direction yourself while element will appear.
PS same situation we have with iOS. Native XCUITest sees elements outside so Appium also sees them. and we just scroll window or scrollable area until element appears. looks same applies for MacOS.

This might be happening because of an implicit behaviour in java client, which replaces values of all “element” entries in execute_script args. You could either try to scroll by absolute coordinates as a workaround or wait until the next Appium version is published. Check the discussion at https://github.com/appium/appium/issues/15392 for more details

Tried to perform a ‘macos:scroll’ to the element not in the viewport, but getting the following error -

[Mac2Driver]e[39m Executing extension command ‘macos: scroll’
[debug] e[35m[WD Proxy]e[39m Proxying [POST /wda/element/47DC01EB-D5B4-426E-818E-CCBB70386956/scroll] to [POST http://127.0.0.1:10100/session/566F5029-4E32-47BC-BB58-DAA4C77CD060/wda/element/47DC01EB-D5B4-426E-818E-CCBB70386956/scroll] with body: {“deltaX”:0,“deltaY”:0}
[debug] e[35m[WebDriverAgentMac]e[39m [xcodebuild] t = 187.62s Find the “Email bot” StaticText
[debug] e[35m[WebDriverAgentMac]e[39m [xcodebuild] t = 187.62s Requesting snapshot of accessibility hierarchy for app with pid 42786
[debug] e[35m[WebDriverAgentMac]e[39m [xcodebuild] t = 189.41s Find: Descendants matching type Any
[debug] e[35m[WebDriverAgentMac]e[39m [xcodebuild] t = 189.41s Find: Elements matching predicate ‘BLOCKPREDICATE(0x600003a15380)’
[debug] e[35m[WebDriverAgentMac]e[39m [xcodebuild] t = 189.42s Find: Element at index 2
[debug] e[35m[WebDriverAgentMac]e[39m [xcodebuild] t = 189.43s Scroll “Email bot” StaticText by dx: 0.00, dy: 0.00
[debug] e[35m[WebDriverAgentMac]e[39m [xcodebuild] t = 189.43s Wait for com.myapp.ist.ToAppPrime.uat to idle
[debug] e[35m[WebDriverAgentMac]e[39m [xcodebuild] t = 189.44s Find the “Email bot” StaticText
[debug] e[35m[WebDriverAgentMac]e[39m [xcodebuild] t = 189.44s Requesting snapshot of accessibility hierarchy for app with pid 42786
[debug] e[35m[WebDriverAgentMac]e[39m [xcodebuild] t = 191.12s Find: Descendants matching type Any
[debug] e[35m[WebDriverAgentMac]e[39m [xcodebuild] t = 191.13s Find: Elements matching predicate ‘BLOCKPREDICATE(0x600003a15380)’
[debug] e[35m[WebDriverAgentMac]e[39m [xcodebuild] t = 191.13s Find: Element at index 2
[debug] e[35m[WebDriverAgentMac]e[39m [xcodebuild] t = 191.15s Synthesize event
[debug] e[35m[WebDriverAgentMac]e[39m [xcodebuild] /usr/local/lib/node_modules/appium/node_modules/appium-mac2-driver/WebDriverAgentMac/WebDriverAgentRunner/WebDriverAgentRunner.m:48: error: -[UITestingUITests testRunner] : Unable to find hit point for StaticText, {{261.5, 973.0}, {71.0, 19.0}}, label: ‘Email bot’
[debug] e[35m[WebDriverAgentMac]e[39m [xcodebuild] t = 191.50s Wait for com.myapp.ist.ToAppPrime.uat to idle
[debug] e[35m[WD Proxy]e[39m Got response with status 200: {“value”:null,“sessionId”:“566F5029-4E32-47BC-BB58-DAA4C77CD060”}
[debug] e[35m[W3C (53f45e63)]e[39m Responding to client with driver.execute() result: null
e[35m[HTTP]e[39m e[37m<-- POST /wd/hub/session/53f45e63-93a5-4b77-abba-4929a8251efb/execute/sync e[39me[32m200e[39m e[90m3883 ms - 14e[39m
e[35m[HTTP]e[39m e[90me[39m
[debug] e[35m[WebDriverAgentMac]e[39m [xcodebuild] t = 191.50s Tear Down
[debug] e[35m[WebDriverAgentMac]e[39m [xcodebuild] Test Case ‘-[UITestingUITests testRunner]’ failed (191.706 seconds).
[debug] e[35m[WebDriverAgentMac]e[39m [xcodebuild] Test Suite ‘UITestingUITests’ failed at 2021-06-14 14:41:04.081.
[debug] e[35m[WebDriverAgentMac]e[39m Executed 1 test, with 1 failure (0 unexpected) in 191.706 (191.708) seconds
[debug] e[35m[WebDriverAgentMac]e[39m [xcodebuild] Test Suite ‘WebDriverAgentRunner.xctest’ failed at 2021-06-14 14:41:04.082.
[debug] e[35m[WebDriverAgentMac]e[39m Executed 1 test, with 1 failure (0 unexpected) in 191.706 (191.709) seconds
[debug] e[35m[WebDriverAgentMac]e[39m [xcodebuild] Test Suite ‘All tests’ failed at 2021-06-14 14:41:04.083.
[debug] e[35m[WebDriverAgentMac]e[39m Executed 1 test, with 1 failure (0 unexpected) in 191.706 (191.710) seconds
[debug] e[35m[WebDriverAgentMac]e[39m [xcodebuild] 2021-06-14 14:41:04.354 xcodebuild[42776:738340] [MT] IDETestOperationsObserverDebug: 192.448 elapsed – Testing started completed.
[debug] e[35m[WebDriverAgentMac]e[39m 2021-06-14 14:41:04.354 xcodebuild[42776:738340] [MT] IDETestOperationsObserverDebug: 0.000 sec, +0.000 sec – start
[debug] e[35m[WebDriverAgentMac]e[39m 2021-06-14 14:41:04.354 xcodebuild[42776:738340] [MT] IDETestOperationsObserverDebug: 192.448 sec, +192.448 sec – end
[debug] e[35m[WebDriverAgentMac]e[39m [xcodebuild] Test session results, code coverage, and logs:
[debug] e[35m[WebDriverAgentMac]e[39m /Users/nikhil_narayanan/Library/Developer/Xcode/DerivedData/WebDriverAgentMac-dkbvwguarsmfuteuvwhwonkwsgjn/Logs/Test/Test-WebDriverAgentRunner-2021.06.14_14-37-50-+0530.xcresult
[debug] e[35m[WebDriverAgentMac]e[39m [xcodebuild] Failing tests:
[debug] e[35m[WebDriverAgentMac]e[39m WebDriverAgentRunner:
[debug] e[35m[WebDriverAgentMac]e[39m -[UITestingUITests testRunner]
[debug] e[35m[WebDriverAgentMac]e[39m
[debug] e[35m[WebDriverAgentMac]e[39m ** TEST EXECUTE FAILED **

Try different element. You see - XCTest does not really like this one

:smiley: that’s the problem. Without clicking that element, won’t be able to proceed further.
Even did a programmatic scroll to that element before clicking. But still does not work.