Wierd whitespace character in RanoreXpath : Object Identification and Technologies

Wierd whitespace character in RanoreXpath

Technology specific object identification, supported applications, web technologies, and 3rd party controls.

Wierd whitespace character in RanoreXpath

Postby mdavidson » Mon Oct 10, 2011 4:06 pm

Hello all,

I have this issue with my AUT whereby the inner text value of a certain element contains a whitespace character that I am unable to account for in my tests.

The following is an example of the code used to produce the RanoreXpath for the element:

Code: Select all
DivTag divValue = Repository.VosDomXpath + "//div[@id~'dropdown']//div[@innertext='" + value + "']";


When the value 'Next Week' is passed in the value parameter, a RanoreXpath like this is produced:

Code: Select all
/dom[@domain='46.51.166.61']//div[@id~'dropdown']//div[@innertext='Next Week']


Problem is, an exception is thrown because this RanoreXpath yields no results... when I use the Spy tool to bring up the available values for the innertext attribute of the div I am looking for, the value 'Next Week' appears. This therefore produces the exact same RanoreXpath as the one shown above.

Why were these seemingly identical RanoreXpaths yielding different results?

To find out, I popped them both in notepad++ and used the 'Show All Characters' button (the one that reveals carriage return and whitespace characters) to see if there was any difference. At first there was not, however when I changed the character encoding from ANSI to UTF-8, notepad++ revealed this wierd whitespace character inbetween 'Next' and 'Week'. A screenshot of notepad++ revealing this is attached.

This character is obviously being produced by the AUT. With that in mind, How do I account for this? I need to pass in different values on the fly i.e. I cannot hard code this whitespace character in my tests...

Cheers in advance.
Attachments
screenshot.JPG
Notepad++ reveling the wierd whitespace character.
screenshot.JPG (40.66 KiB) Viewed 101 times
mdavidson
 
Posts: 3
Joined: Thu Jun 30, 2011 4:49 pm

Re: Wierd whitespace character in RanoreXpath

Postby Ciege » Mon Oct 10, 2011 7:09 pm

You can use a RegEx expression in your XPath. Check out the RegEx information in the User Guide: http://www.ranorex.com/support/user-guide-20/ranorexpath.html
If this or any response has helped you, please reply to the thread stating that it worked so other people with a similar issue will know how you fixed your issue!

Ciege...
User avatar
Ciege
 
Posts: 965
Joined: Thu Oct 16, 2008 7:46 pm
Location: Arizona, USA

Re: Wierd whitespace character in RanoreXpath

Postby mdavidson » Tue Oct 11, 2011 10:01 am

The aforementioned code is contained within a method, it's signature looks like this:

Code: Select all
public static void ChangeSearchFilter(string filter, string value, bool search = true) { ... }


Typical usage would therefore be:

Code: Select all
ChangeSearchFilter("Date Period", "Next Week");
ChangeSearchFilter("Location", "Bridge of Earn");
ChangeSearchFilter("Day of Week", "Tuesday");


The tests are parameterized and these particular values are typically entered in by non-technical users. Also, as seen above, not all values passed in have whitespace in them.

Obviously I can do the regex within the method; how would I go about acheiving this?

My initial thought would be to use regex to match any whitespace characters against the supplied value and replace them with some regex that would do the same in the RanoreXPath.

this is fine, I was just wondering if there was a better way of doing this?

Cheers
mdavidson
 
Posts: 3
Joined: Thu Jun 30, 2011 4:49 pm

Re: Wierd whitespace character in RanoreXpath

Postby mdavidson » Tue Oct 11, 2011 10:41 am

I have overcome this issue with the following code (as suggested above):

Code: Select all
DivTag divValue = Repository.VosDomXpath + "//div[@id~'dropdown']//div[@innertext~'" + value.Replace(" ", @"\s") + "']";


It was more straightforward than I had anticipated! :)
mdavidson
 
Posts: 3
Joined: Thu Jun 30, 2011 4:49 pm

Re: Wierd whitespace character in RanoreXpath

Postby Support Team » Tue Oct 11, 2011 10:50 am

Hi,

you can also simply copy/paste the string form Notepad++ to your assignment if you don't want to use the mentioend regexp.

Regards,
Tobias
Support Team
User avatar
Support Team
Site Admin
 
Posts: 4845
Joined: Fri Jul 07, 2006 5:30 pm
Location: Graz, Austria


Return to Object Identification and Technologies

Who is online

Users browsing this forum: No registered users and 0 guests