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

Is this the right Find Expression?

2 Answers 87 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
John
Top achievements
Rank 1
John asked on 26 Nov 2012, 11:57 PM
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 Answers, 1 is accepted

Sort by
0
John
Top achievements
Rank 1
answered on 27 Nov 2012, 12:13 AM
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;
    }
}


0
Plamen
Telerik team
answered on 30 Nov 2012, 11:48 AM
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
Tags
General Discussions
Asked by
John
Top achievements
Rank 1
Answers by
John
Top achievements
Rank 1
Plamen
Telerik team
Share this question
or