The string you pass to the
GetAttribute[
^] method is the
name of the attribute you want to retrieve.
You are passing in the
value of the attribute called
class
. That will not work. There is no such attribute, and there never can be, because attribute names cannot contain spaces.
You
could change your test to:
if (link.GetAttribute("class") == "ipsNotificationCount ipsHide")
{
...
}
But that would be inefficient, and likely to break if the order of the class names changed, or another class was added to the element.
Instead, use the
GetElementsByClassName[
^] method to find the element(s) with the specified class:
var links = GeckoWB.Document.GetElementsByClassName("ipsNotificationCount");
foreach (var link in links)
{
string value = link.GetAttribute("data-currentcount");
if (!string.IsNullOrWhiteSpace(value))
{
int currentCount;
if (int.TryParse(value, out currentCount))
{
...
}
}
}