Last active
September 24, 2016 06:31
-
-
Save pluswave/7861e55d7a3cc9ec2f47ede5e533d1f3 to your computer and use it in GitHub Desktop.
使用Phontamjs (2.1)模拟,让TPLINK路由器(WVR458G)重新拨号
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"use strict"; | |
var page = require('webpage').create(); | |
page.onConsoleMessage = function(msg) { | |
console.log(msg); | |
}; | |
/* | |
page.onUrlChanged = function (url){ | |
console.log(url); | |
};*/ | |
var to = null; | |
var toWanFrame = false; | |
page.onLoadFinished = function(status){ | |
console.log(page.url); | |
console.log(status); | |
if (page.url == 'http://192.168.1.1/logon/logon.htm') { | |
page.evaluate(function() { | |
document.getElementById('txt_usr_name').value = "username"; | |
document.getElementById('txt_password').value = "password"; | |
document.getElementById('btn_logon').click(); | |
}); | |
} | |
else if( page.url == 'http://192.168.1.1/logon/loginJump.htm' ) { | |
page.render('test1.png'); | |
console.log('loginJump'); | |
page.evaluate(function(){ | |
setTimeout(function(){ | |
document.getElementById('btn_confirm').click(); | |
},2000); | |
}); | |
} | |
else if (page.url == 'http://192.168.1.1/Index.htm' ){ | |
page.render('index.png'); | |
to = to || setTimeout( function() { | |
page.evaluate(function(){ | |
document.getElementById('fst_Network').click(); | |
document.getElementById('sec_Zone_Setting').click(); | |
console.log('here'); | |
}); | |
toWanFrame = true; | |
}, 3000); | |
if( toWanFrame ){ | |
page.switchToFrame('ifm_func_module'); | |
console.log('wan ... '); | |
console.log(page.frameContent); | |
page.evaluate(function(){ | |
disConnect(3,2); | |
}); | |
setTimeout( function() { | |
phantom.exit(0); | |
}, 3000); | |
} | |
} | |
}; | |
page.open("http://192.168.1.1/logon/logon.htm"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment