Short answer is: there is no all scripts completed
event, so it's not possible.
However, if you are looking for a solution
and not for a short not possible
, consider this:
Indy TIdHTTP does not handle JS scripts at all and it should not do it. Its functionality is to perform (GET, POST, ...) HTTP requests.
Contrary, browsers have built-in JS engine to handle client side scripts. The problem is that they can run continuously, well, even with some pauses. Browsers have just DOM
is loaded
event. Many websites have attached code to this event to execute later JS code.
The majority of websites runs a series of DOM transformation client scripts after DOM is ready
event and after this we may somehow consider that the page is ready to be read by the real human users or web scrapers.
To catch this state there are some approaches to consider:
- A timer. Simplest but not the best, load the page and wait some time. Consider here network problems, or page changes, that later may take more or less time. Sometimes excessive waiting waste execution time.
- A periodic DOM element/property check. Sometimes scripts add some properties or elements when the needed state is reached. Analyze your ready loaded website.
- Busy or ReadyState. TWebBrowser or OLE
B := CreateOleObject('InternetExplorer.Application');
have Busy and ReadyState properties. You may check if it is not Busy for some time, consider it complete.
- An intelligent combination of the ways mentioned above. For example Browser.Busy with a Timeout may do the trick. If the site is specific and one, an element lookup may work. This is preferred way to go.
Considering this you may define your own function NavigateAndWaitComplete(URL, [Element], Timeout)
that will do the magic.