Clicking Windows Calculator buttons with AutoItLibrary for Robot Framework and RIDE

WePython 1 Months+

Description of problem and goals

I have Robot Framework, RIDE and AutoItLibrary installed. For a simple test case, I want to open an instance of Windows Calculator, click the "7" button, keep the window open for a couple of seconds, then close the window.

The current test case is running and passing, but the "7" button does not appear to be clicked. Every step apart from clicking the button is being performed.

The current strategy being used to click the appropriate button is to do it via coordinates. Using the AutoIt finder tool, the coordinates of the "7" button were found. Unfortunately, the finder tool does not show the name or ID of controls in the Calculator Window:

It appears that the problem is due to the fact that the coordinates are relative to the entire screen, not the Calculator window. So, when an instance of this Window is opened automatically by Robot Framework, it may be a different location on the screen, so the given coordinates may not represent the location of the required button.

How can the button be reliably clicked?

Test Case Code

*** Settings ***
Library           AutoItLibrary

*** Test Cases ***
TC0
    # Opens the Calculator, waits until it is active, keeps it open for 2 seconds, then closes it.
    Run    calc.exe
    Win Wait Active    Calculator
    ControlClick    Calculator    ${EMPTY}    ApplicationFrameInputSinkWindow1    left    1    50    350
    BuiltIn.Sleep    2s
    Win Close    Calculator
-----------------Answer-----------------

Set mouse coordinate as 0 using set option:

Auto It Set Option     'MouseCoordMode'    0
Auto It Set Option     'GUICoordMode'    0
Auto It Set Option     'PixelCoordMode'    0

https://www.autoitscript.com/wiki/AutoItSetOption

MouseCoordMode Sets the way coords are used in the mouse functions, either absolute coords or coords relative to the current active window:

0 = relative coords to the active window

1 = absolute screen coordinates (default)

2 = relative coords to the client area of the active window


Previous : How to automate testing of Zebra TC75X barcode scanner?
Next : How to get variable in Flexible File Writer in JMeter