Home > Back-end >  Master for help, getElementByID error message
Master for help, getElementByID error message

Time:10-09

Design an automatic landing site, login web site source code display button as follows:


I quoted in Delphi programs:
Doc:=UiWebBrowser1. Document as ihtmldocument2;
Userinputelement:=(doc. All. The item (" username ", 0) as ihtmlinputelement);
Userinputelement. Value:='test';
Pwdinputelement:=(doc. All. The item (' password2, 0) as ihtmlinputelement);
Pwdinputelement. Value:='test';
UIWebBrowser1. OleObject. GetElementByID (' btnlogin). Click;

Running in front of the normal, the last button automatically submit, he always appear
Method getelementbyid "" not supported by automation object

Excuse me each expert, how to solve the login

CodePudding user response:

Var
I: word;
Docs: OleVariant;

DOcs:=WEB OleObject. Document. GetElementsByTagName (" button ");
For I:=0 to docs. Do length - 1
The begin
If (docs. The item (I). The id='btnLogin') and (pos (' log in 'docs. The item (I) value) & lt;> 0) then
The begin
Docs. The item (I). Click;
break;
end;
end;

CodePudding user response:

Olevariant types at compile time Delphi do not check the grammar, direct execution... Such use is because getemementbyid not Delphi to own this kind of function.

CodePudding user response:

Should pay attention to the case of the problem,

CodePudding user response:

Let's write some code, I used should be OK:
 
Var BTN: IHTMLInputButtonElement;
BTN:=doc. All. The item (' btnLogin, 0) as IHTMLInputButtonElement;
(BTN as IHtmlElement). Click;

CodePudding user response:

OleObject. the document . GetElementByID (' btnlogin). Click;

I probably won't come back, study upstairs two code,
  • Related