Can regular expressions or something similar be used in Finds?

2 posts, 0 answers
  1. Dren
    Dren avatar
    10 posts
    Member since:
    Aug 2011

    Posted 08 Oct 2012 Link to this post

    Hi,

    The Silverlight application I am testing has a popup with the text inside it "Cannot delete ABC." where ABC is the name of the object.

    Doing this works and it finds the popup:
    var foundPopup = popup.VisualTree.Find.ByExpression(new XamlFindExpression("TextContent=Cannot delete ABC"));


    But...
    The object isn't always going to be called ABC. I'd like to parameterise it. I was hoping a regular expression or something like that could be used to do this.

    What is the best way to have a wildcard substitute for ABC?

    Thanks,
    Dren
  2. Plamen
    Admin
    Plamen avatar
    8 posts

    Posted 11 Oct 2012 Link to this post

    Hello Dren,

    If only the 'ABC' is changing, it's easiest to use the tilde (~) to indicate a partial match based on the static portion of the string:
    var foundPopup = popup.VisualTree.Find.ByExpression(new XamlFindExpression("TextContent=~Cannot delete"));


    All the best,
    Plamen
    the Telerik team
    Quickly become an expert in Test Studio, check out our new training sessions!
    Test Studio Trainings
Back to Top