Is this the right Find Expression?

3 posts, 0 answers
  1. John
    John avatar
    2 posts
    Member since:
    May 2012

    Posted 26 Nov 2012 Link to this post

    I have the following anchor tag that I am trying to find.

     

     <li id="Benton County, WA" class="ui-menu-item" role="menuitem">

      <a class="ui-corner-all" tabindex="-1">Benton County, <strong>WA</strong></a>

     </li>

     

    I am using the following find expression, which always ends up being null.
    HtmlFindExpression expression = new HtmlFindExpression("id=Benton County, WA", "|", "tagname=a");

    What am I doing wrong?
  2. John
    John avatar
    2 posts
    Member since:
    May 2012

    Posted 26 Nov 2012 Link to this post

    Okay, more info...

    I must not be using the find expresion correctly because when I added logging it appears that the HtmlFindExpression is not null but that the object that I am trying to find is.

    Here is the code -
    [CodedStep(@"New Coded Step")]
    public void CORSWebTest_CodedStep()
    {
     
        // Verify element 'List Item' 'contains' Benton Co.
        HtmlFindExpression expression = new HtmlFindExpression("id=Benton County, WA", "|", "tagname=a");
     
        if (expression == null)
        {
            Log.WriteLine(LogType.Information, "HtmlFindExpression expression is null");
        }
        else
        {
            Log.WriteLine(LogType.Information, "HtmlFindExpression expression is not null");
        }
     
        var findByExpression = Pages.HomeCORS.Find.ByExpression<ArtOfTest.WebAii.Controls.HtmlControls.HtmlAnchor>(expression);
     
        if (findByExpression == null)
        {
            Log.WriteLine(LogType.Information, "Pages.HomeCORS.Find.ByExpression is null");
        }
        else
        {
            Log.WriteLine(LogType.Information, "Pages.HomeCORS.Find.ByExpression is not null");
            var tagName = Pages.HomeCORS.Find.ByExpression<ArtOfTest.WebAii.Controls.HtmlControls.HtmlAnchor>(expression).TagName;
        }
    }


  3. Plamen
    Admin
    Plamen avatar
    8 posts

    Posted 30 Nov 2012 Link to this post

    Hi John,

    I apologize for the delay in getting back to you on this. The HtmlFindExpression cannot be null in your case, because you are defining it in your code. As for the "findByExpression" element, it can be null if the element is not found using the Find Expression. However I cannot tell why you are unable to find that element without access to the actual page where this element is located. 

    I have created a sample demo page using the provided HTML snippet, however as you can see in this video, I wasn't able to reproduce the problem you are experiencing using the same find expression. To be able to help you further with this, please provide the means to reproduce the issue locally(either in your app or on a public site). Alternatively, you can capture a Fiddler trace using FiddlerCap and send it to us in a zip file. If you deem that information too sensitive for this forum, you can create a support ticket and attach it there. Thanks for providing the information we need to best assist you.

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