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.
- Homebrew installation
- Maven configuration
- Java installation
- Android SDK installation
- Appium installation and configuration.
- Android and iOS Emulators
- POM examples (for iOS and Android).
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!
This project consist of several important parts, everything has been mounted on the structure of a Maven project.
- 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.
- Configure the test executions parameters: platform name and app name
- 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).
- Suites: Here we can group sets of tests to run it together.
- test.properties & log4j2.properties: Here we store some common tests properties and the log4j2 properties.
- Constant: on this package we include every Constant class related to each Page Object along with the ID or Xpath to find the elements.
- PageObject: on this package we include every PageObject needed to create the tests.
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'");
}
Important: To run the test are absolutely necessary two conditions:
- The emulator should be running (only on Android, on iOS the MacOSX can create a new instance).
- Appium should be running.