Advanced Usage of SeeTest Automation On Real-time Mobile Automation Project

Advanced Usage Of SeeTest Automation:

In our previous tutorial, we discussed more on the widely used SeeTest commands and some advanced commands to perform complex actions on the mobile app and to control device level actions etc.

This is the last tutorial in our 4-part SeeTest Automation Tutorial Series.

While working with the automation of complex mobile apps, we may face situations where the Object is not being identified or not having a unique property to identify the elements, automation of hybrid mobile apps that contain Native and Web elements in a single view, execution of the same test script in multiple devices at the same time (parallel execution) etc.

Here, in this tutorial, we will discuss how SeeTest Automation can be used for a real-time Mobile Automation project to automate some production value of mobile apps.

Advanced usage of SeeTest Automation

Image Recognition & Object Repository

As mentioned earlier, SeeTest Automation supports Image & Text recognition to identify the elements apart from Native and Web recognition methods. This is an important feature as this can help to identify the elements that do not have any Native or Web unique property.

When Native or Web recognition fails, we go for Image recognition. In order to use the Image Recognition feature, we need to extract the image from the Object and store it in a place for using the same. SeeTest Automation refers to this repository as Object Repository.

There are various ways to extract and add an image to the Object Repository, but the best option is to add it from the ‘Debug’ tab of the SeeTest command window.

Figure 1 Debug window


In order to go into the Debug mode, select the Debug tab displayed next to the Test tab in the command window. There you can see some scenes captured during the object spy. If you want to capture a current scene, click on the first icon displayed in the toolbar.

When we hover over any element, the information regarding its x and y coordinate and the color will be displayed in the bottom bar.

In the above figure, if we need to identify the EriBank logo by its image, then we need to extract the image and add to the object repository.

In order to extract the image, follow the below steps:

  • Click on the logo to select it.
  • Do a right click and choose Extract Image.
  • Select Create New Object in the displayed popup and click OK.

Figure 2 Add Image

Add image

  • Provide the name of the object as Logo.
  • Make sure no checkboxes are selected under Native and Web tabs.
  • Select Image tab and click on Edit.
  • Select 1:1 as display ratio and draw a rectangle on the logo alone. This will neglect the other parts of the image while searching for the logo.

Figure 3 Edit Image

Edit Image

  • Click on OK.
  • Now the logo will be highlighted with a red rectangle. This means SeeTest Automation will search for the highlighted portion while trying to recognize the logo.

Figure 4 Edited image

Edited image

  • Choose Advance Similarity from the Scanning Type drop-down and make Sensitivity between 90-100%.
  • Now click on Test to check whether SeeTest Automation identifies the image or not.
  • If the test is successful, you can add a command in the command window to check for the presence of this image via IsElementFound command by setting Zone as ‘default’ and Element as ‘Logo’.

Figure 5 Check for image

Check for image

After the execution of commands from the command window, SeeTest Automation will launch a test report by default. The test report after executing the command shown in the above figure will look like the below figure.

Figure 6 SeeTest report

SeeTest Report

On navigating to the step in which the test for the logo is performed, the report will show which element it is recognized after searching for the logo image. From the above report, it correctly identified the logo.

You can disable Auto report launch if you find it annoying by navigating to the Tools menu and then uncheck the Launch Report.

Figure 7 Disable auto report launch

Disable report launching

If SeeTest still does not identify the object, we can modify the object to include Native/Web properties of the container that contains the image into the object by following some steps.

Those steps include:

  • Go to the Debug tab.
  • Click on the EriBank Logo image to select it.
  • Right-click on the selected Logo image to view the available actions.
  • Choose ‘Show Properties’ from the context menu displayed. This will open the Object Properties window that we may get during Object Spy.

Figure 8 Object properties

Object properties

  • From Object Properties, the Native/Web element in which the Logo is displayed will be selected by default.
  • Check the properties list and identify the unique property. If the property does not uniquely identify the image container, SeeTest will search for all the image containers for the Logo image. If the property uniquely identifies the container that displays the Logo, then we can minimize the search as SeeTest may look into that particular container only for the image.
  • After finding the property and its value for the image container, copy it and click the Close button.
  • When we look into the Logo object in the Object Repository, we can see that the Image icon is enabled and remaining icons are disabled. This means that the Object only contains an image and not Native/Web properties, Texts etc.

