Add Regular Expression when using a Variable : General Questions

Add Regular Expression when using a Variable

Ask general questions here.

Add Regular Expression when using a Variable

Postby Nadeem » Tue Dec 06, 2011 3:07 pm

Hello,

Somebody might have touched on this topic already but i failed to find it in my search so decided to post my question.

I am validating to check the innertext of en element; so my XPath is as follows:

".............\div/div/div/h2[@innertext~'(?i:06 December 2011)']"

Now, obviously the date will change and I want to pass that through as a variable, whereby it gets picked from an Excel spreadsheet using the formula "=TEXT(TODAY(),"dd mmmm yyyy")".

I am using the regular expression of ~'(?i:06 December 2011)'] because Excel displays the date as "06 December 2011" and the innertext value equals "06 december 2011". Hence, me using this expression matches the text regardless of case sensitivity.

Now my problem is this, how can i keep this regular expression but pass the value through as a variable. If i do the below, Ranorex does not identify it as a variable. :?

".............\div/div/div/h2[@innertext~'(?i:$Var_CurrentDate)']"

Clearly i am not doing it correctly, more to the point, can we?

I do not want to use code as we are trying to refrain from any code. Reason being, we want our solution accessible to all Testers (who lack C# experience) so that they can modify the scripts if required.

Regards
Nadeem
Nadeem
 
Posts: 10
Joined: Fri Jul 01, 2011 10:26 am

Re: Add Regular Expression when using a Variable

Postby Support Team » Tue Dec 06, 2011 4:41 pm

Hi,
Nadeem wrote:Clearly i am not doing it correctly, more to the point, can we?

You could use following RxPath to solve your issue.
div/div/div/h2[@innertext~'(?i:'+$Var_CurrentDate+')']

You are able to concatenate variables in the RxPath with the char + as you know it from a string in code.

Regards,
Peter
Ranorex team
User avatar
Support Team
Site Admin
 
Posts: 4837
Joined: Fri Jul 07, 2006 5:30 pm
Location: Graz, Austria


Return to General Questions

Who is online

Users browsing this forum: No registered users and 0 guests