Using Appium 2 with Katalon Studio

Appium has now officially released version 2 but it is not fully supported inside Katalon Studio yet (there is a proof of concept version that works for somethings but has a few bugs too. Here is a link to that version https://docs.katalon.com/docs/proof-of-concept/execute-mobile-tests-with-appium-2.x-in-katalon-studio-poc).

My team has been using appium 2 for a while as we have needed the updated support for xcode 14 and I will share the necessary steps for getting Appium 2.0 to work inside Katalon Studio including using the remote execution function and launching the appium server manually. This may not be the best solution for everyone but my team has been using this method since the beginning of the year. The appium server can be launched in your terminal by running:
appium

First step is to make sure you have the correct version of appium installed and the correct drivers. Katalon has already posted a blog on how to do this so I will refer to it A Full Guide To Testing With Appium 2.0.

Next you will need to update the desired capabilities to match which type of execution you wish to do iOS/Android. Instead of updating the Mobile capabilities you will be putting these capabilities in the Remote section (Project Settings → Desired Capabilities → Remote). You will need to update a few more sections than you usually do for mobile capabilities including server URL, server type and Appium Driver. The other difference is that for any appium capabilites you will need to preface the capability with appium: Here is an example of my desired capabilities for an iOS app project and an Android one.

The next thing that should be noted is that the Mobile.startExistingApplication() command will not work on appium 2. My team uses testflight builds and apptester builds to do our automated tests so we needed a way to launch apps that are already installed on the device. On iOS you can just use the startApplication command but instead of using appFile as the first parameter just use a string of the bundle identifier with the second parameter set to false. This will essentially do the same thing.

Mobile.startApplication('bundle-id', false) // will launch app on device and not uninstall after

On android this is a little trickier as neither the startApplication or startExistingApplication commands will work. Instead I needed to read in the desired capabilities and start the application by using the RunConfiguration.getDriverPreferencesProperties and the AppiumDriverManager.createMobileDriver command. In code this looks like:

DesiredCapabilities capabilities = new DesiredCapabilities()
Map caps = RunConfiguration.getDriverPreferencesProperties("Remote")
caps.each{ key, value -> println " ${key}:${value}" }
AppiumDriverManager.createMobileDriver(MobileDriverType.ANDROID_DRIVER, capabilities, new URL("http://localhost:4723"))

Replacing a single command with these commands isn’t great but in practice you can add this into a test listener and then add the command driver = MobileDriverFactory.getDriver() into each test.

Using the object spy or object recorder will also be a little different. For both iOS and Android you will use the remote option in the Mobile object spy and mobile recorder dropdowns. On iOS you will just make sure that the desired capabilities are set correctly and then put in the bundle id in the Cloud Application ID option. For android you will have to actually give it a path to an apk. It does not need to be the apk you plan on testing with (and I would recommend just placing a demo apk in a path you can remember). The app that will be launched for android should be set by the appium:appPackage desired capability.

With these changes you should be able to use appium 2 inside of Katalon Studio with both iOS and Android projects. Eventually I expect that Katalon will put out an update that fully supports appium 2 but until then this method should work. Hopefully this can help some users hoping to use appium 2.

The last caveat is that when you run your tests Katalon Studio will not ask you which device you wish to run the tests on like it would for normal android and iOS execution and instead the desired capabilities will need to be set for the device you are running on. I have created custom keywords for this that will check available devices and update the udid on iOS or the deviceName/platformVersion using RunConfiguration.

6 Likes

Hi,

Thank you for such a detail tip

@kreno Thanks for sharing

1 Like

Hi folks, :wave:

We are delighted to inform you that Katalon Studio version 9.1.0 has just been released which also brings support for Appium 2.x. You can learn more in our announcement topic below: :point_down:

Should you encounter any bug whilst using KS 9.1.0, or have any other questions, feel free to create a topic in Bugs Report or Katalon Studio

Thanks, :sunglasses:
Albert from Katalon Community team