Page 1 of 1

script not executed properly

Posted: Thu Nov 19, 2009 4:45 pm
by Ruser
Hi,

I am seeing a very weird Ranorex issue: some script not executed properly, and it was not repeatable, next time the script went through without any problem. It should not be coding issue since the scripts are very straightforward ones - button/object clicks. It doesn't happen very often neither, only twice to me. As I said, can't reproduce it.

I am wondering if anyone sees the same behaviour as I did. What might be the cause?

Re: script not executed properly

Posted: Thu Nov 19, 2009 5:46 pm
by Ciege
Can you elaborate on "not executed properly"?

Are you receiving any errors or exceptions in you automation code or AUT? Do things just "hang up"? Are objects not being found properly? It's hard to diagnose without knowing more details.

Re: script not executed properly

Posted: Thu Nov 19, 2009 6:36 pm
by Ruser
Sure, my bad...

for example, a simple button click script,

repo.object.dom.button1.click();

the ranorex just didn't execute it but didn't throw any error neither. So from Ranorex standpoint, this step passed and went to the next step. It failed at the next step because of the validation.

Next time I ran it, no problem. Looks weird to me. Maybe some interruption from outside, like OS, other opening program caused this?
Ciege wrote:Can you elaborate on "not executed properly"?

Are you receiving any errors or exceptions in you automation code or AUT? Do things just "hang up"? Are objects not being found properly? It's hard to diagnose without knowing more details.

Re: script not executed properly

Posted: Thu Nov 19, 2009 6:43 pm
by Ciege
Are you surrounding your click (as well as the rest of your test code) with a try/catch to check if an exception is thrown? Specifically if an object not found exception is thrown.

On the surface, it sounds like you are not catching Ranorex exceptions so failures are just continuing on to the next step. It probably is an issue where the button1 in your example is not found within the timeout so the click isn't occurring.

Since you are using an RXpath with DOM in it I am assuming you are testing a web app. You need to make sure of the following things before you issue a click on an object:
1) is the page done loading (check ready state)
2) is the webdocument that holds the object done loading
3) is the object loaded and ready
4) you could search for the object before you try to click it
5) increase your timeout for the .click
6) catch and handle exceptions returned by Ranorex (most important!)

Re: script not executed properly

Posted: Fri Nov 20, 2009 2:30 pm
by Support Team
The problem could also be that Ranorex really clicked the button, but the button did not recognize the click. Ranorex does not have a way to check whether the button actually was clicked or not, you can only check that yourself by evaluating the reaction of your application to the click.

It could be that your button is already there, so Ranorex finds it, but is not yet enabled, i.e. cannot be clicked yet. Try inserting a delay between getting the element and clicking it:
Button button1  = repo.object.dom.button1;
Delay.Milliseconds(1000);
button1.Click();
Regards,
Alex
Ranorex Support Team

Re: script not executed properly

Posted: Mon Nov 23, 2009 4:21 pm
by Ruser
Thank you both, Ciege and Alex. I believe adding some delay would help.

Re: script not executed properly

Posted: Mon Nov 23, 2009 4:29 pm
by Ciege
My I suggest not adding just an arbitrary delay.

If you just delay for say 10 seconds it may work most of the time but 1) there may be time that it takes 11 seconds and your script would fail and 2) there may be time it takes 1 second and now you are waiting for 9 seconds unnecessarily (doesn't seem like a lot now, but as you continue to add delays and your script grows these numbers add up).

So I suggest doing the searches and checking readystate then maybe add a 1/2 or a full second delay then continue.