Einzelnen Beitrag anzeigen

Volker Z.

Registriert seit: 3. Dez 2012
Ort: Augsburg, Bayern, Süddeutschland
419 Beiträge
 
Delphi XE4 Ultimate
 
#2

AW: TWebbrower and how to click an image button with no id or tags?

  Alt 19. Mai 2014, 21:07
Hello,

Zitat:
I have a problem. Does anyone have any idea how to click an image button with no id or tags in TWebBrowser?
I don' t know whether this particular button becomes unique by the attributes classname and tabIndex; if so you could try it this way:

Delphi-Quellcode:
procedure TForm1.Button1Click(Sender: TObject);
var
  d : IHTMLDocument3;
  c : IHTMLElementCollection;
  i : Integer;
  e : IHTMLElement;
  s : string;
begin
  d := WebBrowser1.Document as IHTMLDocument3;
  if not Assigned (d) then
    Exit;

  c := d.getElementsByTagName ('button');
  for i := 0 to c.length - 1 do
    begin
      e := c.item (i, EmptyParam) as IHTMLElement;
      if not Assigned (e) then
        Exception.Create ('Your message');

      if e.className = 'x-btn-textthen
        begin
          s := e.getAttribute ('tabIndex', 0);
          if s = '0then
            e.click
        end
    end
end;
Best regards
Volker Zeller
  Mit Zitat antworten Zitat