I am using casperjs and following is the code
var casper = require('casper').create();
var x = require('casper').selectXPath;
casper.start('http://google.co.in/', function() {
// search for 'casperjs' from google form
this.test.assertExists(x('//*[@type="text"]'), 'the element exists');
});
casper.run(function() {
// echo results in some pretty fashion
this.echo('').exit();
});
it wasn’t able to find any element with attribute type as text though there are plenty.
This is the output I get
FAIL the element exists
# type: assertExists
# subject: false
# selector: {"type":"xpath","path":"//*[@type=\"text\"]"}
Google has been known to not be bot-friendly. In order for this to work, you must set the UserAgent.
This was tested under CasperJS-1.0.0 and PhantomJS-1.8.0
You can visit http://whatsmyuseragent.com/ to see what your current UserAgent is.
Update: Removed CasperJS-1.0.0 code in favor of backwards-compatible code.