Troubleshooting Exceptions on Mobile - (Recommended: KS 7.x + Appium 1.15.1)

Mobile Testing Exception Troubleshooting Tips

Here are some common troubleshooting steps to take when you encounter errors trying to spy, record, or execute a mobile test in Katalon Studio:

If you see one of the following exceptions, you should check your Appium installation:

  • Execution Exception
  • NullPointerException
  • java.util.HashMap cannot be cast to org.openqa.selenium.WebElement
  • Unable to parse remote response
  • Support for xcode 0.1 is not supported. please upgrade to version 7.3 or higher
  • The instrumentation process cannot be initialized

For Android testing:

For best compatibility, it is recommended that you install Appium Server 1.15.1. Please note that this is NOT the same as Appium Desktop.

To install Appium Server from the command line, using npm:

npm install -g appium@1.15.1

For iOS testing:

If you are building with Xcode 10/11 and/or testing on iOS 12/13 devices, it is recommended that you install Appium Server 1.15.1. _Please note that this is NOT the same as Appium Desktop.

To install Appium Server from the command line, using npm:

npm install -g appium@1.15.1

SWTException or Web Driver Exception

This can often be seen on Android tests on login, credit card, or other sensitive data screens. Android allows developers to mark these screens as “secure” so that screenshots cannot be taken. This interferes with Katalon Studio’s Mobile Spy and Test Recorder previews, since they rely on screenshots.

Luckily, even after getting this error, you can still capture and export Test Objects on these screens as you normally would, you just won’t see a preview of the screen while you’re doing it.

Could not proxy command to remote server. Original error: Error connect ECONNREFUSED 127.0.0.1:54339

Clearing Appium Processes

Sometimes there are rogue appium processes that don’t exit when there are Katalon errors. These can interview with new tests and causes them to be unresponsive. To try to clear these out, the most straightforward way is to quit Katalon, close the simulators, and restart your computer.

Alternatively, you can check to see if there are running appium processes in the Terminal using ps -ef | grep appium. You might see something like this:

  501 48742     1   0 Fri02PM ??         0:04.12 /usr/local/Cellar/node/9.11.1/bin/node /Users/chris/.nvm/versions/node/v9.2.0/lib/node_modules/appium/build/lib/main.js --tmp /var/folders/90/26pjk1q50wd9xfn9q3q6tkyc0000gn/T//Katalon/Appium/Temp1551470186488 -p 55334 --chromedriver-port 55335 --log-level info --webkit-debug-proxy-port 0
  501 60974     1   0 Sat11PM ??         0:40.81 /usr/local/Cellar/node/9.11.1/bin/node /Users/chris/.nvm/versions/node/v9.2.0/lib/node_modules/appium/build/lib/main.js --tmp /var/folders/90/26pjk1q50wd9xfn9q3q6tkyc0000gn/T//Katalon/Appium/Temp1551587426507 -p 51192 --chromedriver-port 51193 --log-level info --webkit-debug-proxy-port 0

In these cases, the 2nd column is the process id, e.g. 48742 and 60974. To kill those processes, you can use kill <processid> in the Terminal where <processid> is the id from the listing. If they don’t seem to close, you can be more forceful with kill -9 <processid>.

Try re-running your tests after the processes have been cleared up.

No mobile device with name <device_name> available

This can often be caused by not calling the MobileBuiltInKeywords.startApplication() function at the beginning of a test or calling the function with a non-existent app file.

“Unable to start application…”

There might be a mismatch between the package name and the activity name in your settings.

There are some Appium DesiredCapabilities you can set that might help you get around this. In your Project->Settings menu, go to Execution->Default->Mobile->Android.

Add new entries for appWaitActivity and appWaitDuration. Here’s a description of what those activities mean: Desired Capabilities - Appium

When done, it should look something like this:

Name              Type   Value
appWaitActivity   String   *
appWaitDuration   Number   30000

Fail to start Appium server in 60 seconds

This can be caused by Katalon Studio not being able to find the Appium modules under the currently selected version of Node. It can happen when there is a system version of Node installed, but there are also versions of Node installed via Node Version Manager (nvm). The location of Node is not configurable in Katalon Studio, so this can lead to confusion.

