Tuesday, 3 January 2017

Creating Appium and Maven Project


Video Tutorial - 

 

 

Why Maven and Appium?

Appium is good tool for mobile automation. But, when using it for testing and building a test framework, it feels underpowered. Integrating Maven with Appium provides following benefits as, Apache Maven provides support for managing the full lifecycle of a test project.

1. Maven is mainly used for defining project structure, dependencies, build, and test management.
2. Using pom.xml(Maven) you can configure dependencies needed for building, executing and testing code.
3. Maven automatically downloads the necessary files from the repository while building the project.

How to Install Maven 


1. Down Load latest version of Maven from THIS LINK.
2. Add an Environmental Variable MAVEN_HOME as shown below

Appium with Maven

3. Add Maven bin path in 'path' System Variable

Appium and Maven
Add caption

4. Go to command prompt and run command 'mvn -version'

Maven Installation
Add caption

5.Check the results to ensure it is installed successfully

Maven Installation

Create Maven Project in Eclipse -

1. Open Eclipse
Appium Eclipse Maven Project

2. Go to New -> Project ->

Appium Eclipse Maven Project

3. Select Simple Maven Project -> Next

Appium Eclipse Maven Project


4. Enter SampleTestProject in Group Id and Artifact Id -> Finish

Appium Eclipse Maven Project

5. Check the project structure and right click on JRE System Library and click on properties.
 

6. Select workspace default jre.



Install TestNG in Eclipse 

1. Help -> Install New Software

2. Click on Add -> Enter TestNG and path http://beust.com/eclipse/ -> click OK

Installa TestNG in eclipse

3. Select TestNG and click on Next

Installa TestNG in eclipse

4. Again Click on NEXT 
Installa TestNG in eclipse

5. Click on Accept and Finish

Installa TestNG in eclipse


6. Click on Ok for Security Warning dialog box and then installation will start

 

7. Then Restart your Eclipse

Add TestNG and Appium in Pom.xml 

1. Open pom.xml 


 2. Copy below code within <Project> tag of Pom.xml


<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>2.46.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>io.appium</groupId>
<artifactId>java-client</artifactId>
<version>3.1.0</version>
<scope>provided</scope>
</dependency>
<dependency>
  <groupId>org.testng</groupId>
  <artifactId>testng</artifactId>
  <version>6.8</version>
  <scope>test</scope>
</dependency>
</dependencies>
3. Create a TestNG class and write a sample Test Case . Refer Appium tutorial for writing sample test case.And you can run maven test by right clicking on project and click on maven test.




2 comments:

  1. Need code for how to handle Toast message and check whether wifi or mobile data is enabled or not in mobile device before launching Apk or mobile site.

    ReplyDelete
  2. I feel really happy to have seen your webpage and look forward to so
    many more entertaining times reading here. Thanks once more for all
    the details.


    Android Training in Bangalore

    ReplyDelete