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 : How can i find this button wit
Solution 1:
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;
Solution 2:
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');
Post a Comment for "How To Find A Button With "value" In Html Page (webbrowser - Delphi)"