Getting Started with Appium 2.0 Beta

This article was written by Srinivasan Sekar and Sai Krishna.

======================================

Appium released its first major version almost 7 years ago. Since then, Appium has rolled out a lot of new features and its automation backend architecture has evolved quite a lot.

Appium 2.0, the next major release, has been in talks for a couple of years now, as Jonathan Lipps and the team have been brainstorming and implementing new features.

Appium team has released 2.0.0-beta.10 recently with the official Appium image plugin and some minor bug fixes and improvements over its earlier beta versions. Appium 2.0 beta versions can be installed using the below command:

npm install -g appium@next

Appium server can take up several optional arguments. In addition to the server arguments, Appium 2.0 introduces new arguments:

  • -ah to specify a directory to install Appium drivers
appium server -ah /path/to/install/drivers driver install uiautomator2
  • -ka or –keep-alive-timeout to specify the number of seconds the Appium server should apply as both the keep-alive timeout and the connection timeout for all requests. Defaults to 600 seconds.
appium server -ka 800

Appium drivers (UIAutomator2 driver, XCUITest driver, Espresso Driver, etc) are tightly coupled with Appium Server but from Appium 2.0 these drivers are separated from Appium Server and can be installed separately based on users’ needs. Creating custom drivers for any new platform or special use cases are going to be easy from Appium 2.0.

For example, in the future, we might have an Appium Wear driver to automate WearOS Apps or an Appium KaiOS driver to automate smart feature apps in kaiOS.

To list all the available drivers in appium, enter the following command:

appium driver list✔ Listing available drivers- uiautomator2 [not installed]- xcuitest [not installed]- youiengine [not installed]- windows [not installed]- mac [not installed]- mac2 [not installed]- espresso [not installed]- tizen [not installed]- flutter [not installed]- safari [not installed]- gecko [not installed]

To install a driver for say uiautomator2 driver, Appium now has subcommands to install, update, etc

appium driver install uiautomator2
Attempting to find and install driver 'uiautomator2'
✔ Installing 'uiautomator2' using NPM install spec 'appium-uiautomator2-driver'Driver uiautomator2@1.61.2 successfully installed- automationName: UiAutomator2- platformNames: ["Android"]

To view the list of installed appium drivers, type the following command:

appium driver list --installed✔ Listing installed drivers- uiautomator2@1.61.2 [installed (NPM)]

There are many other options offered by the Drivers CLI to install drivers from a specific source, update all the installed drivers, etc. This simplifies the overall installation process and users have the flexibility to choose to upgrade drivers without updating the server itself.

Appium plugins will be here to help with the various use cases that require a change to Appium’s default behavior. These changes provide users an opportunity to build new plugins in the future, for example, Jonathan Lipps is currently working on a driver for Roku smart TV!

The Appium team continues to maintain some plugins which can be found here.

Plugins help add arbitrary functionality before or after actual Appium commands. Also, the plugin can modify the Appium Server itself to introduce new commands and distribute them. For example, the current “image” plugin from Appium helps find an element by an image and also helps in image comparison too.

To list all available Appium Plugins:

appium plugin list✔ Listing available plugins- images [not installed]

To install an Appium plugin, use this command and replace “images” with the name of the plugin you’d like to install:

appium plugin install images

To activate a plugin when starting the Appium server, use the following command (replace “images” with the name of the plugin you’d like to activate):

appium server -ka 800 --plugins=images -pa /wd/hub[Appium] Welcome to Appium v2.0.0-beta.10[Appium] Non-default server args:[Appium] plugins: {[Appium] 0: images[Appium] }[Appium] basePath: /wd/hub[Appium] keepAliveTimeout: 800[Appium] tmpDir: /var/folders/f5/fwh8w_ms6q377gn_fb2bmjp40000gp/T[Appium] Appium REST http interface listener started on 0.0.0.0:4723[Appium] Available drivers:[Appium] - uiautomator2@1.61.2 (automationName 'UiAutomator2')[Appium] - xcuitest@3.36.0 (automationName 'XCUITest')[Appium] Available plugins:[Appium] - images@1.1.2 (ACTIVE)

No code changes are required at this time in the client script to execute using the latest Appium server.

The minimum node version required for the Appium server to run is node 12.

A lot of new plugins are expected to come soon. The ability to easily create new drivers and plugins in Appium 2.0 will help solve many interesting use cases and problems that were hard to solve before. Watch this space as we share more details related to the same as it happens.

Credits to Jonathan Lipps, Mykola Mokhnach, kazucocoa, and other contributors for their wonderful contributions to the Appium community.

Originally published at https://applitools.com on February 9, 2021.

Deliver visually perfect web and mobile apps with AI-powered end-to-end visual testing & monitoring. Get started, free: http://bit.ly/ApplitoolsFree