How to find a button with "value" in html page (Webbrowser - Delphi)
i have a html page that it have 3 forms with 3 submit buttons . buttons have no name but they have value :
<input type="submit" VALUE="Login">
How can i find this button with its value and click on it ?
开发者_StackOverflowThanks
procedure TForm1.Button1Click(Sender: TObject);
var
ovElements: OleVariant;
i: Integer;
begin
ovElements := WebBrowser1.OleObject.Document.forms.item(0).elements;
for i := 0 to (ovElements.Length - 1) do
if (ovElements.item(i).tagName = 'INPUT') and
(ovElements.item(i).type = 'SUBMIT') and
(ovElements.item(i).Value = 'Login') then
ovElements.item(i).Click;
end;
I use in this case my Procedure WB_send_Click_by_Value:
procedure WB_send_Click_by_Value(WB: TWebbrowser;form_nr:nativeint;tag,typ,val: string);
var ovElements: OleVariant;
i: Integer;
begin
ovElements := WB.OleObject.Document.forms.item(form_nr).elements;
for i := 0 to (ovElements.Length - 1) do
begin
if AnsiSameText(ovElements.item(i).tagName,tag) and
AnsiSameText(ovElements.item(i).type,typ) and
AnsiSameText(ovElements.item(i).value,val) then
ovElements.item(i).Click;
end;
end;
I use this Procedure for Buttons in WebPage Formular 1 like:
WB_send_Click_by_Value(Webbrowser1,0,'input','submit','ok');
or e.g. for RadioButtons in Form 2 like:
WB_send_Click_by_Value(Webbrowser1,1,'input','radio','dns');
精彩评论