Skip to content
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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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/
Binary file not shown.
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,12 @@
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,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 driverIntial=new DriverIntialize();
String folder_name;
DateFormat df;
static ArrayList<AppiumDriver> driverlistAppium=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);

driverIntial.capability=capabilities;
driverIntial.driver= new AndroidDriver(new URL("https://device.pcloudy.com/appiumcloud/wd/hub"), driverIntial.capability);
driverlistAppium.add(driverIntial.driver);

}



@Test
public void Test() throws IOException, InterruptedException {



}



}
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package com.pCloudy.testNG;

import java.io.IOException;

import org.openqa.selenium.By;

import org.openqa.selenium.WebElement;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.Test;

import io.appium.java_client.AppiumDriver;

public class TestCase extends Runner{

public AppiumDriver<WebElement> Hostdriver;
public AppiumDriver<WebElement> Childdriver;

@Test
public void Test() throws IOException, InterruptedException {

Hostdriver=driverlistAppium.get(0);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@SridattaRishi still the list has been used. Please access the driver through some unique value like deviceName and all

Childdriver=driverlistAppium.get(1);

System.out.println(driverlistAppium.size());
Hostdriver.findElement(By.xpath("//android.widget.Button[@resource-id='com.pcloudy.appiumdemo:id/accept']")).click();
Thread.sleep(5000);


Childdriver.findElement(By.xpath("//android.widget.Button[@resource-id='com.pcloudy.appiumdemo:id/btnrefuse']")).click();
Thread.sleep(5000);


}
@AfterMethod
public void endTest() throws IOException {

Hostdriver.quit();
Childdriver.quit();

}


}
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 -->