再就是单纯的找到网页上面的控件了,找到控件的方法有好多种,然后再填值
下在的代码是我的登陆考勤的代码,填写用户帐号和密码,并点按钮
var
Htm
levariant;
k:integer;
t:OleVariant;
begin
while WebBrowser1.ReadyState <READYSTATE_COMPLETE do
Application.ProcessMessages;
sleep(2000);
t := WebBrowser1.Document;
htm:=t.all.item(0,varEmpty);
for k := 0 to t.all.length - 1 do
begin
if (uppercase(t.all.item(k).tagName)='INPUT')and(uppercase(t.all.item(k).type)='TEXT') and (uppercase(t.all.item(k).name)='USERNAME') then
begin
t.all.item(k).value:=UserID;
RichEdit1.Lines.Add('填写用户名称:'+UserID+'时间:'+FormatdateTime('c',now));
end;
if (uppercase(t.all.item(k).tagName)='INPUT')and(uppercase(t.all.item(k).type)='PASSWORD') then
begin
t.all.item(k).value:=UserPwd;
RichEdit1.Lines.Add('填写用户密码:'+UserPwd+'时间:'+FormatdateTime('c',now));
end;
if (uppercase(t.all.item(k).tagName)='INPUT')and(uppercase(t.all.item(k).type)='SUBMIT') and (uppercase(t.all.item(k).name)='SUBMIT') then
begin
t.all.item(k).click;
RichEdit1.Lines.Add('点击登陆按钮,时间:'+FormatdateTime('c',now));
while WebBrowser1.ReadyState <READYSTATE_COMPLETE do
Application.ProcessMessages;
sleep(2000);
//WebBrowser1.Navigate('http://169.254.0.15:86//general/table_index.php');
WebBrowser1.Navigate(CUrl+'general/attendance/personal');
end;
end;
end;