Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Netzwerke (https://www.delphipraxis.net/14-netzwerke/)
-   -   Delphi TWebbrower and how to click an image button with no id or tags? (https://www.delphipraxis.net/180422-twebbrower-how-click-image-button-no-id-tags.html)

direktor 19. Mai 2014 13:52

TWebbrower and how to click an image button with no id or tags?
 
Hello,

I have a problem. Does anyone have any idea how to click an image button with no id or tags in TWebBrowser? The button code is below:

<BUTTON aria-disabled=true style="POSITION: relative; WIDTH: 16px" class=x-btn-text tabIndex=0 aria-describedby=x-auto-2 __eventBits="6144">&nbsp;
<IMG style="POSITION: absolute; WIDTH: 12px; BACKGROUND: url(https://na1.sf.com/projRes/datacloud...CCDA.cache.png) no-repeat -12px 0px; HEIGHT: 12px; TOP: 2px; LEFT: 1px" class=" x-btn-image" role=presentation border=0 src="https://na1.sf.com/projRes/datacloud/gen/datacloud.listview.Jigsaw/clear.cache.gif" onload='this.__gwtLastUnhandledEvent="load";' __gwtLastUnhandledEvent="load">
</BUTTON>

Any idea is welcome.

Volker Z. 19. Mai 2014 21:07

AW: TWebbrower and how to click an image button with no id or tags?
 
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-text' then
        begin
          s := e.getAttribute ('tabIndex', 0);
          if s = '0' then
            e.click
        end
    end
end;
Best regards

direktor 20. Mai 2014 05:57

AW: TWebbrower and how to click an image button with no id or tags?
 
Volker thank you for your reply. This bastards used a new technique developed only a few months ago. Check this out:

http://www.w3.org/wiki/PF/XTech/HTML5/RoleAttribute
http://www.w3.org/TR/2013/WD-wai-ari...cessiblewidget
http://www.w3.org/TR/2011/CR-wai-aria-20110118/
http://www.w3.org/TR/2013/WD-wai-ari...30307/#aria_ex
http://www.w3.org/TR/2013/WD-wai-ari...0307/#keyboard
http://www.w3.org/WAI/PF/
http://www.w3.org/TR/
http://www.w3.org/TR/xhtml-role/
http://www.w3.org/1999/xhtml/

They replaced custom html tags and objects with user defined controlled by javascript widgets. That's you you see <button ... instead of <input type=button...

direktor 20. Mai 2014 08:14

AW: TWebbrower and how to click an image button with no id or tags?
 
Volker you are a genious! It really works!

Tomski 23. Feb 2021 11:02

AW: TWebbrower and how to click an image button with no id or tags?
 
Danke Volker, diese Routine klappt hervorragend...


Alle Zeitangaben in WEZ +1. Es ist jetzt 12:30 Uhr.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz