Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Notification when a given script is loaded #87

Open
o0Djeen0o opened this issue Dec 22, 2017 · 0 comments
Open

Notification when a given script is loaded #87

o0Djeen0o opened this issue Dec 22, 2017 · 0 comments

Comments

@o0Djeen0o
Copy link

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 :

  • wait for goTo() promise to be resolved, but then it is too late for me, as execution of scriptC is already done.

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:

  • I must use a dedicated QUnit runner for tests and, thus, have some callbacks definitions to inject in order to be notified.
  • I cannot ask users to put a dedicated script for that in the scripts requests. (let's say a script B', to be ran just between script B and C), as the solution must also work without this runner, so no custom dev possible in client final solution.

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 ;-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant