procedure TForm1.Button1Click(Sender: TObject);
var
Doc: IHTMLDocument2;
userinputelement, pwdinputelement: ihtmlinputelement;
begin
doc := WebBrowser1.document as ihtmldocument2;
userinputelement := (doc.all.item(‘username’, 0) as ihtmlinputelement);
userinputelement.value := Trim(‘aaaaaaaa’);
pwdinputelement := (doc.all.item(‘userpwd’, 0) as ihtmlinputelement);
pwdinputelement.value := Trim(‘bbbbbbb’);
//模拟点击按钮
//WebBrowser1.OleObject.document.all.item(‘btnLogin’).click;
//根据按钮ID来模拟点击
// WebBrowser1.OleObject.document.getElementByID(‘btnLogin’).click ;
//按第几个按钮来点击
//WebBrowser1.OleObject.document.getElementsByTagName(‘Input’).item(4).click;
//串
//模拟登录如下。
WebBrowser1.oleobject.document.Forms.Item(0, 3).submit;
end;
发表评论