C
Chris
Hi,
I'm trying to figure out how to submit javascript forms using win32com
in order to complete repetitive processes.
The Webpage Source: (I tried to include only the important stuff)
----------------------------------------------
<SCRIPT language="JavaScript">
function mainPageOnLoad() {
initLogin();
setEnterToSubmit('loginForm','loginrequest');
}
</SCRIPT>
<form name="loginForm" method="post" action="/cs/login.do">
<input type="hidden" name="nxtpage" value="">
<input type="hidden" name="currentpage" value="login">
<input type="hidden" name="lng" value="en_CA">
<td width="38%" align="right" valign="middle" height="25"
class="detailslabel">
Name: </td>
<td width="62%" class="detailsvalue">
<input type="text" name="name" maxlength="15" size="15"
value="">
<td width="38%" align="right" valign="middle" height="25"
class="detailslabel">
Password: </td>
<td width="62%" align="left" valign="middle" height="25"
class="detailsvalue">
<input type="password" name="password" maxlength="15" size="15"
value="">
<a href="javascript:submitLoginForm('loginForm','loginrequest')"><img
src="../images/cs/en_CA/btn_ok.gif" alt="OK" border="0"></a>
<a
href="javascript:submitForm('loginForm','loginrequestchangepassword')"><img
src="../images/cs/en_CA/btn_changepassword.gif" alt="Change Password"
border="0"></a>
<a href="javascript:submitForm('loginForm','preferences')"><img
src="../images/cs/en_CA/btn_preferences.gif" alt="Preferences"
border="0"></a>
<script type="text/javascript" language="JavaScript">
<!--
var focusControl = document.forms["loginForm"].elements["name"];
if (focusControl.type != "hidden") {
focusControl.focus();
}
// -->
</script>
----------------------------------------------
My code so far is this:
----------------------------------------------
from win32com.client import Dispatch
from time import sleep
ie = Dispatch('InternetExplorer.Application')
ie.Visible = 1
ie.Navigate("http://ispds-sepsr.prv:7500/cs/welcome.jsp")
while ie.ReadyState != 4:
sleep(1)
doc = ie.Document
while doc.readyState != "complete":
sleep(1)
doc.loginForm.name.value = 'username'
doc.loginForm.password.value = 'password'
doc.loginForm.loginform.action = '/cs/login.do'
-------------------------------------------------
Well it doesn't seem to work like other javascript sites (eg. like the
google.ca form)which is where i snagged the script from.
I don't really have a clue about this module, or even javascript so any
help would be appreciated.
P.S. sorry about the mess
I'm trying to figure out how to submit javascript forms using win32com
in order to complete repetitive processes.
The Webpage Source: (I tried to include only the important stuff)
----------------------------------------------
<SCRIPT language="JavaScript">
function mainPageOnLoad() {
initLogin();
setEnterToSubmit('loginForm','loginrequest');
}
</SCRIPT>
<form name="loginForm" method="post" action="/cs/login.do">
<input type="hidden" name="nxtpage" value="">
<input type="hidden" name="currentpage" value="login">
<input type="hidden" name="lng" value="en_CA">
<td width="38%" align="right" valign="middle" height="25"
class="detailslabel">
Name: </td>
<td width="62%" class="detailsvalue">
<input type="text" name="name" maxlength="15" size="15"
value="">
<td width="38%" align="right" valign="middle" height="25"
class="detailslabel">
Password: </td>
<td width="62%" align="left" valign="middle" height="25"
class="detailsvalue">
<input type="password" name="password" maxlength="15" size="15"
value="">
<a href="javascript:submitLoginForm('loginForm','loginrequest')"><img
src="../images/cs/en_CA/btn_ok.gif" alt="OK" border="0"></a>
<a
href="javascript:submitForm('loginForm','loginrequestchangepassword')"><img
src="../images/cs/en_CA/btn_changepassword.gif" alt="Change Password"
border="0"></a>
<a href="javascript:submitForm('loginForm','preferences')"><img
src="../images/cs/en_CA/btn_preferences.gif" alt="Preferences"
border="0"></a>
<script type="text/javascript" language="JavaScript">
<!--
var focusControl = document.forms["loginForm"].elements["name"];
if (focusControl.type != "hidden") {
focusControl.focus();
}
// -->
</script>
----------------------------------------------
My code so far is this:
----------------------------------------------
from win32com.client import Dispatch
from time import sleep
ie = Dispatch('InternetExplorer.Application')
ie.Visible = 1
ie.Navigate("http://ispds-sepsr.prv:7500/cs/welcome.jsp")
while ie.ReadyState != 4:
sleep(1)
doc = ie.Document
while doc.readyState != "complete":
sleep(1)
doc.loginForm.name.value = 'username'
doc.loginForm.password.value = 'password'
doc.loginForm.loginform.action = '/cs/login.do'
-------------------------------------------------
Well it doesn't seem to work like other javascript sites (eg. like the
google.ca form)which is where i snagged the script from.
I don't really have a clue about this module, or even javascript so any
help would be appreciated.
P.S. sorry about the mess