I'm trying to get the text inside a span in a web browser, the problem is that the span does not have a id.
This is the code I've tried:
var findhuv1 = webBrowser2.Document.GetElementsByTagName("span").OfType<HtmlElement>()
.Where(html => html.GetAttribute("class").Equals("huv1")).FirstOrDefault().InnerText;
label14.Text = findhuv1;
This is the HTML code on the webpage:
<span class="huv1">6436347</span>
The problem is that my code only returns with an error:
System.NullReferenceException
System.Linq.Enumerable.FirstOrDefault<TSource>(...) returned null.
I need help to figure out what I'm doing wrong. I don't have access to edit the HTML codes on the webpage.