procedure TForm1.Button1Click(Sender: TObject);
begin
web.Navigate('mail.163.com');
(((web.Document as IHTMLDocument2).body.all as
IHTMLElementCollection).item('username',0) as IHTMLTextAreaElement).value:='a'; //错在这行 (((web.Document as IHTMLDocument2).body.all as
IHTMLElementCollection).item('password',0) as IHTMLTextAreaElement).value :='b'
end;这样写的,不知道摸拟点登陆按钮要怎么写了??
begin
web.Navigate('mail.163.com');
(((web.Document as IHTMLDocument2).body.all as
IHTMLElementCollection).item('username',0) as IHTMLTextAreaElement).value:='a'; //错在这行 (((web.Document as IHTMLDocument2).body.all as
IHTMLElementCollection).item('password',0) as IHTMLTextAreaElement).value :='b'
end;这样写的,不知道摸拟点登陆按钮要怎么写了??
IHTMLElementCollection).item('username',0) as IHTMLTextAreaElement).value:='a'; //错在这行 (((web.Document as IHTMLDocument2).body.all as
IHTMLElementCollection).item('password',0) as IHTMLTextAreaElement).value :='b' 放在web的onnaviagecomplete(大概是这个名字吧)事件里
var
Docs, ovElements: OleVariant; try
WebBrowser1.Navigate('mail.163.com');
while WebBrowser1.ReadyState < READYSTATE_COMPLETE do
Application.ProcessMessages; Docs := WebBrowser1.OleObject.Document;
ovElements := Docs.GetElementByName('username');
ovElements.Value :='aaa'; Docs := WebBrowser1.OleObject.Document;
ovElements := Docs.GetElementByName('password');
ovElements.Value :='bbb'; Docs := WebBrowser1.OleObject.Document;
ovElements := Docs.GetElementByID('btn1');
ovElements.Click;
except end;
出来一个错误框:Project Project1.exe raised exception class EAccessViolation with message 'Access violation at address 0045424F in module 'Project1.exe'. Read of address 00000000'. Process stopped. Use Step or Run to continue
[Error] Unit1.pas(49): Missing operator or semicolon
[Fatal Error] Project1.dpr(5): Could not compile used unit 'Unit1.pas'
SHDocVw;
[Error] Unit1.pas(70): Declaration expected but 'TRY' found
[Fatal Error] Project1.dpr(5): Could not compile used unit 'Unit1.pas'加了也不行。哎
那么你已经引用了SHDocVw单元,重复的可以去掉 [Error] Unit1.pas(49): Missing operator or semicolon
检查一下哪儿缺分号,仔细检查
var
Docs, ovElements: OleVariant;
begin
try
Web.Navigate('mail.163.com');
while Web.ReadyState < READYSTATE_COMPLETE do
Application.ProcessMessages; Docs := Web.OleObject.Document;
ovElements := Docs.GetElementByName('username'); //错在这行
ovElements.Value :='aaa'; Docs := Web.OleObject.Document;
ovElements := Docs.GetElementByName('password');
ovElements.Value :='bbb'; Docs := Web.OleObject.Document;
ovElements := Docs.GetElementByID('btn1');
ovElements.Click;
except
end;
end;错误框里写着:Project Project1.exe raised exception class EOleError with message 'Method 'GetElementByName' not supported by automation object'. Process stopped. Use Step or Run to continue.
Docs, ovElements: OleVariant;
begin
try
Web.Navigate('mail.163.com');
while Web.ReadyState < READYSTATE_COMPLETE do
Application.ProcessMessages; Docs := Web.OleObject.Document;
ovElements := Docs.GetElementByID('username'); //错在这行
ovElements.Value :='aaa'; Docs := Web.OleObject.Document;
ovElements := Docs.GetElementByID('password');
ovElements.Value :='bbb'; Docs := Web.OleObject.Document;
ovElements := Docs.GetElementByID('btn1');
ovElements.Click;
except
end;
end;
var
Docs, ovElements: OleVariant;
begin
try
wbPage.Navigate('mail.163.com');
while wbPage.ReadyState < READYSTATE_COMPLETE do
Application.ProcessMessages; Docs := wbPage.OleObject.Document;
ovElements := Docs.GetElementsByName('username');
ovElements.value :='aaa'; Docs := wbPage.OleObject.Document;
ovElements := Docs.GetElementsByName('password');
ovElements.value :='bbb'; Docs := wbPage.OleObject.Document;
ovElements := Docs.GetElementByID('btn1');
ovElements.Click;
except end;
end;错在ovElements.value这个不行,我是用delphi7的