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

Find.ByContent partial match

3 Answers 50 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Steve
Top achievements
Rank 1
Steve asked on 14 Aug 2013, 08:25 PM
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?

3 Answers, 1 is accepted

Sort by
0
Mario
Telerik team
answered on 19 Aug 2013, 08:14 PM
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
0
Steve
Top achievements
Rank 1
answered on 19 Aug 2013, 09:07 PM
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

0
Mario
Telerik team
answered on 22 Aug 2013, 08:08 PM
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
Tags
General Discussions
Asked by
Steve
Top achievements
Rank 1
Answers by
Mario
Telerik team
Steve
Top achievements
Rank 1
Share this question
or