Running Tests

Go back to tutorial

Process of Running Tests

We will now be discussing at length about the process of running  test. Further, this will include the process of preparing your app for test using iOS, Android, and windows.

Preparing your app for Test for Running Tests

Preparing your app for test (iOS)

You must remember that the test apps run on the simulator, that have to be compiled specifically for the simulator. Now when we execute below command in the Xcode project –

> xcodebuild -sdk iphonesimulator6.0

Moreover, this will help to create a build/Release-iphonesimulator directory in your Xcode project. Further, it contains the .app package that needs to be communicated with the Appium server.

Preparing your app for test (Android)

Preparing your app for test (Android) requires nothing in particular to be done to run your .apk using Appium. But, if you want to zip it up, you can.

Preparing your app for test (Windows)

Preparing your app for test (Android) nothing in particular needs to be done to run your test.

Running your test app 

Running your test app with Appium (iOS)

At first, make sure Appium is running –

node .

Thereafter, script your WebDriver test, send in the following desired capabilities in Java –

DesiredCapabilities capabilities = new DesiredCapabilities();

capabilities.setCapability(MobileCapabilityType.PLATFORM_NAME, “iOS”);

capabilities.setCapability(MobileCapabilityType.PLATFORM_VERSION, “7.1”);

capabilities.setCapability(MobileCapabilityType.DEVICE_NAME, “iPhone Simulator”);

capabilities.setCapability(MobileCapabilityType.APP, myApp);

Thereby, using your WebDriver library of your choice, set the remote session to use these capabilities and connect to the server running at port 4723 of localhost. You should be all set now!

Running your test app with Appium (Android)

First, make sure you have one and only one Android emulator or device connected. Therefore, while running adb devices, you should see one device connected. This is the device Appium will use for tests. Of course, to have a device connected, you will require to have made an Android AVD. But in case the Android SDK tools are on your path, you can simply run –

emulator -avd <MyAvdName>

Also, make sure Appium is running –

node .

Let us consider several ways to start an Appium application –

  • apk or zip only, the default activity will be launched (‘app’ capability)
  • apk + activity (‘app’ + ‘appActivity’ capabilities)
  • apk + activity + intent (‘app’ + ‘appActivity’ + ‘appIntent’ capabilities)

Thereafter, script your WebDriver test, by sending below desired capabilities in Java –

DesiredCapabilities capabilities = new DesiredCapabilities();

capabilities.setCapability(MobileCapabilityType.PLATFORM_NAME, “Android”);

capabilities.setCapability(MobileCapabilityType.PLATFORM_VERSION, “4.4”);

capabilities.setCapability(MobileCapabilityType.DEVICE_NAME, “Android Emulator”);

capabilities.setCapability(MobileCapabilityType.APP, myApp);

Further, using your WebDriver library of choice, you must set the remote session to use these capabilities. And thereafter connect to the server running at port 4723 of localhost.

Running your test app with Appium (Android devices < 4.2, and hybrid tests)

The Android devices before version 4.2 (API Level 17) do not have Google’s UiAutomator framework installed. In general, this is what Appium uses to perform the automation behaviors on the device. Further, for earlier devices or tests of hybrid (webview-based) apps, Appium comes bundled with another automation backend referred as Selendroid.

 

To use Selendroid, the set of desired capabilities should be changed, by adding the automationName capability and specifying the Selendroid automation backend. Usually, you would be required to use a . before your activity name like, .MainActivity, in Java –

DesiredCapabilities capabilities = new DesiredCapabilities();

capabilities.setCapability(MobileCapabilityType.AUTOMATION_NAME, “Selendroid”);

capabilities.setCapability(MobileCapabilityType.PLATFORM_NAME, “Android”);

capabilities.setCapability(MobileCapabilityType.PLATFORM_VERSION, “2.3”);

capabilities.setCapability(MobileCapabilityType.DEVICE_NAME, “Android Emulator”);

capabilities.setCapability(MobileCapabilityType.APP, myApp);

capabilities.setCapability(MobileCapabilityType.APP_PACKAGE: “com.mycompany.package”);

capabilities.setCapability(MobileCapabilityType.APP_ACTIVITY: “.MainActivity”);

Post this, Appium will start up a Selendroid test session instead of the default test session. But, one of the downsides to using Selendroid is that its API differs sometimes significantly with Appium’s. Therefore, we recommend you thoroughly read Selendroid’s documentation before writing your scripts for older devices or hybrid apps.

Running your test app with Appium (Windows)

In this case, simply ensure that Appium is listening, and run your test with your test runner of choice.

Boost your chances for better job opportunities. Practice and Prepare for Mobile Testing (Appium) Exam Now!

Go back to tutorial

Writing and Running Tests In Appium
Desired Capabilities

Get industry recognized certification – Contact us

keyboard_arrow_up
Open chat
Need help?
Hello 👋
Can we help you?