Jump to content

Targetting a control


Recommended Posts

Hello,

I am developing a desktop application using visual basic .NET (visual studio 2005). I plan to use autoit to do functional test for the application (simulate user action and checking the results). When creating the script, I run into problem when trying to target controls (buttons, textbox, etc):

  • first I tried using ID (ControlClick "formmain", "", "66736"), but whenever I rebuild, the ID changes
  • second I tried class and instance number (ControlClick "formmain", "", "[CLASS:WindowsForms10.EDIT.app.0.378734a; INSTANCE:4]"), but then I have to update the script whenever I change the zorder of the control (bring to front and send to back) because it will change the instance number
Is there another way to reference a control?
Link to comment
Share on other sites

Hello,

I am developing a desktop application using visual basic .NET (visual studio 2005). I plan to use autoit to do functional test for the application (simulate user action and checking the results). When creating the script, I run into problem when trying to target controls (buttons, textbox, etc):

  • first I tried using ID (ControlClick "formmain", "", "66736"), but whenever I rebuild, the ID changes
  • second I tried class and instance number (ControlClick "formmain", "", "[CLASS:WindowsForms10.EDIT.app.0.378734a; INSTANCE:4]"), but then I have to update the script whenever I change the zorder of the control (bring to front and send to back) because it will change the instance number
Is there another way to reference a control?
Hello, endyc;

The beta version of AutoIt allows the targeting of WinForm controls. For example, if a WinForm contained a text field that was named "txtUsername", then one could reference that control like so:

"[NAME:txtUsername]"

If you do not wish to use the beta version, I wrote a set of functions that assist in obtaining the control handle. Just follow the link in my signature.

HTH,

Zach Fisher...

Link to comment
Share on other sites

The beta version of AutoIt allows the targeting of WinForm controls. For example, if a WinForm contained a text field that was named "txtUsername", then one could reference that control like so:

"[NAME:txtUsername]"

If you do not wish to use the beta version, I wrote a set of functions that assist in obtaining the control handle. Just follow the link in my signature.

Thanks! I think I'll try the beta first. Actually I am using AutoItX inside NUnit tests. Do you happen to have a vb.net version of your function library?
Link to comment
Share on other sites

Thanks! I think I'll try the beta first. Actually I am using AutoItX inside NUnit tests. Do you happen to have a vb.net version of your function library?

The beta version of AutoItX contains the same functionality. If you're using an xUnit testing framework for functional test automation, you may want to also look at NUnitForms and/or UIAutomation.

HTH,

Zach Fisher...

Edited by zfisherdrums
Link to comment
Share on other sites

The beta version of AutoItX contains the same functionality. If you're using an xUnit testing framework for functional test automation, you may want to also look at NUnitForms and/or UIAutomation.

NUnitForms looks abandoned. Version 2 is still in alpha and no updates since 2006.

Still googling for UI Automation, can't seem to find any code samples.

Link to comment
Share on other sites

Try Class and Text

Post your code because code says more then your words can. SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y. Use Opt("MustDeclareVars", 1)[topic="84960"]Brett F's Learning To Script with AutoIt V3[/topic][topic="21048"]Valuater's AutoIt 1-2-3, Class... is now in Session[/topic]Contribution: [topic="87994"]Get SVN Rev Number[/topic], [topic="93527"]Control Handle under mouse[/topic], [topic="91966"]A Presentation using AutoIt[/topic], [topic="112756"]Log ConsoleWrite output in Scite[/topic]

Link to comment
Share on other sites

NUnitForms looks abandoned. Version 2 is still in alpha and no updates since 2006.

Still googling for UI Automation, can't seem to find any code samples.

Check these out when you have time:

http://msdn.microsoft.com/en-us/library/ms747327.aspx

http://msdn.microsoft.com/en-us/magazine/cc163465.aspx

Also, I failed to mention the White Project from Thoughtworks. This is a good one:

http://www.codeplex.com/white

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...