The entire quoted unit mshtml;
Path: C:\windows\assembly\GAC\Microsoft.mshtml\7.0.3300.0__b03f5f7f11d50a3a\Microsoft.mshtml.dll//Different version paths are different
First, how to use WebBrowser to get all the source code of the Web page
1. No frame included
String s= WB1. DocumentText;
2. Contains the framework
IHTMLDocument2 doc=wb1. Document.domdocument as IHTMLDocument2;
IHTMLFramesCollection2 Frames=doc.frames as IHTMLFramesCollection2;
int i_frame=0; 1th Frame
IHTMLWindow2 Frame=frames.item (ref i_frame) as IHTMLWindow2;
IHTMLDocument2 doc2=frame.document as IHTMLDocument2;
IHTMLDocument3 doc3=frame.document as IHTMLDocument3;
strings = Doc2.body.innerHTML;
Second, WebBrowser how to get the elements of the Web page
1. Based on element ID
HtmlElement ele= WB1. document.getElementById ("ID");
2. Depending on the element name
HtmlElement ele= WB1. document.all["Name"];
3. No ID, no name element
3.1 WebBrowser traverse the page elements:
HTMLDocument doc=wb1. Document;
HtmlElementCollection Elements=doc. All;
foreach (htmlelement element in elements)
{
if (element. GetAttribute ("innerText") = = "Submit Answer")//element's Innnertext attribute is "submit Answer"
{
Element. InvokeMember ("click"); Analog click
Break
}
}
3.2 WebBrowser based on the tag traversal of the element (input, a,img,span,li,div,etc.)
Input: All types that can be entered, such as text box, tick box, check box, drop-down list, picture, etc.
A:A tags, can be linked with hyperlinks
IMG: Picture Type
Span:span type
Li: Drop-down list, list box, etc.
Div:div
HtmlElementCollection eles = WB1. document.getElementsByTagName ("a") as htmlelementcollection;
foreach (HtmlElement ele in Eles)
{
if (ele. GetAttribute ("href")! = null)
if (ele. GetAttribute ("href") = = "Hyperlink to a label")
{
element. InvokeMember ("click"); Analog Click
Break
}
}
3.3 Index number according to the element
HtmlElement ele= WB1. DOCUMENT.ALL[0]; A 1th element
HtmlElement ele= WB1. document.getElementsByTagName ("input") [0]; Element of the first inuput type
3.4 Getting unknown elements based on known elements
C # WebBrowser Development Guide