0

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: enter image description here

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
3
  • Is this for learning purposes, or what risk are you investigating with this test? – pavelsaman Oct 14 '20 at 5:08
  • @pavelsaman it's for the purposes of learning to use this framework for desktop automation and testing. – Al2110 Oct 14 '20 at 5:15
  • Please accept the answer if it helped by clicking the tick sign – PDHide Oct 15 '20 at 7:11
2

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.