Reading Time: <20 minutes
What’s up Guys! Welcome to automationcalling.com
I’m writing this post because of some of my friends, my whatsApp groups and Test Professional requested me to write “how to simply setup Mobile Test Automation on Genymotion”. I’m sure there are many websites have such information but I want to give a try, from scratch to simple very test automation on Calculator App (Android Native App).
Coming Soon! (Mobile Test Automation – Native App – Parallel Execution with Real Devices, Genymotion and Cloud)
In this article, we are going to look on the following areas:
- Genymotion Installation & Setup
- Genymotion troubleshooting
- How to upload “apk” file on Virtual Device.
- Configuring Appium Server for Genymotion
- How to Run Very Simple Automation Test
Before go to this topic, I would recommend you to take a look on the following blogs and get familiarization on Android SDK Manager installation, ADB commands and Appium Desktop Server configuration.
- Installing Android Studio on Windows
- Installing Appium Desktop and Setting up Selenium Grid
- ADB Commands and trouble shooting…
Pre-requisites
- Make sure Virtualization must be enabled in your windows.
- To do this, reboot your system or While switch on PC/laptop, press “F2”. The BIOS setting does show up where verify virtualization is enabled.
- Make sure you have minimum 3GB RAM capacity in your laptop.
- Download Genymotion Personal Edition from here https://www.genymotion.com/fun-zone/
- While downloading, it takes you to sign up account, complete the procedure.
- Once sign in for download, it ask you to install only Genymotion or Genymotion with Virtual box. (If you already installed virtual box then Genymotion installer is fair enough).
- This is personal edition only purpose for Game, POC for Development or Automation Test etc., not entertained for Business. Please read agreement clearly before install in case if you are going to install in office PC or laptop.
Genymotion Installation Setup:
Genymotion or Genymotion with virtual box Installation is pretty simple steps
- Double click on installer and follow next, next button and complete installation
- Once installation is complete, Genymotion window is launched like below.
- Click on ‘Add’ Device in Genymotion window
- Login with user account/password for personal license
- Select Android version and its corresponding device name, click ‘Next’ button
- Device details will be displayed as below
- Device starts deploy
- After deployment in your machine, the device virtual box file downloaded in the following location
- Launch the virtual box and start it
- Click ‘Start’ button on Genymotion window
- Finally! congratulations, device is launched successfully.
Genymotion Troubleshooting
- Open Oracle Virtual Box
- Settings -> System
- set Base Memory to 1024MB, click ok
In case you see the error message “Device got no IP Address”
- Go to Oracle virtual box
- Click ‘Global Tools’
- Please make sure Adapter and DHCP Server shows assigned IP address
Upload APK file to Virtual Device
Drag and Drop APK file
- Download sample apk file.
- drag and drop on devices, the App will be displayed as below.
Install App using command line
Run the following command: adb install <application name>.apk
Configuring Appium Server for Genymotion
- To verify device gets connect, supply command “adb devices” which will list ip address and its port.
- further, please familiar on the following page regarding how to find App Package name and run Appium server.
How to Run Very Simple Automation Test
Pre-requisites:
- The above mentioned configuration setup must be done for Genymotion
- App must be installed (but this example I use Android Native Calculator App)
To Initialize Driver:
public void driverInit() throws MalformedURLException { caps = new DesiredCapabilities(); caps.setCapability("platformName", "Android"); caps.setCapability("deviceName", "Samsung Galaxy S8"); caps.setCapability("udid", "IPADDRESS:5555"); //Give Device ID of your mobile phone caps.setCapability("platformVersion", "8.0"); caps.setCapability("appPackage", "com.android.calculator2"); caps.setCapability("appActivity", "com.android.calculator2.Calculator"); caps.setCapability("autoGrantPermissions", "true"); caps.setCapability("noReset", "true"); caps.setCapability("skipUnlock", "true"); driver = new AndroidDriver<>(new URL("http://127.0.0.1:4729/wd/hub"), caps); driver.manage().timeouts().implicitlyWait(60, TimeUnit.SECONDS); }
Test Script:
public class SampleTestSuites extends DriverInit { @BeforeClass public void init() throws MalformedURLException { driverInit(); } @Test public void summationTest() { driver.findElement(By.id("com.android.calculator2:id/digit_9")).click(); driver.findElement(By.id("com.android.calculator2:id/op_mul")).click(); driver.findElement(By.id("com.android.calculator2:id/digit_5")).click(); driver.findElement(By.id("com.android.calculator2:id/eq")).click(); Assert.assertEquals("45",driver.findElement(By.id("com.android.calculator2:id/result")).getText()); } @AfterClass public void tearDown() { driver.quit(); } }
Test Automation Execution
Conclusion
Genymotion is a wonderful tool to automate App on Android OS. The personal edition is basically for doing POC, Game etc., for Companies, they offer Desktop and Cloud license version. Maintenance is very less, able to support both Manual and Automation (Parallel test is possible).
Disadvantage: You cannot install iOS.
Thanks for your time. Please subscribe automationcalling.com for more updates!
Leave a Reply