Webbrowser GetAttribute("class") Method Not Working
When working with Webbrowser's GetAttribute() method, you often encountered an issue wherein GetAttribute("class") does not work as expected. 1 2 3 if (Element.GetAttribute( "class" ).Contains( "_textFontColor" )) { //other codes here } After investigating from MSDN docs, I found out a comment below the documentation which states that you have to use className instead of class. Well, that did the trick. :-) 1 2 3 4 5 6 7 8 9 10 11 12 13 HtmlElementCollection elements = WebBrowser1.Document.GetElementsByTagName( "A" ); foreach (HtmlElement Element in elements) { if (Element.GetAttribute( "className" ).Contains( "_textFontColor" )) { //other codes here } } HtmlElementCollection elements = WebBrowser1.Document.GetElementsByTagName( "a" ); foreach (HtmlElement Element in elements) { if (Element.GetAttribute( "className" ).Contains( "_textFontColor" ))