I'm trying to find a parent Div by the <h2> TextContent = "Cleaning and Inspection (LLT)" by iterating throw aReadOnlyCollection of HtmlDivs and get a NullException.
public
ReadOnlyCollection<HtmlDiv> InfoObjectList
{
get
{
return
GetDataTab().Find.AllByExpression<HtmlDiv>(
"class=infoObjPrint"
);
}
}
public
virtual
HtmlDiv GetInfoObject(
string
infoObjectText)
{
foreach
(var item
in
InfoObjectList)
{
var text = item.Find.ByContent(
"h2"
).TextContent.Trim();
if
(text.Equals(infoObjectText))
{
return
item;
}
}
return
null
;
}
<
div
class
=
"infoObjPrint"
id
=
"S05842977912008092400000"
>
<
a
data-name
=
"S05842977912008092400000"
></
a
>
<
h2
><
span
class
=
"searchTermHighlight"
>Cylinder Head</
span
> Cleaning and Inspection (LLT)</
h2
>
<
div
class
=
"tipsContainer"
data-id
=
"S05842977912008092400000"
></
div
>
<
p
>
<
span
class
=
"clsListTitle"
>Tools Required</
span
>
</
p
>
<
ul
class
=
"clsBULLET"
>
<
li
>
<
span
class
=
"clsEmphBOLD"
>EN 46122 </
span
>