Skip to content

Commit b27be8e

Browse files
Fix gestures for latest appium 2 beta version (#6)
* update command to start server with plugin * fix gestures for latest appium 2 beta version * bump new version
1 parent a79d20f commit b27be8e

6 files changed

Lines changed: 37 additions & 34 deletions

File tree

.prettierrc.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"printWidth": 100,
3+
"singleQuote": true
4+
}

README.md

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,15 @@ appium plugin install --source=npm appium-gestures-plugin
1919
The plugin will not be active unless turned on when invoking the Appium server:
2020

2121
```
22-
appium --plugins=gestures
22+
appium --use-plugins=gestures
2323
```
2424

2525
# Drag and Drop test without plugin
26+
2627
```
27-
MobileElement dragMe = (MobileElement) new WebDriverWait(driver, 30)
28-
.until(elementToBeClickable(MobileBy.AccessibilityId("dragMe")));
28+
WebElement dragMe = wait.until(elementToBeClickable(AppiumBy.accessibilityId("dragMe")));
2929
Point source = dragMe.getCenter();
30-
MobileElement dropzone = (MobileElement) new WebDriverWait(driver, 30)
31-
.until(elementToBeClickable(MobileBy.AccessibilityId("dropzone")));
30+
WebElement dropzone = wait.until(elementToBeClickable(AppiumBy.accessibilityId("dropzone")));
3231
Point target = dropzone.getCenter();
3332
PointerInput finger = new PointerInput(PointerInput.Kind.TOUCH, "finger");
3433
Sequence dragNDrop = new Sequence(finger, 1);
@@ -46,28 +45,29 @@ driver.perform(singletonList(dragNDrop));
4645
# Usage
4746

4847
# Drag and Drop
48+
4949
```
50-
MobileElement source = (MobileElement) new WebDriverWait(driver, 30)
51-
.until(elementToBeClickable(MobileBy.AccessibilityId("dragMe")));
52-
MobileElement destination = (MobileElement) new WebDriverWait(driver, 30)
53-
.until(elementToBeClickable(MobileBy.AccessibilityId("dropzone")));
50+
RemoteWebElement source = (RemoteWebElement) wait
51+
.until(elementToBeClickable(AppiumBy.accessibilityId("dragMe")));
52+
RemoteWebElement destination = (RemoteWebElement) wait
53+
.until(elementToBeClickable(AppiumBy.accessibilityId("dropzone")));
5454
55-
driver.addCommand(HttpMethod.POST, String.format("/session/%s/plugin/actions/dragAndDrop",
56-
driver.getSessionId()), "dragAndDrop");
55+
driver.addCommand(HttpMethod.POST, String.format("/session/%s/plugin/actions/dragAndDrop",
56+
driver.getSessionId()), "dragAndDrop");
5757
driver.execute("dragAndDrop", ImmutableMap.of("sourceId", source.getId(), "destinationId", destination.getId()));
5858
```
59+
5960
# Horizontal Swipe
61+
6062
```
61-
MobileElement source = (MobileElement) new WebDriverWait(driver, 30)
62-
.until(elementToBeClickable(MobileBy.AccessibilityId("slider")));
63+
RemoteWebElement source = (RemoteWebElement) wait.until(elementToBeClickable(AppiumBy.accessibilityId("slider")));
6364
65+
driver.addCommand(HttpMethod.POST, String.format("/session/%s/plugin/actions/swipe", driver.getSessionId()), "swipe");
6466
65-
driver.addCommand(HttpMethod.POST, String.format("/session/%s/plugin/actions/swipe",
66-
driver.getSessionId()), "swipe");
67-
driver.execute("dragAndDrop", ImmutableMap.of("elementId", source.getId(), "percentage", 50));
67+
driver.execute("swipe", ImmutableMap.of("elementId", source.getId(), "percentage", 50));
6868
```
6969

70-
# WDIO
70+
# WDIO
7171

7272
```
7373
driver.addCommand(
@@ -91,18 +91,18 @@ driver.addCommand(
9191
})
9292
);
9393
await driver.dragAndDrop(sourceId, destinationId);
94-
94+
9595
```
96-
## Supported
9796

98-
* Horizontal Swipe
99-
* Drag and Drop
100-
### TODO
97+
## Supported
10198

102-
* swipe vertically
103-
* double click
104-
* longpress
105-
* zoom
106-
* multi finger swipe
99+
- Horizontal Swipe
100+
- Drag and Drop
107101

102+
### TODO
108103

104+
- swipe vertically
105+
- double click
106+
- longpress
107+
- zoom
108+
- multi finger swipe

package-lock.json

Lines changed: 3 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "appium-gestures-plugin",
3-
"version": "1.0.0-beta.3",
3+
"version": "1.0.0-beta.4",
44
"description": "",
55
"main": "./lib/index.js",
66
"scripts": {

src/gestures/swipe.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,7 @@ async function horizontalSwipe(elementId, percentage, driverInfo) {
4747
],
4848
};
4949
let actionsUrl = `${driverInfo.driverUrl}/actions`;
50-
log.info(
51-
`Performing Swipe ${actionsUrl} with ${JSON.stringify(actionsData)}`
52-
);
50+
log.info(`Performing Swipe ${actionsUrl} with ${JSON.stringify(actionsData)}`);
5351

5452
if (driverInfo.automationName === 'XCuiTest') {
5553
await post({

src/sessionInfo.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export default function sessionInfo(driver) {
1111
driverUrl: `${baseUrl}/session/${jwProxySessionId}`,
1212
};
1313
} else {
14-
const baseUrl = `http://${driver.uiautomator2.host}:${driver.uiautomator2.systemPort}/wd/hub`;
14+
const baseUrl = `http://${driver.uiautomator2.host}:${driver.uiautomator2.systemPort}`;
1515
const jwProxySessionId = driver.uiautomator2.jwproxy.sessionId;
1616
return {
1717
baseUrl,

0 commit comments

Comments
 (0)