Delphi7 WebBrowser Klikanie w button

0

Ema

Jak Kliknąć w przycisk w Webbrowser
w PHp wygląda to tak:

<input type="image" class="button sendButton" src="adresobrazka" alt="Wyślij wiadomość" title="Wyślij wiadomość">

W delphi daje tak:
WebBrowser1.OleObject.Document.getElementById('sendButton').click;

ale nie działa ;/

0

W ten sposób nie odnajdziesz, bo nie ma imienia.
Trzeba iterować wszystko aby go odnaleźć.

0

Na pewno się jakoś da bo jest program napisany w delphi 7 i klika ten button ;), więc musi być sposób

0

więc musi być sposób

Przeczytaj ponownie post @_13th_Dragon

2

A jak ma działać gdzie w tym kodzie HTML anie PHP widzisz atrybut id="sendButton" ?
Trochę miało tego kodu HTML gdyby było więcej można by znaleźć lepszy sposób niż szukanie wszystkich input (np. można by przeszukać tylko określony form)

var
  Document: IHTMLDocument3;
  Elements: IHTMLElementCollection;
  Element: IHTMLInputElement;
  i: Integer;
begin
  Document:= WebBrowser1.Document as IHTMLDocument3;
  if Assigned(Document) then
  begin
    Elements:= Document.getElementsByTagName('input');
    if Assigned(Elements) then
    begin
      for i:=0 to Elements.length - 1 do
      begin
        Element:= Elements.item(i, EmptyParam) as IHTMLInputElement;
        if (AnsiCompareStr(Element.type_, 'image') = 0) and
            (AnsiCompareStr(Element.alt, 'Wyślij wiadomość') = 0) then
        begin
          //IHTMLElement(Element).click; ten kod powodował Access Violation w nowych Delphi 
          OleVariant(Element).click; //ten działa w starych i nowych
          break;
        end;
      end;
    end;
  end;
end;
0

Dokładnie chodzi o wysyłanie wiadomości w chomikowych rozmowach ( chomikuj.pl )

Cały kod ( chyba ;d )

<div class="messageRow alt" id="messageForm">
<form action="/action/ChomikChat/SendMessage" id="chatSendMessage" method="post"><input id="TargetChomikId" name="TargetChomikId" type="hidden" value="1356719" /><input id="Mode" name="Mode" type="hidden" value="Last" /><input id="bskr" name="bskr" type="hidden" value="-8588421355628118025" /><div class="maniac avatar"><a href="/" title=""><img alt="" src="" /><span></span></a></div>        <p class="userInfo">
            <a href="#">k</a></p>
<textarea cols="20" id="chomikChatMessage" name="Message" rows="2">
</textarea>        <input type="image" class="button sendButton" src="http://x1.static-chomikuj.pl/res/2e4e98b866.png" alt="Wyślij wiadomość" title="Wyślij wiadomość" />
        <div class="clear">
        </div>
</form>    <a id="sendMessageValidator" class="validator errorText"  href="javascript:;" rel="nofollow"></a>
</div>
0

W takim razie wystarczy:
WebBrowser1.OleObject.Document.getElementById('chatSendMessage').submit;

0

Nie działa
Po wykonaniu funkcji przekierowuje mnie na//chomikuj.pl/Error404.aspx?aspxerrorpath=/action/ChomikChat/SendMessage

chatSendMessage zmieniałem na inne ale ten sam efekt

1 użytkowników online, w tym zalogowanych: 0, gości: 1