script not executed properly

Ask general questions here.
Ruser
Posts: 24
Joined: Wed Oct 07, 2009 3:26 pm

script not executed properly

Post by Ruser » Thu Nov 19, 2009 4:45 pm

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?

User avatar
Ciege
Posts: 1336
Joined: Thu Oct 16, 2008 6:46 pm
Location: Arizona, USA

Re: script not executed properly

Post by Ciege » Thu Nov 19, 2009 5:46 pm

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.
If this or any response has helped you, please reply to the thread stating that it worked so other people with a similar issue will know how you fixed your issue!

Ciege...

Ruser
Posts: 24
Joined: Wed Oct 07, 2009 3:26 pm

Re: script not executed properly

Post by Ruser » Thu Nov 19, 2009 6:36 pm

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.

User avatar
Ciege
Posts: 1336
Joined: Thu Oct 16, 2008 6:46 pm
Location: Arizona, USA

Re: script not executed properly

Post by Ciege » Thu Nov 19, 2009 6:43 pm

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!)
If this or any response has helped you, please reply to the thread stating that it worked so other people with a similar issue will know how you fixed your issue!

Ciege...

User avatar
Support Team
Site Admin
Site Admin
Posts: 12145
Joined: Fri Jul 07, 2006 4:30 pm
Location: Houston, Texas, USA
Contact:

Re: script not executed properly

Post by Support Team » Fri Nov 20, 2009 2:30 pm

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

Ruser
Posts: 24
Joined: Wed Oct 07, 2009 3:26 pm

Re: script not executed properly

Post by Ruser » Mon Nov 23, 2009 4:21 pm

Thank you both, Ciege and Alex. I believe adding some delay would help.

User avatar
Ciege
Posts: 1336
Joined: Thu Oct 16, 2008 6:46 pm
Location: Arizona, USA

Re: script not executed properly

Post by Ciege » Mon Nov 23, 2009 4:29 pm

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.
If this or any response has helped you, please reply to the thread stating that it worked so other people with a similar issue will know how you fixed your issue!

Ciege...