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="JavaS cript">
function mainPageOnLoad( ) {
initLogin();
setEnterToSubmi t('loginForm',' loginrequest');
}
</SCRIPT>
<form name="loginForm " method="post" action="/cs/login.do">
<input type="hidden" name="nxtpage" value="">
<input type="hidden" name="currentpa ge" value="login">
<input type="hidden" name="lng" value="en_CA">
<td width="38%" align="right" valign="middle" height="25"
class="detailsl abel">
Name: </td>
<td width="62%" class="detailsv alue">
<input type="text" name="name" maxlength="15" size="15"
value="">
<td width="38%" align="right" valign="middle" height="25"
class="detailsl abel">
Password: </td>
<td width="62%" align="left" valign="middle" height="25"
class="detailsv alue">
<input type="password" name="password" maxlength="15" size="15"
value="">
<a href="javascrip t:submitLoginFo rm('loginForm', 'loginrequest') "><img
src="../images/cs/en_CA/btn_ok.gif" alt="OK" border="0"></a>
<a
href="javascrip t:submitForm('l oginForm','logi nrequestchangep assword')"><img
src="../images/cs/en_CA/btn_changepassw ord.gif" alt="Change Password"
border="0"></a>
<a href="javascrip t:submitForm('l oginForm','pref erences')"><img
src="../images/cs/en_CA/btn_preferences .gif" alt="Preference s"
border="0"></a>
<script type="text/javascript" language="JavaS cript">
<!--
var focusControl = document.forms["loginForm"].elements["name"];
if (focusControl.t ype != "hidden") {
focusControl.fo cus();
}
// -->
</script>
----------------------------------------------
My code so far is this:
----------------------------------------------
from win32com.client import Dispatch
from time import sleep
ie = Dispatch('Inter netExplorer.App lication')
ie.Visible = 1
ie.Navigate("ht tp://ispds-sepsr.prv:7500/cs/welcome.jsp")
while ie.ReadyState != 4:
sleep(1)
doc = ie.Document
while doc.readyState != "complete":
sleep(1)
doc.loginForm.n ame.value = 'username'
doc.loginForm.p assword.value = 'password'
doc.loginForm.l oginform.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="JavaS cript">
function mainPageOnLoad( ) {
initLogin();
setEnterToSubmi t('loginForm',' loginrequest');
}
</SCRIPT>
<form name="loginForm " method="post" action="/cs/login.do">
<input type="hidden" name="nxtpage" value="">
<input type="hidden" name="currentpa ge" value="login">
<input type="hidden" name="lng" value="en_CA">
<td width="38%" align="right" valign="middle" height="25"
class="detailsl abel">
Name: </td>
<td width="62%" class="detailsv alue">
<input type="text" name="name" maxlength="15" size="15"
value="">
<td width="38%" align="right" valign="middle" height="25"
class="detailsl abel">
Password: </td>
<td width="62%" align="left" valign="middle" height="25"
class="detailsv alue">
<input type="password" name="password" maxlength="15" size="15"
value="">
<a href="javascrip t:submitLoginFo rm('loginForm', 'loginrequest') "><img
src="../images/cs/en_CA/btn_ok.gif" alt="OK" border="0"></a>
<a
href="javascrip t:submitForm('l oginForm','logi nrequestchangep assword')"><img
src="../images/cs/en_CA/btn_changepassw ord.gif" alt="Change Password"
border="0"></a>
<a href="javascrip t:submitForm('l oginForm','pref erences')"><img
src="../images/cs/en_CA/btn_preferences .gif" alt="Preference s"
border="0"></a>
<script type="text/javascript" language="JavaS cript">
<!--
var focusControl = document.forms["loginForm"].elements["name"];
if (focusControl.t ype != "hidden") {
focusControl.fo cus();
}
// -->
</script>
----------------------------------------------
My code so far is this:
----------------------------------------------
from win32com.client import Dispatch
from time import sleep
ie = Dispatch('Inter netExplorer.App lication')
ie.Visible = 1
ie.Navigate("ht tp://ispds-sepsr.prv:7500/cs/welcome.jsp")
while ie.ReadyState != 4:
sleep(1)
doc = ie.Document
while doc.readyState != "complete":
sleep(1)
doc.loginForm.n ame.value = 'username'
doc.loginForm.p assword.value = 'password'
doc.loginForm.l oginform.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
Comment