Lesson #17: How to add new mobile actions

Sometimes, you may find it necessary to do some things in your test that cannot be achieved with built-in actions, nor with the user-defined actions that build upon them.
Such user-scripted actions can be used to supplement the functionality of built-in TestArchitect actions. Examples of situations that you want to perform bring item to view or zoom action, you have to add implement a harness action.

Prerequisites:

What you will learn:

  • How to implement your new mobile actions in programming language Java.


Please download the sample project first and see the Readme file of each project to know how to implement TestArchitect Harness with Java language.

Best practice to use TestArchitect Harness for mobile testing

Let’s get started with TaHarnessWithBestPractice project (in the sample projects above).
Examples: you want to interact with an item in List View out of the mobile screen, Test Architect has not supported scrolling to item yet. And now you have to implement new mobile action to scroll and click the expected item.

  1. Unlike the other platform, attach session is prerequisites action. You have to attach with retrieved session Id after connect device.
    In Test Architect client, please implement the script as below:



    Besides that, in the harness project, please reference method action_attachSession in class Mod_Mobile_Example.java to implement harness action attach session.

    public static void action_attachSession() throws MalformedURLException {
    	String serverUrl = AbtLibrary.getArgByIndex(1);
    	String sessionId = AbtLibrary.getArgByIndex(2);
    
    	if(serverUrl.length() == 0) {
    		AbtLibrary.reportError("The 'server url' argument cannot be empty.");
    		return;
    	}
    
    	if(sessionId.length() == 0) {
    		AbtLibrary.reportError("The 'session id' argument cannot be empty.");
    		return;
    	}
    
        String completeUrl = serverUrl + "/session/" + sessionId;
    
        URL remoteSessionAddress = new URL(completeUrl);
        AbtLibrary.report("remoteSessionAddress: " + remoteSessionAddress);
    
        driver = new AppiumDriver(remoteSessionAddress, "Android", "UIAutomator2");
    }
    

    In case you execute the test script with Selected Desired Capabilities file, you can get session Id via action get device session id.

  2. Implement harness action bring item to view to scroll the item that you want to interact. Please take a look method action_bringItemtoView in class Mod_Mobile_Example.

  3. Now you have a new powerful action to scroll the item in list view. And you can click the item!

Notes:

  • The AppiumDriver which is attached in action_attachSession method is a standard Java Interface of Appium Java Client. So you can implement a lot of interesting function with that object.
    For more informations about AppiumDriver, please reference Appium Java Client AppiumDriver.

Copyright © 2024 LogiGear Corporation. All rights reserved. LogiGear is a registered trademark, and Action Based Testing and TestArchitect are trademarks of LogiGear Corporation. All other trademarks contained herein are the property of their respective owners.

LogiGear Corporation

1730 S. Amphlett Blvd. Suite 200, San Mateo, CA 94402

Tel: +1 (650) 572-1400