I am new to phantomjs. Just started with a dumb automation of the application I'm working on. Somehow, the following code seems to be great for sites like hotmail, facebook, etc., but it doesn’t work for my application under test. Below is the code I'm using: -
var page = require("webpage").create();
page.settings.userAgent="Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/37.0.2049.0 Safari/537.36"
phantom.clearCookies();
phantom.cookiesEnabled = true;
var homePage = "https://www.somewebsite.com";
page.open(homePage, function(status) {
var url = page.url;
console.log("Status: " + status);
console.log("Loaded: " + url);
page.evaluate(function(){
document.getElementById('myUsername').value='username;
document.getElementById('myPassword').value='password';
});
page.render("before.png");
page.evaluate(function(){
document.getElementById('myLoginButton').click();
});
setTimeout(function() {
page.render("after.png");
phantom.exit();
}, 10000);
});
The error message I get is "Your browser is set to block all cookies. Please enable them to access the website."
Although I wrote the expression "phantom.cookiesEnabled = true;" this does not seem to allow. I have already tried changing the user agent, but no luck. Did I miss something?
Thanks Advance, Harsheath Coley
source
share