Webbrowser click nameless button and DELPHI ID

Asked

Viewed 1,654 times

1

I know for me to click this button here!

<input type="submit" id="btnSubmit"  name="avancar" value="   Avancar  " onclick="return onSubmit();">

I use this code

webBrowser1.OleObject.Document.all.Item('avancar', 0).click;

more when the button has no name what I do in this case here

<td><a href="javascript:void(0)" class="button-default" onclick="calcula()">Calcular</a></td>

Can someone help me on this case ?

1 answer

1

try this:

procedure TForm1.btnFazerClick(Sender: TObject);
var
   documento: IHTMLDocument2;
   elemento: IHTMLElement;
   intIndex: Integer;
begin
   documento := wbGeral.Document as IHTMLDocument2;
   for intIndex := 0 to documento.links.length - 1 do
   begin
      elemento := documento.links.item(intIndex, '') as IHTMLElement;
      if elemento.innerText = 'Calcular' then
      begin
         elemento.click;
         Exit;
      end;
   end;
end;

Import Activex Microsoft HTML Object Library to access Ihtmlelement and Ihtmldocument2 types

Browser other questions tagged

You are not signed in. Login or sign up in order to post.