Skip to content

Instantly share code, notes, and snippets.

@kamituel
Created September 27, 2013 08:17
Show Gist options
  • Save kamituel/6725575 to your computer and use it in GitHub Desktop.
Save kamituel/6725575 to your computer and use it in GitHub Desktop.
Steps to reproduce bug in Casper.js
<!doctype html>
<html>
<body>
<button id="indexBtn">Open popup</button>
<script>
document.querySelector('button').addEventListener('click', openPopup);
function openPopup () {
window.open('popup.html', 'name', 'width=750, height=300');
}
</script>
</body>
</html>
<!doctype html>
<html>
<body>
<button id="popupBtn">Close</button>
<script>
document.querySelector('button').addEventListener('click', function () {
window.close();
});
</script>
</body>
</html>
'use strict';
casper.test.begin('Popup issue', function (test) {
casper.start('index.html', function () {
test.assertExists('button#indexBtn');
this.click('button');
});
casper.withPopup(/popup/, function () {
this.echo('Within popup');
this.click('button');
});
casper.then(function () {
this.echo('Back to the index.html');
test.assertExists('button#popupBtn');
test.done();
});
});
casper.run();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment