Помощь - Поиск - Пользователи - Календарь
Полная версия этой страницы: Twebbrowser
Форум программистов > Системное программирование > Delphi и Pascal > Delphi - Сети
Rampl
Подскажите как программно нажать на ссылку с определенным InnerText, в Twebbrowsere?
etc
TWebBrowser.Navigate + F1
Rampl
procedure TForm1.Button2Click(Sender: TObject);
var
  HtmlDocument: IHtmlDocument2;
  HtmlCollection: IHtmlElementCollection;
  HtmlElement: IHtmlElement;
  I: Integer;
begin
  HtmlDocument := WebBrowser1.Document as IHtmlDocument2;
  HtmlCollection := HtmlDocument.All;
  HtmlCollection := HtmlCollection.Tags('A') as IHTMLElementCollection;
  for I := 0 to HtmlCollection.Length - 1 do begin
  HtmlElement := HtmlCollection.Item(i, 0) as IHtmlElement;
    


end;
end;

Что дальше надо написать чтобы произошел click с определенным InnerText?
etc
InnerText тут для поиска? вы прочитали справку по указанному методу?
Rampl
Мне надо найти ссылку в WebBrowser1 и нажать на неё.
Нашёл решение.
procedure TForm1.Button2Click(Sender: TObject);
var
  HtmlDocument: IHtmlDocument2;
  HtmlCollection: IHtmlElementCollection;
  HtmlElement: IHtmlElement;
  I: Integer;
begin
  HtmlDocument := WebBrowser1.Document as IHtmlDocument2;
  HtmlCollection := HtmlDocument.All;
  HtmlCollection := HtmlCollection.Tags('A') as IHTMLElementCollection;
  for I := 0 to HtmlCollection.Length - 1 do begin
    HtmlElement := HtmlCollection.Item(i, 0) as IHtmlElement;
    if   HtmlElement.InnerText = 'текст ссылки' then
    begin
     HtmlElement.click;
  end;
end;
end;
Для просмотра полной версии этой страницы, пожалуйста, пройдите по ссылке.
Форум IP.Board © 2001-2008 IPS, Inc.