0

I'm trying to get fields or objects in Desktop application with TestComplete. But get a problem, because I can't get ID, because there are no ID! But other properties such as MappedName, FullName.. can change by themselves when I do new start of application.. And in the end, there are no stable and unique properties that I can use.

Is any of you had the same problem?

Please, help me to solve this problem. I need to write automation tests (I use Visual Basic language)..but don't know how I can get the objects then...

  • What kind of application are you testing, web or desktop? – Niels van Reijmersdal Nov 2 '15 at 14:27
  • OP has mentioned that it is a Desktop application :) – Dhiman Nov 2 '15 at 15:07
  • @Viktoriia: the label/text of the fields which is being displayed over the UI is static? irrespective of the position and other parameters of the element e.g. Label 'Name' will always be displayed as 'Name' no matter where it is shown on the page. Is the same true in your case too? – Dhiman Nov 2 '15 at 15:30
  • It's like the same mine problem described here: sqa.stackexchange.com/questions/11516/… We don't have a solution for this either because names etc change with every build – bish Nov 2 '15 at 15:41
  • I testing Desktop application, as I wrote above. I din't get question about Label "Name".. With labels everything okay. – Viktoriia Nov 3 '15 at 7:13
1

With a desktop application you've got several ways you can do this:

  • Have the developers set a distinctive ID for every field - This is by far the best option because it will save you a lot of time and is relatively low effort on the part of the dev team. It may not be possible if you are working with an application that uses specialized components or is written with a tool TestComplete doesn't fully support.
  • Look for properties that don't change with each build - This is more time-consuming, but can be done by looking for labels, captions, and so forth. Your test code may need to do things like find the button with the caption "Update"
  • Manually map the objects you're dealing with to an object name you choose - TestComplete will automatically map an object name to its name and path within the application. You need to edit the mapping to identify the object by something that doesn't change, then give the mapped object a unique name you can use throughout your script code. This has the added advantage that when an object is removed from a form or moved to a different form, you don't need to make major changes to your code - you modify the object map, the navigation code, and the code that interacts with that specific item to use the new flow, and you're done.
  • Use keyboard shortcuts if all else fails - this is the worst way to deal with the items, but it can be done: your application will have keyboard shortcuts (or at minimum, tab stops). Using them to get to the part of the application you're working with is fragile and will cost you a lot in rework every time the forms and process flows change, but it will give you a way to reach the objects you need to interact with. Sometimes this is the only way you can interact with an object - if your version of TestComplete doesn't fully support the application components, this may be your only option.

I've used all these methods, and combined them - where components didn't give me any other means to access them, I used the tab/keyboard shortcuts and keystrokes method (and commented my code extensively). Elsewhere I used IDs if I could get the developers to provide them, and static properties if I couldn't. And everything I could get an object handle on got mapped.

  • Yeah, with IDs is the best way, I know. There are no properties that are not change. They all change by new start. Even if I give unigue MappedName by myself. Everything gone then.. I tried with shotcuts: I can get object, but there no possibility to do checks and I'm not sure, if there's possibillity to input data.. ? – Viktoriia Nov 3 '15 at 14:01
  • How can I be when I need to check anything? – Viktoriia Nov 3 '15 at 14:19
  • @Viktoriia - if you use keyboard shortcuts you can get a reference to the object, make sure it's the right type of object, and use keystrokes to interact with it. TestComplete includes built in methods that return the field type of the current object, which you can use with a find method (find the object with the label "My Label" that is a radio button field, select that object, then use [Space] to select the first option) – Kate Paulk Nov 4 '15 at 12:22
0

We have done something like below. First we know the object type, ex; textfield, passwordfield or button ext,.. This object wont change only we can proceed or else you need to find difference type unique value. Then we write small function to get object count of that object type. Then we can identify the object from that. Ex; Let say your page have two text fields, then scripts will return two for object type text. Then you can access first one or second one. http://community.smartbear.com/t5/Functional-Web-Testing/I-am-getting-more-object-number-than-actual-values-when-I-try-to/m-p/103022#M25323

  • I'm testing Desktop app – Viktoriia Nov 4 '15 at 6:04
  • Not an issue can use the above approach. Need to change following line only. obj = Sys.Yourprocessnamehere.FindAllChildren(PropArray, ValuesArray,2000) – Dev Perera Nov 4 '15 at 7:44
  • But there is no working code, in your link((. How can I do that? – Viktoriia Nov 4 '15 at 8:21
  • I don't understand how it's works. It's wrote "No text fields found!".... – Viktoriia Nov 4 '15 at 8:23
  • first you need to open your desktop app and navigate to the object you want. Then open test complete click on object spy and select your object. In the object spy you can get full path like sys.process("myprocess")... Use that parth to find the object in the scripts. Also you need to find object type from the object spy then update following of the scripts, – Dev Perera Nov 4 '15 at 8:33
0

It depends on the object and properties used.

1) If objects are dynamic then it would be difficult for developers to hard code IDs. In this case you should look for data associated with object.

2) Properties like MappedName and FullName depend on the whole hierarchy leading up to the object, so if any parent object moves or changes then this property will change too.

3) Properties that are auto-generated will change with each build. You should talk to your developers to hard code certain properties with a unique value/id, that way these will not change with each build and you can use it for testing.

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.