Saturday 18 July 2020

Hybrid App Automation using Appium

In the Mobile world, we see multiple types of apps namely Native App, Hybrid App & the browser based application, Web App. Also, we see multiple types of operating systems like Android, iOS, Windows, Firefox OS etc.

Automated testing of these many variation of apps, is very tricky & difficult task. Not all of them are supported by single automation tool. Having said that, Appium which is built over Selenium webdriver supports most of the OS & apps with various configurations.

In this article, you would know a way to automate the Hybrid App using AndroidDriver.

Prerequisites:

  1. Android SDK is downloaded and installed. (ANDROID_HOME env. variable should be set)
  2. Either Emulator or  Real device (USB debugging enabled) is available.
  3. Appium desktop app or non GUI package is installed. 

Steps:

  1. Create a java project in eclipse 'AppiumMobileTesting'.
  2. Create a class 'TestHybridApp.java'.
  3. Connect your device(USB debugging enabled), to system's USB port & accept if any confirmation pop ups.
  4. Start Appium Server. Once the device is connected, open the 'Appium Inspector Session' providing the suitable capabilities.
  5. Open the Hybrid app in the device and you see the same screen on inspector session.
  6. Click on the required control in inspector session & then the related locator details are shown on the right hand side in appium inspector.

Friday 6 March 2020

How to query or filter Json using RestAssured JsonPath


REST Assured(RA) is a framework built on Java to test the REST services. It supports any HTTP method but has explicit support for GET, POST, PUT, DELETE, HEAD, OPTIONS, PATCH and includes specifying & validating like Headers, Cookies etc.

For validating and querying the Webservice responses, it has couple of libraries 'JsonPath' and 'XMLPath' for parsing Json and XML responses accordingly.

Even-though we know that, we have to use these libraries but most of the times we get into situations where we forget or we are not sure of the actual syntax. Here are list of few scenarios and it's JsonPath syntax (XMLPath syntax are almost similar) for your reference.

All the Jsonpath examples in this post, use the following Json:

 
{
   "store":{
      "book":[
         {
            "category":"reference",
            "author":"Nigel Rees",
            "title":"Sayings of the Century",
            "price":8.95
         },
         {
            "category":"fiction",
            "author":"Evelyn Waugh",
            "title":"Sword of Honour",
            "price":12.99
         },
         {
            "category":"horror",
            "author":"Herman Melville",
            "title":"Moby Dick",
            "isbn":"0-553-21311-3",
            "price":8.99
         },
         {
            "category":"fiction",
            "author":"J. R. R. Tolkien",
            "title":"The Lord of the Rings",
            "isbn":"0-395-19395-8",
            "price":22.99
         }
      ],
      "bicycle":{
         "color":"red",
         "price":19.95
      }
   },
   "city":"Bangalore"
}



Following examples let you know,how to effectively use the JsonPath to extract the required values from the RESTful json in different scenarios: