Уважаемые форумчане -как нажать ссылку типа
Код HTML:
<a class="button_medium" href="/game/battle/player/engage?opponent_id=2073360&drid=2444">Сражаться</a>
Пробовал через :
Код:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | var HtmlDocument : IHtmlDocument2;
i : integer ;
HtmlCollection : IHtmlElementCollection;
HtmlElement : IHtmlElement;
spisok : string ;
stop: integer ;
begin
HtmlDocument := WebBrowser1 . Document as IHtmlDocument2;
HtmlCollection := HtmlDocument . All;
for i := 0 to HtmlCollection . length - 1 do
begin
if stop = 1 then Exit;
HtmlElement := HtmlCollection . Item(i, 1 ) as IHtmlElement;
spisok := HtmlElement . InnerText;
Trim(spisok);
if spisok = 'Сражаться' then
begin
HtmlElement . click;
Exit;
end ;
end ;
end ;
|
-При нажатии не происходит абсолютно ничего, есть вариант с кодом:
Код:
1 | WebBrowser1 . OleObject . document . links . Item(номер_ссылки_в_документе). click
|
- но в моем случае номер ссылки постоянно меняется.
Объясните что не так в моем коде, или покажите пожалуйста как нужно?