Use Regex in Verification

6 posts, 0 answers
  1. Chandresh
    Chandresh avatar
    41 posts
    Member since:
    May 2015

    Posted 01 Jun 2015 Link to this post

    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

  2. Ivaylo
    Admin
    Ivaylo avatar
    782 posts

    Posted 04 Jun 2015 Link to this post

    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!
  3. Chandresh
    Chandresh avatar
    41 posts
    Member since:
    May 2015

    Posted 09 Jun 2015 in reply to Ivaylo Link to this post

    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

  4. Ivaylo
    Admin
    Ivaylo avatar
    782 posts

    Posted 09 Jun 2015 Link to this post

    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!
  5. subhash
    subhash avatar
    6 posts
    Member since:
    Apr 2019

    Posted 11 Jun Link to this post

    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

  6. Plamen Mitrev
    Admin
    Plamen Mitrev avatar
    91 posts

    Posted 13 Jun Link to this post

    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!
Back to Top