Skip to content

Instantly share code, notes, and snippets.

Created January 14, 2016 08:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/deb3e022d75ad1711e5a to your computer and use it in GitHub Desktop.
Save anonymous/deb3e022d75ad1711e5a to your computer and use it in GitHub Desktop.
var page = require('webpage').create(),
testindex = 0,
loadInProgress = false;
page.onLoadStarted = function() {
loadInProgress = true;
console.log("load started");
};
page.onLoadFinished = function() {
loadInProgress = false;
console.log("load finished");
};
var steps = [
function() {
//Load Login Page
page.open("http://www.sd.10086.cn/eMobile/qryBalance.action?menuid=qryBalance");
},
function() {
page.evaluate(function(obj) {
var form = document.getElementById("Form0");
form.elements["mobileNum"].value = '手机号';
form.elements["service_PWD"].value = '密码';
//这里需要点选“服务密码”选项
form.elements['button'].click();
return document.title;
});
loadInProgress = true;
},
function() {
page.render('login-succ.png');
}
];
var interval = setInterval(function() {
if (!loadInProgress && typeof steps[testindex] == "function") {
steps[testindex]();
testindex++;
}
if (typeof steps[testindex] != "function") {
phantom.exit();
}
}, 10);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment