| |

VerySource

 Forgot password?
 Register
Search
View: 825|Reply: 2

After opening the page in WebBrowser, to click a button, how to achieve it, please advise!

[Copy link]

1

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-1-28 00:00:01
| Show all posts |Read mode
Thank you!
Reply

Use magic Report

0

Threads

21

Posts

15.00

Credits

Newbie

Rank: 1

Credits
15.00

 United States

Post time: 2020-3-9 22:00:01
| Show all posts
IHTMLElement: click
Reply

Use magic Report

0

Threads

8

Posts

9.00

Credits

Newbie

Rank: 1

Credits
9.00

 China

Post time: 2020-3-17 17:30:01
| Show all posts
uses MSHTML;

procedure TForm1.WebBrowser1DocumentComplete (Sender: TObject;
  const pDisp: IDispatch; var URL: OleVariant);
var
  vHTMLDocument2: IHTMLDocument2;
  vHTMLElement: IHTMLElement;
  vHTMLElementCollection: IHTMLElementCollection;
begin
  if not Assigned (TWebBrowser (Sender) .Document) then Exit;
  TWebBrowser (Sender) .OnDocumentComplete: = nil; // only once
  vHTMLDocument2: = TWebBrowser (Sender) .Document as IHTMLDocument2;
  vHTMLElementCollection: = vHTMLDocument2.body.all as IHTMLElementCollection;
  vHTMLElement: = vHTMLElementCollection.item ('q', 0) as IHTMLElement;
  if not Assigned (vHTMLElement) then Exit;
  (vHTMLElement as IHTMLInputElement) .value: = 'Delphi';
  vHTMLElement: = vHTMLElementCollection.item ('btnG', 0) as IHTMLElement;
  if not Assigned (vHTMLElement) then Exit;
  vHTMLElement.click;
end;

procedure TForm1.FormCreate (Sender: TObject);
begin
  WebBrowser1.Navigate ('http://www.google.cn');
end;
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list