День добрый. Господа, не пойму где я ошибся? Суть: найти нужный элемент по ссылке и нажать на него программно. При повторном нажатии на Button2 - вылетает ошибка .
Последовательность действий:
Button1 - ОК
Button2 - ОК
Button1 - ОК
Button2 - "Invalid floating point operation".
Код:
procedure TForm1.Button1Click(Sender: TObject);
begin
WebBrowser1.Navigate('http://urz.be/f84');
end;
Код:
procedure TForm1.Button2Click(Sender: TObject);
var
pole: Variant;
i: Word;
Document: IHtmlDocument2;
str: string;
begin
if pos('images/', Edit3.Text) <> 0 then
begin
for i := 0 to WebBrowser1.OleObject.Document.Images.Length - 1 do
begin
try
Document := WebBrowser1.Document as IHtmlDocument2;
Str := (Document.Images.Item(i, 0) as IHTMLImgElement).Href;
if Pos(Edit3.Text, str) <> 0 then ((Document.Images.Item(i, 0) as IHTMLImgElement) as IHTMLElement).click;
except
end;
end;
end
else
begin
try
pole:=WebBrowser1.OleObject.Document.getElementByid(Edit3.Text);
pole.Click;
except
end;
end;
end;