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.

Pre-requisites

  1. 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.
  2. Make sure you have minimum 3GB RAM capacity in your laptop.
  3. 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

  1. Double click on installer and follow next, next button and complete installation
  2. Once installation is complete, Genymotion window is launched like below.
  3. launchpage
  4. Click on ‘Add’ Device in Genymotion window
  5. genymotionhomepage
  6. Login with user account/password for personal license
  7. license_personal
  8. Select Android version and its corresponding device name, click ‘Next’ button
  9. selectDevices
  10. Device details will be displayed as below
  11. devicedetails
  12. Device starts deploy
  13. device_deployment
  14. After deployment in your machine, the device virtual box file downloaded in the following location
  15. DeviceDeployment_virtualbox
  16. Launch the virtual box and start it
  17. Start_Samsung_Galaxy_S8_vbox
  18. started_virtualbox
  19. Click ‘Start’ button on Genymotion window
  20. startingDevices
  21. Finally! congratulations, device is launched successfully.
  22. devicelaunched

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
  • adapter

Upload APK file to Virtual Device

Drag and Drop APK file

  1. Download sample apk file.
  2. drag and drop on devices, the App will be displayed as below.
  3. appstartedPage

Install App using command line

Run the following command: adb install <application name>.apk

Configuring Appium Server for Genymotion

  1. To verify device gets connect, supply command “adb devices” which will list ip address and its port.
  2. 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

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s