Mobile applications, today, are undeniably an integral part of people’s lives. In fact, mobile applications change the way businesses work. New applications are being created to cater to all segments of the society. There are numerous platforms and framework to build mobile applications. It is essential to deliver a high quality product to achieve the desired business goals.
Most of the leading mobile OS platforms provide a development kit for mobile application development, using native coding languages. Cross platform development is, also, very familiar which reduces the development cost and deploys the application in different platforms.
Testing of mobile applications has become pretty much important. Both manual testing and automation testing play a significant role to achieve the quality. Hence, it becomes imperative to have a robust automation framework that can help automate application on any platform.
This article explains the step-by-step approach about how automation testing is performed for Oracle MAF application using Appium tool.
Oracle Mobile Application Framework (MAF)
Appium – Open Source Mobile Automation Tool
Appium is an open source tool that can be used to automate your mobile applications. Similar to Selenium WebDriver which is an open source tool used to automate web browsers, Appium is an automation library used to drive your mobile applications, and even the web browser within the mobile simulator, emulator or real device. It allows you to write tests against multiple mobile platforms using the same API.
Getting Started with Appium Tool
Launching MAF App using Appium
Before starting your test, ensure that you have set up all the Appium prerequisites in your machine.
- JDK (Java Development Kit)
- Selenium Server JAR
- Webdriver Language Binding Library
- Appium for Mac
- Install and set up Appium client on your Mac machine. Select your desired MAF Application and copy into your system. Make sure that this is an ‘.app’ file because you are running on iOS simulator.
- Start your Appium client and choose your ‘.app file path by clicking in ‘iOS Settings’ icon from Appium client. You can choose the application by:
- Clicking on ‘Choose’ button and navigate to ‘.app file location.
- Copying and pasting your ‘.app file path from your clipboard.
- Click on settings button and mark the ‘Prelaunch the application’ option
- Then, click on Launch button. Appium launch your MAF application in iOS simulator. For the first time it takes some time to launch the application. Check your Appium log for the status. Sometimes, you may need to relaunch the application, if the app is not launched in the first attempt.
Recording Test Scripts using Appium Inspector
Appium has an ‘Inspector‘ to record and playback the test scripts. It records and plays application behavior by inspecting DOM and generates the test scripts in any desired language. However, currently there is no support for Appium Inspector for Microsoft Windows. In Windows, it launches the Appium Server but fails to inspect elements.
Start with Appium Inspector on Mac Machine
After successful launch of your MAF application in simulator, you can inspect and identify all the elements using the inspector. Appium must be running with an app, open for inspector to work. Otherwise, it will not work.
- Click on magnifying glass icon to launch the Appium inspector.
- Appium Inspector window will open with your app preview on right window.
- Launching your Appium Inspector will show the element hierarchy in column-wise structure. Also, user can apply actions using buttons like Tap, Swipe etc.
- Use Record button to begin the building of your tests.
- Select the language you want to generate the tests from the lower window of Appium Inspector.
- Tap on element you want to execute and choose action steps to generate the tests. You can see the red out line for the fields which is selected.
- Test code that is generated by Appium will appear at the bottom of the screen. This will get updated based on the test performed on Appium Inspector.
A code generated for sending a text in a Username UI Text field looks as follows:
Once you are done, copy and paste the code in to your class to run the test scripts.
Before you execute the recorded tests, ensure that all capabilities are set in your configuration file to start the test in simulator or a real device.
A sample Appium configuration class is given below:
Then, create your test class and use test scripts recorded from Appium Inspector. The UI element may not be identifying while executing the scripts. So, convert the UI element as mobile elements and execute the same.
Sample Test Scripts for Few Scenarios
- Login to the application with username and password field. The below sample code is used to login to the application with username and password field.
2. Select an option from check box.
Oracle MAF is a powerful tool to develop the hybrid application and deploy on both iOS and Android platforms. Manual testing on multiple platforms can be an arduous task for both developers and end-users. Appium helps to develop robust and extensible frameworks. It supports test automation on diverse set of native and hybrid application across different platforms.
Sr. Test Engineer, RapidValue Solutions