[Webtest] Newbie help with logon using form and javascript ...
Burnash, James (James)** CTR **
webtest@lists.canoo.com
Wed, 1 Sep 2004 15:01:15 -0400
All,
Greetings! I am a VERY new user of WebTest, as well as Ant, but have some experience with XML - but none with Java Script or Java itself :-(
I'm trying to get the login on the following page to work - but the Submit button on the page is un-named, and there is no action= for that button. It appears to me that a Javascript function is called when that button is clicked, so I've tried using ClickButton - to no avail - I get a button not found error.
I've attached my Ant/WebTest build file, and the build output below as well.
I apologize for my ignorance in these matters - but I am a technical person, so don't hold back.
James J Burnash
Systems Engineer
Here's the build script:
<project name="SimpleTest" basedir="." default="main">
<property name="base.dir" value="${basedir}"/>
<property name="webtest.home" value="../.."/>
<taskdef file="${webtest.home}/webtestTaskdefs.properties">
<classpath>
<fileset dir="${webtest.home}" includes="**/lib/*.jar"/>
</classpath>
</taskdef>
<target name="main">
<testSpec name="myTest">
<config
host="ebizunixtest2.bla.com"
protocol="http"
port="20060"
basepath="" />
<steps>
<invoke
stepid="go to CMS Login page"
url="html/CMSLogin.htm"/>
<verifytitle
stepid="we should see the CMS Login title"
text="CMS Login" />
<new_selectform
name="Login" />
<setinputfield stepid="set user name"
name="USER"
value="burnash" />
<setinputfield stepid="set password"
name="PASSWORD"
value="ironwall14" />
<clickbutton stepid="Click the submit button" label="bc_Submit"/>
<verifytitle
stepid="we should see the CMS Select Task title"
text="CMS Select Task Page" />
</steps>
</testSpec>
</target>
</project>
Here's the page source:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD><TITLE>ECMS Login</TITLE>
<META content="text/html; charset=windows-1252" http-equiv=Content-Type><LINK
href="../stylesheets/style.css" rel=stylesheet type=text/css>
<SCRIPT language=JavaScript type=text/javascript>
<!--
if(window.event + "" == "undefined") event = null;
function HM_f_PopUp(){return false};
function HM_f_PopDown(){return false};
popUp = HM_f_PopUp;
popDown = HM_f_PopDown;
//-->
</SCRIPT>
<SCRIPT language=JavaScript>
function resetCredFields()
{
document.Login.PASSWORD.value = "";
}
function checkUserName(){
var userName = document.Login.USER.value;
var domainIndex = userName.indexOf(unescape('%5C'));
if (domainIndex != -1)
{
var emplDomain = userName.substring(0, domainIndex);
var emplHandle = userName.substring(domainIndex+1, userName.length);
document.Login.USER.value = emplHandle;
}
}
function submitForm()
{
// Strip target without params
targetWithParams = document.Login.target.value;
queryStrIdx = targetWithParams.indexOf("?");
if ( queryStrIdx > 0 )
{
// there is query string
if( targetWithParams.indexOf("SMLOCALE") > 0 ) // SMLOCALE hs been defined
{}
else
document.Login.target.value = targetWithParams + "&SMLOCALE=US-EN";
}
else
document.Login.target.value = document.Login.target.value + "?SMLOCALE=US-EN";
//alert("Final Target is " + document.Login.target.value );
document.Login.submit();
}
</SCRIPT>
<SCRIPT language=JavaScript1.2 type=text/javascript>
<!--
//HM_PG_MenuWidth = 150;
HM_PG_FontFamily = "Verdana,Arial,sans-serif";
HM_PG_FontSize = 6.5;
HM_PG_FontBold = 1;
HM_PG_FontItalic = 0;
HM_PG_FontColor = "#0033CC";
HM_PG_FontColorOver = "#FFFFFF";
HM_PG_BGColor = "#EAEAEA";
HM_PG_BGColorOver = "#0033CC";
HM_PG_ItemPadding = 2;
HM_PG_BorderWidth = 1;
HM_PG_BorderColor = "#666666";
HM_PG_BorderStyle = "solid";
HM_PG_SeparatorSize = 1;
HM_PG_SeparatorColor = "#FFFFFF";
//HM_PG_ImageSrc = "HM_More_black_right.gif";
//HM_PG_ImageSrcLeft = "HM_More_black_left.gif";
//HM_PG_ImageSrcOver = "HM_More_white_right.gif";
//HM_PG_ImageSrcLeftOver = "HM_More_white_left.gif";
//HM_PG_ImageSize = 5;
//HM_PG_ImageHorizSpace = 0;
//HM_PG_ImageVertSpace = 2;
HM_PG_KeepHilite = true;
HM_PG_ClickStart = 0;
HM_PG_ClickKill = false;
HM_PG_ChildOverlap = 20;
HM_PG_ChildOffset = 10;
HM_PG_ChildPerCentOver = null;
HM_PG_TopSecondsVisible = .1;
HM_PG_StatusDisplayBuild =0;
HM_PG_StatusDisplayLink = 0;
HM_PG_UponDisplay = null;
HM_PG_UponHide = null;
HM_PG_RightToLeft = false;
HM_PG_CreateTopOnly = 1;
HM_PG_ShowLinkCursor = 1;
HM_PG_NSFontOver = true;
//HM_a_TreesToBuild = [2];
//-->
</SCRIPT>
<SCRIPT language=JavaScript type=text/javascript>
<!--
function MM_openBrWindow(theURL,winName,features) { //v2.0
window.open(theURL,winName,features);
}
//-->//-->
</SCRIPT>
<SCRIPT language=JavaScript>
<!--
function MM_reloadPage(init) { //reloads the window if Nav4 resized
if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);
// -->
</SCRIPT>
<META content="MSHTML 5.00.2920.0" name=GENERATOR></HEAD>
<BODY bgColor=#ffffff leftMargin=0 onload=resetCredFields(); topMargin=0
marginheight="0" marginwidth="0">
<SCRIPT language=Javascript>
function clearFields(form){
document.forms[0].USER.value='';
document.forms[0].PASSWORD.value='';
}
</SCRIPT>
<FORM action="/login.fcc" method=post name=Login onSubmit='return checkUserName()'><INPUT name=SMENC type=hidden
value=ISO-8859-1> <INPUT name=SMLOCALE type=hidden value=US-EN> <INPUT
name=target type=hidden value="/release/ECMSMainHomePage"> <INPUT
name=smauthreason type=hidden value=0> <INPUT name=SY_Form_Name type=hidden
value=loginForm> <INPUT name=Originator_Pub type=hidden value=ECMSLogin>
<TABLE border=0 cellPadding=0 cellSpacing=0 width="100%">
<TBODY>
<TR>
<TD width=68>
<TABLE border=0 cellPadding=0 cellSpacing=0>
<TBODY>
<TR>
<TD> </TD>
<TD> </TD>
<TD> </TD></TR></TBODY></TABLE></TD>
<TD width="100%"><SPACER height="1" width="1" type="block"></TD>
<TD align=right width=41> </TD>
<TD align=right width=41> </TD>
<TD align=right width=57> </TD>
<TD align=right width=10><IMG border=0 height=9
src="../images/transpixel.gif" width=10></TD></TR>
<TR bgColor=#0033cc>
<TD colSpan=6 height=1><SPACER height="1" width="1" type="block"></TD></TR>
<TR>
<TD bgColor=#cccccc colSpan=6 height=2><SPACER height="2" width="1"
type="block"></TD></TR>
<TR>
<TD bgColor=#ffffff colSpan=6 height=10><SPACER height="10" width="1"
type="block"></TD></TR></TBODY></TABLE>
<TABLE border=0 cellPadding=0 cellSpacing=0 width="100%">
<TBODY>
<TR>
<TD height=7 width=195><IMG border=0 height=1
src="../images/transpixel.gif" width=195></TD>
<TD width=9><SPACER height="1" width="1" type="block"></TD>
<TD rowSpan=2 width=1><IMG height=45 src="../images/logo_emcs2.gif"
width=98><SPACER height="1" width="1" type="block"></TD>
<TD align=left rowSpan=2 width=2><IMG height=21
src="../images/dottedv_home.gif" width=9> </TD>
<TD align=left rowSpan=2 width=1>
<TABLE border=0 cellPadding=0 cellSpacing=1>
<TBODY>
<TR>
<TD width=10><IMG height=9 src="../images/transpx.gif"
width=10></TD>
<TD noWrap><IMG alt="Customer Center" border=0 height=28
src="../images/title_ecms2.gif" width=189></TD></TR>
<TR>
<TD width=10> </TD>
<TD height=11 noWrap> </TD></TR></TBODY></TABLE></TD>
<TD align=right rowSpan=2 vAlign=top width=623><IMG height=65
src="../images/logo.gif" width=215></TD></TR>
<TR>
<TD vAlign=top width=195>
<TABLE align=left border=0 cellPadding=0 cellSpacing=0 width="100%">
<TBODY>
<TR align=left>
<TD bgColor=#999999 height=1 width=20><SPACER height="1" width="1"
type="block"></TD>
<TD bgColor=#999999 height=1 width=120><SPACER height="1" width="1"
type="block"></TD>
<TD bgColor=#999999 height=1 width=60><SPACER height="1" width="1"
type="block"></TD></TR>
<TR>
<TD><SPACER height="1" width="1" type="block"></TD>
<TD> </TD>
<TD><SPACER height="1" width="1" type="block"></TD></TR>
<TR>
<TD><SPACER height="1" width="1" type="block"></TD>
<TD></TD></TR>
<TR>
<TD><SPACER height="1" width="1" type="block"></TD>
<TD> </TD>
<TD><SPACER height="1" width="1"
type="block"></TD></TR></TBODY></TABLE></TD>
<TD align=left vAlign=top width=9><IMG alt="" border=0 height=58
src="../images/curve.gif" width=9></TD></TR>
<TR align=left>
<TD bgColor=#999999 height=1 width=195><SPACER height="1" width="1"
type="block"></TD>
<TD width=9><SPACER height="1" width="9" type="block"></TD>
<TD bgColor=#999999 colSpan=4 height=1><SPACER height="1" width="1"
type="block"></TD></TR></TBODY></TABLE>
<TABLE border=0 cellPadding=7 cellSpacing=0 width="100%">
<TBODY>
<TR vAlign=top>
<TD vAlign=top width=180>
<P><IMG border=0 height=1 src="../images/transpixel.gif" width=180>
<BR></P></TD>
<TD vAlign=top width="100%">
<TABLE border=0 cellPadding=0 cellSpacing=0 width="100%">
<TBODY>
<TR>
<TD class=V14> </TD></TR></TBODY></TABLE>
<TABLE border=0 cellPadding=0 cellSpacing=0 width="100%">
<TBODY>
<TR>
<TD class=H1>ECMS Login</TD></TR>
<TR>
<TD height=8><SPACER height="1" width="1" type="block"></TD></TR>
<TR>
<TD class=T1><BR>Enter your NT username and password, then
click the Submit button.<BR></TD></TR>
<TR>
<TD class=V14>
<TABLE border=0 cellPadding=2 cellSpacing=0 width="100%">
<TBODY>
<TR>
<TD class=V20> </TD></TR>
<TR>
<TD class=V20><B>User Name</B></TD></TR>
<TR>
<TD class=V20><INPUT name=USER size=30> </TD></TR><!--Begin spacer--><!--End spacer--></TBODY></TABLE></TD></TR></TBODY></TABLE>
<TABLE border=0 cellPadding=2 cellSpacing=0 width="100%">
<TBODY>
<TR>
<TD></TD></TR>
<TR>
<TD class=V20 height=8> </TD></TR>
<TR>
<TD class=V20 height=8><B>Password</B></TD></TR>
<TR>
<TD class=V20 height=8><INPUT name=PASSWORD size=30 type=password>
</TD></TR>
<TR>
<TD class=V20 height=8> </TD></TR>
<TR>
<TD class=V20 height=8> </TD></TR>
<TR>
<TD class=V20>
<TABLE border=0 cellPadding=0 cellSpacing=0 width="80%">
<TBODY>
<TR>
<TD background=../images/dot.gif height=1><IMG height=1
src="../images/blank.gif"
width=1></TD></TR></TBODY></TABLE></TD></TR>
<TR>
<TD class=V20> </TD></TR>
<TR>
<TD class=V20><INPUT alt=Submit border=0 cache
src="../images/buttons/bc_Submit.gif" type=image> <A
href="javascript:clearFields(this)"><IMG alt=Cancel border=0
src="../images/buttons/bc_Clear.gif"></A></TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE><!-- #BeginLibraryItem "/Library/Footer.lbi" -->
<SCRIPT language=JavaScript type=text/javascript>
function openCopyright()
{
window.open("/html/ECMSCopyright.html")
}
</SCRIPT>
<TABLE border=0 cellPadding=0 cellSpacing=0 width="100%">
<TBODY>
<TR>
<TD class=V20> </TD></TR><!--
<tr>
<td align="center"><span class="T1"><a href="javascript:openCopyright()">Copyright</a> ©
Eternal Tech Bla Bla, Inc. All rights reserved.</span> </td>
</tr> -->
<TR>
<TD height=10><SPACER height="1" width="1"
type="block"></TD></TR></TBODY></TABLE><!-- #EndLibraryItem --></FORM>
<SCRIPT language=JavaScript1.2 src="../images/HM_Loader.js"
type=text/javascript></SCRIPT>
</BODY></HTML>
... and here's the output from Ant / WebTest ...
Buildfile: ECMSLogin.xml
main:
[testSpec] INFO (Step.java:211) - Start Step: null "[implict setup step]" (1/9)
[testSpec] INFO (Step.java:206) - Completed Step: null "[implict setup step]" (1/9)
[testSpec] INFO (Step.java:211) - Start Step: invoke "go to CMS Login page" (2/9)
[testSpec] INFO (Target.java:146) - -> gotoTarget(by url): http://ebizunixtest2.bla.com:20060/html/Login.htm
[testSpec] INFO (Context.java:190) - Current form set to none
[testSpec] INFO (Step.java:206) - Completed Step: invoke "go to CMS Login page" (2/9)
[testSpec] INFO (Step.java:211) - Start Step: verifytitle "we should see the CMS Login title" (3/9)
[testSpec] INFO (Step.java:206) - Completed Step: verifytitle "we should see the CMS Login title" (3/9)
[testSpec] INFO (Step.java:211) - Start Step: new_selectform "<unknown>" (4/9)
[testSpec] INFO (Context.java:188) - Current form set to (action=/login.fcc)
[testSpec] INFO (Step.java:206) - Completed Step: new_selectform "<unknown>" (4/9)
[testSpec] INFO (Step.java:211) - Start Step: setinputfield "set user name" (5/9)
[testSpec] INFO (Step.java:206) - Completed Step: setinputfield "set user name" (5/9)
[testSpec] INFO (Step.java:211) - Start Step: setinputfield "set password" (6/9)
[testSpec] INFO (Step.java:206) - Completed Step: setinputfield "set password" (6/9)
[testSpec] INFO (Step.java:211) - Start Step: clickbutton "Click the submit button" (7/9)
BUILD FAILED
C:\webtest\doc\samples\ECMSLogin.xml:13: Test failed.
Test step clickbutton named "Click the submit button" failed with message "Button with name <<not specified>> and value <bc_Submit> not found!"
Total time: 5 seconds