All Projects → shankybnl → Mobileautomationframework

shankybnl / Mobileautomationframework

Single code base framework to test android and iOS app using appium (v6.1.0), maven, testng,java. Option to start appium server programmatically.

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to Mobileautomationframework

MasterAppiumFramework
Automation Testing | Mobile | Java | OOPS | Appium | TestNG | Maven | ExtentReport | Java mail API | Logging (Log4J2) | Design Patterns (Page Object Model, Singleton) | Page Factories | Jenkins | Data-Driven Testing using JSON file | Expected Data using XML file
Stars: ✭ 27 (-59.09%)
Mutual labels:  maven, test-automation, appium, testng
SHAFT ENGINE
SHAFT is an MIT licensed test automation engine. Powered by best-in-class frameworks like Selenium WebDriver, Appium & RestAssured it provides a wizard-like syntax to increase productivity, and built-in wrappers to eliminate boilerplate code and to ensure your tests are extra stable and your results are extra reliable.
Stars: ✭ 170 (+157.58%)
Mutual labels:  maven, test-automation, appium
Carina
Carina automation framework: Web, Mobile, API, DB
Stars: ✭ 549 (+731.82%)
Mutual labels:  test-automation, appium, testng
Coteafs Appium
📱 Wrapper Appium Framework in Java which supports Automation of Mobile and Tablet apps.
Stars: ✭ 93 (+40.91%)
Mutual labels:  hacktoberfest, test-automation, appium
Appiumtestdistribution
A tool for running android and iOS appium tests in parallel across devices... U like it STAR it !
Stars: ✭ 764 (+1057.58%)
Mutual labels:  cucumber, appium, testng
MasterSeleniumFramework
Automation Testing | Web | Java | OOPS | Selenium WebDriver | TestNG | Maven | ExtentReport | Allure Reports | Java mail API | Design Patterns (Page Object Model, Singleton) | Jenkins | Data-Driven Testing using JSON file
Stars: ✭ 52 (-21.21%)
Mutual labels:  maven, test-automation, testng
carina
Carina automation framework: Web, Mobile, API, DB etc testing...
Stars: ✭ 652 (+887.88%)
Mutual labels:  test-automation, appium, testng
MAQS
Magenic's automation quick start
Stars: ✭ 46 (-30.3%)
Mutual labels:  test-automation, appium
Autonomx
Autonomx provides a complete testing platform for UI (Web, iOS, Android, Win) and API testing. It provides a feature rich and viable testing solution for end to end testing. It's designed to be fast, scalable, reliable and adaptable to any requirements for ever growing projects.
Stars: ✭ 14 (-78.79%)
Mutual labels:  appium, testng
CodeSpecJS
UI Automation Testing without writing a single line of code
Stars: ✭ 16 (-75.76%)
Mutual labels:  test-automation, cucumber
Cucumber
A monorepo of common components - building blocks for implementing Cucumber in various languages.
Stars: ✭ 3,299 (+4898.48%)
Mutual labels:  hacktoberfest, cucumber
carina-demo
Carina demo project.
Stars: ✭ 40 (-39.39%)
Mutual labels:  maven, appium
OneFramework
Automation for iOS, Android, & Web Apps with one codebase. Like it, Star it & spread the word !!!
Stars: ✭ 46 (-30.3%)
Mutual labels:  appium, testng
manon
🧪 Play with SpringBoot 2, JWT, Querydsl, GraphQL, Docker, ELK, PostgreSQL, MariaDB, Redis, MongoDB, Flyway, Maven, Gradle, TestNG, JUnit5, JaCoCo, GreenMail, CI, Quality Gates, Prometheus, Gatling, etc.
Stars: ✭ 26 (-60.61%)
Mutual labels:  maven, testng
karate-runner
VSCode Extension for Karate
Stars: ✭ 23 (-65.15%)
Mutual labels:  test-automation, cucumber
Robotframework Appiumlibrary
AppiumLibrary is an appium testing library for RobotFramework
Stars: ✭ 259 (+292.42%)
Mutual labels:  test-automation, appium
autotest-framework
UI自动化测试框架,支持APP、Web、HTML5三端, 基于SpringBoot框架, 采用Page Object设计模式,基于 TestNG 测试框架构建测试用例,支持消息通知、失败截屏、HTTP 报告、并发执行等特性
Stars: ✭ 98 (+48.48%)
Mutual labels:  appium, testng
TestLeafSeleniumTraining
This is public repository for Selenium Learners at TestLeaf
Stars: ✭ 80 (+21.21%)
Mutual labels:  cucumber, testng
Strongbox
Strongbox is an artifact repository manager.
Stars: ✭ 412 (+524.24%)
Mutual labels:  hacktoberfest, maven
Karate
Test Automation Made Simple
Stars: ✭ 5,497 (+8228.79%)
Mutual labels:  test-automation, cucumber

Facing an issue while executing the tests, please log the issue. For any help/queries on this framework. Please feel free to drop an email @ [email protected] If you find it helpful, star the repository and share with your network on LinkedIn,Twitter etc :) Connect with me on LinkedIn Cheers!

