-
Notifications
You must be signed in to change notification settings - Fork 49
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
File added #59
base: master
Are you sure you want to change the base?
File added #59
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<h1 style="display:flex;flex-direction:row;align-items: center;"><a target="_blank" rel="noopener noreferrer" href="https://www.pcloudy.com"><img src="/images/pcloudy.png" style="max-width:100%;"></a><span>pCloudy Appium Sample Projects</span></h1> | ||
|
||
## About [pCloudy](https://www.pcloudy.com) | ||
|
||
pCloudy platform provides single click access to real Android and IOS devices directly from your browser. Use these real Mobile Devices to click-and-perform Manual Testing and Automation Testing for your App. Integrate our platform with CI for continuous Automation Testing and test your App on multiple real Mobile Devices with every change of your App. | ||
|
||
pCloudy is a popular mobile testing platform integrated with Appium script which enables you to automate test of mobile apps as well. | ||
|
||
Read more here https://www.pcloudy.com | ||
|
||
Clone the project | ||
Enter pCloudy username & APIKey in Runner class | ||
Enter apk name which should be already there in the cloud driver. | ||
Open Terminal | ||
cd to the directory which contains the project | ||
Run the command mvn test | ||
For more details, please refer below link: https://www.pcloudy.com/appium-integration-architecture-redefined-appium-runs-become-simpler-with-pcloudy/ |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<groupId>Chapter2-TestNgwithpCloudyonMultipleDeviceAndroid</groupId> | ||
<artifactId>Chapter2-TestNgwithpCloudyonMultipleDeviceAndroid</artifactId> | ||
<version>0.0.1-SNAPSHOT</version> | ||
<build> | ||
<sourceDirectory>src</sourceDirectory> | ||
<plugins> | ||
<plugin> | ||
<artifactId>maven-compiler-plugin</artifactId> | ||
<version>3.3</version> | ||
<configuration> | ||
<source>1.8</source> | ||
<target>1.8</target> | ||
</configuration> | ||
</plugin> | ||
|
||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-surefire-plugin</artifactId> | ||
<version>2.20</version> | ||
<configuration> | ||
<suiteXmlFiles> | ||
<suiteXmlFile>testng.xml</suiteXmlFile> | ||
</suiteXmlFiles> | ||
</configuration> | ||
</plugin> | ||
|
||
|
||
</plugins> | ||
</build> | ||
<packaging>jar</packaging> | ||
|
||
<name>Chapter2-TestNgwithpCloudyonMultipleDeviceAndroid</name> | ||
<url>http://maven.apache.org</url> | ||
|
||
<properties> | ||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
</properties> | ||
|
||
<dependencies> | ||
<!-- https://mvnrepository.com/artifact/io.appium/java-client --> | ||
<dependency> | ||
<groupId>io.appium</groupId> | ||
<artifactId>java-client</artifactId> | ||
<version>6.0.0-BETA3</version> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.testng</groupId> | ||
<artifactId>testng</artifactId> | ||
<version>6.11</version> | ||
</dependency> | ||
|
||
</dependencies> | ||
</project> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
package com.pCloudy.testNG; | ||
|
||
import java.io.File; | ||
import java.io.IOException; | ||
import java.net.MalformedURLException; | ||
import java.net.URL; | ||
import java.text.DateFormat; | ||
import java.text.SimpleDateFormat; | ||
import java.util.ArrayList; | ||
import java.util.Date; | ||
import org.apache.commons.io.FileUtils; | ||
import org.openqa.selenium.By; | ||
import org.openqa.selenium.OutputType; | ||
import org.openqa.selenium.TakesScreenshot; | ||
import org.openqa.selenium.WebElement; | ||
import org.openqa.selenium.remote.DesiredCapabilities; | ||
import org.testng.annotations.AfterMethod; | ||
import org.testng.annotations.BeforeMethod; | ||
import org.testng.annotations.BeforeTest; | ||
import org.testng.annotations.Parameters; | ||
import org.testng.annotations.Test; | ||
import io.appium.java_client.AppiumDriver; | ||
import io.appium.java_client.android.AndroidDriver; | ||
import io.appium.java_client.service.local.AppiumDriverLocalService; | ||
|
||
public class Runner { | ||
|
||
AppiumDriverLocalService service; | ||
public AppiumDriver<WebElement> driver; | ||
driverIntialize ob=new driverIntialize(); | ||
String folder_name; | ||
DateFormat df; | ||
static ArrayList<AppiumDriver> driverAppium=new ArrayList(); | ||
|
||
|
||
@Parameters({"deviceName"}) | ||
@BeforeMethod | ||
public void prepareTest(String deviceName) throws IOException, InterruptedException { | ||
|
||
DesiredCapabilities capabilities = new DesiredCapabilities(); | ||
|
||
capabilities.setCapability("pCloudy_Username", "[email protected]"); | ||
capabilities.setCapability("pCloudy_ApiKey", "m3pbymd6k69622p99dkjtj5k"); | ||
capabilities.setCapability("pCloudy_ApplicationName", "pCloudy_Appium_Demo.apk"); | ||
capabilities.setCapability("pCloudy_DurationInMinutes", 10); | ||
//capabilities.setCapability("pCloudy_DeviceManafacturer", deviceName); | ||
//capabilities.setCapability("pCloudy_DeviceVersion", "8.0.0"); | ||
capabilities.setCapability("pCloudy_DeviceFullName", deviceName); | ||
capabilities.setCapability("newCommandTimeout", 600); | ||
capabilities.setCapability("launchTimeout", 90000); | ||
capabilities.setCapability("appPackage", "com.pcloudy.appiumdemo"); | ||
capabilities.setCapability("appActivity", "com.ba.mobile.LaunchActivity"); | ||
capabilities.setCapability("pCloudy_EnableVideo", true); | ||
|
||
ob.capability=capabilities; | ||
ob.driver= new AndroidDriver(new URL("https://device.pcloudy.com/appiumcloud/wd/hub"), ob.capability); | ||
driverAppium.add(ob.driver); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Don't add driver in list it is very bad programming because it may changed or in future different driver can come into picture. |
||
|
||
} | ||
|
||
|
||
|
||
@Test | ||
public void Test() throws IOException, InterruptedException { | ||
|
||
|
||
|
||
} | ||
|
||
|
||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package com.pCloudy.testNG; | ||
|
||
import java.io.IOException; | ||
|
||
import org.openqa.selenium.By; | ||
import org.openqa.selenium.OutputType; | ||
import org.openqa.selenium.TakesScreenshot; | ||
import org.testng.annotations.AfterMethod; | ||
import org.testng.annotations.Test; | ||
|
||
public class TestCase extends Runner{ | ||
|
||
@Test | ||
public void Test() throws IOException, InterruptedException { | ||
|
||
System.out.println(driverAppium.size()); | ||
driverAppium.get(0).findElement(By.xpath("//android.widget.Button[@resource-id='com.pcloudy.appiumdemo:id/accept']")).click(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Don't use index to get driver it is very bad programming because it may changed or in future different driver can come into picture. |
||
Thread.sleep(5000); | ||
|
||
|
||
driverAppium.get(1).findElement(By.xpath("//android.widget.Button[@resource-id='com.pcloudy.appiumdemo:id/btnrefuse']")).click(); | ||
Thread.sleep(5000); | ||
|
||
|
||
} | ||
@AfterMethod | ||
public void endTest() throws IOException { | ||
|
||
driverAppium.get(0).quit(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Don't use index to get driver it is very bad programming because it may changed or in future different driver can come into picture. |
||
driverAppium.get(1).quit(); | ||
|
||
} | ||
|
||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package com.pCloudy.testNG; | ||
|
||
import org.openqa.selenium.WebElement; | ||
import org.openqa.selenium.remote.DesiredCapabilities; | ||
|
||
import io.appium.java_client.AppiumDriver; | ||
public class driverIntialize { | ||
|
||
public AppiumDriver<WebElement> driver; | ||
public DesiredCapabilities capability; | ||
|
||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd"> | ||
<suite thread-count="3" configfailurepolicy="continue" name="pCloudy Suite" parallel="tests"> | ||
<test name="Test"> | ||
<parameter name="deviceName" value="SAMSUNG_GalaxyJ4Plus_Android_9.0.0_94cc6"/> | ||
<classes> | ||
<class name="com.pCloudy.testNG.Runner"/> | ||
</classes> | ||
</test> <!-- Test --> | ||
<test name="Test1"> | ||
<parameter name="deviceName" value="SAMSUNG_GalaxyS8_Android_8.0.0_7a932"/> | ||
<classes> | ||
<class name="com.pCloudy.testNG.TestCase"/> | ||
</classes> | ||
</test> <!-- Test --> | ||
</suite> <!-- Suite --> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ClassName should start from caps. And please work on naming convention.