How to login Amazon using PhantomJS – Working example
Intro
PhantomJS is a handy tool for automatizing tasks or testing some specific parts of the system, but sometimes tasks you need to perform are behind login screen which makes your job much harder. I decided to write a running script for PhantomJS which will login to the Amazon using provided username and password. After receiving several emails I implemented a PhantomJS script which logs in into Twitter account and gets all tweets from the stram, and you can check it in my post Login to the Twitter and extract tweets using PhantomJS If you are working with CasperJS then read my post about "How to login to Amazon using CasperJS", How to login Facebook using CasperJS
Basic steps
Every time when you need to handle login system with PhantomJS or CasperJS you have to think about the following things:
- Submit login form
- Store cookies received by server
- Resend cookies upon every new request
- Save cookies (optional)
Submitting login form defers from system to system, from website to website. One way to submit a form is to send POST request to the login URL. Sometimes, this approach is not good and it will not work, because login form may contain hidden fields/values which are generated dynamically, and system will refuse to login you if you are not submitting these hidden fields.
Better approach is to simulate click on submit button, and this approach is used in my working example.
PhantomJS and CasperJS are automatically managing cookies received from server, which is really helpful, but this feature works only during script execution and once the script is finished, cookies are deleted.
You have to implement file cookie management yourself If you want to store cookies in a file, and read them next time the script is executed.
I had a lot of problems to successfully login on Amazon website, and that is why I decided to share a code with you. Here are the steps that we need to take in order to login Amazon:
- Visit Amazon's home page
- Simulate click on Sing in button (do not copy and paste URL of sing in page, this link can expire and your PhantomJS script will not work)
- On the sign in page, populate username and password fields
- Click on Sing in button
Amazon will refuse to login a user if cookes and javascript are not enabled. You can check this if you disable cookies or javascript in your browser (Chrome, Mozilla) and then try to login.
Final solution
Here is the final solution which will login you to the Amazon website. The same pattern can be used for Facebook, Google etc.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
var steps=[]; var testindex = 0; var loadInProgress = false;//This is set to true when a page is still loading /*********SETTINGS*********************/ var webPage = require('webpage'); var page = webPage.create(); page.settings.userAgent = 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/44.0.2403.157 Safari/537.36'; page.settings.javascriptEnabled = true; page.settings.loadImages = false;//Script is much faster with this field set to false phantom.cookiesEnabled = true; phantom.javascriptEnabled = true; /*********SETTINGS END*****************/ console.log('All settings loaded, start with execution'); page.onConsoleMessage = function(msg) { console.log(msg); }; /**********DEFINE STEPS THAT FANTOM SHOULD DO***********************/ steps = [ //Step 1 - Open Amazon home page function(){ console.log('Step 1 - Open Amazon home page'); page.open("https://amazon.com", function(status){ }); }, //Step 2 - Click on the Sign in button function(){ console.log('Step 2 - Click on the Sign in button'); page.evaluate(function(){ document.getElementById("nav-link-yourAccount").click(); }); }, //Step 3 - Populate and submit the login form function(){ console.log('Step 3 - Populate and submit the login form'); page.evaluate(function(){ document.getElementById("ap_email").value="AMAZON USERNAME"; document.getElementById("ap_password").value="AMAZON PASSWORD"; document.getElementById("ap_signin_form").submit(); }); }, //Step 4 - Wait Amazon to login user. After user is successfully logged in, user is redirected to home page. Content of the home page is saved to AmazonLoggedIn.html. You can find this file where phantomjs.exe file is. You can open this file using Chrome to ensure that you are logged in. function(){ console.log("Step 4 - Wait Amazon to login user. After user is successfully logged in, user is redirected to home page. Content of the home page is saved to AmazonLoggedIn.html. You can find this file where phantomjs.exe file is. You can open this file using Chrome to ensure that you are logged in."); var fs = require('fs'); var result = page.evaluate(function() { return document.querySelectorAll("html")[0].outerHTML; }); fs.write('AmazonLoggedIn.html',result,'w'); }, ]; /**********END STEPS THAT FANTOM SHOULD DO***********************/ //Execute steps one by one interval = setInterval(executeRequestsStepByStep,50); function executeRequestsStepByStep(){ if (loadInProgress == false && typeof steps[testindex] == "function") { //console.log("step " + (testindex + 1)); steps[testindex](); testindex++; } if (typeof steps[testindex] != "function") { console.log("test complete!"); phantom.exit(); } } /** * These listeners are very important in order to phantom work properly. Using these listeners, we control loadInProgress marker which controls, weather a page is fully loaded. * Without this, we will get content of the page, even a page is not fully loaded. */ page.onLoadStarted = function() { loadInProgress = true; console.log('Loading started'); }; page.onLoadFinished = function() { loadInProgress = false; console.log('Loading finished'); }; page.onConsoleMessage = function(msg) { console.log(msg); }; |
If you want to edit the steps, just change the entries in the steps array.
NOTE: Change AMAZON USERNAME and AMAZON PASSWORD with your username and password.
How to run a script
In order to run code above, make the following steps:
- Download and save phantomjs.exe on desktop
- Make new empty JavaScript file, and save it to the desktop
- Copy code above, and paste it to the newly created file
- Run CMD, navigate to Desktop and run the following command: phantomjs.exe filename.js
Additional notes
The script is based on the CSS selectors, and may not work in the future if Amazon website heavily changes. If you encounter problems, you can email an author, or you can open Amazon website and check weather IDs of HTML elements (input fields, ID of the login form) are changed.
http://code-epicenter.com/how-to-login-amazon-using-phantomjs-working-example/How to login Amazon using PhantomJS - Working examplehttp://code-epicenter.com/wp-content/uploads/2015/08/phantom.jpghttp://code-epicenter.com/wp-content/uploads/2015/08/phantom-150x150.jpgJavaScriptLibrariesProgrammingTutorialsAmazon,JavaScript,PhantomJS,Web scrappingIntro PhantomJS is a handy tool for automatizing tasks or testing some specific parts of the system, but sometimes tasks you need to perform are behind login screen which makes your job much harder. I decided to write a running script for PhantomJS which will login to the Amazon using...Amir DuranAmir Duranamir.duran@gmail.comAdministratorAmir Duran is software engineer who currently lives and works in Germany. He obtained Masters degree diploma on Faculty of Electrical Engineering in Sarajevo, department Computer science. With good educational background he is specialized in designing and implementing a full-stack web based applications.Code Epicenter
Hello Amir,
I’m getting following error:
TypeError: ‘null’ is not an object (evaluating ‘document.getElementById(“ap_email”).value=”myemail@gmail.com”‘)
phantomjs://webpage.evaluate():2
phantomjs://webpage.evaluate():5
phantomjs://webpage.evaluate():5
It seems that it cant find the object, but i just checked and the name of the email field is indeed “ap_email”. Any ideas?
Cheers
Hi Thomas, please check your email.
It works now, thank you.
Hello Thomas,
I’ve run into the same errors as you :
TypeError: ‘null’ is not an object (evaluating ‘document.getElementById(“ap_email”).value=”myemail@gmail.com”‘)
phantomjs://webpage.evaluate():2
phantomjs://webpage.evaluate():5
phantomjs://webpage.evaluate():5
I cant figure out why.. Do you happen to remember the cause for this ?
Thanks,
Peter
Hi Amir,
I am new to Casperjs and Phantomjs, i have a casperjs script which logs into a website by filling up the form and then request some URL’s and do some scraping . After a successful login I want to run 5 URl’s one after the other and scrape from each and every URL and then logout. But the problem is the script doesn’t stay logged in for more than two or three URL’s. Any idea about why it does so??
Thanks
Hi Ankur,
I’m really glad that you are working with CaspjerJS and PhantomJS. Pls check your email so we can inspect your code.
Hi,
thanks for this code, I’m experiencing an error when running it though:
And the resulting page shows me not logged in.
Hi Paul,
I’ve checked the script, and it works with amazon.co.uk. If you are still experiencing issues, pls let me know.
Regards, Amir!
Hello Amir,
I’m getting the exact same error that you helped correct for Thomas above:
TypeError: null is not an object (evaluating ‘document.getElementById(“j_password”).value=”readonly”‘)
Can you please help correct this for me?
Thanks for your help!
Nick
Hi Nick, please check your email.
I’ve got the same error! why don’t you put the answer right here? but send it to peoples emails? i saw 2 peoples had the same problem, and you answered the same way, “check your email”
Hi there, I’m also receiving the error…
TypeError: ‘null’ is not an object (evaluating ‘document.getElementById(“nav-link-yourAccount”).click’)
Thanks!
Hello Amir,
I seem to have run into the same errors as Thomas. Could you please tell me what went wrong?
TypeError: ‘null’ is not an object (evaluating ‘document.getElementById(“ap_email”).value=”myemail@gmail.com”‘)
phantomjs://webpage.evaluate():2
phantomjs://webpage.evaluate():5
phantomjs://webpage.evaluate():5
Thanks,
Peter
I am also having the Thomas/Nick problem. Any help greatly appreciated.
Hi Amir,
I tried to use same phantomJS script which you mentioned above on my website. But i’m not able to redirect the next page after providing username and password
Can you pls help me in this regard?
Pls. let me know if you need more info regarding this.
Thanks,
Hussain
My problem has been resolved now
Thank you.
Did you resolve your issue?
Hi Amit,
I tried to run the above code , i am getting following error:
Step 2 – Click on the Sign in button
TypeError: null is not an object (evaluating ‘document.getElementById(“nav-link-yourAccount”).click’)
undefined:2
Could you please assist.
Thank you!!
Probably you are using some other Amazon website, or DOM elements changed since the last time I wrote the script. You have to ensure that username and password fields are having ID as specified in Phantom script.
The error message means there is no element by ID “nav-link-yourAccount”. Check the source code of your Amazon page to make sure it is there. My guess is that Amazon changed something since then.
Amir, first tks for this code. I try work with this for login a web site and crawling next page after login. but the response is only : ok. Looks like logged but not redirect to next page… i use your code like that:
var steps=[];
var testindex = 0;
var loadInProgress = false;//This is set to true when a page is still loading
/*********SETTINGS*********************/
var webPage = require(‘webpage’);
var page = webPage.create();
page.settings.userAgent = ‘Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/44.0.2403.157 Safari/537.36’;
page.settings.javascriptEnabled = true;
page.settings.loadImages = false;//Script is much faster with this field set to false
phantom.cookiesEnabled = true;
phantom.javascriptEnabled = true;
/*********SETTINGS END*****************/
console.log(‘All settings loaded, start with execution’);
page.onConsoleMessage = function(msg) {
console.log(msg);
};
/**********DEFINE STEPS THAT FANTOM SHOULD DO***********************/
steps = [
//Step 1 – Open Amazon home page
function(){
console.log(‘Step 1 – Abrindo página de login’);
page.open(“http://parceriascury.housecrm.com.br”, function(status){
});
},
//Step 3 – Populate and submit the login form
function(){
console.log(‘Step 3 – Preenchendo o form’);
page.evaluate(function(){
document.getElementById(“login”).value=”xxx”;
document.getElementById(“senha”).value=”xxx”;
document.getElementById(“frmlandingpage”).submit();
});
},
//Step 4 – Wait Amazon to login user. After user is successfully logged in, user is redirected to home page. Content of the home page is saved to AmazonLoggedIn.html. You can find this file where phantomjs.exe file is. You can open this file using Chrome to ensure that you are logged in.
function(){
console.log(“Step 4 – Wait Amazon to login user. After user is successfully logged in, user is redirected to home page. Content of the home page is saved to AmazonLoggedIn.html. You can find this file where phantomjs.exe file is. You can open this file using Chrome to ensure that you are logged in.”);
var fs = require(‘fs’);
var result = page.evaluate(function() {
return document.documentElement.outerHTML;
});
fs.write(‘C:\\phantomjs\\logado_cury_10.html’,result,’w’);
},
];
/**********END STEPS THAT FANTOM SHOULD DO***********************/
//Execute steps one by one
interval = setInterval(executeRequestsStepByStep,5000);
function executeRequestsStepByStep(){
if (loadInProgress == false && typeof steps[testindex] == “function”) {
//console.log(“step ” + (testindex + 1));
steps[testindex]();
testindex++;
}
if (typeof steps[testindex] != “function”) {
console.log(“test complete!”);
phantom.exit();
}
}
/**
* These listeners are very important in order to phantom work properly. Using these listeners, we control loadInProgress marker which controls, weather a page is fully loaded.
* Without this, we will get content of the page, even a page is not fully loaded.
*/
page.onLoadStarted = function() {
loadInProgress = true;
console.log(‘Loading started’);
};
page.onLoadFinished = function() {
loadInProgress = false;
console.log(‘Loading finished’);
};
page.onConsoleMessage = function(msg) {
console.log(msg);
};
If i login with manual method the next page is : http://parceriascury.housecrm.com.br/parceiro_busca, this page have dinamic html generated by js, i has found my mistake and no success…
Apreciate if u can help me…
Sorry my bad english…
Try to do same thing with CasperJS. It is much easier. You can find few examples on this blog, and please let me know if you are then experiencing problems.
Thanks for sharing this- good stuff! Keep up the great work, we look forward to reading more from you in the future!
Hi, Amir thanks for the code.
I want ask, how to solve the captcha on Amazon using Phantom.JS ?
thanks.
sorry for my bad english, i’m from Indonesia.
There are are few ways you can handle captchas. First one is to save your cookies and resend them. Doing it this way, you can mimic real user, and Amazon will not ask you captcha so often.
Other way is to use captcha solvers that are available. Here is a link:
http://scraping.pro/8-best-captcha-solving-services-and-tools/
var steps=[];
var testindex = 0;
var loadInProgress = false;//This is set to true when a page is still loading
/*********SETTINGS*********************/
var webPage = require(‘webpage’);
var page = webPage.create();
page.settings.userAgent = ‘Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/44.0.2403.157 Safari/537.36’;
page.settings.javascriptEnabled = true;
page.settings.loadImages = false;//Script is much faster with this field set to false
phantom.cookiesEnabled = true;
phantom.javascriptEnabled = true;
/*********SETTINGS END*****************/
console.log(‘All settings loaded, start with execution’);
page.onConsoleMessage = function(msg) {
console.log(msg);
};
/**********DEFINE STEPS THAT FANTOM SHOULD DO***********************/
steps = [
//Step 1 – Open Amazon home page
function(){
console.log(‘Step 1 – Open Amazon home page’);
page.open(“https://amazon.com”, function(status){
});
},
//Step 2 – Click on the Sign in button
function(){
console.log(‘Step 2 – Click on the Sign in button’);
page.includeJs(
‘https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js’,
function() {
(page.evaluate(function() {
var $navHover = $(‘#nav-link-accountList’);
var $navClick = $(‘.nav-action-button’);
$navHover.trigger(‘hover’);
$navClick.click();
}))
}
);
},
//Step 3 – Populate and submit the login form
function(){
console.log(‘Step 3 – Populate and submit the login form’);
page.includeJs(
‘https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js’,
function() {
(page.evaluate(function() {
var $ap_email = $(‘#ap_email’);
var $ap_password = $(‘#ap_password’);
var $ap_submit = $(“form[name=’form_name’]”);
$ap_email.value=”d1231231l”;
$ap_password.value=”grass101″;
$ap_submit.submit();
}))
}
);
},
//Step 4 – Wait Amazon to login user. After user is successfully logged in, user is redirected to home page. Content of the home page is saved to AmazonLoggedIn.html. You can find this file where phantomjs.exe file is. You can open this file using Chrome to ensure that you are logged in.
function(){
console.log(“Step 4 – Wait Amazon to login user. After user is successfully logged in, user is redirected to home page. Content of the home page is saved to AmazonLoggedIn.html. You can find this file where phantomjs.exe file is. You can open this file using Chrome to ensure that you are logged in.”);
var fs = require(‘fs’);
var result = page.evaluate(function() {
return document.querySelectorAll(“html”)[0].outerHTML;
});
fs.write(‘AmazonLoggedIn.html’,result,’w’);
},
];
/**********END STEPS THAT FANTOM SHOULD DO***********************/
//Execute steps one by one
interval = setInterval(executeRequestsStepByStep,50);
function executeRequestsStepByStep(){
if (loadInProgress == false && typeof steps[testindex] == “function”) {
//console.log(“step ” + (testindex + 1));
steps[testindex]();
testindex++;
}
if (typeof steps[testindex] != “function”) {
console.log(“test complete!”);
phantom.exit();
}
}
/**
* These listeners are very important in order to phantom work properly. Using these listeners, we control loadInProgress marker which controls, weather a page is fully loaded.
* Without this, we will get content of the page, even a page is not fully loaded.
*/
page.onLoadStarted = function() {
loadInProgress = true;
console.log(‘Loading started’);
};
page.onLoadFinished = function() {
loadInProgress = false;
console.log(‘Loading finished’);
};
page.onConsoleMessage = function(msg) {
console.log(msg);
};
Can you send me the example of code to save cookies and resend them ?
i tried to modify your code, and successfully. But if i input wrong email and wrong password, the result is same and then AmazonLoggedIn.html is created. it should be not created, because i input wrong email and wrong password. So whats wrong with the code ?
Thank you.
hi amir
i am getting following error.
Step 2 – Click on the Sign in button
TypeError: ‘null’ is not an object (evaluating ‘document.getElementById(“nav-link-yourAccount”).click’)
phantomjs://webpage.evaluate():2
phantomjs://webpage.evaluate():3
phantomjs://webpage.evaluate():3
Step 3 – Populate and submit the login form
TypeError: ‘null’ is not an object (evaluating ‘document.getElementById(“ap_email”).value=”haish.hans46@gmail.com”‘)
phantomjs://webpage.evaluate():2
phantomjs://webpage.evaluate():5
phantomjs://webpage.evaluate():5
Step 4 – Wait Amazon to login user. After user is successfully logged in, user is redirected to home page. Content of the home page is saved to AmazonLoggedIn.html. You can find this file where phantomjs.exe file is. You can open this file using Chrome to ensure that you are logged in.
test complete!
Hello Amir,
I have updated the id/selectors used to get the dom elements as they have changed on the amazon page. I’m currently getting these errors…
_______________________________________________________________________________________________________________________________
All settings loaded, start with execution
Step 1 – Open Amazon home page
Loading started
Loading finished
Step 2 – Click on the Sign in button
TypeError: null is not an object (evaluating ‘x.click’)
undefined:3
:4
Step 3 – Populate and submit the login form
TypeError: null is not an object (evaluating ‘document.getElementById(“ap_email”).value=”ptanzy@comcast.net”‘)
undefined:2
:5
Step 4 – Wait Amazon to login user. After user is successfully logged in, user is redirected to home page. Content of the home page is saved to AmazonLoggedIn.html. You can find this file where phantomjs.exe file is. You can open this file using Chrome to ensure that you are logged in.
test complete!
_______________________________________________________________________________________________________________________________
It seems these errors occur whenever I try to access a property or function of an element. The element and selector names should be correct as I was able to access them within Chrome debugger. The code follows
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
var steps=[];
var testindex = 0;
var loadInProgress = false;//This is set to true when a page is still loading
/*********SETTINGS*********************/
var webPage = require('webpage');
var page = webPage.create();
page.settings.userAgent = 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/44.0.2403.157 Safari/537.36';
page.settings.javascriptEnabled = true;
page.settings.loadImages = false;//Script is much faster with this field set to false
phantom.cookiesEnabled = true;
phantom.javascriptEnabled = true;
/*********SETTINGS END*****************/
console.log('All settings loaded, start with execution');
page.onConsoleMessage = function(msg) {
console.log(msg);
};
/**********DEFINE STEPS THAT FANTOM SHOULD DO***********************/
steps = [
//Step 1 – Open Amazon home page
function(){
console.log('Step 1 – Open Amazon home page');
page.open("https://www.pandora.com/", function(status){
});
},
//Step 2 – Click on the Sign in button
function(){
console.log('Step 2 – Click on the Sign in button');
page.evaluate(function(){
var x = document.querySelector("span.nav-line-3");
x.click();
});
},
//Step 3 – Populate and submit the login form
function(){
console.log('Step 3 – Populate and submit the login form');
page.evaluate(function(){
document.getElementById("ap_email").value="ptanzy@comcast.net";
document.getElementById("ap_password").value="diablo2";
document.getElementById("signInSubmit").click();
});
},
//Step 4 – Wait Amazon to login user. After user is successfully logged in, user is redirected to home page. Content of the home page is saved to AmazonLoggedIn.html. You can find this file where phantomjs.exe file is. You can open this file using Chrome to ensure that you are logged in.
function(){
console.log("Step 4 – Wait Amazon to login user. After user is successfully logged in, user is redirected to home page. Content of the home page is saved to AmazonLoggedIn.html. You can find this file where phantomjs.exe file is. You can open this file using Chrome to ensure that you are logged in.");
window.setTimeout(function(){
page.render('vector.pdf');
phantom.exit();
},7000);
// var fs = require('fs');
// var result = page.evaluate(function() {
// return document.querySelectorAll("html")[0].outerHTML;
//});
//fs.write('AmazonLoggedIn.html',result,'w');
},
];
/**********END STEPS THAT FANTOM SHOULD DO***********************/
//Execute steps one by one
interval = setInterval(executeRequestsStepByStep,50);
function executeRequestsStepByStep(){
if (loadInProgress == false && typeof steps[testindex] == "function") {
//console.log("step " + (testindex + 1));
steps[testindex]();
testindex++;
}
if (typeof steps[testindex] != "function") {
console.log("test complete!");
phantom.exit();
}
}
/**
* These listeners are very important in order to phantom work properly. Using these listeners, we control loadInProgress marker which controls, weather a page is fully loaded.
* Without this, we will get content of the page, even a page is not fully loaded.
*/
page.onLoadStarted = function() {
loadInProgress = true;
console.log('Loading started');
};
page.onLoadFinished = function() {
loadInProgress = false;
console.log('Loading finished');
};
page.onConsoleMessage = function(msg) {
console.log(msg);
};
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
Any assistance would be appreciated.
Nevermind. Found my silly mistake. It works.
Getting login failed error.. I am trying on different site with modified username id password ID and form ID? WHAT CAN be the possible reasons for such an error the script is getting executed and the html file Is also getting generated with the “login failed error” inside that html file..? Help
Hi Amir,
Thank for the code.
I get a issue. Because i login a new machine and new location. The amazon redirect to security code page and we must submit to get a security code. So how to pass this step?
Thank you
Hi, Im new on phantomjs.
I need to login in a page and scrap some pages continually every 10 seconds creating html files wich I will read with my software.
I could read and scrap the initial page using:
var system = require(‘system’);
var page = require(‘webpage’).create();
// system.args[0] is the filename, so system.args[1] is the first real argument
var url = system.args[1];
// render the page, and run the callback function
page.open(url, function () {
// page.content is the source
console.log(page.content);
// need to call phantom.exit() to prevent from hanging
phantom.exit();
});
and it works ok but I need to login first and keep scraping some pages every 10 secs
The URL I ned to scrap is https://bort.com.ar/index.php
Any help will be appreciate!
Thanks and greetings!
Alberto
Hey, These instructions worked for me. Thanks a lot dude.
Hello.
This is a great tutorial.
I tried it on amazon uk and as others, I got the error
TypeError: null is not an object (evaluating ‘document.getElementById(“ap_password”).value=”pass”‘)
I tried a lot of things, but nothing manages to fill in the password and submit the form.
The value is there, but something prevents the form from being submitter or I can’t figure out what’s the problem.
Can you please give an advice?
Best regards.
Hi,
Could you please advise for this?
TypeError: ‘null’ is not an object (evaluating ‘document.getElementById ……’)
phantomjs://webpage.evaluate():2
phantomjs://webpage.evaluate():5
phantomjs://webpage.evaluate():5
Thanks.
Hi Amir, I am getting the same error message as theothers, and the page opens but I am not signed in.. Can you help
Does this still work? I’ve updated the HTML elements to match but it’s still redirecting me to the login page.
It should work. Maybe selectors changed. Make sure you inspect Amazon DOM to find out name of the fields.
Thanks for the great article this is very useful info thanks for the wonderful post.