NotExists on Repository Item w\ RanoreXPath with Regular Exp

Ask general questions here.
tgagel
Posts: 33
Joined: Tue Jun 04, 2013 7:50 pm

NotExists on Repository Item w\ RanoreXPath with Regular Exp

Post by tgagel » Tue Jun 04, 2013 8:24 pm

Hello all,

My company is evaluating Ranorex and I'm having an issue with the Exists and NotExists Validations against a Repository item with a RanoreXPath which uses Expressions. Specifically I'm trying to creating a generic reusable validation which checks the page for an error message and, if an error exists, the validation fails. What I'm seeing is that my NotExists validation is always passing even if the repository item (the error) is on the page. Shouldn't it fail if it is finding the item?

My repository item has an Xpath like this:

Code: Select all

/dom[@domain~'.*myurl1.com' or @domain~'.*.*myurl2.com' or @domain~'.*.*myurl3.com']//div[@id='ctl00_ValidationSummary' and @visible='True']
(My company has identical sites at different urls, thus the need to do the or's for the domains.

I've also tried the repository item like this (since the error text is red) with the same results:

Code: Select all

/dom[@domain~'.*myurl1.com' or @domain~'.*.*myurl2.com' or @domain~'.*.*myurl3.com']//div[@style~'color:.*Red.*']
Setting up a 1 step NotExists script to find either of these repository items results in the test always passing, even when the item is clearly on the screen and the repository is able to find it via the 'Highlight Element' option. My script is very basic and looks like this:
- Validate
- NotExists
- MyObjectFromRepository

This test passes if whether repository item exists or does not exist. If I change the validation to a simpler object from the repository, like an element I just recorded, NotExist and Exist work as expected. Am I doing something wrong in my RanoreXPath? I'm confused because I'd expect 'Highlight Element' and the validation run to be consistent.

Thanks.
Last edited by tgagel on Wed Jun 05, 2013 1:15 pm, edited 1 time in total.

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

Re: NotExists on Repository Item w\ RanoreXPath with Regular Exp

Post by Support Team » Tue Jun 04, 2013 9:21 pm

I noticed that your RanoreXPaths are not valid, they are missing a bracket "]" after the attribute myurl3.com'. Is this just an editing error when you copied the paths to the forum post? It should actually not be possible to add such a path to the repository :D

Have you tried to highlight the repository item using a right click on the item and selecting "Highlight Element"?
Have you tried a longer timeout for the repository item?

Regards,
Alex
Ranorex Team
.
Image

tgagel
Posts: 33
Joined: Tue Jun 04, 2013 7:50 pm

Re: NotExists on Repository Item w\ RanoreXPath with Regular Exp

Post by tgagel » Wed Jun 05, 2013 1:18 pm

Thanks for the reply.

The missing bracket was a copy/paste/edit error. Fixed.

I am able to highlight the item via right-click and 'Highlight Element'.

I upped the timeout on the repository item from 100ms to 1s and the test now works as expected. (Although 500ms still doesn't work). I'll try the full test using the 1s timeout and check the results.

Thanks!

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

Re: NotExists on Repository Item w\ RanoreXPath with Regular Exp

Post by Support Team » Wed Jun 05, 2013 2:01 pm

Hi,

Please notice that one second is still not a very long timeout.

The Search Timeout property defines the maximum time which Ranorex should take in order to search for the corresponding element.
As soon as Ranorex finds the element the corresponding action is performed. Ranorex "waits" until the element is found or the time is up.

Regards,
Markus
.
Image

tgagel
Posts: 33
Joined: Tue Jun 04, 2013 7:50 pm

Re: NotExists on Repository Item w\ RanoreXPath with Regular Exp

Post by tgagel » Wed Jun 05, 2013 2:59 pm

Right. I do have a validation checking to make sure the page loads before the NotExists error validation runs. So far the 1 second timeout is doing exactly what I want.

A somewhat related question/issue I'm sometimes having. I am setting up our repository such that the 'App Root Folder' has the domain set with a regular expression like:

Code: Select all

Base: /dom[@domain~'.*myurl1.com' or @domain~'.*.*myurl2.com' or @domain~'.*.*myurl3.com']
This allows me to play back the tests from this repository in any of our several urls fine. However I'm trying to build more of the repository out and Ranorex sometimes wants to create a new 'App Root Folder' for the newly recorded repository items. (So it creates a new 'app root folder' with a base like "Base: /dom[@domain='www.myurl1.com']" for example). When it captures the items this way I cannot move the items into my main app root folder.

I say sometimes because earlier it was working like described above (creating a new 'app root folder') but I just tried again and it added the item into my main 'app root folder' like I wanted. Any tips or ways to ensure Ranorex records into an existing 'app root folder'? (I have no idea why it didn't work and then resolved itself for me but it was pretty painful there for a while).

Thanks.

tgagel
Posts: 33
Joined: Tue Jun 04, 2013 7:50 pm

Re: NotExists on Repository Item w\ RanoreXPath with Regular Exp

Post by tgagel » Wed Jun 05, 2013 8:46 pm

I believe I figured this out. I already had that item and name in my repository so when I recorded it a second time it made the new app root folder. After resolving the duplicate name I am able to move the items into my main app root folder.

tgagel
Posts: 33
Joined: Tue Jun 04, 2013 7:50 pm

Re: NotExists on Repository Item w\ RanoreXPath with Regular Exp

Post by tgagel » Fri Jun 07, 2013 3:10 pm

Well, I'm back to struggling with my original problem again and it does seem to be a repository timeout thing. I now have to increase the repository search timeout to 10 seconds to ensure that the NotExists validation finds the error and fails appropriately. (It ends up finding it after 7 or 8 seconds with the 10 second timeout). Since this element will not exist 99% of the time and this validation is run on every page in our application, I don't want to have the timeout to be very long (10 seconds would add a ton of extra time to the tests since the test is repeated and will timeout/pass most of the time). I'm further confused because when I use the 'Highlight Element' option on my 'ErrorMessageVisible' repository item it, when it exists, finds and highlights it in less than a second. Why is the Validate NotExists of that same repository item taking significantly longer? Any suggestions on optimizing this validation?

Thanks.

krstcs
Ranorex Guru
Posts: 2683
Joined: Tue Feb 07, 2012 4:14 pm
Location: Austin, Texas, USA

Re: NotExists on Repository Item w\ RanoreXPath with Regular Exp

Post by krstcs » Fri Jun 07, 2013 3:49 pm

Assuming the object does not exist, ValidateNotExist waits for the full time-out of the item being searched for in order to make sure it, in fact, doesn't exist. This is by design.

If the item DOES exist, the ValidateNotExist routine will fail immediately because the item exists.

This is exactly the opposite of the ValidateExist routine.

I would recommend looking at your test situation again and seeing if there is a better way to check for the condition you want since it sounds like this may not be the best way.

In a test you should know going in what data inputs and what expected outputs there should be. There should not be a situation where you have unknown expected results for a test case. If there is a timing issue with the system under test, you might just need to have the timeouts set higher. If this test case is 99%, then you might want to see what the 1% condition is and see if there is a way to isolate the two cases so you know what to expect every time.
Shortcuts usually aren't...

tgagel
Posts: 33
Joined: Tue Jun 04, 2013 7:50 pm

Re: NotExists on Repository Item w\ RanoreXPath with Regular Exp

Post by tgagel » Fri Jun 07, 2013 4:16 pm

Thanks for the reply.
krstcs wrote:If the item DOES exist, the ValidateNotExist routine will fail immediately because the item exists.
Regarding this, when the item (the error message) does exist the NotExists routine doesn't fail immediately. It searches for 7 or 8 seconds before finding it failing the test. The 'Highlight Element' option in the repository finds the same item much quicker (< 1 second). I'm not sure why there is a such a significant difference in the timing.
krstcs wrote:I would recommend looking at your test situation again and seeing if there is a better way to check for the condition you want since it sounds like this may not be the best way.
I'll have to give it more thought but in our application the page may load fine and an error message at the top indicates something behind the scenes or in the setup is wrong. I'm not sure if there's another way to flag when this error exists then a Validate Exists (or NotExists in my case since passing means it's not there). If the Validate NotExists would fail as quickly as the repository finds the item (when present), it would work great.

krstcs
Ranorex Guru
Posts: 2683
Joined: Tue Feb 07, 2012 4:14 pm
Location: Austin, Texas, USA

Re: NotExists on Repository Item w\ RanoreXPath with Regular Exp

Post by krstcs » Fri Jun 07, 2013 4:29 pm

OK, so that brings up some questions. I don't mean any offense, as you might have done these, but I wanted to make sure. :D Sometimes we get tunnel-visioned on problems and miss the simple stuff.

It sounds like the repository object is not matching up with the object in the SUT.

1. Have you verified that the item in your script is the same one you are looking at in the repository?
2. Have you verified that the item in the repository has the same path as the object in the system under test?
3. Have you used spy to look at the SUT object to make sure there aren't any changes happening at run-time that would make Ranorex not find the XPath that the repository object points to?
4. Have you tried putting both Exist and NotExist in the same script pointing at the same object? This might show you that one passes and one fails so you can see the situations more clearly. I would set them to not stop on failure in the step properties. It will still show the failure in the report, but it will allow it to continue on to the next step so you can see both.

Just some thoughts.
Shortcuts usually aren't...

tgagel
Posts: 33
Joined: Tue Jun 04, 2013 7:50 pm

Re: NotExists on Repository Item w\ RanoreXPath with Regular Exp

Post by tgagel » Fri Jun 07, 2013 9:02 pm

Thanks for the advice. I went back into the Spy tool and found a quicker way to identify the error. The test now fails out when the error exists in about a second and a half instead of the 7 or 8 from before.

krstcs
Ranorex Guru
Posts: 2683
Joined: Tue Feb 07, 2012 4:14 pm
Location: Austin, Texas, USA

Re: NotExists on Repository Item w\ RanoreXPath with Regular Exp

Post by krstcs » Fri Jun 07, 2013 9:33 pm

Great! Always better when the automation takes LESS time than manual testing... :D
Shortcuts usually aren't...