Challenges Using Appium for Mobile App Testing

0.00 avg. rating (0% score) - 0 votes

Mobile automation poses different types of challenges in comparison to the automation of Web browsers. New tool sets are making it easier and easier to engage in genuine agile development on Mobile. In particular, true test-driven development—which was formerly a hard, upstream slog on Mobile—is becoming increasingly attainable.

2 years back, At Naukri we used to test the Mobile Applications manually. With the increase in technology and functionality in mobile apps we were facing many challenges while doing manual testing like:

  1. There is huge fragmentation of both devices and mobile operating system versions, which makes it difficult to do manual comprehensive testing across all of the versions for all of the devices.
  1. It is difficult for a manual tester to hold a device and keep testing an app for around 6-7 hours, as well as do this for different devices.

So the best possible solution seems to be automation testing where devices and mobile OS can be configured dynamically. The tool we are using since 2 years for automating mobile apps in Naukri is Appium. It is the most widely used open source tool to automate mobile apps, Android and iOS, and works on the philosophy of Webdriver’s HTTP JSON Wire Protocol client server architecture. Now, instead of doing repeated manual testing during mobile releases, we run our automation suite through Appium which executes all the functional test cases of the app and gives us enough confidence in the release build. Thus saving us from doing monotonous work manually.

Before going further, let’s throw some light on why we have chosen Appium as the automation tool for mobile app testing:

  • Support for both platforms iOS and android.
  • You can write and run your tests using any language or test framework.
  • It allows you to write tests against multiple mobile platforms using the same API.
  • It is an open-source tool that you can easily contribute to.
  • Doesn’t require access to your source code or library. You are testing with which you will actually ship.
  • Able to run on selenium grid.
  • Selenium Webdriver compatible.

In this blog, we will be exploring a few interesting challenges and their solutions that we faced while doing Mobile App automation using Appium.

How difficult is it to set up a working environment?

The assumption is that Appium comes with a not-so-tiny documentation, so users are not really left alone. However it is not so straightforward to set up Appium to work on a Windows or Mac machine. We can install the command-line application as well as GUI for getting the locators & helps in debugging. Also beware [sudo], as Appium will surely bite you back late in time if you installed it as a [superuser]. The sudo Terminal command can be used by administrators to execute commands as a different user (for example, as root). When executing this command, you will be prompted to enter the password for the administrator account you are currently logged in as.

Now Let’s discuss some of the challenges that we faced at Naukri while automating the mobile app (Android or iOS) and the approach we followed to solve them.

Challenge 1: <iOS only> INSTRUMENTS CRASHED ON STARTUP: The most familiar error that every one of you must have faced is this.

Challenge 1

Appium is not able to launch the application. This behavior happens both on simulator and real device.

Solution:

If you are using iOS Simulator, do the following…

In Appium, go to Developer Settings, Check Custom Server Flags and write –native-instruments-lib in the text box. Now start Appium Server.

If you are using device: you need to enable UI automation in developer option in your iPhone device

How to enable UI Automation ==> Switch off the iDevice ==> Connect it to the Mac running Xcode ==> Switch it back on to have Developer options appear under device Settings ==> Tap on developer option and Enable UI automation.

UIMovie

Challenge 2: Could not start a new session. Possible error could be browser start up failure—–

Solution:

1. Check that the port number that you are giving in Appium app and in capabilities. Port should be same while starting Appium (through app/commandline) & the port given while initializing driver.

Port Number

driver = new IOSDriver(new URL(“http://127.0.0.1:4444/wd/hub”), capabilities);

2. Set correct capabilities-

For iOS:

Capability for iOS

For Android:

Capability for Android

Challenge 3: BAD APP- error: Failed to start an Appium session, err was: Error: Bad app:”

Solution: This error is due to the app path which is specified incorrectly either in your project while running through ant or in Appium app while running through appium app.

Specify the correct app path in your project and restart the appium OR

In Appium app, enter the correct app path under android settings or iOS settings whichever platform you are using.

Challenge 4:<iOS Only> Multiple dead elements created at background by appium.

Solution: Using size of the element and finding the last element solves this problem.

For example: To click on an Apply button from hamburger menu, we use this code:

List<WebElement> appliedJobsList = driver.findElements(this.ApplyHistoryAlternateButton_Btn);

appliedJobsList.get(appliedJobsList.size()-1).click();

Challenge 5: Scrolling issue.

Solution: Appium is not able to find elements that are not visible on screen. Naukri team created generic method to scroll through the screen and find element and also “ScrollToExact()” method provided by Java to scroll to exact location.

ScrollToExact

Challenge 6:<iOS only> App is not installed on device. Will try installing app. And then installation failed.

This challenge is faced in iOS device while running test case, Appium is neither able to install the app in the device nor launch the pre-existing app.

Solution: Due to a security fix in a dependency of ideviceinstaller, it is installed without sudo and with the ElCapitan OS; the ideviceinstaller has to be installed through appium.

Open terminal and run the following command:

  • sudo chmod -R 777 /var/db/lockdown/

Challenge 7: <iOS only> Could not initialize ideviceinstaller, make sure it is installed and works on your system).

Solution: Run these 3 commands to solve the issue:

  • cd /usr/local/Library
  • brew update
  • brew install ideviceinstaller

These are some of the issues that we faced while doing automation of Naukri mobile apps using Appium and found solutions that are now regressively used. Referring to a document having solutions to all the issues surely minimize the effort of searching the solutions to same issue repeatedly.

Hope listing of the issues that we faced while automating Mobile Apps with their solutions might help you.

Reply back for any queries regarding the solutions or any other challenges that you might be facing using appium. We will surely try to help.

Happy Automation!!!