Mobile automation testing framework (Android and iOS) - supports both cucumber and testng tests

Single code base framework to test android and iOS app using appium. It is a boilerplate code. Clone it and you are good to go!

Framework with testng tests setup and execution (cucumber BDD tests here)

Package : UITestFramework : It includes the common classes (and methods) which are required by each test to perform actions. Below are classes in this package:

image

retryLogic : It has classes to implement retry in case of failure of a test. Retry count is set to 1 as of now. Test will be run once if it fails during the execution.

image

Add below listener to testng.xml file to include retry functionality.

image

CreateSession.java : All the methods to create a new session and destroy the session after the test(s) execution is over. Each test extends this class. Below are the methods in CreateSession class in their execution order.

  1. invokeAppium() - method starts Appium server. Calls startAppiumServer method to start the session depending upon your OS.

  2. createDriver(String os, Method methodName) - method creates the driver depending upon the passed parameter (android or iOS) and loads the properties files (config and test data properties files).

  3. Tests execution (tests are present in IntegrationTests.tests package)

  4. teardown() - method quit the driver after the execution of test(s)

  5. stopAppium() - method to stop Appium server. Calls stopAppiumServer() method to stop session depending upon your OS.

GenericMethods.java : It is a common repository for all the webdriver and appium methods which are called in each coreLogic classes. Every new method which is being used in coreLogic classes should be added in this class as well. It is to reduce the duplicate code. Each screen class extends this class. Below are few methods defined in this class:

waitForVisibility(By targetElement) - method to wait for an element to be visible findElement(By locator) - method to find an element findElements(By locator) - method to find all the elements of specific locator

MysqlDatabase.java : This can be used if any DB values need to be verifiedIt has method to read DB and get data from required table. For more help, read on this link: http://www.vogella.com/tutorials/MySQLJava/article.html

Package : app : It contains the app build against which tests would be executed.

Package : config - It contains three files config.properties, android_config.properties and iOS_config.properties.

config.properties : Path to android and iOS config files are defined in this file. Other common required values like DB connection information etc. could be written in this file.

image

  1. android_config.properties - contains the location of the file where test data required by android tests is defined

  2. iOS_config.properties - contains the location of the file where test data required by iOS tests is defined

Package: testData : This package contains files having android and iOS test data. It contains two files: en_US_android.properties and en_US_iOS.properties.

image

  1. en_US_android.properties - All test data required by android tests is defined in this file.

  2. en_US_iOS.properties - All test data required by iOS tests is defined in this file.

Package: logger : It contains Log.java class which contains methods to show the logs on console and save the logs in LogFile.txt of each run.

image

Package: IntegrationsTests : This package has sub-packages: screens, coreLogic, tests.

image

Package: IntegrationTests.screens : Classes in this package contains locators which are being used in coreLogic classes. Each page in mobile application is mapped to screen. E.g. for android login page, its AndroidLoginScreen. Segregated the locators on the bases of platform: android or iOS

Package: IntegrationTests.screens.android : Each screen on andriod app will be having as screen class under this package. It contains all the locators which are visible on that screen. E.g. - AndroidLoginScreen. Each android screen class extends GenericMethods.java.

image

Package: IntegrationTests.screens.ios : Each screen on ios app will be having as screen class under this package. It contains all the locators which are visible on that screen. E.g. - IOSLoginScreen etc. Each iOS screen class extends GenericMethods.java.

Package: IntegrationTests.coreLogic : Classes in this package contains methods which performs intended actions and validations required by a test. Divided the coreLogic package depending on the platform : android, ios and base

Package: IntegrationTests.coreLogic.base : For each screen there would be corresponding coreLogic class. Classes under this package contains abstract methods which are defined in their respective classes in coreLogic.android and coreLogic.ios package. Eg: LoginCoreLogic.

Package: IntegrationTests.coreLogic.android : For each base coreLogic there would be corresponding android coreLogic (e.g. - AndroidLoginCoreLogic) where abstract method declared in base class are defined. Corresponding base class, coreLogic will be extended by android coreLogic class. E.g. for LoginCoreLogic base class, AndroidLoginCoreLogic will extend LoginCoreLogic.

Package: IntegrationTests.coreLogic.ios : For each base coreLogic class there would be corresponding ios coreLogic class (e.g. - IOSLoginCoreLogic) where abstract method declared in base class are defined.Corresponding base coreLogic class will be extended by ios coreLogic class. E.g. for LoginCoreLogic base class, IOSLoginCoreLogic will extend LoginCoreLogic.

image

Package: tests.testngTests : This package contains all the tests. In each test there is instantiateHelpers(String invokeDriver) method which creates the object at runtime of the coreLogic classes required in the test. Object creation happens depending on the platform passed through invokeDriver parameter (android or ios). Then test calls methods defined in the coreLogic (of which object is created).

Javadoc of the project can be found in doc folder. It contains information all classes and methods.

Execution flow of test test

Below is execution flow with help of login test as example.

image

When testng_android.xml file runs, it executes invokeAppium() method (part of CreateSession class in UITestFramework package) present under @BeforeSuite annotation. Right now, it is commented out. You can make changes in these method as per your platform to start appium server programmatically. As of now before running your test, start appium server on your machine

