2011-06-09 19:11:39 +04:00
|
|
|
// Read the Phantom webpage '#intro' element text using jQuery and "includeJs"
|
|
|
|
|
2015-04-10 10:51:00 +03:00
|
|
|
"use strict";
|
2011-09-13 00:17:54 +04:00
|
|
|
var page = require('webpage').create();
|
2011-06-09 19:11:39 +04:00
|
|
|
|
|
|
|
page.onConsoleMessage = function(msg) {
|
|
|
|
console.log(msg);
|
|
|
|
};
|
|
|
|
|
2015-04-10 10:51:00 +03:00
|
|
|
page.open("http://phantomjs.org/", function(status) {
|
|
|
|
if (status === "success") {
|
2011-06-09 19:11:39 +04:00
|
|
|
page.includeJs("http://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js", function() {
|
|
|
|
page.evaluate(function() {
|
2014-03-01 11:16:48 +04:00
|
|
|
console.log("$(\".explanation\").text() -> " + $(".explanation").text());
|
2011-06-09 19:11:39 +04:00
|
|
|
});
|
2015-04-10 10:51:00 +03:00
|
|
|
phantom.exit(0);
|
2011-06-09 19:11:39 +04:00
|
|
|
});
|
2015-04-10 10:51:00 +03:00
|
|
|
} else {
|
|
|
|
phantom.exit(1);
|
2011-06-09 19:11:39 +04:00
|
|
|
}
|
|
|
|
});
|