Find.ByContent partial match

4 posts, 0 answers
  1. Steve
    Steve avatar
    35 posts
    Member since:
    Jan 2011

    Posted 14 Aug 2013 Link to this post

    I have an HtmlListItem with the following innerText:

    Emergency Override ConfidentialEmergency Medical CareQualified Service OrganizationPatient conscious, hystericalTo avert serious threats to health or safetyPursuant to reporting of abuse, or violencePursuant to Public Health ActivitiesPursuant to law enforcement activitiesPursuant to activities of Medical Examiner

    This property is coming from it's child HtmlUnorderedList with it's children HtmlListItems.  Its parent is an HtmlUnorderedList.  If I do the following, the find works:

    HtmlUnorderedListObject.Find.ByContent<HtmlListItem>("Emergency Override ConfidentialEmergency Medical CareQualified Service OrganizationPatient conscious, hystericalTo avert serious threats to health or safetyPursuant to reporting of abuse, or violencePursuant to Public Health ActivitiesPursuant to law enforcement activitiesPursuant to activities of Medical Examiner", FindContentType.InnerText);


    But, doing the following does not:
    HtmlUnorderedListObject.Find.ByContent<HtmlListItem>("p:Emergency Override Confidential", FindContentType.InnerText);

    Is the space in the partial string throwing the Find off?

  2. Mario
    Admin
    Mario avatar
    8 posts

    Posted 19 Aug 2013 Link to this post

    Hi Steve,

    Thank you for contacting Telerik Support.

    As an alternative, could you try to use the ByExpression find method to locate the same list item by its innertext? Let me know whether that works, for example:

    HtmlUnorderedListObject.Find.ByExpression<HtmlListItem>("InnerText=~Emergency Override Confidential");

    If this is successful, we may have some issue with the original code which, to me, looks to have proper syntax. I will wait for your response to continue my investigation.

    Regards,
    Mario
    Telerik
    Quickly become an expert in Test Studio, check out our new training sessions!
    Test Studio Trainings
  3. Steve
    Steve avatar
    35 posts
    Member since:
    Jan 2011

    Posted 19 Aug 2013 Link to this post

    Works perfectly - from the immediate window in Visual Studio:

    var pus = _browser.Find.ById<HtmlUnorderedList>(AARReasonListULId).Find.ByExpression<HtmlListItem>("InnerText=~Emergency Override Confidential");

    {HtmlListItem:<li style="width: 100% !important; white-space: nowrap !important;" class="has_child">}

    base {ArtOfTest.WebAii.Controls.HtmlControls.HtmlContainerControl}: {HtmlListItem:<li style="width: 100% !important; white-space: nowrap !important;" class="has_child">}

    var vomit = _browser.Find.ById<HtmlUnorderedList>(AARReasonListULId).Find.ByContent<HtmlListItem>("p:Emergency Override Confidential", FindContentType.InnerText);

    null

  4. Mario
    Admin
    Mario avatar
    8 posts

    Posted 22 Aug 2013 Link to this post

    Hi Steve,

    Thanks for the update. There seems to be an issue with the Find.ByContent method while indicating a partial match ('p:') and only after changing FindContentType to InnerText (as I found it to work correctly with an alternate example using the default, TextContent). I have created this entry in our public Feedback Portal for our devs to continue with the investigation.

    Luckily the workaround I provided you in my last reply should be just as reliable. Please let me know whether you have any additional questions.

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