Figure 9 Object repository

Object repository

  • Double click on the Logo object in the Object Repository to edit the Object. This will open up the Edit Object window.
  • In the Native tab, check Enable Android checkbox and choose the unique property name from the drop-down and its value in the corresponding text box.

Figure 10 Edit Object

Edit Object

  • Click on OK.
  • Now the Object will have Native property as well along with the Image and the Object Repository will reflect the same by enabling the Native property icon for the Logo object.

Figure 11 Object Repository – Native & Image properties for the Logo object

Object repository - Native & Image

  • If you perform IsElementFound, the search will be quicker and the possibility to find the element will be more.

Mobile Web Automation Testing

Automation testing of Mobile Web app using SeeTest is similar to automation of Native applications except that Mobile Web apps will run on the mobile browser instead of the Native container. In iOS, the mobile web app testing is performed in Safari while in Android, tests are performed in Chrome.

The following section explains about Mobile web automation using SeeTest Automation in an Android device.

In order to test a web app, launch the web app in the Chrome browser by using SeeTest Launch command with the app path as ‘Chrome:URL’ where URL is the URL of the web app under test (Example: Chrome:

Then do Object Spy and the web elements will be displayed inside the blue rectangles in the device reflection.

After you identify the XPaths of the desired element, you can use normal SeeTest commands by setting zone as ‘WEB’ to perform tests.

Figure 12 Launching web app

web app testing

Figure 13 Web app Object Spy

launching web app

Hybrid App Automation Testing

Automation testing of Hybrid applications is similar to testing of Native applications. Hybrid applications will run in a native container and render web elements inside that. Therefore, we will get a combination of Native and Web Elements to be identified during testing and we can see the same in the Object Spy too.

Figure 14 Hybrid app – Object Spy

Hybrid App- object spy

The above figure shows the Object Spy window of a hybrid app (Amazon). As mentioned earlier, we can see Native elements (highlighted with red) and Web elements (highlighted in blue) in the Object Spy.

If we need to retrieve the price of the Mobile device (iPhone 8) shown in the above figure, then we need to identify which property of the element contains the price from the Object Spy.

Figure 15 Object Spy – Buying price multiple detections

Object spy - multiple detections

From the above figure, while filtering the elements with the class as buyingPrice, we get two occurrences. The first element that is having the same XPath is not on the screen right now or it is hidden. But we need to identify the element that is currently on the screen. So we add another property called ‘onScreen’ to the query.

Setting the value of the onScreen property will tell SeeTest to look into the elements that are currently displayed on the device.

Figure 16 On screen element filtering

object spy - onscreen

From figure 16, we can see that the text property of the element contains the price as Rs 64,000. So we need to extract the value of the text property of the element. We can use GetElementProperty command with Zone as WEB and Element Representation as the formed XPath.

Figure 17 Retrieving text property

Retrieving text property

From the above figure, we can see that SeeTest Automation has detected the element correctly and displayed the result of GetElementProperty to retrieve the text property of the element in the log window. The report also will convey the same. If we navigate to the ‘Data’ tab in the report for the Property Retrieval step, then we can see the retrieved property value.

Figure 18 Retrieve property Report

Retrieve property-result

Figure 19 Retrieve property – Result data

Retrieve property-result data

Sometimes there are chances for multiple web views in the same scene. While searching for a web element using SeeTest Automation, it always looks into the first web view of the element. If the desired element is inside another web view that is not first, then the element identification fails.

SeeTest provides a facility to switch between web views by using SetDefaultWebView. It takes WebView Locator as the parameter. Either we can specify the web view number starting from 0 or we can mention the web view id or the name (Example – id=webview1) as seen in the Object Spy as the web view locator.

Interruption Testing Automation

As far as mobile devices are concerned, they are always subjected to some kind of interruptions during the testing process. It can be an unexpected popup displayed by the device (battery low notification), or a phone call or SMS or unexpected popup displayed by the other apps.

These interruptions will interrupt the flow of testing and all the steps after the interruption might fail. SeeTest Automation provides a facility to handle this kind of interruptions by its client libraries.

This feature is available only when we are implementing test scripts with any of the SeeTest supported programming/language (Java, C#, Python, Perl, Ruby etc.) and not available from the command window of SeeTest Automation.

If we need to handle incoming calls during testing, then we can add a Mobile Listener that listens to the events after each time interval. When the desired behavior is found, the code inside the Mobile Listener function will execute.

Suppose incoming call notification will have Accept and Reject options. Then we first check for the presence of the Reject button and if found click on it.

The below code will reject incoming calls during testing. You might have to modify XPaths according to your device.

client.addMobileListener("NATIVE", "xpath=//*[@text='Incoming call']",
 new MobileListener() {
 public boolean recover(String type, String xpath) {"NATIVE", "xpath=//*[@text='Reject']", 0, 1);
 return true;

In the Mobile Listener, we specify the condition to detect an interruption and in overridden recover method, we specify the code to handle the interruption. In the above code, the Mobile Listener checks for the presence of an element whose xpath is //*[@text=’Incoming call’].

If SeeTest Automation found that element on the screen, then the recovery function will start to execute.

Recover function will click on Reject button whose XPath is given as //*[@text=’Reject’]. This will not consume much additional memory but the testing will become a little bit slower when compared to the earlier situation as SeeTest Automation will check for the event specified in the Mobile Listener after each time interval.

Parallel Execution

When we discussed Execution Agents, we said that Execution Agents would help us to perform parallel test execution on multiple devices.

An execution agent assigned to one device cannot be used for another device if we need to execute tests on both devices at the same time. If we connect two devices to SeeTest Automation, one device will take port 8889 and the other will take 8890.

Whatever action we perform using SeeTest Java Client whose port is set to 8889 during the initialization, those actions will be reflected in the device that is connected to the port 8889. Parallel execution can only be performed from a framework (Java, C#, Python etc.) and not from the SeeTest command window.

For the parallel execution of the same test in multiple devices, we should not hardcode the port number in the script. Instead, we need to let SeeTest choose the ports dynamically and assign the appropriate ports to them. This can be achieved by using WaitForDevice command.

Once the device is connected via WaitForDevice command, it is mandatory to release the same using ReleaseDevice command so that we can use the device for future tests.

Continuous Integration using Jenkins

This section describes how to integrate the tests written using SeeTest Automation with Jenkins as a part of Continuous Integration. We will use the Maven Project that we created earlier to integrate with Jenkins.

The steps are as follows:

  • Launch Jenkins.
  • Create a Jenkins Freestyle Project and name it as EriBank Test.

Figure 20 Create Jenkins Project

Create jenkins project

Figure 21 Configure Jenkins Project

Configure jenkins project

  • Click on the Advanced button and check Custom Workspace to set the workspace.
  • Enter the path to the Maven Project in the Directory text box.

Figure 22 Configure Jenkins Project – Workspace

Configure jenkins project - workspace

  • Add Build Step – Invoke top-level Maven targets.

Figure 23 Configure Jenkins Project – Build Step

Configure jenkins project - build

  • Specify goal as ‘clean test’.

Figure 24 Configure Jenkins Project – Maven Goal

Configure jenkins project - goal

  • Select Publish JUnit test result report as the Post Build Action.
  • Enter **/surefire-reports/TEST-*.xml in the Test Report XMLs text box.

Figure 25 Configure Jenkins Project – Publish JUnit results

Configure jenkins project - junit results

  • Click on Save.
  • Now build the Jenkins job.
  • The project will start to build. After clicking on the build and select Console Log, you can see the console log. If you are running maven from Jenkins for the first time, Maven will download all the dependencies and this will take a little bit of time. Console log will show the progress of downloading.

Figure 26 Jenkins Project Console

Jenkins project console

After the test, Jenkins would publish the JUnit test results and we can view the same by clicking on the Test Results link in the build.


In this tutorial, we discussed how SeeTest Automation can be used in a real-time Mobile Automation project to automate complex mobile apps that are required to be thoroughly checked as a part of the QA.

With this, we have covered all the relevant aspects of SeeTest Automation and fit to automate some real-time mobile apps. I am sure that this series of SeeTest Automation tutorials would have given you a wide knowledge of the various concepts in SeeTest Automation.

If possible, take a SeeTest Certification and add it to your portfolio to get better career opportunities.

This concludes our SeeTest Automation series.