본문 바로가기

.NET/C#

webbrowser control c#에서 특정 엘러먼트 찾기

HtmlElementCollection elc = this.webBrowser2.Document.GetElementsByTagName("a"); // a 태그를 다 찾는다

            foreach (HtmlElement el in elc)

            {

                var id = el.GetAttribute("id"); 특성값이 id 인 모든 엘러먼트를 찾는다.

                if (id.Contains("test")) 엘러먼트 id값이 test인 엘러먼트를 찾는다.

                {

                    el.InvokeMember("click"); // 해당 엘러먼트를 클릭한다.

                }

            }



혹시 class특성으로 찾으시려면 className으로 특성을 찾아야합니다.


class는 안되더라고요