Dziękuję za odpowiedź, ale nadal nie mogę sobie poradzić.
Mam takie kody:
wywołuję stronę przyciskiem, ale tu też mam problem. Po kliknięciu przycisku i wyświetleniu strony muszę ponownie kliknąć przycisk wywołania strony, żeby program analizował formularz.
'WebBrowser2.Navigate('https://login.ingbank.pl/mojeing/app/#login');'
W zdarzeniu WebBrowser2 dodałem kod:
procedure TForm1.WebBrowser2DocumentComplete(Sender: TObject;
const pDisp: IDispatch; var URL: OleVariant);
var
Elements: IHTMLElementCollection;
elem: IHTMLInputElement;
i: Integer;
CurrentBrowser: IWebBrowser2;
TopBrowser: IWebBrowser2;
Doc3 : IHTMLDocument3;
begin
try
CurrentBrowser := pDisp as IWebBrowser2;
TopBrowser := (Sender as TWebbrowser).DefaultInterface;
if Assigned(CurrentBrowser) and Assigned(TopBrowser) then
begin //if assigned
if CurrentBrowser = TopBrowser then
begin //if CurrentBrowser
Doc3 := CurrentBrowser.Document as IHTMLDocument3;
Doc3.getElementById('login-input').setAttribute('value', 'login', 0);
Elements:= Doc3.getElementsByTagName('input');
if Assigned(Elements) then
begin // if Assigned(Elements)
for i:=0 to Elements.length - 1 do
begin //for i
elem:= Elements.item(i, EmptyParam) as IHTMLInputElement;
try
if Pos('button', elem.src) >= 0 then
begin
OleVariant(elem).click; showmessage('click');
end;
except
showmessage('błąd przycisku');
end;
end; //for i
end; // if Assigned(Elements)
end; //if CurrentBrowser
end;//if assigned
except
showmessage('błąd WebBrowser2DocumentComplete');
end;
end;
Jak użyję
Doc3.getElementsByTagName('button');
to w
if Pos('button', elem.src) >= 0 then
nie znajduje button
Jak użyję
Doc3.getElementsByTagName('input');
to w
if Pos('button', elem.src) >= 0 then
znajduje przycisk, to wyświetla showmessage, ale nie klika w przycisk.
Proszę o podpowiedź.