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:
- 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.
- 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.
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—–
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.
driver = new IOSDriver(new URL(“http://127.0.0.1:4444/wd/hub”), capabilities);
2. Set correct capabilities-
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.
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/
Solution: Run these 3 commands to solve the issue:
- cd /usr/local/Library
- brew update
- brew install ideviceinstaller
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.
Learn more on the differences and advantages of each framework on upcoming webinar where we are going to compare Appium vs Espresso: CLICK HERE TO REGISTER