C # How to query by tagname and name in the webbrowser1 Control
// Prevent multiple page refresh operations
If (Num = 1 )
{
String GetUserName = system. configuration. configurationsettings. deleetask [ " Y2000username " ]. Tostring ();
String Getuserpassword = system. configuration. configurationsettings. deleetask [ " Y2000userpassword " ]. Tostring ();
Int A = 1 ;
Int All = webbrowse zafen r1.document. Body. All. count;
For ( Int I = 0 ; I <all; I ++)
{
Htmlelement getelement = webbrowser1.document. All [I];
// Obtain the element containing the input tag
If (Getelement. tagname. toupper (). tostring () = " Input " )
{
// Locate the element based on the name attribute of input and assign a value to the user name input box.
If (Getelement. Name. tostring () = " Username " )
{
Webbrowser1.document. All [I]. setattribute ( " Value " , GetUserName );
}
Shi Dafu sprinkled on the doctor's sofa // Find this element based on the name attribute of input and assign a value to the password input box.
If (Getelement. Name. tostring () = " Passwd " )
{
Webbrowser1.document. All [I]. setattribute ( " Value " , Getuserpassword );
} 1
// Based on the name attribute of input, find the submit button and execute the action
If (Getelement. Name. tostring () = " Submit " )
{0, 222222
// Filter elements with the same "name = submit" on the click Page
If (A = 1 )
{
Webbrowser1.document. All [I]. invokemember ( " Click " );
}
A ++;
}
}
Num ++;
}
Element (when no ID is available) traverses the form Element