Skip to content

Instantly share code, notes, and snippets.

@vzaidman
Created February 9, 2018 12:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vzaidman/b28a9abad7174c252be514f95bf4c249 to your computer and use it in GitHub Desktop.
Save vzaidman/b28a9abad7174c252be514f95bf4c249 to your computer and use it in GitHub Desktop.
yield Nightmare()
.goto('http://yahoo.com')
.type('input[title="Search"]', 'github nightmare')
.click('.searchsubmit')
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