Reputation: 1129
Documentation says: Cookies are enabled in PhantomJS by default. But not sure why Amazon returns that page.
Here is my code:
var webdriverio = require('webdriverio');
var opts = desiredCapabilities: {
browserName: 'phantomjs',
javascriptEnabled: true
},
"host": "localhost",
"port": 4444
};
var email = ''; // your email
var password: ''; // your password
var client = webdriverio
.remote(opts)
.init()
.url('https://www.amazon.co.uk/gp/sign-in.html')
.setValue('#ap_email', email)
.setValue('#ap_password', password)
.submitForm('form[name="signIn"]')
.then(function() { // save the screenshot
this.saveScreenshot(__dirname + '/loginPage.png');
})
.end();
I had logged the cookies object it returns empty/none:
{
sessionId: 'a96eb340-bb6a-11e5-ae83-c52b2435a008',
status: 0,
value: []
}
, and tried to set a custom Cookie with
.setCookie({name: '', value: '', domain: 'amazon.co.uk'})
But still have the same problem..
As I think phantomJS is blocking it because when i changed the browserName
with chrome
then it works fine.. Still, I want it work via phantom.
Your help will be appreciated - Thanks.
Upvotes: 0
Views: 1148
Reputation: 515
Maybe the website is not recognizing phantom as a normal browser and hence showing you this error message.
Add the User-Agent string in the browser capabilities as follows. This will tell the site that the traffic is coming from a normal browser.
var opts = desiredCapabilities: {
browserName: 'phantomjs',
'phantomjs.page.settings.userAgent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:36.0) Gecko/20100101 Firefox/36.0 WebKit',
javascriptEnabled: true
},
"host": "localhost",
"port": 4444
};
Upvotes: 1