@@ -22,61 +22,77 @@ The plugin will not be active unless turned on when invoking the Appium server:
2222appium --use-plugins=gestures
2323```
2424
25- # Drag and Drop test without plugin
25+ # Usage
26+
27+ Sample app used to demonstrate below gesture is available [ here] ( https://github.com/webdriverio/native-demo-app/releases )
28+
29+ # Swipe Left
2630
2731``` java
28- WebElement dragMe = wait. until(elementToBeClickable(AppiumBy . accessibilityId(" dragMe" )));
29- Point source = dragMe. getCenter();
30- WebElement dropzone = wait. until(elementToBeClickable(AppiumBy . accessibilityId(" dropzone" )));
31- Point target = dropzone. getCenter();
32- PointerInput finger = new PointerInput (PointerInput . Kind . TOUCH , " finger" );
33- Sequence dragNDrop = new Sequence (finger, 1 );
34- dragNDrop. addAction(finger. createPointerMove(ofMillis(0 ),
35- PointerInput . Origin . viewport(), source. x, source. y));
36- dragNDrop. addAction(finger. createPointerDown(PointerInput . MouseButton . MIDDLE. asArg()));
37- dragNDrop. addAction(new Pause (finger, ofMillis(600 )));
38- dragNDrop. addAction(finger. createPointerMove(ofMillis(600 ),
39- PointerInput . Origin . viewport(),
40- target. x, target. y));
41- dragNDrop. addAction(finger. createPointerUp(PointerInput . MouseButton . MIDDLE. asArg()));
42- driver. perform(singletonList(dragNDrop));
32+ RemoteWebElement carousel = (RemoteWebElement ) wait. until(presenceOfElementLocated(AppiumBy . accessibilityId(" Carousel" )));
33+
34+ driver. executeScript(" gesture: swipe" , Map . of(" elementId" , carousel. getId(), " percentage" , 50 , " direction" , " left" ));
4335```
4436
45- # Usage
37+ # Swipe Right
4638
47- # Drag and Drop
39+ ``` java
40+ RemoteWebElement carousel = (RemoteWebElement ) wait. until(presenceOfElementLocated(AppiumBy . accessibilityId(" Carousel" )));
41+
42+ driver. executeScript(" gesture: swipe" , Map . of(" elementId" , carousel. getId(), " percentage" , 50 , " direction" , " right" ));
43+ ```
44+
45+ # Swipe Up
4846
4947``` java
50- RemoteWebElement source = (RemoteWebElement ) wait
51- .until(elementToBeClickable(AppiumBy . accessibilityId(" dragMe" )));
52- RemoteWebElement destination = (RemoteWebElement ) wait
53- .until(elementToBeClickable(AppiumBy . accessibilityId(" dropzone" )));
48+ RemoteWebElement scrollView = (RemoteWebElement ) wait. until(presenceOfElementLocated(AppiumBy . accessibilityId(" Swipe-screen" )));
5449
55- driver. executeScript(" gesture: dragAndDrop" , ImmutableMap . of(" sourceId" , source. getId(), " destinationId" , destination. getId()));
50+ driver. executeScript(" gesture: swipe" , Map . of(" elementId" , scrollView. getId(),
51+ " percentage" , 50 ,
52+ " direction" , " up" ));
5653```
5754
58- # Horizontal Swipe
55+ # Swipe Down
5956
6057``` java
61- RemoteWebElement slider = (RemoteWebElement ) driver . findElement( AppiumBy . accessibilityId(" slider " ));
58+ RemoteWebElement scrollView = (RemoteWebElement ) wait . until(presenceOfElementLocated( AppiumBy . accessibilityId(" Swipe-screen " ) ));
6259
63- driver. executeScript(" gesture: swipe" , ImmutableMap . of(" elementId" , slider. getId(), " percentage" , 50 , " direction" , " right" ));
60+ driver. executeScript(" gesture: swipe" , Map . of(" elementId" , scrollView. getId(),
61+ " percentage" , 50 ,
62+ " direction" , " down" ));
6463```
6564
66- # Vertical Swipe
65+ # scrollElementIntoView
6766
6867``` java
69- RemoteWebElement slider = (RemoteWebElement ) driver. findElement(AppiumBy . accessibilityId(" listview" ));
68+ RemoteWebElement scrollView = (RemoteWebElement ) wait. until(presenceOfElementLocated(AppiumBy . accessibilityId(" Swipe-screen" )));
69+
70+ driver. executeScript(" gesture: scrollElementIntoView" , Map . of(" scrollableView" , scrollView. getId(),
71+ " strategy" , " accessibility id" ,
72+ " selector" , " WebdriverIO logo" ,
73+ " percentage" , 50 ,
74+ " direction" , " up" ,
75+ " maxCount" , 3 ));
7076
71- driver. executeScript(" gesture: swipe" , ImmutableMap . of(" elementId" , slider. getId(), " percentage" , 50 , " direction" , " up" ));
77+ ```
78+
79+ Sample app used to demonstrate below gesture is available [ here] ( https://github.com/AppiumTestDistribution/appium-demo/blob/main/VodQA.apk )
80+
81+ # Drag and Drop
82+
83+ ``` java
84+ RemoteWebElement source = (RemoteWebElement ) wait. until(elementToBeClickable(AppiumBy . accessibilityId(" dragMe" )));
85+ RemoteWebElement destination = (RemoteWebElement ) wait. until(elementToBeClickable(AppiumBy . accessibilityId(" dropzone" )));
86+
87+ driver. executeScript(" gesture: dragAndDrop" , Map . of(" sourceId" , source. getId(), " destinationId" , destination. getId()));
7288```
7389
7490# Double Tap
7591
7692``` java
7793RemoteWebElement doubleTapMe = (RemoteWebElement ) driver. findElement(AppiumBy . accessibilityId(" doubleTapMe" ));
7894
79- driver. executeScript(" gesture: doubleTap" , ImmutableMap . of(" elementId" , doubleTapMe. getId()));
95+ driver. executeScript(" gesture: doubleTap" , Map . of(" elementId" , doubleTapMe. getId()));
8096```
8197
8298# Long Press
@@ -86,20 +102,7 @@ Pressure has to be between 0 and 1.
86102``` java
87103RemoteWebElement longPress = (RemoteWebElement ) driver. findElement(AppiumBy . accessibilityId(" longpress" ));
88104
89- driver. executeScript(" gesture: longPress" , ImmutableMap . of(" elementId" , longPress. getId(), " pressure" , 0.5 , " duration" , 800 ));
90-
91- ```
92-
93- # ScrollIntoView
94-
95- ``` java
96- ImmutableMap map = ImmutableMap . of(" scrollableView" , scrollView. getId(),
97- " strategy" , " accessibility id" ,
98- " selector" , " WebdriverIO logo" ,
99- " percentage" , 50 ,
100- " direction" , " up" ,
101- " maxCount" , 3 );
102- driver. executeScript(" gesture: scrollElementIntoView" , map);
105+ driver. executeScript(" gesture: longPress" , Map . of(" elementId" , longPress. getId(), " pressure" , 0.5 , " duration" , 800 ));
103106
104107```
105108
@@ -112,10 +115,10 @@ await driver.execute('gesture: dragAndDrop', { sourceId, destinationId });
112115## Supported
113116
114117- Swipe Left, right, up and down
118+ - scrollElementIntoView
115119- Drag and Drop
116120- Double Tap
117121- Long Press
118- - scrollElementIntoView
119122
120123### TODO
121124
0 commit comments