Page 1 of 2

Ranorex.CommandFailedException / SerializationException

Posted: Tue Apr 28, 2009 11:50 am
by jabelshauser
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

Posted: Tue Apr 28, 2009 12:53 pm
by Support Team
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

Posted: Tue Apr 28, 2009 1:08 pm
by jabelshauser
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

Posted: Tue Apr 28, 2009 1:31 pm
by Support Team
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

Posted: Tue Apr 28, 2009 2:04 pm
by jabelshauser
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

Posted: Tue Apr 28, 2009 3:26 pm
by Support Team
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

Posted: Thu Apr 30, 2009 12:21 pm
by jabelshauser
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

Posted: Thu Apr 30, 2009 12:30 pm
by Support Team
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

Posted: Thu Apr 30, 2009 12:55 pm
by Support Team
You could also try the same without element caching:

Code: Select all

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

Posted: Tue May 05, 2009 9:04 am
by jabelshauser
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

Posted: Tue May 05, 2009 4:17 pm
by Support Team
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

Posted: Wed May 06, 2009 8:36 am
by jabelshauser
It is a Windows Forms Control, yes so far only with a Exceed-Control

regards Jörg

Posted: Thu May 07, 2009 2:40 pm
by Support Team
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

Re: Ranorex.CommandFailedException / SerializationException

Posted: Mon Jun 22, 2009 9:31 am
by jabelshauser
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

Re: Ranorex.CommandFailedException / SerializationException

Posted: Mon Jun 22, 2009 5:26 pm
by Support Team
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