Strange RanorexPath expression error
Posted: Wed Jan 20, 2010 7:49 am
Hello
I have the following problem: I have a screen where I want to wait for the 'Close' button to become active before going on with my test scenario.
I use the following code for this:
public bool WaitForCompletion(int timeoutSeconds)
{
const int WaitTime = 10;
int timePassed = 0;
while (timePassed <= timeoutSeconds)
{
this.Form.Self.Activate(); // <- strange behavior from this line
if (this.Form.Close.Enabled)
{
this.TakeScreenshot();
return true;
}
Delay.Seconds(WaitTime);
timePassed += WaitTime;
}
this.TakeScreenshot();
return false;
}
But then I get the following exception:
Ranorex.ElementNotFoundException: No element found for path '/form[@controlname='MainForm']/container[@controlname='WorkAreaPanel']/element/container[@caption='Workplace']/tabpage/tabpagelist/tabpage/button[@accessiblename='Close']/container[@controlname='WorkAreaPanel']/element/container[@caption='Workplace']/tabpage/tabpagelist/tabpage/button[@accessiblename='Close']' within 5000ms.
It seems that it messes up the RanorexPath which is, in RanorexSpy from where I have generated the code:
"/form[@controlname='MainForm']" for the MainForm and the Child is the Close Button with container[@controlname='WorkAreaPanel']/element/container[@caption='Workplace']/tabpage/tabpagelist/tabpage/button[@accessiblename='Close']
What I found out is that when I use "this.Form.Self.Activate();" the RanorexPath expression gets messed up. I think this is a bug in the RanorexPath Builder that adds the relative part from the close button a second time.
EDIT: When I don't use Activate() I get the following exception:
Ranorex.ElementNotFoundException: No element found for path 'container[@controlname='WorkAreaPanel']/element/container[@caption='Workplace']/tabpage/tabpagelist/tabpage/button[@accessiblename='Close']' within 10s.
Which in my opinion cannot be found because it does not search for the absolute path including the "/form[@controlname='MainForm']" part?!
Is there another way to ensure that the form is active? I thought it should not be necessary for the form to be active when I want to check whether a button is enabled or not but Ranorex couldn't find it when it was not the active window. So I tried it with the Activate() method.
Any hints or suggestions?
Best Regards
Philipp Dolder
I have the following problem: I have a screen where I want to wait for the 'Close' button to become active before going on with my test scenario.
I use the following code for this:
public bool WaitForCompletion(int timeoutSeconds)
{
const int WaitTime = 10;
int timePassed = 0;
while (timePassed <= timeoutSeconds)
{
this.Form.Self.Activate(); // <- strange behavior from this line
if (this.Form.Close.Enabled)
{
this.TakeScreenshot();
return true;
}
Delay.Seconds(WaitTime);
timePassed += WaitTime;
}
this.TakeScreenshot();
return false;
}
But then I get the following exception:
Ranorex.ElementNotFoundException: No element found for path '/form[@controlname='MainForm']/container[@controlname='WorkAreaPanel']/element/container[@caption='Workplace']/tabpage/tabpagelist/tabpage/button[@accessiblename='Close']/container[@controlname='WorkAreaPanel']/element/container[@caption='Workplace']/tabpage/tabpagelist/tabpage/button[@accessiblename='Close']' within 5000ms.
It seems that it messes up the RanorexPath which is, in RanorexSpy from where I have generated the code:
"/form[@controlname='MainForm']" for the MainForm and the Child is the Close Button with container[@controlname='WorkAreaPanel']/element/container[@caption='Workplace']/tabpage/tabpagelist/tabpage/button[@accessiblename='Close']
What I found out is that when I use "this.Form.Self.Activate();" the RanorexPath expression gets messed up. I think this is a bug in the RanorexPath Builder that adds the relative part from the close button a second time.
EDIT: When I don't use Activate() I get the following exception:
Ranorex.ElementNotFoundException: No element found for path 'container[@controlname='WorkAreaPanel']/element/container[@caption='Workplace']/tabpage/tabpagelist/tabpage/button[@accessiblename='Close']' within 10s.
Which in my opinion cannot be found because it does not search for the absolute path including the "/form[@controlname='MainForm']" part?!
Is there another way to ensure that the form is active? I thought it should not be necessary for the form to be active when I want to check whether a button is enabled or not but Ranorex couldn't find it when it was not the active window. So I tried it with the Activate() method.
Any hints or suggestions?
Best Regards
Philipp Dolder