Skip to content

Commit

Permalink
Fix gestures for latest appium 2 beta version (#6)
Browse files Browse the repository at this point in the history
* update command to start server with plugin

* fix gestures for latest appium 2 beta version

* bump new version
  • Loading branch information
SrinivasanTarget authored Jul 30, 2022
1 parent a79d20f commit b27be8e
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 34 deletions.
4 changes: 4 additions & 0 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"printWidth": 100,
"singleQuote": true
}
54 changes: 27 additions & 27 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,15 @@ appium plugin install --source=npm appium-gestures-plugin
The plugin will not be active unless turned on when invoking the Appium server:

```
appium --plugins=gestures
appium --use-plugins=gestures
```

# Drag and Drop test without plugin

```
MobileElement dragMe = (MobileElement) new WebDriverWait(driver, 30)
.until(elementToBeClickable(MobileBy.AccessibilityId("dragMe")));
WebElement dragMe = wait.until(elementToBeClickable(AppiumBy.accessibilityId("dragMe")));
Point source = dragMe.getCenter();
MobileElement dropzone = (MobileElement) new WebDriverWait(driver, 30)
.until(elementToBeClickable(MobileBy.AccessibilityId("dropzone")));
WebElement dropzone = wait.until(elementToBeClickable(AppiumBy.accessibilityId("dropzone")));
Point target = dropzone.getCenter();
PointerInput finger = new PointerInput(PointerInput.Kind.TOUCH, "finger");
Sequence dragNDrop = new Sequence(finger, 1);
Expand All @@ -46,28 +45,29 @@ driver.perform(singletonList(dragNDrop));
# Usage

# Drag and Drop

```
MobileElement source = (MobileElement) new WebDriverWait(driver, 30)
.until(elementToBeClickable(MobileBy.AccessibilityId("dragMe")));
MobileElement destination = (MobileElement) new WebDriverWait(driver, 30)
.until(elementToBeClickable(MobileBy.AccessibilityId("dropzone")));
RemoteWebElement source = (RemoteWebElement) wait
.until(elementToBeClickable(AppiumBy.accessibilityId("dragMe")));
RemoteWebElement destination = (RemoteWebElement) wait
.until(elementToBeClickable(AppiumBy.accessibilityId("dropzone")));
driver.addCommand(HttpMethod.POST, String.format("/session/%s/plugin/actions/dragAndDrop",
driver.getSessionId()), "dragAndDrop");
driver.addCommand(HttpMethod.POST, String.format("/session/%s/plugin/actions/dragAndDrop",
driver.getSessionId()), "dragAndDrop");
driver.execute("dragAndDrop", ImmutableMap.of("sourceId", source.getId(), "destinationId", destination.getId()));
```

# Horizontal Swipe

```
MobileElement source = (MobileElement) new WebDriverWait(driver, 30)
.until(elementToBeClickable(MobileBy.AccessibilityId("slider")));
RemoteWebElement source = (RemoteWebElement) wait.until(elementToBeClickable(AppiumBy.accessibilityId("slider")));
driver.addCommand(HttpMethod.POST, String.format("/session/%s/plugin/actions/swipe", driver.getSessionId()), "swipe");
driver.addCommand(HttpMethod.POST, String.format("/session/%s/plugin/actions/swipe",
driver.getSessionId()), "swipe");
driver.execute("dragAndDrop", ImmutableMap.of("elementId", source.getId(), "percentage", 50));
driver.execute("swipe", ImmutableMap.of("elementId", source.getId(), "percentage", 50));
```

# WDIO
# WDIO

```
driver.addCommand(
Expand All @@ -91,18 +91,18 @@ driver.addCommand(
})
);
await driver.dragAndDrop(sourceId, destinationId);
```
## Supported

* Horizontal Swipe
* Drag and Drop
### TODO
## Supported

* swipe vertically
* double click
* longpress
* zoom
* multi finger swipe
- Horizontal Swipe
- Drag and Drop

### TODO

- swipe vertically
- double click
- longpress
- zoom
- multi finger swipe
5 changes: 3 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "appium-gestures-plugin",
"version": "1.0.0-beta.3",
"version": "1.0.0-beta.4",
"description": "",
"main": "./lib/index.js",
"scripts": {
Expand Down
4 changes: 1 addition & 3 deletions src/gestures/swipe.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,7 @@ async function horizontalSwipe(elementId, percentage, driverInfo) {
],
};
let actionsUrl = `${driverInfo.driverUrl}/actions`;
log.info(
`Performing Swipe ${actionsUrl} with ${JSON.stringify(actionsData)}`
);
log.info(`Performing Swipe ${actionsUrl} with ${JSON.stringify(actionsData)}`);

if (driverInfo.automationName === 'XCuiTest') {
await post({
Expand Down
2 changes: 1 addition & 1 deletion src/sessionInfo.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export default function sessionInfo(driver) {
driverUrl: `${baseUrl}/session/${jwProxySessionId}`,
};
} else {
const baseUrl = `http://${driver.uiautomator2.host}:${driver.uiautomator2.systemPort}/wd/hub`;
const baseUrl = `http://${driver.uiautomator2.host}:${driver.uiautomator2.systemPort}`;
const jwProxySessionId = driver.uiautomator2.jwproxy.sessionId;
return {
baseUrl,
Expand Down

0 comments on commit b27be8e

Please sign in to comment.