Unable to access the checkbox object
I am trying to perform an upgrade tests.
In the upgrade tests dialog, there are 4 objects.
The first one is "Uninstall earlier version", which is a checkbox, eventhough the object mapping says Button, with the object mapping of "Window("Button","",1)", the object Type is CheckBox
Then we have three buttons, "Back", "Next" and "Cancel", their object Types are Button. The BACK and NEXT button are disabled untill we have checked the "Checkbox" of "Uninstall earlier Version". When trying to access the "uninstall earlier version", the button of "Cancel" is clicked.
To be put in more detail, if i consider the "uninstall earlier version" as a button, "mainDialog.Window("Button", "", 1)", then the cancel button object is clicked, eventhough the mapped object name of cancel button is Button("Cancel").
And if i consider it as a checkbox object, i get the "Invalid procedure call or argument", the code for that checkbox goes as follows,
If mainDialog.Window("Button", "", 1).wState = cbUnchecked Then mainDialog.Window("Button", "", 1).wState = cbChecked End If
Any help on solving this problem is highly appreciated.
Thanks in advance!
I'm not a VB guru so forgive bad code syntax. Also, your first screenshot showing the Standard view of the preoprties cuts off at WndStylesEx. Other than the Extended options in the second shot, I'm assuming there are no other properties?
That said, instead of using Window("Button", "", 1) to identify it, you can do a FindChild call. It would look something like this
If mainDialog.FindChild(["ObjectType", "ObjectIdentifier"], ["Checkbox", "0"], 1).wState = cbUnchecked Then mainDialog.FindChild(["ObjectType", "ObjectIdentifier"], ["Checkbox", "0"], 1).wState = cbChecked End If
Some articles for your reading pleasure:
https://support.smartbear.com/testcomplete/docs/reference/test-objects/members/common-for-all/findchild-method.htmlAnd, I would suggest you investigate using NameMapping for object identification. Please review