Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
SEO Metadata
titleAndroid - Build your first test

This tutorial allows you to build or execute test cases on Android devices connected to the cloud using Appium Drivers or SeeTest Automation C#/Java client

This tutorial allows you to build or execute test cases on Android devices connected to the cloud using Appium Drivers or SeeTest Automation C#/Java client

To develop a test you will need to Connect to a mobile device in Automation Mode

Table of Contents
include.*Step.*

Step 1 : Prepare your Application

Using the Application Manager (upload your application to the Digital Assurance Lab Application Center, you can later Manage Cloud Applications via the cloud based Web UI.Image Removed.

Click on the App Manager dialog box.

Image Added

This will open up App Manager application dialog box. Click Browse Files  to pick up desired Application to upload from your local hard drive.

Image Added


Next, Select the application and install and launch it on the device

Note: In As shown the screenshot below icon highlighted with 1  indicates Install and 2 indicates Launch.Image Removedclick Install icon for installation of the app.

After then installation application can be launched using the Launch button when it gets enabled.

Image Added

Step 2 : Open the Object Spy 

The Object Spy provides a visual representation of the application objects layout.

The Object Spy tool  allows you to filter elements using XPath queries for selecting an Element's identification method.

Unique XPath generator will create a unique XPath expression for the selected element.


Step 3 : Create a project with a Java IDE 

Create new Appium project in Eclipse (Gradle \ Maven)

  1. Create a new gradle project, File->New->Other... and Select 'Gradle Project'

  2.  Check the 'Create a simple project (skip archetype selection)' check box. Click 'Next' button.

  3. Open the newly created project, open the build.gradle file that was created. Replace the generated content with the following:

    Code Block
    languagegroovy
    themeEclipse
    titlebuild.gradle
    collapsetrue
    apply plugin: 'java'
    apply plugin: 'maven'
    apply plugin: 'eclipse'
     
    repositories {
             
         maven { url "http://repo.experitest.com:8010/Maven2/" }
    /*    Optional Use the Cloud server as a maven repository
    //    maven { url "<Your Cloud URL>/download-file" }
    */
        maven { url "http://repo.maven.apache.org/maven2" }
        
         mavenCentral()
    }
    dependencies {
        compile group: 'com.experitest', name: 'appium', version:'4.1.2'
    }


    Run the clean, cleanEclipse and eclipse task to prepare your eclipse environment. 

Maven

  1. Create a new Maven project, File->New->Other... and Select 'Maven Project' -> Create A simple Project 


2. Open and edit the source of your Project POM.xml File



Replace the content with the code below


Code Block
languagejava
themeEclipse
titlepom.xml
collapsetrue
<project>
    <modelVersion>4.0.0</modelVersion>
    <groupId>Your.Group.Id</groupId>
    <artifactId>Your.Artifact.Id</artifactId>
    <version>Your.Version</version>
    <repositories>
            <repository>
            <releases>
                <enabled>true</enabled>
                <updatePolicy>always</updatePolicy>
                <checksumPolicy>fail</checksumPolicy>
            </releases>
            <id>Experitest.repo1</id>
            <name>CloudRepository</name>
            <url>http://repo.experitest.com:8010/Maven2/</url>
            <layout>default</layout>
        </repository>
    </repositories>
     
<dependencies>
    <dependency>
    <groupId>com.experitest</groupId>
    <artifactId>appium</artifactId>
    <version>4.1.2</version>
    </dependency>
</dependencies>
</project>
 

Step 4 : Write your first Test Class

Create a Test Class under src/test/java folder in your project 

Info

Set Experitest Url

Please make sure you replace <EXPERITEST_URL> with appropriate URL in the sample test below.

Code Block
languagejava
themeEclipse
titleFirstTest
collapsetrue
import java.net.MalformedURLException;
import java.net.URL;
import org.junit.*;
import org.openqa.selenium.By;
import org.openqa.selenium.remote.DesiredCapabilities;
import io.appium.java_client.android.AndroidDriver;
import io.appium.java_client.remote.MobileCapabilityType;

public class FirstTest {

	AndroidDriver driver;
	@Before
	public void setUp() throws MalformedURLException{
		DesiredCapabilities dc = new DesiredCapabilities();
		dc.setCapability(MobileCapabilityType.UDID, <USE THE UDID OF THE DEVICE>); //Place here the UDID of the device
		dc.setCapability("username", <YOUR SEETESTCLOUD USERNAME>); //Your SeeTestCloud Username 
		dc.setCapability("password", <YOUR SEETESTCLOUD PASSWORD>); //Your SeeTestCloud Password
// If you wish to Continue with the current session, WITHOUT INSTALLING AND LAUNCHING THE APP, comment the line below
		dc.setCapability(MobileCapabilityType.APP, "C:\\APPS\\eribank.apk");
		driver = new AndroidDriver<>(new URL(<EXPERITEST_URL>), dc);
	}
	@Test
	public void exampleTest(){
		driver.findElement(By.xpath("//*[@id='usernameTextField']")).sendKeys("company");
		driver.findElement(By.xpath("//*[@id='passwordTextField']")).sendKeys("company");
		driver.findElement(By.xpath("//*[@text='Login']")).click();
		driver.findElement(By.xpath("//*[@text='Logout']")).click();
	}
	
	@AfterM
	public void tearDown(){
		driver.quit();
	}
}