Join the webinar on 'Open source GenAI tools for Test Automation' on May 28th or May 30th.
close
Appium 2.0 Migration Playbook

Appium 2.0 Migration Playbook

August 18, 2023
 by 
Rohan SinghRohan Singh
Rohan Singh

Appium 2.0 has finally been released! HeadSpin has been a proud supporter of Appium, and we are so excited to show you how to install the latest version of Appium and start using it in your existing scripts.

In order to get started on Appium version 2.0 on HeadSpin, please reach out to helpdesk@headspin.io, and we will install Appium 2.0 on each of your devices.

For local testing, we will need to do a new install.

Installing Appium 2.0

Appium 2.0 is now the default that can be installed through NPM:


npm i --g appium

This will install Appium globally so it can be run from anywhere in your command line . You can start the Appium server with the following command:


appium

You should see some output that starts with a line like this:


rohan@Rohans-MacBook-Pro-14 appium_2 % appium
[Appium] Welcome to Appium v2.0.1 (REV 0ccd099bff8e384043883c4ae01b589794b13d72)
[Appium] Appium REST http interface listener started on http://0.0.0.0:4723
[Appium] You can provide the following URLS in your client code to connect to this server:
[Appium] 	http://127.0.0.1:4723/ (only accessible from the same host)
[Appium] 	http://192.168.0.62:4723/
[Appium] No drivers have been installed in /Users/rohan/.appium. Use the "appium driver" command to install the one(s) you want to use.
[Appium] No plugins have been installed. Use the "appium plugin" command to install the one(s) you want to use.

Install Appium version 2.0 Drivers

As can be seen, the Appium server is up and running. Appium 2.0 has a major architectural change where it uses drivers to interact with a range of devices and browsers. In addition, there are plugins to enable more advanced features.

This greatly simplifies the complexity of Appium and allows the community to contribute easily.

Let’s go ahead and install the Android UIAutomator2 and iOS XCUITest drivers


appium driver install uiautomator2
appium driver install xcuitest

You should get two successfully installed messages


✔ Installing 'uiautomator2' using NPM install spec 'appium-uiautomator2-driver'
ℹ Driver uiautomator2@2.29.4 successfully installed
- automationName: UiAutomator2
- platformNames: ["Android"]

✔ Installing 'xcuitest' using NPM install spec 'appium-xcuitest-driver'
ℹ Driver xcuitest@4.33.2 successfully installed
- automationName: XCUITest

Porting existing scripts

A major change in Appium 2.0 is that instead of the /wd/hub base path, now it is just /.

This can be changed when instantiating the webdriver request or changed on loading the Appium server with the following command:


appium --base-path=/wd/hub

Using Appium Inspector

Appium Desktop has been deprecated and now the inspector functionality will move to Appium Inspector. It can be downloaded from:

appium/appium-inspector: A GUI inspector for mobile apps and more, powered by a (separately installed) Appium server (github.com)

Or even used in the browser version at https://inspector.appiumpro.com. In order to use this on a local Appium server, please start the server with the --allow-cors flag.

Lastly you can use HeadSpin’s integrated inspector.

HeadSpin inspector integration

Using Appium 2.0 on HeadSpin

Since HeadSpin manages the Appium server and driver installations for you, the migration to Appium version 2.0 is seamless. However, there are still a few updates you’ll want to make to your capabilities, to ensure a smooth transition.

First we can check which versions of Appium are available on each server with the following command:


curl -X GET https://{ headspin-host }:{ headspin-port }/v0/{your-api-token}/wd/hub/versions

This data can be obtained from the UI as follows:

Device Lists

Click on the three dots next to the device under test and click ‘Automation Configuration’

Device configuration

Then take the Web Driver URL append /versions to the end. Eg:


curl -X GET "https://dev-au-mel-1.headspin.io:7024/v0/4707c0d8da834821b6862bdd7185c039/wd/hub/versions"
{"status": 0, "value": {"default": "1.22.3", "available": ["2.0.0", "1.21.0", "1.20.2", "1.22.1", "1.22.0", "1.22.3", "1.22.2"], "drivers": {"default": {"uiautomator2": "2.29.1"}}, "plugins": {"default": {}}}, "session_id": null}

(If your host doesn’t have any Appium 2 servers or plugins available, or if you need a specific version, get in touch with your HeadSpin support contact or helpdesk@headspin.io, and we’ll get things sorted out for you.)

To use the desired version of Appium with plugins, please add the following capability to your Appium script:


{
    "headspin:appiumOptions": {
        "version": "2.0.0",
        "plugins": ["images", "relaxed-caps"]
    }
}

You can also just change the version or plugins with the following capabilities:


headspin:appiumVersion
headspin:appiumPlugins

Appium 2.0 Migration Playbook

4 Parts

Close

Perfect Digital Experiences with Data Science Capabilities

Utilize HeadSpin's advanced capabilities to proactively improve performance and launch apps with confidence
popup image