Hi,
I'm running win 7 as administrator, with UAC off. I run my tests in single separate process in Nunit.
Here is scenario:
I have some dialog which contains beside other controls two buttons, 'Link' and 'Cancel'.
When I click on 'Link' button some message box appears. When I close message box I try to click on 'Cancel' but my button cannot be found. But when I try to click on "Cancel' without clicking on 'Link' and hence not showing message box, my 'Cancel' button can be found.
I though it might be something with cache option in repository, I turned off caching, but problem was still here.
Than I tried to change my path to 'Cancel' button and I was able to find it.
But the problem is that I'll need to have 2 RxPaths for same button depending on whether message box has been shown or not, which is pretty unuseful.
Path before message box is shown is: element[@controlName='cancelButton']/button
And after message box is shown is: button[@controlName='cancelButton']
More info, I tried to search for path using Ranorex Spy in both situations, but Ranorex Spy always returns same path, this one: element[@controlName='cancelButton']/button
So by ranorex spy I was able to find element even after message box appearing, but through automation API I wasn't able.
Why is this happening? How can I solve it?
RxPath changing in runtime
- Support Team
- Site Admin
- Posts: 12145
- Joined: Fri Jul 07, 2006 4:30 pm
- Location: Houston, Texas, USA
- Contact:
Re: RxPath changing in runtime
Hi,
For further information about the RanoreXPath please have a look at follwoign chapters of our user guide:
RanoreXPath
RanoreXPath Editor
RanoreXPath - tips and tricks
Regards,
Tobias
Ranorex Team
Basically the follwoing RanoreXPath will fit both scenarios:WajdaW wrote:Path before message box is shown is: element[@controlName='cancelButton']/button
And after message box is shown is: button[@controlName='cancelButton']
Code: Select all
//*[@controlName='cancelButton']
RanoreXPath
RanoreXPath Editor
RanoreXPath - tips and tricks
Regards,
Tobias
Ranorex Team
Re: RxPath changing in runtime
How should I cast this element to button adapter since once it can be Element with child element of type Button, and once can be Button?Code: Select all
//*[@controlName='cancelButton']
- Support Team
- Site Admin
- Posts: 12145
- Joined: Fri Jul 07, 2006 4:30 pm
- Location: Houston, Texas, USA
- Contact:
Re: RxPath changing in runtime
Hi,
basically you can also use the RanoreXPath:
which will also work for both scenarios, as a button is always an element too.
Regards,
Tobias
basically you can also use the RanoreXPath:
Code: Select all
element[@controlName='cancelButton']
Regards,
Tobias
Re: RxPath changing in runtime
Thanks Tobias, I used /*[@controlname='cancelButton'] path.
And than I checked in runtime whether element is Button or not, if not than I used it's child.
That solved problem.
Best regards,
Vladimir
And than I checked in runtime whether element is Button or not, if not than I used it's child.
That solved problem.
Best regards,
Vladimir
Re: RxPath changing in runtime
Hi there,
It looks like I have a very similar problem to that discussed in this thread. My Ranorex Spy goes from recognizing /container and /text element to generalizing them both to elements and appending a new /text element onto the path as shown below.
My initial ranorex path that worked the previous 2 days:
1)
My ranorex path that worked this morning:
2)
And a couple of hours later:
3)
10 minutes later, the path reverted back to code snippet #2.
Just to note, I'm using .Net 4.0 on a 64-bit machine and the problem only seems to occur when the application we're testing is closed and re-opened. I'm wondering if the path name inconsistency has to do with some setting that I am unaware of?
Or maybe I can solve the problem like the original poster did.
I'm thinking of changing the path to the following "//element[@controlname='txtFileNamePrefix']".
It looks like I have a very similar problem to that discussed in this thread. My Ranorex Spy goes from recognizing /container and /text element to generalizing them both to elements and appending a new /text element onto the path as shown below.
My initial ranorex path that worked the previous 2 days:
1)
Code: Select all
"/form[@controlname='formBarcodeProcess']/container/text[@controlname='txtFileNamePrefix']"
2)
Code: Select all
"/form[@controlname='formBarcodeProcess']/element[@controlname='grpBinderInfo']/element[@controlname='txtFileNamePrefix']/text[@accessiblename='Attachment Name:']"
3)
Code: Select all
"/form[@controlname='formBarcodeProcess']/container/text[@controlname='txtFileNamePrefix']
/text[@accessiblename='Attachment Name:']"
Just to note, I'm using .Net 4.0 on a 64-bit machine and the problem only seems to occur when the application we're testing is closed and re-opened. I'm wondering if the path name inconsistency has to do with some setting that I am unaware of?
Or maybe I can solve the problem like the original poster did.
I'm thinking of changing the path to the following "//element[@controlname='txtFileNamePrefix']".
Re: RxPath changing in runtime
For anyone else wondering what the original poster's solution code is for checking if that element (or its child) is of the desired type, here's some sample code of how I think it's done:
When I came back to my machine this morning all my original paths from code snippet #1 were working again... So temporarily I'm all set, though I'm sure it will be short lived.
Code: Select all
Ranorex.Text textArea;
Ranorex.Core.Element textElement;
if(Host.Local.TryFindSingle("element path name here", 2000, out textElement)
{
if( textElement.As<Text>() != null )
{
//the element is of type text.
textArea = textElement.As<Text>();
}
else if( textElement.Children[0].As<Text>() != null)
{
//the child is your text element.
textArea = textElement.Children[0].As<Text>();
}
}
- Support Team
- Site Admin
- Posts: 12145
- Joined: Fri Jul 07, 2006 4:30 pm
- Location: Houston, Texas, USA
- Contact:
Re: RxPath changing in runtime
Hi,
(http://www.ranorex.com/support/user-gui ... files.html),
so we can help you to figure things out.
Another helpful adapter (next to the ' * ' adapter) would be the 'optional' adapter ' ? ', since in snippet 1 and 3 your element is wrapped in a container and in snippet 2 it isn't.
With this adapter it is possible to mark some parts of a path as optional which means that the referred elements can be found even if optional parts of the path do not exist (e.g. container).
Kind regards,
Larissa
Ranorex Support Team
Usually the path should always be built the same way. If the problem occurs again, please make snapshotsI'm wondering if the path name inconsistency has to do with some setting that I am unaware of?
(http://www.ranorex.com/support/user-gui ... files.html),
so we can help you to figure things out.
'//' will work of sure.Or maybe I can solve the problem like the original poster did.
I'm thinking of changing the path to the following "//element[@controlname='txtFileNamePrefix']".
Another helpful adapter (next to the ' * ' adapter) would be the 'optional' adapter ' ? ', since in snippet 1 and 3 your element is wrapped in a container and in snippet 2 it isn't.
With this adapter it is possible to mark some parts of a path as optional which means that the referred elements can be found even if optional parts of the path do not exist (e.g. container).
Kind regards,
Larissa
Ranorex Support Team