День добрый. Господа, не пойму где я ошибся? Суть: найти нужный элемент по ссылке и нажать на него программно. При повторном нажатии на Button2 - вылетает ошибка .
Последовательность действий:
Button1 - ОК
Button2 - ОК
Button1 - ОК
Button2 - "Invalid floating point operation".
Код:
1 2 3 4 | procedure TForm1 . Button1Click(Sender: TObject);
begin
end ;
|
Код:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | 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 ;
|