Ask a Question

Finding Objects Delphi

petra
Contributor

Finding Objects Delphi

Hi there.

 

Sometimes Test complete can't find the right object.

 

The correct name of the object (marked in red in attachment) is DBText12.

 

Every x-th time TC says "No the name isn't DBText ...... The name is shape1"

 

On these times TC also couldn't "see" buttons, but only the Panel behind

 

Do anyone have an idea how to handle.

 

pe:

 

Cancelling this teststep is no idea if you click on the object, a window appears.

 

Searching for DBText OR shape is no good idea too.

 

Please help!

 

 

 

 

16 REPLIES 16
Colin_McCrae
Community Hero

Re: Finding Objects Delphi

Need more info.

 

Is this a mapped object? What properties are you using to map it? Because it sounds like it's finding the wrong object sometimes, which suggests your mapping is not strong enough.

 

And what are you trying to do at the point it finds the wrong object? Is this during a run? Sounds like you don't get an error message, more that the test doesn't work as it finds and uses the wrong object.

 

But need more details to have any chance of working out what's going on ....

petra
Contributor

Re: Finding Objects Delphi

Errorwarning is

 

An error occurred while accessing the "Click" method or property of the "DBText12" object.
The object or one of its parent objects was not found.

Object Whose Method or Property Was Accessed

Alias:Aliases.Kasse.ArtBei.DBText12
Name mapping item:NameMapping.Sys.Kasse.ArtBei.DBText12

Object That Was Not Found

Alias:Aliases.Kasse.ArtBei.DBText12
Name mapping item:NameMapping.Sys.Kasse.ArtBei.DBText12

 

 

Mapped with TDBText (ClassName)

DBText* (Native DelphiObject.Name)

 

 

 

I try to make a klick in this window named DBText12. Then another window appears.

 

 

 

Test:

 

 


DBText12 Click ... Clicks at point (73, 9) of the 'DBText12' object.

 

(a window appears if dbText12 is found -- on this window)


BitBtnCancel Click ... Clicks at point (74, 27) of the 'BitBtnCancel' object.

 

 

Colin_McCrae
Community Hero

Re: Finding Objects Delphi

OK.

 

Sounds like either a sync issue - so the object is not yet ready at the point you're trying to use it. In which case, you should put some sort of checking step in before you try and use it.

 

Or ....

 

Your mapping is not tight enough and it's failing to identify something at runtime. If this is the case, it could be anything in the object tree for "NameMapping.Sys.Kasse.ArtBei.DBText12". If any of the components are not available, it will fail as you're describing as the object at the end of the tree can't be found. One bad link breaks the chain.

 

I have no idea what "shape1" that you mention in your original post has to do with any of this? What you're describing sound like a standard "object not found" type problem.

petra
Contributor

Re: Finding Objects Delphi

The crazy one is this

 

I have several test-steps.

This "opening the Table" about 15 or 20 times in the whole test. 

the first 10 times it works fine, in the 11 test it crashes. or 1 works, the next crashes.

 

My Test is splitted in several "mini-Tests" (dont know the correct word)

1 i open my .exe file

2 logging in

3 opening the table

4 adding coca cola, beer and so on on my table ( like a waiter will do)

 

then different actions.

 

repeating the 4 teststeps above.

next action

 

....

So i dont think the problem is the namemapping.

 

 

petra
Contributor

Re: Finding Objects Delphi

Next time i make a screenshot of object spy then you maybe see what i mean.

Trying your hints yet

Colin_McCrae
Community Hero

Re: Finding Objects Delphi

Without knowing EXACTLY what the other steps you do are.

 

Or EXACTLY how the application is responding to these steps.

 

You're not likely to get an exact answer. Just potential pitfalls.

 

You say you repeatedly re-use the same controls. But we don't know what you do within each of these repeats. Or how the application state is changing as a result of your tests. Presume other things are also happening, not just constantly clicking on this same field/button? Much as I'd love to assume that everything stays the same, I can't. And neither should you!

 

It's kind of hard to say what's happening. But you posted the error yourself. Object not found. To which I've already mentioned two possible things that could be causing that.

 

But if it's happening intermittently (you say sometimes the first time you use it, sometimes the 11th) then it sounds more like a sync issue - ie. Something is usually ready at the point you try and use it, but not always. So you may need to verify that objects are in a ready state (an action on a previous object will often affect the state of other objects) before you attempt to use them.

Colin_McCrae
Community Hero

Re: Finding Objects Delphi

A photo of the object spy will not necessarily provide the answer if it's a sync problem.

 

By the time you screenshot it, yes .... the application has caught up and the object has rendered and enabled itself fully. So everything looks fine. But at the point your test tried to use it, that may not be the case. That's what a sync issue is.

tristaanogre
Community Hero

Re: Finding Objects Delphi


@Colin_McCrae wrote:

 

 

But if it's happening intermittently (you say sometimes the first time you use it, sometimes the 11th) then it sounds more like a sync issue - ie. Something is usually ready at the point you try and use it, but not always. So you may need to verify that objects are in a ready state (an action on a previous object will often affect the state of other objects) before you attempt to use them.


I'm with @Colin_McCrae... scripts tend to run faster than a user usually does them... and they are pretty "stupid".  They will attempt to do something without first making sure that you CAN do that something.  As a human user, when you're going through your application, there are hints that you need to wait before you can proceed... like mouse cursor shape, messages, on screen, etc.  So, you need to make your automation "smart" to do this kind of stuff.

The simplest way around your problem, if it is a sync issue, is to do some sort of check of the existance or readiness of the object in question before you attempt to interact with it.  "Object not found" is easily resolved by either increasing your global Auto-wait timeout (the installed default is 10 seconds) or by utilizing the WaitAliasChild (or WaitChild or WaitNNN method) to wait for the child object to return before proceeding and then checking the "Exists" property on whatever is returned to make sure that, yes, we got it.


Robert Martin
[Hall of Fame]
Please consider giving a Kudo if I write good stuff
----

Why automate?  I do automated testing because there's only so much a human being can do and remain healthy.  Sleep is a requirement.  So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.

Mysterious Gremlin Master
Vegas Thrill Rider
Extensions available
petra
Contributor

Re: Finding Objects Delphi

Seems like it is a timeproblem

Standart autowait timeout is set at 1 minutes . Cat LOL

Maybe i will make a delay.

Checkpoints: In case of failor its not possible do reach any button or text. 

By the way. i tested my program in midday, I dind't change anything, and it worked. 

 

Thanks to you two

 

cancel
Showing results for 
Search instead for 
Did you mean: