Skip to content

estefafdez/appium-native-java-example

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

61 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Appium-native-java-example

Example on iOS and Android using Appium. The aim of this project is provide a maven project in order to run automated test with Android and iOS easily.


Prerequisites

  1. Homebrew installation
  2. Maven configuration
  3. Java installation
  4. Android SDK installation
  5. Appium installation and configuration.
  6. Android and iOS Emulators
  7. POM examples (for iOS and Android).

How to start with the project

First, you have to clone the repository to get the project structure.

Secondly, change in the pom.xml the values according to the OS you need and your application name.

Finally, enjoy coding!

Project structure

This project consist of several important parts, everything has been mounted on the structure of a Maven project.

In the pom:
  1. We have defined as a dependency all the properties necessary to run the project and to configure it. You can change the versions into the pom.xml on the dependencies and plugin section.
  2. Configure the test executions parameters: platform name and app name
In the src/test/resources:
  1. Files: in this folder you need to copy the application you are going to test. You can include several apps inside (for iOS and Android for example).
  2. Suites: Here we can group sets of tests to run it together.
  3. test.properties & log4j2.properties: Here we store some common tests properties and the log4j2 properties.
In the src/main/java:
  1. Constant: on this package we include every Constant class related to each Page Object along with the ID or Xpath to find the elements.
  2. PageObject: on this package we include every PageObject needed to create the tests.
In the src/test/java:

On this package we create all the Test Classes in order to interact with every PageObject and every ConstantPage.

All test should start with test and have a self-descriptive name, for example: testLoginOnApp.

*** Remember do not forget to use the AssertTrue or AssertFalse on the checks methods and include the custom message for the error.

One example of a test case is:

	/**
	 * Test to be an example for the first iOS Test using the TestApp.app application <br>
	 */
	@Test(description = "testIosExample")
	public void testIosExample() {

			/** Create a new instance of the IosHomePage */
			IosHomePage iosHomePage = new IosHomePage(driver);			
			
			/** Wait until the Home Page is ready */
			iosHomePage.waitForReadyPageByID();
	
			/** Click on the input "Enter your name" */
			iosHomePage.clickOnInput();
				
			/** Send a text into the input */
			iosHomePage.sendKeyToInput("QA Rocks"); 
				
			/** Click on the "Click!" button */
			iosHomePage.clickOnButton();
			
			/** Check Switch button. By default is enable */
			assertTrue(iosHomePage.checkSwitchButtonStatus(), "The Switch button is not enabled");
				
			/** Check if the Switch label is "Click on the switch button" */
			assertTrue(iosHomePage.checkSwitchLabel("Click on the switch button:"), "The Label does not have the text: 'Click on the switch button'");
				
			/** Click on the Switch button */
			iosHomePage.clickOnSwitchButton();
			
			/** Check Switch button. It should be disabled */
			assertFalse(iosHomePage.checkSwitchButtonStatus(), "The Switch button is not disabled");
				
			/** Check if the Switch label is "OFF" */
			assertTrue(iosHomePage.checkSwitchLabel("OFF"), "The Label does not have the text 'OFF'");
				
			/** Click on the Switch button again */
			iosHomePage.clickOnSwitchButton();
			
			/** Check Switch button, it should be enabled */
			assertTrue(iosHomePage.checkSwitchButtonStatus(), "The Switch button is not enabled");
				
			/** Check if the Switch label is "ON" */
			assertTrue(iosHomePage.checkSwitchLabel("ON"), "The Label does not have the text 'ON'");
	}

Run the test.

Important: To run the test are absolutely necessary two conditions:

  1. The emulator should be running (only on Android, on iOS the MacOSX can create a new instance).
  2. Appium should be running.

About

A Java example using Appium to test native application: iOS and Android.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages