void DownloadFile(object sender, WebBrowserDocumentCompletedEventArgs e)
{
HtmlElementCollection links = webBrowser1.Document.Links;
foreach (HtmlElement link in links) //
{
if (link.InnerText.Equals("*.pdf"))
{
link.InvokeMember("Click");
break;
}
}
}
How do I find the first instance of a pdf file using HTML element. I was trying to do *.pdf but it does not work.
Looks like you are using C#, you've tagged this as htmlelements which is a Java library, so you might have the wrong place.
However, if InnerText gets the link
href
(or if the link text contains the .pdf) then you probably want:EndsWith(".pdf")
instead of
Equals("*.pdf")
.