Version 1
[yaffs-website] / node_modules / phantomjs-prebuilt / lib / phantom / examples / phantomwebintro.js
diff --git a/node_modules/phantomjs-prebuilt/lib/phantom/examples/phantomwebintro.js b/node_modules/phantomjs-prebuilt/lib/phantom/examples/phantomwebintro.js
new file mode 100644 (file)
index 0000000..6cb4e46
--- /dev/null
@@ -0,0 +1,21 @@
+// Read the Phantom webpage '#intro' element text using jQuery and "includeJs"
+
+"use strict";
+var page = require('webpage').create();
+
+page.onConsoleMessage = function(msg) {
+    console.log(msg);
+};
+
+page.open("http://phantomjs.org/", function(status) {
+    if (status === "success") {
+        page.includeJs("http://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js", function() {
+            page.evaluate(function() {
+                console.log("$(\".explanation\").text() -> " + $(".explanation").text());
+            });
+            phantom.exit(0);
+        });
+    } else {
+      phantom.exit(1);
+    }
+});