When I run the following code, I am unable to find any element by an id when trying to assign a value to 'element'. If I run the code in the browser console, I get back an assignment.
Edited Question:So I added the casper.evaluate method but I'm still getting a null response.
phantom.casperTest = true;
casper.test.begin('assertExists() tests', 2, function suite(test) {
casper.start('http://www.google.com', function() {
test.assertTitleMatches(/Google/);
var element = casper.evaluate(function() {
var f = document.getElementById('tsf');//this line is returning null
return(JSON.stringify(f));
});
casper.echo("element is:" + element);
this.test.assertExists( element,
'the element exists'
);
}).run(function() {
test.done();
});
});