Select Page
GYRA Desktop Application Automation Testing Tool for Windows for Free

Name

GYRA – Free Desktop Application Automation Testing Tool

Version

1.0

Date

September 1, 2022

GYRA is a free Desktop Application Automation testing tool that we have developed to overcome the many challenges and limitations that are present in other tools. With the launch of GYRA, you can say goodbye to tools that have poor reliability, slow execution speeds, complex setup process, no active support, and lack of support for Java & Windows 11. As we have addressed all these major issues, we are confident that you will be able to enhance the quality of your desktop app automation testing.

Getting Started with GYRA:

As promised, GYRA will be an easy tool to use in comparison that has an easy setup and execution process. So make sure to follow the documentation and get a clear understanding of how GYRA works. Let’s start with the prerequisites, and then proceed to the code snippets you will need to know to perform various actions in the tool.

Pre-Requisite:

To use GYRA, you must set up the server and the client library by following a few simple steps that we have mentioned.

Step-1: Download the Gyra Server EXE File and Start the Server exe file.
(By default, the port number will be 3000)

gyra-server-1.0.exe (The default portNumber is 3000)
gyra-server-1.0.exe --port=8208

Step-2: Add this ‘Dependency’ in the Maven project.

<dependency>
    <groupId>com.codoid.products</groupId>
    <artifactId>gyra-client</artifactId>
    <version>1.0</version>
</dependency>

Example:

In this below-mentioned code, we have launched the Notepad application and clicked the ‘File’ option from the menu.

Server server = new Server("localhost", 3000);	
//To initialize the Server 

        server.openApplication("C:\\WINDOWS\\system32\\notepad.exe");
// To launch the Windows application

        Desktop desktop = server.getDesktop();
//By using this Server class object, we will take control of the Desktop first and then take control of all the running apps. 

        Window window = desktop.findWindow(By.name("untitled - Notepad"));	
//To find the window using the locator strategy and attach the window session in the window reference object.

        window.findElement(By.xpath("//MenuItem[@name='File']")).click();	
// Using findElement keyword, to find the particular element and then 'click' action performed.

The different locating strategies in Gyra-client are as follows:

window.findElement(By.name("File"));
window.findElement(By.partialName("Fil"));
window.findElement(By.controlType("MenuItem"));
window.findElement(By.automationId("Item 1"));
window.findElement(By.className("Menu Item1"));
window.findElement(By.xpath("//MenuItem[@name='File']"));

Special Note for Xpath Locators:

S. No Supported Not Supported
1 //MenuItem[@name=’File’] //Menu/MenuItem[@name=’File’]
2 //Edit[@ClassName=’TextBox’ and @name=’Search’] Shift

Note: For the above-mentioned Locating technique[By.xpath], we have to be more precise in providing the element location. Because unlike Selenium, traversing through the element is not supported.

Find Elements:

The findElements command takes By object as the parameter and returns a list of windows elements.

Code:

 List<Element> hyperLinks = pane.findElements(By.controlType("hyperlink"));
        for (Element link : hyperLinks) {
            link.click();
        }

Code Snippets:

Now let’s take a look at the code snippets that will help you perform keyboard actions, mouse actions, screenshot comparison function, wait functions, and find element properties.

1. Native Events

2. Element Properties

3. Keyboard Actions

4. Mouse Actions

5. Screenshot Comparison Functions

6. Wait Functions

Native Events:

The actions we are about to see differ from the regular keyboard and mouse action commands as they will be performed directly on the Windows Native elements instead of mimicking the actual interaction of the user.

Single Click:

window.findElement(By.xpath("//MenuItem[@name='File']")).click();

Double click:

window.findElement(By.xpath("//MenuItem[@name='File']")).doubleClick();

Mouse Click:

window.findElement(By.xpath("//MenuItem[@name='File']")).mouseClick();
//To place the mouse pointer at the center of the element and perform a click. 

Right Click:

window.findElement(By.xpath("//MenuItem[@name='File']")).rightClick();

SendKeys:

Element txtField =window.findElement(By.name("EditUser"));
txtField.sendKeys("Codoidian");
String strField=txtField.getValue();	
// It’ll return the Text box value

ComboBox:

To select a particular option from the combobox

//Way-1
Element comboBoxSource=window.findElement(By.xpath("//ComboBox[@name='Source:']"));       
ComboBox comboBox = new ComboBox(comboBoxSource);
comboBox.select("Rear Tray");

//Way-2:
Element weekComboBox = window.findElement(By.automationId("firstDayOfWeek"));
ComboBox comboBox = new ComboBox(weekComboBox);
comboBox.expand();
weekComboBox.sendKeys("Monday");
comboBox.collapse();

Toggle:

Element btnToggle = window.findElement(By.automationId("Toggle"));
btnToggle.toggle();

Element Properties:

Element btnLogin = window.findElement(By.automationId("loginId"));

btnLogin.getName(); 
// To get the visible value for the element
btnLogin.getHelpText();    
 // Te retrieve the Tooltip

btnLogin.getTop();
btnLogin.getLeft();
btnLogin.getBottom();
btnLogin.getRight();
// You will be able to retrieve the Coordinates

Keyboard Actions:

Keyboard keyboard = desktop.getKeyboard(); 	
// To get complete control of the keyboard

keyboard.sendKeys("{WIN}");
// If you are passing any special key such as shift, alt, ctrl, and so on, make sure to use "Curly braces - {}"

If you want to press more than one key, you can use the below-mentioned pattern,

keyboard.sendKeys("{CTRL}X");
keyboard.sendKeys("{CTRL}{SHIFT}{ALT}S");

Mouse Actions:

Mouse mouse = server.getDesktop().getMouse();
// To get control of the mouse

Mouse Move:

mouse.move(10, 20);
//To move the mouse cursor to the specified X & Y Coordinates.

Click Action:

mouse.move(10, 20);
mouse.click(Keys.LEFT);	// Left click
mouse.click(Keys.RIGHT);	// Right Click
//To left/right click on the specified X and Y coordinates

Screenshot Comparison Functions:

By comparising the screenshot of the actual image with the expected image, GYRA will be able to give a score that denotes the difference between the actual and expected images. Likewise, GYRA will also be able to deliver a difference image depicting what the change between the two images are as well. So let’s see the code snippets for those functions.

Note: Make sure that the expected image is in the same resolution as the screenshot.

Capture Screenshot:

To capture a screenshot of the entire screen that we will later use to compare.

Example:

byte[] imgByte = server.getDesktop().takeScreenShot();
FileUtils.writeByteArrayToFile(new File("imgEntireScreenshot.png"), imgByte);

Get Difference from the Image Comparison:

This function can be used to compare the screenshot with the expected image and show the difference between the two images as a separate image.

Element msPaintPane = desk.findElement(By.automationId("59648"));
 ImageCompareOutput output = msPaintPane.compareScreenShot("report/Expected.png");
FileUtils.writeByteArrayToFile(new File("report/difference.png"), output.getDiffImage());

Get Score from the Image Comparison:

To get the score that denotes the difference between the two images. For example, if the images are a 100% match without any difference, the return value will be 0. If there are any differences, a value greater than 0 will return based on the level of the difference.

double scoreValue=output.getScore();
DecimalFormat formatter = new DecimalFormat("#0.000000");
System.out.println("--- Output Score: "+formatter.format(scoreValue));

Note: The difference score is calculated based on the difference in the RGB values and are highly accurate.

Compare Images:

You can also use GYRA to compare 2 images of your choice to get the difference image and score using the above-mentioned functions (getDiff & getScore).

Code:

ImageCompareOutput output = server.compareImage
                ("report/Actual.png", "report/Expected2.png");

Get Score from the Image Comparison:

Once the images have been compared, you will be provided with a score that denotes the difference between the actual and expected images. For example, if the images are a 100% match without any difference, the return value will be 0. If there are any differences, a value greater than 0 will return based on the level of the difference.

double scoreValue=output.getScore();
DecimalFormat formatter = new DecimalFormat("#0.000000");
System.out.println("--- Output Score: "+formatter.format(scoreValue));

Compare Image:

You can also use GYRA to compare 2 images of your choice. (Actual & Expected images)

Code:

ImageCompareOutput output = server.compareImage
                ("report/Actual.png", "report/Expected2.png");

Wait Functions:

Wait functions are very important to automation and you can wait for a window or even wait for an element using the below commands.

Wait for Window:
Window window = desktop.waitForWindow(By.partialName("Notepad"), 15);

Wait for Element:
Element txtAllowance = desktop.waitForElement(By.xpath("//Edit[@AutomationId='AllowancePeriod']"), 15);

Written By

Submit a Comment

Your email address will not be published.

Comments(0)