This is a migrated thread and some comments may be shown as answers.

How to use RegEx in Find Logic?

5 Answers 429 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Madhu
Top achievements
Rank 1
Madhu asked on 09 May 2011, 07:58 PM
Hello Support,

How to use Regular Expressions (RegEx) in building a Find logic?
If you could have any tutorial/videos, it will really helpful.

Thanks,
Madhu.

5 Answers, 1 is accepted

Sort by
0
Anthony
Telerik team
answered on 09 May 2011, 11:42 PM
Hello Madhu,

Check out the detailed step-by-step guide on Test Studio. A simple search on "RegEx" will take you to the chapter on regular expression:
http://www.telerik.com/documents/automated-testing-tools/WebUITestStudioQAEditionStepByStep.pdf

Test Studio uses regular expressions the same way they're used in the .NET Framework. What this means is that you can look at any .NET RegEx tutorials. Here is an example I found useful:
http://support.microsoft.com/kb/308252  

In this tutorial you can see an example:
Regex emailregex = new Regex("(?<user>[^@]+)@(?<host>.+)"); 
which is a regular expression object used to describe an e-mail pattern. For instance:
johndoe@tempuri.org

If you wanted to verify an e-mail link using Test Studio you can use the same regular expression in your regex verification: (?<user>[^@]+)@(?<host>.+)

I hope this answers your question; please don't hesitate to contact us again if you need more help.

Regards,
Anthony
the Telerik team
Do you think you know all the new features coming out in Test Studio R1 2011? Think again - we have some surprises and will share them with you in the What's New in Test Studio R1 2011 Webinar on May 12th.
Register Today!
0
Rohit
Top achievements
Rank 2
answered on 19 Jan 2012, 12:29 PM
How to find an element using expression.

My Scenario is :-
In My application there is link generated at Run time. It is a hyperlink which contain(IA:Auto1234567890 | rohit malhotra | 4000 rs)
I want to find this hyperlink with only this string "Auto1234567890" instead of  (IA:Auto1234567890 | rohit malhotra | 4000 rs) exact same. 

i used the code snippet below:-

Manger.ActiveBrowser.Imagehyperlink.Find.ByTextContent("Auto1234567890").Highlight();
Manger.ActiveBrowser.Imagehyperlink.Find.ByTextContent("~Auto1234567890").Highlight(); (contains)
Manger.ActiveBrowser.Imagehyperlink.Find.ByTextContent("%{Auto1234567890}%").Highlight(); (using wild cards)

All are fails Element not found :( :( :( :( :( 


but it fail  :( :( :( :( :(  


Please help me how can i find the element which contains string only "Auto1234567890" instead of  (IA:Auto1234567890 | rohit malhotra | 4000 rs) exact same.



 
0
Anthony
Telerik team
answered on 19 Jan 2012, 04:24 PM
Hello Rohit,

Use the following code to locate a link based on a partial match of its text content:

HtmlAnchor a = Find.ByExpression<HtmlAnchor>("textcontent=~Auto1234567890");
Assert.IsNotNull(a);
a.Click();

Find more information here.

Kind regards,
Anthony
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Rohit
Top achievements
Rank 2
answered on 20 Jan 2012, 10:03 AM
Hi Anthony,

we are using silverlight application please tell me solution regarding the same.
0
Anthony
Telerik team
answered on 20 Jan 2012, 04:09 PM
Hello,

Use the following code to locate a Silverlight element based on a partial match of its text content: 

SilverlightApp app = ActiveBrowser.SilverlightApps()[0];
FrameworkElement fe = app.Find.ByTextContent("~Auto1234567890");
fe.User.Click();

See here for more information. 

Regards,
Anthony
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
General Discussions
Asked by
Madhu
Top achievements
Rank 1
Answers by
Anthony
Telerik team
Rohit
Top achievements
Rank 2
Share this question
or