Webbrowser click button without name and ID DELPHI

1

I know that for me to click on 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 anyone help me in this case?

    
asked by anonymous 11.06.2016 / 06:37

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 the Microsoft HTML Object Library to have access to the IHTMLElement and IHTMLDocument2 types

    
13.06.2016 / 13:09