Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 1555fd2

Browse filesBrowse files
authored
Merge pull request appium-boneyard#128 from saikrishna321/master
added new cross platform app and able to run single tests across plat…
2 parents 893a4b7 + 4b60318 commit 1555fd2
Copy full SHA for 1555fd2

File tree

Expand file treeCollapse file tree

7 files changed

+110
-14
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

7 files changed

+110
-14
lines changed
Open diff view settings
Collapse file

‎NOTICE‎

Copy file name to clipboard
+14-1Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,15 @@
11
Appium Sample Code (https://github.com/appium/sample-code)
2-
Copyright 2013-2014 Appium Contributors
2+
3+
Cross Platform Application for Android/iOS
4+
https://github.com/saikrishna321/VodQAReactNative
5+
6+
vodQA - Sample cross platform app built using reactNative.
7+
Reason for building the cross platform app using reactNative is to get over the obstacles of automating apps
8+
built using react native and to write a single script to automate cross platform apps using Appium.
9+
vodQA app code is open sourced here and same was used for various appium workshops conducted by ThoughtWorks.
10+
11+
Same is available for all community activities without any license required/ involved.
12+
13+
Application holds all possible gestures like slide, swipe, longpress, doubletap, DragAndDrop and also webview.
14+
15+
Copyright 2016-2017 Appium Contributors
Collapse file

‎sample-code/apps/VodQA.apk‎

Copy file name to clipboard
7.07 MB
Binary file not shown.
Collapse file
3.16 MB
Binary file not shown.
Collapse file

‎sample-code/examples/java/junit/README.md‎

Copy file name to clipboardExpand all lines: sample-code/examples/java/junit/README.md
+5Lines changed: 5 additions & 0 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,8 @@ To compile and run all tests, run:
1616
To run a single test, run:
1717

1818
mvn -Dtest=com.saucelabs.appium.SimpleTest test
19+
20+
To run a single test on specific platform(android/ios)
21+
22+
mvn clean -Dtest=AndroidDragAndDrop test -Dplatform=android
23+
Collapse file

‎sample-code/examples/java/junit/pom.xml‎

Copy file name to clipboardExpand all lines: sample-code/examples/java/junit/pom.xml
+3-3Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
<dependency>
1818
<groupId>io.appium</groupId>
1919
<artifactId>java-client</artifactId>
20-
<version>5.0.0-BETA6</version>
20+
<version>5.0.0-BETA8</version>
2121
</dependency>
2222
<dependency>
2323
<groupId>com.googlecode.json-simple</groupId>
@@ -54,8 +54,8 @@
5454
<plugin>
5555
<artifactId>maven-compiler-plugin</artifactId>
5656
<configuration>
57-
<source>1.7</source>
58-
<target>1.7</target>
57+
<source>1.8</source>
58+
<target>1.8</target>
5959
</configuration>
6060
</plugin>
6161
</plugins>
Collapse file
+13-10Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,25 @@
11
package com.saucelabs.appium;
22

3+
import io.appium.java_client.MobileBy;
34
import io.appium.java_client.MobileElement;
45
import io.appium.java_client.TouchAction;
56
import org.junit.Test;
6-
import org.openqa.selenium.WebElement;
7+
import org.openqa.selenium.support.ui.ExpectedConditions;
8+
import org.openqa.selenium.support.ui.WebDriverWait;
79

810
import static org.junit.Assert.assertEquals;
911

10-
public class AndroidDragAndDrop extends BaseDriver {
12+
public class AndroidDragAndDrop extends BaseCrossPlatformDriver {
1113
@Test
1214
public void testDragAndDrop() throws InterruptedException {
13-
scrollTo("Views").click();
14-
scrollTo("Drag and Drop").click();
15-
MobileElement calc = (MobileElement) driver.findElementById("io.appium.android.apis:id/drag_dot_1");
16-
TouchAction touchAction = new TouchAction(driver);
17-
WebElement destination = driver.findElementById("io.appium.android.apis:id/drag_dot_2");
18-
touchAction.longPress(calc).waitAction(6000).moveTo(destination).perform().release();
19-
Thread.sleep(5000);
20-
assertEquals(driver.findElementById("io.appium.android.apis:id/drag_result_text").getText(), "Dropped!");
15+
login();
16+
driver.findElementByAccessibilityId("dragAndDrop").click();
17+
MobileElement dragMe = (MobileElement) new WebDriverWait(driver, 30)
18+
.until(ExpectedConditions
19+
.elementToBeClickable(MobileBy.AccessibilityId("dragMe")));
20+
new TouchAction(driver).press(dragMe).waitAction(3000)
21+
.moveTo(driver.findElementByAccessibilityId("dropzone")).release().perform();
22+
String expected = driver.findElementByAccessibilityId("success").getText();
23+
assertEquals(expected,"Circle dropped");
2124
}
2225
}
Collapse file
+75Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
package com.saucelabs.appium;
2+
3+
import io.appium.java_client.AppiumDriver;
4+
import io.appium.java_client.MobileBy;
5+
import io.appium.java_client.android.AndroidDriver;
6+
import io.appium.java_client.ios.IOSDriver;
7+
import io.appium.java_client.service.local.AppiumDriverLocalService;
8+
import io.appium.java_client.service.local.AppiumServerHasNotBeenStartedLocallyException;
9+
import org.junit.After;
10+
import org.junit.Before;
11+
import org.openqa.selenium.remote.DesiredCapabilities;
12+
import org.openqa.selenium.support.ui.ExpectedConditions;
13+
import org.openqa.selenium.support.ui.WebDriverWait;
14+
15+
import java.io.File;
16+
import java.io.IOException;
17+
18+
19+
public class BaseCrossPlatformDriver {
20+
public AppiumDriver driver;
21+
private static AppiumDriverLocalService service;
22+
23+
@Before
24+
public void setUp() throws Exception {
25+
service = AppiumDriverLocalService.buildDefaultService();
26+
service.start();
27+
28+
if (service == null || !service.isRunning()) {
29+
throw new AppiumServerHasNotBeenStartedLocallyException(
30+
"An appium server node is not started!");
31+
}
32+
if (System.getProperty("platform").equalsIgnoreCase("ios")) {
33+
iOSCaps();
34+
} else if (System.getProperty("platform").equalsIgnoreCase("android")) {
35+
androidCaps();
36+
}
37+
}
38+
39+
private void androidCaps() throws IOException {
40+
File classpathRoot = new File(System.getProperty("user.dir"));
41+
File appDir = new File(classpathRoot, "../../../apps/");
42+
File app = new File(appDir.getCanonicalPath(), "VodQA.apk");
43+
DesiredCapabilities capabilities = new DesiredCapabilities();
44+
capabilities.setCapability("deviceName", "Android");
45+
capabilities.setCapability("app", app.getAbsolutePath());
46+
driver = new AndroidDriver<>(service.getUrl(), capabilities);
47+
}
48+
49+
private void iOSCaps() throws Exception {
50+
// set up appium
51+
File classpathRoot = new File(System.getProperty("user.dir"));
52+
File appDir = new File(classpathRoot, "../../../apps/");
53+
File app = new File(appDir, "VodQAReactNative.zip");
54+
DesiredCapabilities capabilities = new DesiredCapabilities();
55+
capabilities.setCapability("platformVersion", "10.2");
56+
capabilities.setCapability("deviceName", "iPhone 5s");
57+
capabilities.setCapability("app", app.getAbsolutePath());
58+
driver = new IOSDriver<>(service.getUrl(), capabilities);
59+
}
60+
61+
@After
62+
public void tearDown() throws Exception {
63+
if (driver != null) {
64+
driver.quit();
65+
}
66+
if (service != null) {
67+
service.stop();
68+
}
69+
}
70+
71+
public void login() {
72+
new WebDriverWait(driver, 30).until(ExpectedConditions.
73+
elementToBeClickable(MobileBy.AccessibilityId("login"))).click();
74+
}
75+
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.