Created
February 9, 2018 12:32
-
-
Save vzaidman/b28a9abad7174c252be514f95bf4c249 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
yield Nightmare() | |
.goto('http://yahoo.com') | |
.type('input[title="Search"]', 'github nightmare') | |
.click('.searchsubmit') | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
phantom.create(function (ph) { | |
ph.createPage(function (page) { | |
page.open('http://yahoo.com', function (status) { | |
page.evaluate( | |
function () { | |
var el = document.querySelector('input[title="Search"]') | |
el.value = 'github nightmare' | |
}, | |
function (result) { | |
page.evaluate( | |
function () { | |
var el = document.querySelector('.searchsubmit') | |
var event = document.createEvent('MouseEvent') | |
event.initEvent('click', true, false) | |
el.dispatchEvent(event) | |
}, | |
function (result) { | |
ph.exit() | |
} | |
) // page.evaluate | |
} | |
) // page.evaluate | |
}) // page.open | |
}) // ph.createPage | |
}) // phantom.create | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment