If you need to check a size of control, but it depends on size of window or a screen or depends on size of another control, you might use following approach:
// A procedure that tests whether the combo is no shorter then its parent group
// Works for every parent size
// We call it twice below
proc checkCombo {
with [get-window Preferences | get-group "Open Modes"] {
// Group should not be much wider than the combo
gt [plus [get-combo -after [get-label "Open help search"] | get-property "getSize().x" -raw] 20] [get-property "getSize().x" -raw] | verify-true
}
}
get-preferences-menu | click
get-window Preferences | get-tree | select Help
//Set initial size
get-window Preferences | get-object | invoke setSize 700 700
checkCombo //First check for 700 px size
//Change size
get-window Preferences | get-object | invoke setSize 800 800
checkCombo //Second check for 800 px size
In this example we use get-property command to get numerical value of size (not the use of -raw key).
plus command avoids direct comparison and sets the difference threshold - our group container is wider that combo box under test, but we want to ensure that it is not too wide.
"gt" command compares two numerical values.
The rest of the script illustrates that tested invaraint (relative size of combobox) persists over different window sizes (we check two window sizes, 700 and 800 pixels)