Page 2 of 2

Re: Add Regular Expression when using a Variable

Posted: Thu Dec 13, 2012 4:56 pm
by AccidentReport
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?

Re: Add Regular Expression when using a Variable

Posted: Thu Dec 13, 2012 5:41 pm
by Support Team
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

Re: Add Regular Expression when using a Variable

Posted: Fri Dec 14, 2012 8:32 am
by AccidentReport
Great thanks!

Re: Add Regular Expression when using a Variable

Posted: Wed May 15, 2013 6:26 pm
by blackout
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 (^_^)

Re: Add Regular Expression when using a Variable

Posted: Thu May 16, 2013 4:18 pm
by Support Team
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)

Re: Add Regular Expression when using a Variable

Posted: Thu May 16, 2013 6:16 pm
by blackout
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.

Re: Add Regular Expression when using a Variable

Posted: Fri May 17, 2013 1:57 pm
by Support Team
Hello,

That sounds great.
You are welcome :-)

Regards,
Markus (T)