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

Use Regex in Verification

5 Answers 71 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Chandresh
Top achievements
Rank 1
Chandresh asked on 01 Jun 2015, 07:47 AM

Hi,

 

I want to verify footer information of my site using verify command in TestStudio ide. Let say my footer information is like "Demo version 1.20.01 Copyright 2015". 

I have a version number stored in global variable in Utility class.

 

How can I use Regex to verify this in one statement with global variable ?

 

Thanks,

Chandresh Parmar

5 Answers, 1 is accepted

Sort by
0
Ivaylo
Telerik team
answered on 04 Jun 2015, 07:24 AM
Hello Chandresh,

This request is not Test Studio related, you can learn how to build your regex using this website.

Thank you for your understanding.

Regards,
Ivaylo
Telerik
 
The New Release of Telerik Test Studio Is Here! Download, install,
and send us your feedback!
0
Chandresh
Top achievements
Rank 1
answered on 09 Jun 2015, 05:07 AM

Hello Ivaylo,

Thanks for the reply. I resolved this by created Coded Step instead of using regular step and it worked as I wanted.

 

Thanks,

Chandresh

0
Ivaylo
Telerik team
answered on 09 Jun 2015, 11:05 AM
Hello Chandresh,

Glad to hear you were able to resolve this.

Regards,
Ivaylo
Telerik
 
The New Release of Telerik Test Studio Is Here! Download, install,
and send us your feedback!
0
subhash
Top achievements
Rank 1
answered on 11 Jun 2019, 11:57 AM

Hi

Could you please help me with the coded step for the verification of text content using regular expression
The DOM will look like this 

<div id="ID123" style="">
AutomationTest: Verify Text Message1. <br><br>
<b>Verify Text Message2</b>
<br>Verify Text Message3
<br>
<br>
<b>
Verify Text Message4.
<br>
<br>
<b>Verify Text Message5</b>
<ul class="bullet">
<li>Verify Text Message6</li>
</ul>
<b>Verify Text Message7</b>
<ul class="bullet"><li>Verify Text Message8 Tagen</li>
</ul>
</div>

Need to verify the content  using RegEx "AutomationTest: Verify Text Message1."

This content will be changing dynamically, so i tried using with coded test step, however i'm getting the error as "Object reference not set to an instance of an object."

 HtmlDiv topdiv = Find.ByXPath<HtmlDiv>("//div[@id='ID123']/text()[1]");
            topdiv.AssertContent().TextContent(ArtOfTest.Common.StringCompareType.RegEx,"AutomationTest: Verify Text Message1.");

Could you please advice on this scenario.
Thank you

Subhash

0
Plamen Mitrev
Telerik team
answered on 13 Jun 2019, 12:07 PM
Hello Subhash,

I hosted the DOM tree locally and ran the code, which you have shared. The error that you have experienced is caused by the HtmlDiv's find expression, which does not return a valid element. I did some changes to the XPath and the rest of your code works. Please check the changes I did and apply them to your test project.
HtmlDiv topdiv = Find.ByXPath<HtmlDiv>("//div[@id='ID123']");

I hope the above example will help you automate this scenario.

Regards,
Plamen Mitrev
Progress Telerik
 
The New Release of Telerik Test Studio Is Here! Download, install,
and send us your feedback!
Tags
General Discussions
Asked by
Chandresh
Top achievements
Rank 1
Answers by
Ivaylo
Telerik team
Chandresh
Top achievements
Rank 1
subhash
Top achievements
Rank 1
Plamen Mitrev
Telerik team
Share this question
or