Reading Time: <10 minutes
What’s up guys! Welcome to automationcalling.com
Alright! I have been waiting for this moment because I was stuck with some personal issues, so couldn’t post the blog since a month.
This is a base test automation framework for Native Apps which is implemented using Appium, Selenium, TestNG and Allure Report. This framework supports to run both Android and IOS, it’s possible to extend Windows Phone by creating additional package and added necessary code.
What are we going to take a look?
- Key Feature of this Framework
- Device Farm Configuration setup
- Framework Architecture and implementation
- App Setup & Configuration
- Configuring .apk file in SauceLab for Emulator using REST API
- Configuring .apk file in SauceLab for real devices using REST API
- Configuring .apk file in SauceLab for real device using Manual upload
- Parallel Test on Local, Cloud and Genymotion of your Native App
Some of key feature of this framework:
- Support iOS and Android Native App
- Support parallel execution in Cloud (Real device and Emulators), local real device, Genymotion (Please refer video at bottom of the page)
- Implemented Allure Report which supports to pull parallel test results
- Implemented Page Object Design Pattern and Page Actions are segregated in separate package
- Implemented Common Appium methods in CommonAppium class and Android Utils and IOSUtils classes have own native code related to Mobile Elements
- Used TestNG which actually support parallel execution based on device input and its capabilities.
- Possible to enhance flexibility and customization based on business need.
- Add sample app in resource folder which actually uses to upload in device during test execution
- Support Device can be setup in Wifi or USB which must be configured in json file
- Possible to set Selenium Grid in One Machine, Multiple Appium Server in Same or Different machines where physical device gets connected and Genymotion connected in different machine. For Cloud, no Appium Server required
Device Farm Configuration:
Here is the device farm designed to run your automation suites in local physical, cloud and Genymotion Device farm to make sure automation runs quickly and efficiently with different option.
Automation Framework Architecture and implementation
Driver Implementation UML Basic Diagram:
Automation Framework Architecture Diagram:
App Setup & Configuration
Before go to below setup & configuration, I would recommend to go through the following url and get familiarized with Mobile Automation.
Installing Android Studio on Windows
Installing Appium Desktop and Setting up Selenium Grid
ADB Commands and trouble shooting…
Mobile Test Automation with Genymotion on Window
Configuring .apk file in SauceLab for Emulator using REST API
Prerequisites:
we use REST API endpoints to upload your app (.apk) in SauceLab which required curl support for your Windows/Linux/Mac Machines.
curl -u <SAUCEUSERNAME>:<SAUCE_KEY> -X POST -H "Content-Type: application/octet-stream" https://saucelabs.com/rest/v1/storage/<SAUCEUSERNAME>/your_app.apk?overwrite=true --data-binary @your_app.apk
After you supply the above command, you will receive success message stating username, filename, size, md5 and etag response.
Configuring .apk file in SauceLab for real devices using REST API
The REST API command is same as previous section to upload your .apk file but the difference is, SauceKey is different for real device and rest endpoint url is different. Here we use https://app.testobject.com:443/api/storage/upload for storing real device whereas in previous section the endpoint is different.
for eg., below example:
curl -u "<SAUCEUSER>:<SAUCE_KEY>" -X POST https://app.testobject.com:443/api/storage/upload -H "Content-Type: application/octet-stream" --data-binary @your_app.apk
Configuring .apk file in SauceLab for real devices using Manual Upload
- Once login to SauceLab, Click on “Access Real Device Automation”
- Click on “+New App” button
- The below page shows button which support website, Native App creation
Parallel Test on Local, Cloud and Genymotion of your Native App
In below videos, My device farm has been setup like below:
- 1 real device (My mobile) setup in Wifi, which is configured in Selenium Grid
- 1 Genymotion device setup in physical OS Machine, which is configured in Selenium Grid
- Configured SauceLab Emulator for Android Device
- Configured SuaceLab Real Devices running on Cloud
Prerequisites:
- Start Selenium Grid, This is you can setup in your Jenkins Job too.
- Start Appium Server for Multiple devices. Each Appium Server is mapped to local real device or Genymotion. Note: We can also start Appium Server in command prompt instead of GUI tool.
- Make sure .apk file uploaded in SauceLab for Emulator and real device configuration as mentioned above
- All device farm have been successfuly set, now it’s time for execution.
Device Configuration for Parallel Execution:
For this framework, the device config must be set in testsuite.xml, the below one is the template to configure whether your device must run in local/genymotion/saucelab.
Parallel Execution Videos in Local Device/Genymotion and SauceLab
Parallel Execution in Local Device and Genymotion Video:
Parallel Execution in SauceLab Emulator and Real Devices:
Test Results in Allure:
To clone this framework, please visit my bitbucket repo: automationcalling_bitbucket
Note: Appium Server Config and Selenium grid is available under resource folder for further play.
Thanks for your time. Please subscribe automationcalling.com for more updates!
Thanks Muthu for this article. Couple of Qs
1) I am learning mobile automation and of now using 1 physical device to automate using eclipse at my end so will that be a hurdle?
2) So I think my first target should be selenium grid setup and then follow as u mentioned?
Please advise.
Thanks
VS
LikeLike
Great Vaibhav.
1) I don’t think it will be hurdle, you can use any editor.
2) Check this link, yes this is first setup https://automationcalling.com/2018/09/03/installing-appium-desktop-and-setting-up-selenium-grid/
LikeLike