To get the node executable to point to your selected version of node on MacOS, you can use symbolic linking:

First you’ll need to remove the system’s current node executable:

rm /usr/local/bin/node

Then create a link to your desired version of Node:

ln -s <YOUR_NODE_LOCATION> /usr/local/bin/node

Real iOS Devices Not Showing in Device List

One of the first things you can do is see if the device is recognized by command line tools outside of Xcode:

idevice_id -l

If that does show your device, then it could be that you don’t have permissions to run some of the other command line tools that Katalon (and Appium behind the scenes) require. You can reinstall those tools with:

brew uninstall ideviceinstallerbrew 
brew uninstall libimobiledevice 
brew uninstall libplist
brew uninstall usbmuxd
brew uninstall ios-webkit-debug-proxy

brew install --HEAD usbmuxd
brew link --overwrite usbmuxd

brew install --HEAD libplist
brew link --overwrite libplist

brew install --HEAD libimobiledevice
brew link --overwrite libimobiledevice

brew install --HEAD  ideviceinstaller
brew link --overwrite ideviceinstaller

brew install --HEAD ios-webkit-debug-proxy
brew link --overwrite ios-webkit-debug-proxy

sudo chmod -R 777 /var/db/lockdown/
10 Likes

Nice move @Chris_Trevarthen

I feel bad for seeing you regularly recommending users to install Appium 1.8.1.

Now you can just bookmark this and quote it. :rofl:

Regards !

3 Likes

Hello @Chris_Trevarthen

what is the reason of appium 1.8.1, is because of limitations of katalon or limitations of appium with respect to katalon’s capabilities?

1 Like

Hi @osss.lcc,

I’m not a Katalon nor Appium developer, but from what I can tell, when Appium when to version 1.9.x, it changed some of the libraries that Katalon came to rely on for interfacing with simulators and devices. Around the same time, there were new versions of Xcode, which complicated things as well.

With the beta release of Katalon Studio 6.2, it looks like the Katalon team is working to support Appium 1.12.1, and hopefully future Appium versions won’t affect the functionality of Katalon Studio as much.

Hope this helps,

Chris

3 Likes

Hello Chris

I have installed the right versions of Katalon and Appium and still i can see the java.lang.NullPointerException error. Please suggest if there is anything more i should do. or if the apk file is corrupt. But looks like its a compatibility issue.

Katalon studios- 6.1.4
Appium- 1.8,.1

Thanks,
Ini

1 Like

To follow up, putting a link to ini’s solution they found and posted in another thread:

2 Likes

Hello, thanks for the report concerning the troubleshooting exceptions.
So if i understand good, Android and iOS don’t use the same version of Appium (1.8.1 vs 1.8.2-beta).
I execute tests on both system from a MAC OS. Is it possible to have two versions of Appium on the same MAC? Or i need uninstall and reinstall Appium each time i want execute my tests on iOS and Android?

Thank you for your help,
Best regards,
François

1 Like

Hi @douilly.francois,

You can indeed use the same version of Appium Server for Android and iOS. The reason that there are 2 versions listed are that Xcode10.x and iOS12.x require Appium 1.8.2-beta in order to work, but Android does not have that restriction. So, if you were only running Android tests, it might not be worth going to with an Appium beta, and you can use 1.8.1 instead. However, 1.8.2-beta will work with both Android and iOS.

Hope this helps, and sorry for the confusion,

Chris

1 Like

Thank you for your fast answer Chris, your messages help me a lot.
Exact for me i need 1.8.2-beta for my tests on iOS12, no choice.
I use Katalon 5.10.1 and I just try the katalon spy on Android 7.0, it works.
I had the web driver exception and i dont see the preview, but as you reported i work on a bank application and i can see the objects tree yet :slight_smile:

2 Likes

Hello mr. @Chris_Trevarthen Katalon 7.9.1 how much appium use ?
now using windows 10

1 Like

Hi
i am facing a serious issue while play my recorder android test cases.
need your immediate help.

problem is suppose today i recorded a test case with some functionality with a particular apk than after a day or month it does not play that recording (test cases).

please help

1 Like