Missed ranorex operations. Defensive coding strategy?

Technology specific object identification, supported applications, web technologies, and 3rd party controls.
sundarpn
Posts: 17
Joined: Wed Mar 17, 2010 7:36 pm

Missed ranorex operations. Defensive coding strategy?

Post by sundarpn » Thu Apr 08, 2010 2:52 pm

Hello,
In the context of a webdocument, I had the following in a method to set and inputtag (i.e. text box on the webpage).

.....
m_WebDoc.WaitForDocumentLoaded(); //the patient seclector web page.
Ranorex.InputTag patientInputText = repo.WebDocSelectPatient.inputxtPatientName;
patientInputText.TagValue = searchText;


I noticed that SPORADICALLY, the Input text box is simply not set (no error is thrown). Later my script failes down stream. (I even tried using Innerhtml instead of Tagvalue... ). Now I have added a tryfind single on 'inputPatientName' before setting it. Hasn't failed yet.

So in general :What is a defensive coding stragety? In the above case, after setting the tagValue should I add a check to get the InputTag's value and explicitly check if it was really set (if not thow an error / exception....)?

I have couple of sporadic issues like the above... were Ranorex attempts an 'operation' on a widget but dosen't actually perform it. (no excetion raised either).

One thought to improve stability is to explicity check after the 'operation'. Like say I check a checkbox, then next line I check ... was it really checked?. I set a text field, next line I check if it was really set?....
But flip side, wrapping every single operation (sets, clicks etc) with an assert / conditional check?. There will be too many of them. So appreciate if any of you can shed light on some best practices here.

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: Missed ranorex operations. Defensive coding strategy?

Post by Support Team » Mon Apr 12, 2010 3:07 pm

Hi,

For example ASP.NET pages run as code on the server. Therefore, for the page to be processed, the page is configured to submit to the server when users click buttons (or optionally, when users select check boxes or interact with other controls in the page). Each time, the page is submitted back to itself so it can run its server code again and then render a new version of itself back to the user. So it could happen that the tagvalue is not set to ,for example in your case, the text box.

Also it can be if you call the Navigate() method. Navigate requests a GET and GET should not be used for operations that cause side-effects.

I also created a little samplepage (ASP.Net) with one text box and I observed following:
When i using the Navigate() method it can happen that the tag value is not set, but this is not a Ranorex error. Without this method the TagValue of the text box is set always.

So in your case the only way is to validate the item after you set the TagValue.

Regards,
Peter
Ranorex Support Team
.
Image