LucianoGanga / simple-headless-chrome

Simple abstraction to use Chrome as a Headless Browser with Node JS
MIT License
217 stars 50 forks source link

Notification when a given script is loaded #87

Open o0Djeen0o opened 6 years ago

o0Djeen0o commented 6 years ago

Hi,

I'm facing an issue and don't know if it can be resolved with simple-headless-chrome.

Here is a simple example : A final user has several scripts to be loaded in a page. I must react when a given script is loaded (let's say scriptB).

<!DOCTYPE html>
<html>

<head>
    <title>Unit tests for Rate Plan Component</title>
    <meta http-equiv='X-UA-Compatible' content='IE=edge'>
    <meta charset="utf-8">

    <script src="scriptA.js"/>
    <script src="scriptB.js"/>

    <!-- SEND an evaluateAsync() when script B is loaded ! -->

    <script src="scriptC.js"/>
</head>

<body>

  ...

</body>

</html>

For now, all I've found using this project is :

From DEBUG logs, I can see : HeadlessChrome:events:Network -- Network.loadingFinished

So I guess that knowledge of scripts loaded are possible, but maybe not available.

Context:

So, is there any (easy) way to be notified when a script is effictivly loaded using simple-headless-chrome ?

PS: BTW, really nice and helpful library ;-)