Created
June 29, 2014 18:48
-
-
Save anonymous/94351cd8644251e9b878 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
var page = require('webpage').create(); | |
page.onConsoleMessage = function(msg) { | |
console.log('CONSOLE: ' + msg); | |
}; | |
page.onError = function(msg, trace) { | |
console.log('ERROR: ' + msg + (trace ? ("trace: " + JSON.stringify(trace)) : "")); | |
}; | |
page.content = "<div id='a'>some text</div><p id='b'>more text</p>"; | |
setTimeout(function(){ | |
page.evaluate(function(){ | |
console.log(!!document.querySelector("div#a")); // true | |
console.log(!!document.querySelector("div[id='a']")); // true | |
console.log(!!document.querySelector("div:not([id='a'])")); // false | |
console.log(!!document.querySelector("p:not([id='a'])")); // true | |
console.log(!!document.querySelector("div[id!='a']")); // error | |
}); | |
}, 1000); | |
setTimeout(function(){ | |
phantom.exit(); | |
}, 2000); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment