Ranorex.CommandFailedException / SerializationException

Class library usage, coding and language questions.
jabelshauser
Posts: 55
Joined: Thu Aug 23, 2007 12:00 pm

Ranorex.CommandFailedException / SerializationException

Post by jabelshauser » Tue Apr 28, 2009 11:50 am

Environment:
.Net 1.1, Tests runs with NUnit 2.4, 30 Tests with a long total-duration (ca. 0,5h). Exceptions occurs only after much time is elapsed, never at begin of tests.

Exception:
System.Runtime.Serialization.SerializationException: The type Ranorex.CommandFailedException in Assembly RanorexNet, Version=1.5.0.3287, Culture=neutral, PublicKeyToken=60ca58ec175a86b8 is not marked as serializable.
...no further information

What reasons can this Ex. have ? Are there enhanced trace-capabilities ?

regards
Jörg

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

Post by Support Team » Tue Apr 28, 2009 12:53 pm

Could you please provide us the stacktrace of the exception?

You can use the Logger class to print out debug statements.

Regards,
Alex
Ranorex Support Team

jabelshauser
Posts: 55
Joined: Thu Aug 23, 2007 12:00 pm

Post by jabelshauser » Tue Apr 28, 2009 1:08 pm

the exception occurs when a Child-Element is searched (which is available). If i invoke the test again and immediatly (without pre-duration), the test passes (of course ;-))
There is no further Stack-Trace avl. (how can i get it ?)

Regards Jörg

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

Post by Support Team » Tue Apr 28, 2009 1:31 pm

Please post the message you get by calling the ToString() method of the exception, e.g.:

Code: Select all

try
{
    // exception is thrown somewhere here
}
catch (Exception ex)
{
    string message = ex.ToString();
}
Which method is causing the exception?

Regards,
Alex

jabelshauser
Posts: 55
Joined: Thu Aug 23, 2007 12:00 pm

Post by jabelshauser » Tue Apr 28, 2009 2:04 pm

this method causes the exception:

_obj = _control.Element.FindChild(role, this.GetType().Name);

role = Role.Toolbar

VS- Output:
Eine Ausnahme (erste Chance) des Typs 'Ranorex.CommandFailedException' ist in ranorexnet.dll aufgetreten.

Zusätzliche Informationen: The specified command could not be executed.

thats all !

Regards Jörg

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

Post by Support Team » Tue Apr 28, 2009 3:26 pm

This could be a timing issue.
Can you please try the following:

Code: Select all

_obj = _control.Element.FindChild(role, this.GetType().Name); 
if( _obj == null )
{
    Application.Sleep(500);
    _obj = _control.Element.FindChild(role, this.GetType().Name);
}
or

Code: Select all

try
{
    _obj = _control.Element.FindChild(role, this.GetType().Name); 
}
catch (Ranorex.RanorexException)
{
    Application.Sleep(500);
    _obj = _control.Element.FindChild(role, this.GetType().Name); 
}
Jenö
Ranorex Team

jabelshauser
Posts: 55
Joined: Thu Aug 23, 2007 12:00 pm

Post by jabelshauser » Thu Apr 30, 2009 12:21 pm

no, a retry of the command after a sleep doesn't help.

what can i do else ?
btw: the exception also occur outside NUnit in a console-application

regards Jörg

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

Post by Support Team » Thu Apr 30, 2009 12:30 pm

Has the main thread the STATheadAttribute applied to it? I.e. is the Main method of the ConsoleApplication decorated with the STAThread attribute? That is needed for Element based searches.

Regards,
Alex
Ranorex Support Team

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

Post by Support Team » Thu Apr 30, 2009 12:55 pm

You could also try the same without element caching:

Code: Select all

Ranorex.Element.EnableCaching = false;
Jenö
Ranorex Team

jabelshauser
Posts: 55
Joined: Thu Aug 23, 2007 12:00 pm

Post by jabelshauser » Tue May 05, 2009 9:04 am

no success so far :-(

Some more constraints:
It seems to happen only at Element-Level.
In case of Failure, the testbench teardowns the whole SUT (Software under Test) and setup it again. Then the Test searches successful again the Form with Application.FindForm... and also find a control. But the 1st access at Element-Level fails again. From this point, all Element accesses fails, seems as Ranorex remains in a failed-mode after the 1st failure.
When i suspend the test and the SUT is left running, a new start of an Test with an Element-Access is successful again.
Note: The 1st failure happens always(?) when i access a Exceed-Control

regards Jörg

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

Post by Support Team » Tue May 05, 2009 4:17 pm

The 1st failure happens always(?) when i access a Exceed-Control
Is your Exceed-Control a WPF or Windows Forms control?
Does the exception only happen with this control?

Jenö
Ranorex Team

jabelshauser
Posts: 55
Joined: Thu Aug 23, 2007 12:00 pm

Post by jabelshauser » Wed May 06, 2009 8:36 am

It is a Windows Forms Control, yes so far only with a Exceed-Control

regards Jörg

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

Post by Support Team » Thu May 07, 2009 2:40 pm

so far only with a Exceed-Control
Is the Exceed-Control a 3rd party control? This bug can also happen if the control does not support MSAA (Microsoft Active Accessibility) correctly.
It is a Windows Forms Control
If the control is a Windows Forms Control, then you may have another possibility. Please check the extended properties of the control with RanorexSpyPro. Drag the finder tool of the Spy to the control and check the right side of the Spy window. If the Spy shows the properties of the control, then you can also automate it with the Control.InvokeMethod function.

Jenö
Ranorex Team

jabelshauser
Posts: 55
Joined: Thu Aug 23, 2007 12:00 pm

Re: Ranorex.CommandFailedException / SerializationException

Post by jabelshauser » Mon Jun 22, 2009 9:31 am

i have further analyzed the problem. The Element-structure we use is as follows:

Nameless-Client-Element
'- ElementName (Value="MyTextbox")
'- Another
'- Another2
'- Container
'- Textbox-Element(Value="the Text")

Used Algorithm:
FindChildValue("MyTextbox").Parent.FindChild(Role.Text)

Mostly, the Parent is correct (4 childs as in example) and the following FindChild-Command is succesful, but rarely the parent has only 2 childs and the child structure is a infinite recursion of empty clients, so the following FinChild causes the CommandFailed-Exception.

regards Jörg

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

Re: Ranorex.CommandFailedException / SerializationException

Post by Support Team » Mon Jun 22, 2009 5:26 pm

Hi Jörg!

We will release a new V1.5.2 with some bug fixes (but no new features) in the near future.
I have sent you a download link of the first Beta.
Please try this version and inform us about the results.

Jenö
Ranorex Team
.
Image