Add Regular Expression when using a Variable

Ask general questions here.
AccidentReport
Posts: 76
Joined: Tue Dec 04, 2012 2:30 pm

Re: Add Regular Expression when using a Variable

Post by AccidentReport » Thu Dec 13, 2012 4:56 pm

I only require one variable in the string at this point.

I have created a repository variable called varVariableName.

I have then modified my RxPath for the item to option[@innertext='DOW - '+$varVariableName+' {IN}'].

The test now finds the value correctly. One thing though. Is it possible to make it case insensitive?

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

Re: Add Regular Expression when using a Variable

Post by Support Team » Thu Dec 13, 2012 5:41 pm

Hi,

I am glad it works now.
In the UserGuide section about the RxPath is a example about how to make it case insensitive, I copied it for you:
listitem[@text~'(?i:MyTeXt)']
matches the regular expression case-insensitive, e.g. 'mytext', 'MYTEXT','mYTeXT', ...

Regards,
Markus
.
Image

AccidentReport
Posts: 76
Joined: Tue Dec 04, 2012 2:30 pm

Re: Add Regular Expression when using a Variable

Post by AccidentReport » Fri Dec 14, 2012 8:32 am

Great thanks!

blackout
Posts: 14
Joined: Thu Mar 14, 2013 10:07 am

Re: Add Regular Expression when using a Variable

Post by blackout » Wed May 15, 2013 6:26 pm

Guys, thought I'd revive this thread as it's almost exactly what I'm after...and I seen a screenshot that was EXACTLY what I was after...but then nothing came of it.

I've got my head around repository variables for the most part (I think) but there's a scenario whereby the variable is in the domain.

If I then pass this into the code using something like:

Code: Select all

repo.r_repoVariable = "www.test.com"
it loads the page fine. However, waiting for the page to load fails.

Code: Select all

WebDocument webDoc = "/dom[@domain="+repo.r_serverName+"]";
         webDoc.WaitForDocumentLoaded();
This is causes the output for the domain to be:
I don't understand why it's loading the page fine, yet failing the WaitForPageLoad, when the XPath is:

Code: Select all

/dom[@domain=$r_servername]

Any & all assistance would be greatly appreciated.

Cheers



*EDIT* Nevermind, realised what was happening. Forgot a couple of apostrophes (^_^)

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

Re: Add Regular Expression when using a Variable

Post by Support Team » Thu May 16, 2013 4:18 pm

Hello,

It seems that you have missed the single quotes before/after the domain value.
Could you please try to use the following code snippet instead:
WebDocument webDoc = "/dom[@domain='"+repo.r_serverName+"']";
webDoc.WaitForDocumentLoaded();
Could you please try to set a higher timeout for WaitForPageLoaded (e.g. 5000)?

Regards,
Markus (T)
.
Image

blackout
Posts: 14
Joined: Thu Mar 14, 2013 10:07 am

Re: Add Regular Expression when using a Variable

Post by blackout » Thu May 16, 2013 6:16 pm

Thanks Markus,

I had actually edited the post prior to your response stating what you said, haha. You were spot on ;-)

Funny you should actually say set a longer timeout, possibly around 5000...as due to the fact I couldn't get this working initially, I set a delay with duration 5000 to replace it.

Great mind think alike?


Cheers again.

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

Re: Add Regular Expression when using a Variable

Post by Support Team » Fri May 17, 2013 1:57 pm

Hello,

That sounds great.
You are welcome :-)

Regards,
Markus (T)
.
Image