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

detect events fired on document load #1654

Open
raquelhortab opened this issue Jul 26, 2022 · 0 comments
Open

detect events fired on document load #1654

raquelhortab opened this issue Jul 26, 2022 · 0 comments

Comments

@raquelhortab
Copy link

Hi,
I am trying to detect events / function calls (more specifically an alert) that is fired directly when the document loads (it is placed directly on the script tag, not binded by any event listener:

<script language="JavaScript">
    alert("CODELEARN");  
</script>

but it does not seem to work

I got this on the preload script

window.alert = function(message) {
  send('page', 'alert', message)
}

and

beforeEach(() => {
  nightmare.on('page', (type, message) => {
  if (type == 'alert'){
     alert_messages.push(message);
  }
}

I then check in the test whether I got the expected alert_messages.

This works when the alert is triggered by a click or some other event but not with the example above.

Does anyone know a way to check this other than, for example, duplicating the script tag during the test?

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

No branches or pull requests

1 participant