This article is a comprehensive and pain-free Appium start guide using GenyMotion emulator, TestNG framework and IntelliJ IDE. At the end of the article, you can also find how to do mobile automation with real devices.

Prerequisites

  • Appium for Windows
  • Android SDK
  • JAVA JDK
  • IntelliJ
  • GenyMotion Emulator
  • RapidEE (For changing Windows environmental variables easily.)

Step by Step Instructions

Step-1: Install JAVA JDK

Link: http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html

It is described in this article at step-4.

Step-2: Install Android SDK (Stand-Alone)

Link:  http://developer.android.com/sdk/index.html

Install SDK Tools Only version.

appium

2

2-1

Then, check below options and install them:

  • Android SDK Platform-tools
  • Android SDK Build-tools
  • Android 4.2.2 (API 17)
  • Intel x86 Emulator Accelerator (HAXM installer)
    [It accelerates built-in emulator]

4

5

6

7

Create new environmental variable as ANDROID_HOME and assign it with Android SDK Path.

appium

9

Append Android SDK directory, tools and platform-tools paths to system Path variable.

10

In order to test settings, open command prompt and run adb devices command. You will see below result.

11

Go to, extras\intel\Hardware_Accelerated_Execution_Manager under android SDK folder and install intelhaxm-android.exe . It accelerates built-in emulators.

intelhaxm

Note: If your Intel Virtualization Technology(VT-x) option is enabled in BIOS. You should restart your computer and disable it in your computer’s BIOS.

13

Step-3: Create Built-in Emulator (or you can use GenyMotion (Fast) Emulator ->> Step-4)

Open AVDManager.exe under android SDK path. Then, click “Create” button. After that, set the values as shown in the figure below and click “OK”.

14

You can start emulator by clicking “Start” button.

15

emulator

Step-4: Install and Create Genymotion Emulator (Fast Emulator)

Link: https://www.genymotion.com/

Go to Pricing Page and Select Individual (BASIC) plan and sign-in.

genymotion

Then, click to “with VirtualBox: Download for Windows” button to download it. Then, install it.

18

During installation, trust Oracle Corporation Universal Serial Bus Driver and finish installation and launch Genymotion.

19

20

21

Click “+” sign to add a new device. First, you should sign in.

22

Select a device (I prefer a device with low resolution).

23

24

25

If you want, you can Edit and Delete your emulator anytime you want.

26

Click Start to start emulator. Genymotion is very fast emulator. I highly suggest you to use it.

27

28

Step-5: Install Appium

Link: https://bitbucket.org/appium/appium.app/downloads/

Download the latest release.

29

Extract the zip file and run the installer (appium-installer.exe)

30

Step-6: Open Appium & Emulator and Integrate Them

After Appium installation, right click Appium shortcut and click “Run as administrator

31

Then, Start your Genymotion emulator.

Note: Don’t start Genymotion “Run as administrator” mode!!! If you run as administrator, you cannot drag and drop any item into emulator. Reference link: http://stackoverflow.com/questions/20002138/genymotion-2-0-drag-and-drop

Then, download sample .apk file from here. Andv then save it under “C:\TestApks

33

When you type “adb devices” on command prompt you will see Genymotion emulator as shown below.

35

We should install sample apk into our emulator. First, open virtualbox and do the below settings.

39

40

41

Then, download Genymotion-ARM-Translation_v1.1 from the link below.

http://forum.xda-developers.com/attachment.php?attachmentid=2680937&d=1397258016

and download the gapps-jb-20130813-signed.zip from the link below.

http://en.osdn.jp/projects/sfnet_rommirrors/downloads/gapps-jb-20130813-signed.zip/

Then, follow the guide here to flash emulator with these files.

Here is the video that shows how to do this: https://www.youtube.com/watch?v=vZKiqJyLBkU

After these settings, go to Settings on emulator and apply below settings:

42

Then drag and drop the BitbarSampleApp.apk into Genymotion.

43

Click Android Settings on Appium window.

32

And then, do the below settings as shown below.

34

Then, Click settings icon and set below settings.

54

Then, click to Run icon on Appium.

36

You should see below window.

37

After clicking magnifier icon, inspector window will open and then click “Refresh” button. You will see our test application on inspector window.

44

Alternative Way to Locate Elements: We can also go to “C:\Program Files (x86)\Android\android-sdk\tools” and open “uiautomatorviewer.bat

45

When UI Automator Viewer opens, click the highlighted icon to capture the current view of the application for inspecting elements.

UI Automator is much better option for locating elements.

46

47

Step-7: Writing Test Code with TestNG and IntelliJ

Select New Project

In the New Project window, select Maven on the left side of the screen.

Then, fill the GorupId, ArtifactId as shown below.

48

Copy and paste below line in your pom.xml

Test Scenario:

  • Open the bitBarSample.apk
  • Click second radio button
  • Write “SW Test Academy” on the text area
  • Click the “Answer” button
  • Wait and Check the expected text on the next page

Test Code:

Test Results:

Testing with Real Device

Download your phones driver. I am using Samsung Grand NEO

Link: http://www.driverscape.com/download/gt-i9060

After driver installation you will see below figure on device manager.

49

Then, connect your device and run the following commands

Adb kill-server

Adb start-server

Adb devices

And you will see below result.

50

After that, Change android settings in Appium.

52

Start Appium Server.

53

Then, run the same test on IntelliJ.

Here is the video of the execution: