Breaking Changes in Appium 2.0Multiple breaking changes were introduced in Appium 2.0, lets check out all the changes one by one and also learn how to handle them.
Protocol ChangesAppium 1.x supported “MJSONWP” (Mobile JSON Wire Protocol) and as Appium’s API is based on W3C protocol, it has supported this protocol as well for years. However, going further with Appium 2.x only W3C protocol will be supported and support for older protocol’s will be removed.
Appium Server Base PathThe default server path set in Appium 1.x was `https://localhost:4723/wd/hub`, and the Appium server used to accept different Appium commands on the said URL. In this URL, `/wd/hub` was hardcoded in the path and it was not configurable. With Appium 2.x, the default Appium server base path is `/`. However, if we still want to keep using the old behavior, we can configure the base path by providing the following argument while starting the server – `appium –base-path=/wd/hub`.
Appium Drivers Separated from Appium ServerIn Appium 1.x, when Appium was installed using the Appium command line tool, all the available drivers supported by Appium were installed with it. There was no option to download only the respective driver needed as per the user’s requirement. With Appium 2.x, this has changed. All the Appium drivers are decoupled from the Appium server and all the Appium drivers are now not installed with Appium Server. We can download only the respective Appium driver needed. The following command can be used to install latest version of uiautomator2 driver – `appium driver install uiautomator2` Similarly we can install other Appium drivers like xcuitest, gecko, etc. Appium drivers with specific versions can also be downloaded explicitly, for doing so, the following command can be used. For example, to download XCUITest driver with 4.32.20 version run – `appium driver install firstname.lastname@example.org` It is highly recommended to uninstall all the previous installations of Appium 1.x by using the following command – `appium uninstall -g appium`
Appium Driver Installation PathIn Appium 1.x, when Appium was installed using command line tool, all the Appium drivers used to get installed in the `node_modules` folder in the following path – /path/to/appium/node_modules In Appium 2.x, the default driver installation path has changed and now it gets installed in `APPIUM_HOME` environment variable for which the default path set is `~/.appium` So, when an Appium driver is installed, by default it gets saved to the following path – `$APPIUM_HOME/node_modules/<driver name>`
Appium Driver UpdatesIn Appium 1.x, as the Appium drivers were tightly coupled with Appium Server, the driver updates were rolled only when the Appium Server’s latest version was released. There was no option available to update the Appium drivers separately. With Appium 2.x, the Appium drivers are separated from Appium Server, and are versioned and released separately. We now get the driver updates as and when they happen and we don’t have to wait for Appium Server release to update the drivers. The driver updates can be checked using the following command – `appium driver updates –list` The following command can be used to update the drivers, (here, we are updating uiautomator2 driver)- `appium driver update uiautomator2` In case, if we need to install the specific driver version, we will need to uninstall the existing driver and then re-install the driver with the specific version by running the following commands one by one.
- Uninstalling a driver
- Re-installing driver with specific version
Appium Driver Command line OptionsWith Appium 1.x, Appium server hosted all the command-line options specific to a particular driver. For example, the CLI parameter `–chromedriver-executable` was used with Appium to set the specific location of a chromedriver version, say, with driver uiautomator2. With Appium 2.x, all these command-line options have been moved to the respective Appium Drivers. To set the CLI parameter `–webdriveragent-port` for XCUITest driver, the following command should be used – `appium –driver-xcuitest-webdriveragent-port=5000` Also some driver commands have been completely removed and have been moved to the Appium capabilities. For example, the CLI parameter `–chromedriver-executable` can be set using Appium Capabilities as follows –
- Using Command Line –
- Using Desired Capabilities –
Appium Driver Automation CommandsWith Appium 1.x, when running any Appium command that was not implemented by the corresponding driver, it would throw a `501 Not Yet Implemented` error. With Appium 2.x, this error has been replaced with `404 Not Found`.
Chrome Driver Installation FlagsWith Appium 1.x, the following command line flags helped in customizing the way Chromedriver was installed while installing Appium Server –
Capabilities UpdateWith Appium 1.x, vendor prefix was not required to be updated in the Desired Capabilities of Appium. With Appium 2.x, the vendor prefix is required for all the capabilities except the `browsername` and `platformname` capabilities. The vendor prefix is the name of the vendor in string format followed by a colon (:), for example, “appium:<capability name>”. In the Appium Inspector’s latest version and also in the Appium client bindings in different programming languages, this approach to add the vendor prefix is handled automatically in the respective capability name.
Image Analysis feature moved to PluginAppium 1.x had features like image comparison, finding elements by image,etc. It is now moved to a plugin called images. Images plugin can be installed using the following command – `appium plugin install images` To use the plugin, we need to pass on the –use-plugin argument while starting the Appium Server – `appium –use-plugins=images`
Execute-driver command moved to PluginAppium 1.x had the execute-driver script command. In Appium 2.x it is now moved to a separate plugin called execute-driver. execute-driver plugin can be installed using the following command – `appium plugin install execute-driver` To use the plugin, we need to pass on the –use-plugin argument while starting the Appium Server – `appium –use-plugins=execute-driver`
External files no longer supported for –node-config, –default-capabilities, –allow-insecure, –deny-insecureThe support for providing external files is not longer provided for the following flags in Appium 2.x –
Removed Old DriversOld Appium drivers for iOS and Android, like `uiautomator1` and also the related tool like `authorize-ios` which were not relevant for many years in Appium 1.x have been removed in Appium 2.x
Removed support for starting Appium Server on port zero (–port-0)In Appium 1.x, while starting Appium Server if port 0 was used, it would start the server on any random free port. In Appium 2.x, it is not allowed to start Appium Server on port 0, it is required to specify the port values greater than 1. It is a correct practice moving forward to start the Appium Server on an explicit and known port.
Renamed Internal packagesSome internal Appium npm packages have been renamed. For example, `appium-base-driver` is now @appium/base-driver. Another example is appium-doctor, it is now renamed as @appium/doctor. This is not a breaking change for the Appium users, however those who maintain code that directly works with Appium, will be impacted.
Appium Desktop deprecatedWith Appium 1.x, the Appium Desktop application was used as a GUI application to start Appium Server and it had Appium Inspector inbuilt that helped to locate the mobile elements. With Appium 2.x, Appium Desktop has been deprecated and Appium Inspector has been moved to its own App. Appium Inspector also has the web version of the application which is available at https://inspector.appiumpro.com. However, to use this browser version with local Appium Server, the Server should be started with the flag –allow-cors.
Major New FeaturesThe following major new features have also been introduced in Appium 2.x –
Server PluginsWith Appium 2.x, it is now possible to build a Server Plugin. Plugins help in intercepting and modifying Appium behavior as required. Once built, plugins can be installed, updated and used with Appium server and can be uninstalled as well.
DriversAs the drivers have been decoupled from Appium Server. Appium Drivers can be installed, updated and uninstalled. Appium 2.x also provides the feasibility to build a custom driver as well.
Configuration FileWith Appium 2.x, all the arguments that Appium 1.x required to be provided in the CLI are now able to be passed using a configuration file. Configuration file can be in the following formats –