Good morning.
I'm trying to implement automated authorization for our staff (WiFi). I am done filling their credentials in fields but I can't make it so button is pressed.
Html page source:
<html>
<head>
<title>Web Authentication</title>
<meta http-equiv="Cache-control" content="no-cache">
<meta http-equiv="Pragma" content="no-cache">
<meta http-equiv="Expires" content="-1">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<style>
//not important.
</STYLE>
<noscript>
<meta HTTP-EQUIV="REFRESH" content="0; url=http://ift.tt/2i6iyOm">
</noscript>
<script language="javascript" src="/loginscript.js"></script>
<script>
function getErrorMsgIfAny(){
if(document.forms[0].err_flag.value == 1){
document.writeln(' \
<tr align="center"> <td colspan="2" style="color:#CC0000">Login Error.</td>\
</tr><tr align="center"> <td width="350" class="message" colspan="2">The User Name and Password combination you have entered is invalid. Please try again.</td></tr>\
<tr> <td class="caption" colspan="2"> </td></tr>');
}else{
document.writeln(' ');
}
}
function unhideform(){
document.getElementById("formId").style.display = "block";
}
</script>
</head>
<body bgcolor="#ffffff" text="#000000" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" >
<FORM method="post" ACTION="/login.html">
<INPUT TYPE="hidden" NAME="buttonClicked" SIZE="16" MAXLENGTH="15" VALUE="0">
<INPUT TYPE="hidden" NAME="err_flag" SIZE="16" MAXLENGTH="15" VALUE="0">
<INPUT TYPE="hidden" NAME="err_msg" SIZE="32" MAXLENGTH="31" VALUE="">
<INPUT TYPE="hidden" NAME="info_flag" SIZE="16" MAXLENGTH="15" VALUE="0">
<INPUT TYPE="hidden" NAME="info_msg" SIZE="32" MAXLENGTH="31" VALUE="">
<INPUT TYPE="hidden" NAME="redirect_url" SIZE="255" MAXLENGTH="255" VALUE="">
<INPUT TYPE="hidden" NAME="network_name" SIZE="64" MAXLENGTH="64" VALUE="Guest Network">
<div id="formId">
<table border="0" cellspacing=0 cellpading="0" width="100%">
<tr>
<td width="180" background="../../images/background_web41.jpg" align="middle" style="padding-bottom: 4px;" >
<h1>Login</h1>
</td>
<td height="53" align="right" style="padding-bottom: 4px; padding-right: 20px;" background="../../images/background_web41.jpg"><div align="right"><img src="../../images/cisco/cisco-webauth-logo-2007.gif" width="67" height="40"></div></td>
</tr>
<tr>
<td align="left" width="400">
<div class="content">
<table border="0" cellspacing="10" cellpadding="0">
<tr>
<td>
<table border="0" cellspacing="10" cellpadding="0">
<tr>
<th align="left" width="400">
Welcome
</th>
</tr>
<tr>
<td class="message" align="left" width="400">
You are connected to wireless network of South Ural State University. Please enter username and password provided to you.
</td>
</tr>
</table>
</td>
</tr>
<script>
getErrorMsgIfAny();
</script>
<tr>
<td>
<table border="0" cellspacing="10" cellpadding="0">
<tr>
<td width="100" nowrap>User Name</td>
<td>
<INPUT type="TEXT" name="username" SIZE="25" MAXLENGTH="80" VALUE="">
</td>
</tr>
<tr>
<td nowrap>Password</td>
<td>
<INPUT type="Password" name="password" emweb_type=PASSWORD autocomplete="off" EMWEB_TYPE=PASSWORD onKeyPress="submitOnEnter(event);" SIZE="25" MAXLENGTH="127" VALUE="">
</td>
</tr>
<tr>
<td> </td>
<td>
<script>getHtmlForButton("Submit","Submit","button","submitAction()"); </script>
</td>
</tr>
</table>
</td>
</tr>
</table>
</div>
</td>
<td align="right" >
<table border="0" cellspacing="10" cellpadding="0" >
<tr>
<td align="right" style="padding-top: 25px; padding-right: 20px;"
bgcolor="#ffffff" >
<div ></div></td>
</tr>
</table>
</td>
</tr>
</table>
</div>
<div id="newLoginWebConsent" style="display:none; font-size:13px; font-family: 'CiscoSansThin, Helvetica Neue, Arial, Tahoma, sans-serif';">
<p id="welcomeMsg" style="text-align: center; font-size:20px; margin-top: 25px;">
Welcome to Guest Network
</p>
<div style="margin:30px 10px 30px 10px">
<div id="content" style="border: 2px solid #bbbbbb; border-radius: 3px; margin: 0 auto; padding: 10px; max-width: 600px;">
<div id="page1">
<p>
<span style="font-family:'CiscoSansThin';">Please agree to the terms of use and connect.</span><br/>
<INPUT type="checkbox" id="loginAccept" NAME="loginAccept" onchange="termsAccepted();" / >
I accept the <a href="#" onclick="show_terms_of_use();">terms of use</a>
</p>
<br/><br/>
<BUTTON class="tiny" type="button" id="loginConnectButton" onclick="submitAction();" disabled>
Connect
</button>
</div>
<div id="page2" style="display: none">
<p>
This service is intended for use by authorized guests at this facility. This is an open/unprotected wireless network. By using this service, guests understand and accept that it is their responsibility to protect their own computer while connected to this service, and irrevocably waive any right, cause or action, remedy or other claim against the host with respect to any damage that may be caused to a computer while it is using this network.
</p>
<br/><br/>
<BUTTON class="tiny" type="button" id="loginAcceptButton" onclick="show_accept_terms();">
Back
</button>
</div>
</div>
</div>
<div style="text-align: center;">
<img id="cisco_powered_logo" src="images/cisco_powered_logo.png"/>
</div>
</div>
</FORM>
<script>
</script>
</body>
<HEAD>
<meta http-equiv="Cache-control" content="no-cache">
<meta http-equiv="Pragma" content="no-cache">
<meta http-equiv="Expires" content="-1">
</HEAD>
</html>
I evaluate JS like this (in onPageFinished()):
String injectLogin = "javascript:document.getElementsByName('username')[0].value = '" + login + "';";
String injectPassword = "javascript:document.getElementsByName('password')[0].value = '" + password + "';";
String injectButtonPress = "javascript:document.getElementByName('Submit')[0].click;";
mWebView.evaluateJavascript(injectLogin, null);
mWebView.evaluateJavascript(injectPassword, null);
mWebView.evaluateJavascript(injectButtonPress, null);
I've tried many really weird stuff but can't make it work. Thank you in advance.
Aucun commentaire:
Enregistrer un commentaire