Sign in to follow this  
Followers 0
sfresher

Why is the ControlID keep changing?

7 posts in this topic

#1 ·  Posted (edited)

Big problem, I am doing something for test automation of a GUI app. I just noticed that a button's controlId keeps changing.

For example, a window contains multiple tab, and if switch between different tab, the controlID of a button under the tab is also keep changing. It jumped from instance 5, to instance 10, then instance 13.

How can I track this button, given that I have to randomly switch between tabs for my testing?

Edited by sfresher

Share this post


Link to post
Share on other sites



Big problem, I am doing something for test automation of a GUI app. I just noticed that a button's controlId keeps changing.

For example, a window contains multiple tab, and if switch between different tab, the controlID of a button under the tab is also keep changing. It jumped from instance 5, to instance 10, then instance 13.

How can I track this button, given that I have to randomly switch between tabs for my testing?

Is there One button per tab? or one button for ALL tabs?

and have you Set or Declared a Variable for the button?

I mean like example..$button = GuiCtrlCreateButton..blah then it would always be the same controlID that u have set.

Share this post


Link to post
Share on other sites

Big problem, I am doing something for test automation of a GUI app. I just noticed that a button's controlId keeps changing.

For example, a window contains multiple tab, and if switch between different tab, the controlID of a button under the tab is also keep changing. It jumped from instance 5, to instance 10, then instance 13.

How can I track this button, given that I have to randomly switch between tabs for my testing?

Do you mean that

there is a button below the tab control which is different for each tab item. So the id will always be the same for a given tab.

OR

there is a button which is below the tab control and the id is changed so that it is not always the same for a given tab.

??

You could find the id if you know the position of the button. Search for ChildWIndowFromPoint or this might help.


Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Do you mean that

there is a button below the tab control which is different for each tab item. So the id will always be the same for a given tab.

OR

there is a button which is below the tab control and the id is changed so that it is not always the same for a given tab.

??

You could find the id if you know the position of the button. Search for ChildWIndowFromPoint or this might help.

I cannot upload the snapshot of my application due to company security policy. But it's very similar to this screen (see below). For example, the button "Automatic (recommended)" currently shows as "button1". However, if I click through other tabs, and then return to this tab, the button becomes "button5", "button 6" or whatever. How does this happen?

post-40462-1223073340_thumb.png

Edited by sfresher

Share this post


Link to post
Share on other sites

I cannot upload the snapshot of my application due to company security policy. But it's very similar to this screen (see below).

Nothing below to see!

For example, the button "Automatic (recommended)" currently shows as "button1". However, if I click through other tabs, and then return to this tab, the button becomes "button5", "button 6" or whatever. How does this happen?

I assume that the button which changes has different functions depending on the tab chosen. So, presumably, when a tab item is changed the button is destroyed and a new one created with the relevant event attached to it. Every time a new button is cretae dit will get the next id number.

Could you use the text on the button instead of the id or class name? eg

ControlClick("Window Title","","This &button")


Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites

Opps... I re-uploaded the picture.

The button is the exactly the same button (no function change, under same tab). Isn't the ControlClick only accept controlID, not text as its parameter?

Share this post


Link to post
Share on other sites

. Isn't the ControlClick only accept controlID, not text as its parameter?

No, from the help

A special description can be used as the controlID parameter used in most of the Control...() functions . This description can be used to identify a control by the following properties:

ID - The internal control ID. The Control ID is the internal numeric identifier that windows gives to each control. It is generally the best method of identifying controls. In addition to the AutoIt Window Info Tool, other applications such as screenreaders for the blind and Microsoft tools/APIs may allow you to get this Control ID

TEXT - The text on a control, for example "&Next" on a button

CLASS - The internal control classname such as "Edit" or "Button"

CLASSNN - The ClassnameNN value as used in previous versions of AutoIt, such as "Edit1"

REGEXPCLASS - Control classname using a regular expression

X \ Y \ W \ H - The position and size of a control.

INSTANCE - The 1-based instance when all given properties match.


Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0