Thanks Julien, im using jWebUnit 2.2.. I took the advice in the link you provide. I put alert on the getCookie method and in the condition statement in my login.jsp like this:
if (getCookie("username") != null) { alert("im here inside cookie"); $("j_username").value = getCookie("username"); $("j_password").focus(); } else { alert("else cookie"); $("j_username").focus(); } My external javacript cookie method.. function getCookie(c_name) { alert("getCookie"); if (document.cookie.length > 0) { c_start = document.cookie.indexOf(c_name + "="); if (c_start != -1) { c_start = c_start + c_name.length + 1; c_end = document.cookie.indexOf(";", c_start); if (c_end == -1) c_end = document.cookie.length return unescape(document.cookie.substring(c_start, c_end)); } } return "" } But the alert did not show in the browser. So i assumed that it is not used. when i removed i got a null pointer in beginAt("/login.jsp"). Here is my jWebUnit Test code public void test1() { beginAt("/login.jsp"); assertTitleEquals("Login"); assertFormElementPresent("j_username"); assertFormElementPresent("j_password"); setTextField("j_username", "admin"); setTextField("j_password", "admin"); clickLink("Login"); submit(); //assertTitleEquals("Home Page"); } Can you advice me what went wrong or what im doing wrong.. Thanks a lot Julien for the time and idea.. Julien HENRY wrote: > > Hi Nelson, > > > > JWebUnit (in fact HtmlUnit) is perfectly able to fetch an external > > JavaScript file. What version of JWebUnit are you using? > > > > You may try to read http://htmlunit.sourceforge.net/submittingJSBugs.html > > if you plan to ask for help for your specific error. > > > > Regards, > > > > Julien > > > > > > > > ----- Message d'origine ---- > > > >> >> De : Nelson Biasura <nelson.bias...@aurisoftsys.com> >> >> À : jwebunit-users@lists.sourceforge.net >> >> Envoyé le : Jeu 22 Octobre 2009, 12 h 40 min 22 s >> >> Objet : [JWebUnit-users] getCookie Error External Javascript >> >> >> >> >> >> I have getCookie javascript method in my login.jsp. It is in my >> >> cookie.js, it is >> >> external javacript method. Does jWebUnit can't see an external javascript? >> >> Do anyone have idea what is this error? and how to fix it or work around? >> >> >> >> Below is the error Log: >> >> >> >> [junit] Testcase: >> >> test1(com.voxsant.thinkscan.webapp.action.WebTest): Caused an ERROR >> >> [junit] ReferenceError: "getCookie" is not defined. (script in >> >> http://localhost/login.jsp from ( >> >> 179, 40) to (212, 10)#180) >> >> [junit] ======= EXCEPTION START ======== >> >> [junit] EcmaError: lineNumber=[180] column=[0] lineSource=[ >> >> source>] name=[ReferenceError] so >> >> urceName=[script in http://localhost/login.jsp from (179, 40) to (212, >> >> 10)] message=[ReferenceError: >> >> "getCookie" is not defined. (script in http://localhost/login.jsp from >> >> (179, 40) to (212, 10)#180)] >> >> >> >> [junit] com.gargoylesoftware.htmlunit.ScriptException: >> >> ReferenceError: "getCookie" is not define >> >> d. (script in http://localhost/login.jsp from (179, 40) to (212, 10)#180) >> >> >> >> ------------------------------------------------------------------------------ >> >> Come build with us! The BlackBerry(R) Developer Conference in SF, CA >> >> is the only developer event you need to attend this year. Jumpstart your >> >> developing skills, take BlackBerry mobile applications to market and stay >> >> ahead of the curve. Join us from November 9 - 12, 2009. Register now! >> >> http://p.sf.net/sfu/devconference >> >> _______________________________________________ >> >> JWebUnit-users mailing list >> >> JWebUnit-users@lists.sourceforge.net >> >> https://lists.sourceforge.net/lists/listinfo/jwebunit-users >> >> >> > > > > > > > > > > > > ------------------------------------------------------------------------------ > > Come build with us! The BlackBerry(R) Developer Conference in SF, CA > > is the only developer event you need to attend this year. Jumpstart your > > developing skills, take BlackBerry mobile applications to market and stay > > ahead of the curve. Join us from November 9 - 12, 2009. Register now! > > http://p.sf.net/sfu/devconference > > _______________________________________________ > > JWebUnit-users mailing list > > JWebUnit-users@lists.sourceforge.net > > https://lists.sourceforge.net/lists/listinfo/jwebunit-users > > > ------------------------------------------------------------------------------ Come build with us! The BlackBerry(R) Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9 - 12, 2009. Register now! http://p.sf.net/sfu/devconference _______________________________________________ JWebUnit-users mailing list JWebUnit-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/jwebunit-users ------------------------------------------------------------------------------ Come build with us! The BlackBerry(R) Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9 - 12, 2009. Register now! http://p.sf.net/sfu/devconference _______________________________________________ JWebUnit-users mailing list JWebUnit-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/jwebunit-users