image

After this @BeforeMethod annotation is called, createDriver() method is present under this which loads log4.properties file (used by Log.java for logging purpose). It also load all the required property/config files having test data . First config.properties is loaded and then corresponding to the platform android or iOS, test data fies are loaded. (For eg: for android, android_config.properties and en_US_android.properties files are loaded ) And creates android or iOS driver instance (depending on the platform name passed).

image

Next comes “instantiateHelpers” group. It would be present in every test under @BeforeMethod annotation. It creates object of all the coreLogic classes (depends on platform ios/android) which is required by test to run that test. Object is used to access all the methods present in coreLogic classes. In this case, we are creating object of AndroidLoginCoreLogic class which has methods to login.

image

Next @Test Method is executed. Here, we are calling the methods which is required to verify login flow present in AndroidLoginCoreLogic class using LoginCoreLogic object. And loading required test data from en_US_android_config.properties/en_US_iOS_config.properties.

image

image

Once tests execution is completed. @AfterMethod annotation (present in CreateSession class) is executed to quit the driver.

image

@AfterSuite will be called if it is not commented. It is to stop appium server.

Corresponding coreLogic classes and screens files should be added in same hierarchy. Example for LoginTest. LoginCoreLogic would be under base->LoginCoreLogic.

image

AndroidLoginCoreLogic would be under android->AndroidLoginCoreLogic.

image

IOSLoginCoreLogic would be under iOS -> IOSLoginCoreLogic.

image

Similar thing should be done for element locators. There is no base folder in case of screens.For android locators, it would be under screens->android->AndroidLoginScreen. For iOS locators, it would be under screens->ios->IOSLoginScreen.

How to execute a test

Maven is used as build tool (can be downloaded from here). pom.xml file is present in base directory which has all the required dependencies and code to invoke testng.xml file when executed from command line.

Connect your device to your machine or start the emulator.

Note: start appium server on your machine if not included programatically

Run below commands to execute android testng test:

$ cd mobileautomationframework/ $ mvn test -Dos=android -Dsurefire.suiteXmlFiles=testng.xml

Include iOS app on which you want to run test. Provide its path in config.xml file (iOSAppPath=src/app/path-to-your-iOSfile). And write screen locators in IOSLoginScreen and methods in IOSLoginCorelogic. Now you are ready to run below commands.

Run below commands to execute iOS testng test:

$ cd mobileautomationframework/ $ mvn test -Dos=iOS -Dsurefire.suiteXmlFiles=testng.xml

                                        xxxxxxxxxxxxxxxxxxxxxxxxxxxx

Cucumber BDD tests

image

Package : cucumberIntegrationTests :This package has sub-packages: screens and stepDefinitions. It also includes CucumberRunnerUtil class and CreateSessionCucumber class which are required to keep configurations and creating appium instance respectively.

image

Package: IntegrationTests.screens : Classes in this package contains locators which are being used in coreLogic classes. Each page in mobile application is mapped to screen. E.g. for android login page, its AndroidLoginScreen. Segregated the locators on the bases of platform: android or iOS

Package: IntegrationTests.screens.android : Each screen on andriod app will be having as screen class under this package. It contains all the locators which are visible on that screen. E.g. - AndroidLoginScreen. Each android screen class extends GenericMethods.java.

Package: IntegrationTests.screens.ios : Each screen on ios app will be having as screen class under this package. It contains all the locators which are visible on that screen. E.g. - IOSLoginScreen etc. Each iOS screen class extends GenericMethods.java.

image

Package: stepDefinitions.common : This package has all classes with common methods which can be used across android and iOS platform. It also has BaseSteps class which has initiation and appium driver creation for android or iOS platform.

Package: stepDefinitions.android : It should contain all the stepDefinitions for android features. e.g. AndroidLoginSteps

Package: stepDefinitions.iOS : It should contain all the stepDefinitions for iOS features. e.g. iOSLoginSteps

CucumberRunnerUtil.java: cucumberTestng.xml invokes this class. It has all the configuration for cucumber to execute tests and testng annotations to leverage their benefits.

image

CreateSessionCucumber.java : Similar to Create session class to create driver object and loading test data etc.

How to execute a test

Maven is used as build tool (can be downloaded from here). pom.xml file is present in base directory which has all the required dependencies and code to invoke testng.xml file when executed from command line.

Connect your device to your machine or start the emulator.

Note: start appium server on your machine if not included programatically

Run below commands to execute android cucumber test:

$ cd mobileautomationframework/ $ mvn test -Dos=android -Dsurefire.suiteXmlFiles=cucumberTestng.xml

Include iOS app on which you want to run test. Provide its path in config.xml file (iOSAppPath=src/app/path-to-your-iOSfile). And write screen locators in IOSLoginScreen and methods in IOSLoginCorelogic. Now you are ready to run below commands.

Run below commands to execute iOS cucumber test:

$ cd mobileautomationframework/ $ mvn test -Dos=iOS -Dsurefire.suiteXmlFiles=cucumberTestng.xml

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].