Execute appium test on android native app in java

 If you are new to appium, please refer below links for the prerequisites

  • Eclipse IDE setup
  • Appium setup for windows [Mandatory to have the setup before proceeding]
  • How to find appium locators
  • App Package and activity name

For the appium test: we will be using Selenium, Appium, Eclipse IDE (java) and Android app (.apk) in an emulator or real handset…

Before running appium test on real device or android emulator, make sure we keep the device connected to computer, use adb command to verify.

Ways to install apps (.apk) on mobile or emulators:

  • Install as usual from android play store.
  • Using command line

Have the required .apk file on computer, and connect mobile to computer in debug mode.
open command prompt, type

For appium test, we will use selendroid sample application… [download selendroid-test-app.apk ‘click on view raw to download’]

Required jar files :

  • selenium related jar files [follow webdriver setup to download]
  • java-client-x.x.x.jar

Let’s understand the above code in details:

Code uses testNG, Java and appium…

@BeforeTest

We have capabilities setup for the mobile handset or emulator like DeviceName, Platform, version, app activity, app package etc…
Refer Appium capabilities for more information

then, we have instantiated AndroidDriver object which accepts 2 arguments:

  • URL
  • Capability object

Under @Test, whatever the code present is same as selenium test.

Advertisements

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 )

Twitter picture

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

Facebook photo

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

Google+ photo

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

Connecting to %s