[Webtest] Re: AW: help please

Marc Guillemot Marc Guillemot <mguillemot@yahoo.fr>
Wed, 13 Dec 2006 11:39:54 +0100


With such a script (as copied from your mail), my Firefox complains 
with: "unterminated regular expression literal". Seems to indicate that 
your js code is incorrect. Do you have the same error in your "normal" 
browser?

Marc.

mamtha lalith wrote:
> hi Marc,
> this is the complete console trace
> com.canoo.webtest.engine.StepFailedException:
> Step[clickButton "Adding New Profile" (6/7)]: Script
> error loading page executing webtest at: clickButton
> syntax error (Embedded script in
> http://198.162.18.113:8080/profile/actions/NewProfileFlash?ac=showNewProfile#2)
> Source code: var dates1 =
> /^(?:(((Jan(uary)?|Ma(r(ch)?|y)|Jul(y)?|Aug(ust)?|Oct(ober)?|Dec(ember)?)\
> 31)|((Jan(uary)?|Ma(r(ch)?|y)|Apr(il)?|Ju((ly?)|(ne?))|Aug(ust)?|Oct(ober)?|(Sept|Nov|Dec)(ember)?)\
> (0?[1-9]|([12]\d)|30))|(Feb(ruary)?\
> (0?[1-9]|1\d|2[0-8]|(29(?=,\
> ((1[6-9]|[2-9]\d)(0[48]|[2468][048]|[13579][26])|((16|[2468][048]|[3579][26])00)))))))\,\
> ((1[6-9]|[2-9]\d)\d{2}))/; var dates2 =
> /(0[0-9]|1[0-2])[/ /]([0-2][0-9]|3[01])[/
> /](19[0-9]{2}|[2][0-9][0-9]{2})/; function
> maxLengthCheck(field,len) { var val=field.value;
> if(val.length>len) { alert("Enter Only "+len+"
> Charectors");
> field.value=field.value.substring(0,len); } } function
> printMode() {
> document.forms[0].action='../jsp/CandidateProfilePDF.jsp';
> document.forms[0].method="POST"
> document.forms[0].submit(); } function addTechExp() {
> var msg1=""; var focus1="";
> for(i=0;i<document.forms[0].elements.length;i++) {
> if(document.forms[0].elements[i].type=="text" &&
> document.forms[0].elements[i].name=="technologyName" )
> { if(document.forms[0].elements[i].value=="" ||
> (!(isNaN(document.forms[0].elements[i].value)))) {
> if(msg1=="") { msg1=msg1+"Enter data for Technical
> Skills.\n"; document.forms[0].elements[i].value=""; }
> if(focus1=="") { focus1=i; } } } else
> if(document.forms[0].elements[i].type=="text" &&
> document.forms[0].elements[i].name=="technicalExperiencePeriod"
> ) { if(document.forms[0].elements[i].value=="" ||
> isNaN(document.forms[0].elements[i].value)) {
> if(msg1=="") { msg1=msg1+"Enter data for Technical Exp
> Periods.\n"; } if(focus1=="") { focus1=i; } } else
> if(document.forms[0].elements[i].value>50) {
> if(msg1=="") { msg1=msg1+"Years cant be greated than
> 50.\n"; } if(focus1=="") { focus1=i; } } } }
> if(msg1=="") {
> document.forms[0].action='../actions/NewProfileFlash?ac=addTechnicalExperience';
> document.forms[0].method="POST"
> document.forms[0].submit(); } else { alert(msg1);
> document.forms[0].elements[focus1].focus(); } }
> function removeTechExp(index) {
> document.forms[0].deleteTechExpIndex.value=index;
> document.forms[0].action='../actions/NewProfileFlash?ac=removeTechnicalExperience';
> document.forms[0].method="POST"
> document.forms[0].submit(); } function
> changeTechExpGraphColor(colorCode) {
> document.forms[0].techExpGraphColor.value=colorCode;
> document.forms[0].action='../actions/NewProfileFlash?ac=changeTechExpGraphColor';
> document.forms[0].method="POST"
> document.forms[0].submit(); } function
> changeTechExpGraphChartType() {
> document.forms[0].action='../actions/NewProfileFlash?ac=changeTechExpGraphChartType';
> document.forms[0].method="POST"
> document.forms[0].submit(); } function
> redrawTechExpGraph() { var tflag="true";
> for(i=0;i<document.forms[0].elements.length;i++) {
> if(document.forms[0].elements[i].type=="text" &&
> document.forms[0].elements[i].name=="technicalExperiencePeriod"
> ) { if(isNaN(document.forms[0].elements[i].value)) {
> tflag="false"; document.forms[0].elements[i].value="";
> document.forms[0].elements[i].focus(); alert("Enter
> Numerical Value for Years Field."); return false; } }
> } if(tflag=="true") {
> document.forms[0].action='../actions/NewProfileFlash?ac=redrawTechExpGraph';
> document.forms[0].method="POST"
> document.forms[0].submit(); } } function
> addPrevWorkExp() { var msg2=""; var focus2="";
> for(i=0;i<document.forms[0].elements.length;i++) {
> if(document.forms[0].elements[i].type=="text" &&
> document.forms[0].elements[i].name=="previousCompany"
> ) { if(document.forms[0].elements[i].value=="" ||
> (!(isNaN(document.forms[0].elements[i].value)))) {
> if(msg2=="") { msg2=msg2+"Enter the Previous Company
> Name.\n"; } if(focus2=="") { focus2=i; } } } else
> if(document.forms[0].elements[i].type=="text" &&
> document.forms[0].elements[i].name=="designation" ) {
> if(document.forms[0].elements[i].value=="" ||
> (!(isNaN(document.forms[0].elements[i].value)))) {
> if(msg2=="") { msg2=msg2+"Enter your Designation.\n";
> } if(focus2=="") { focus2=i; } } } else
> if(document.forms[0].elements[i].type=="text" &&
> document.forms[0].elements[i].name=="previousWorkExpPeriod"
> ) { if(document.forms[0].elements[i].value=="" ||
> isNaN(document.forms[0].elements[i].value)) {
> if(msg2=="") { msg2=msg2+"Enter the Work
> Experience.\n"; } if(focus2=="") { focus2=i; } } }
> else if(document.forms[0].elements[i].type=="text" &&
> document.forms[0].elements[i].name=="endDate") {
> if(document.forms[0].elements[i].value=="" ) {
> if(msg2=="") { msg2=msg2+"Enter the Date.\n"; }
> if(focus2=="") { focus2=i; } } } } if(msg2=="") {
> document.forms[0].action='../actions/NewProfileFlash?ac=addPreviousExperience';
> document.forms[0].method="POST"
> document.forms[0].submit(); } else { alert(msg2);
> document.forms[0].elements[focus2].focus(); return
> false; } } function removePrevWorkExp(index) {
> document.forms[0].deletePrevExpIndex.value=index;
> document.forms[0].action='../actions/NewProfileFlash?ac=removePreviousExperience';
> document.forms[0].method="POST"
> document.forms[0].submit(); } function
> changePrevExpGraphColor(colorCode) {
> document.forms[0].prevExpGraphColor.value=colorCode;
> document.forms[0].action='../actions/NewProfileFlash?ac=changePrevExpGraphColor';
> document.forms[0].method="POST"
> document.forms[0].submit(); } function
> changePrevExpGraphChartType() {
> document.forms[0].action='../actions/NewProfileFlash?ac=changePrevExpGraphChartType';
> document.forms[0].method="POST"
> document.forms[0].submit(); } function
> redrawPrevExpGraph() { var pflag="true";
> for(i=0;i<document.forms[0].elements.length;i++) {
> if(document.forms[0].elements[i].type=="text" &&
> document.forms[0].elements[i].name=="previousWorkExpPeriod"
> ) { if(isNaN(document.forms[0].elements[i].value)) {
> pflag="false"; document.forms[0].elements[i].value="";
> document.forms[0].elements[i].focus(); alert("Enter
> Numerical Value for Months field."); return false; } }
> } if(pflag=="true") {
> document.forms[0].action='../actions/NewProfileFlash?ac=redrawPrevExpGraph';
> document.forms[0].method="POST"
> document.forms[0].submit(); } } function addMiscInfo()
> { var msg3=""; var focus3="";
> for(i=0;i<document.forms[0].elements.length;i++) {
> if(document.forms[0].elements[i].type=="text" &&
> document.forms[0].elements[i].name=="otherSkills" ) {
> if(document.forms[0].elements[i].value=="") {
> if(msg3=="") { msg3=msg3+"Enter information for other
> Skills.\n"; } if(focus3=="") { focus3=i; } } } else
> if(document.forms[0].elements[i].type=="text" &&
> document.forms[0].elements[i].name=="commOfficeSkills"
> ) { if(document.forms[0].elements[i].value=="") {
> if(msg3=="") { msg3=msg3+"Enter your communication
> Skills.\n"; } if(focus3=="") { focus3=i; } } } else
> if(document.forms[0].elements[i].type=="text" &&
> document.forms[0].elements[i].name=="education" ) {
> if(document.forms[0].elements[i].value=="") {
> if(msg3=="") { msg3=msg3+"Enter your Education
> details.\n"; } if(focus3=="") { focus3=i; } } } else
> if(document.forms[0].elements[i].type=="text" &&
> document.forms[0].elements[i].name=="degrees" ) {
> if(document.forms[0].elements[i].value=="") {
> if(msg3=="") { msg3=msg3+"Enter your Degrees and
> Certification information.\n"; } if(focus3=="") {
> focus3=i; } } } } if(msg3=="") {
> document.forms[0].action='../actions/NewProfileFlash?ac=addMiscInfo';
> document.forms[0].method="POST"
> document.forms[0].submit(); } else { alert(msg3);
> document.forms[0].elements[focus3 ].focus(); } }
> function removeMiscInfo(index) {
> document.forms[0].deleteMiscInfoIndex.value=index;
> document.forms[0].action='../actions/NewProfileFlash?ac=removeMiscInfo';
> document.forms[0].method="POST"
> document.forms[0].submit(); } function showPreview() {
> document.forms[0].showProfilePreview.value='Y';
> document.forms[0].action='../actions/NewProfileFlash?ac=showProfileFlashDetails';
> document.forms[0].method="POST"
> document.forms[0].submit(); } function
> clearFormFields() {
> for(i=0;i<document.forms[0].length-3;i++)
> document.forms[0].elements[i].value="";
> document.forms[0].action='../actions/NewProfileFlash?ac=showNewProfile';
> document.forms[0].method="POST"
> document.forms[0].submit(); } function
> submitFormFields() { var msg=""; var focuson=""; var
> flag1="true"; var flags="true"; var d1=new
> Array("`","~","!","@","#","$","%","^","&","*","(",")","-","_","+","=","|","}","]","[","{","'",";","\"",":","/","?",".",">",",","<","\\");
> var emailRe =
> /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*\.(\w{2}|(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum))$/
> if(document.forms[0].profileName.value=="" ||
> !isNaN(document.forms[0].profileName.value)) {
> alert("Please Enter Profile Name.");
> document.forms[0].profileName.value="";
> document.forms[0].profileName.focus(); return false; }
> if(document.forms[0].profileName.value!="") { var
> d2=new Array();
> d2=document.forms[0].profileName.value.split('');
> for(i=0;i<d2.length;i++) { for(j=0;j<d1.length;j++) {
> if(d2[i]==d1[j]) { flags="false"; } } }
> if(flags=="false") { alert("Entered Valid Profile
> Name."); document.forms[0].profileName.focus(); return
> false; } }
> if(document.forms[0].profileName.value.length>35 ) {
> alert("Profile name should not be more than 35
> Characters"); document.forms[0].profileName.focus();
> return false; }
> if(document.forms[0].firstName.value=="") {
> alert("Please Enter First Name");
> document.forms[0].firstName.value="";
> document.forms[0].firstName.focus(); return false; }
> if(document.forms[0].firstName.value!="") { var d2=new
> Array();
> d2=document.forms[0].firstName.value.split('');
> for(i=0;i<d2.length;i++) { for(j=0;j<d1.length;j++) {
> if(d2[i]==d1[j] || d2[i]==j) { flags="false"; } } }
> if(flags=="false") { alert("Entered Valid First
> Name."); document.forms[0].firstName.focus(); return
> false; } } if(document.forms[0].lastName.value=="" ) {
> alert("Please Enter Last Name");
> document.forms[0].lastName.value="";
> document.forms[0].lastName.focus(); return false; }
> if(document.forms[0].lastName.value!="") { var d2=new
> Array();
> d2=document.forms[0].lastName.value.split('');
> for(i=0;i<d2.length;i++) { for(j=0;j<d1.length;j++) {
> if(d2[i]==d1[j] || d2[i]==j) { flags="false"; } } }
> if(flags=="false") { alert("Entered Valid Last
> Name."); document.forms[0].lastName.focus(); return
> false; } }
> if(document.forms[0].emailAddress.value=="") {
> alert("Enter your Email Address");
> document.forms[0].emailAddress.value="";
> document.forms[0].emailAddress.focus(); return false;
> } if(document.forms[0].emailAddress.value!="") { if
> (!(emailRe.test(document.forms[0].emailAddress.value)))
> { alert("Email Address is invalid");
> document.forms[0].emailAddress.value="";
> document.forms[0].emailAddress.focus(); return false;
> } } if(document.forms[0].addressLine1.value=="") {
> alert("Please Enter Address1");
> document.forms[0].addressLine1.value="";
> document.forms[0].addressLine1.focus(); return false;
> } if(document.forms[0].city.value=="") { alert("Please
> Enter value for City");
> document.forms[0].city.value="";
> document.forms[0].city.focus(); return false; }
> if(document.forms[0].city.value!="") { var d2=new
> Array(); d2=document.forms[0].city.value.split('');
> for(i=0;i<d2.length;i++) { for(j=0;j<d1.length;j++) {
> if(d2[i]==d1[j] || d2[i]==j) { flags="false"; } } }
> if(flags=="false") { alert("Entered Valid City.");
> document.forms[0].city.focus(); return false; } }
> if(document.forms[0].state.value=="") { alert("Please
> eneter the State."); document.forms[0].state.value="";
> document.forms[0].state.focus(); return false; }
> if(document.forms[0].state.value!="") { var d2=new
> Array(); d2=document.forms[0].state.value.split('');
> for(i=0;i<d2.length;i++) { for(j=0;j<d1.length;j++) {
> if(d2[i]==d1[j] || d2[i]==j) { flags="false"; } } }
> if(flags=="false") { alert("Entered Valid State.");
> document.forms[0].state.focus(); return false; } }
> if(document.forms[0].zipcode.value=="") {
> alert("Please Enter ZIP");
> document.forms[0].zipcode.value="";
> document.forms[0].zipcode.focus(); return false; }
> if(document.forms[0].zipcode.value!="") { var d2=new
> Array(); d2=document.forms[0].zipcode.value.split('');
> for(i=0;i<d2.length;i++) { for(j=0;j<d1.length;j++) {
> if(d2[i]==d1[j]) { alert("Enter Valid Zip Code.");
> document.forms[0].zipcode.focus(); return false; } } }
> } if(document.forms[0].residencePhone.value=="") {
> alert("Please Enter Residence Phone");
> document.forms[0].residencePhone.value="";
> document.forms[0].residencePhone.focus(); return
> false; }
> if(isNaN(document.forms[0].residencePhone.value)) {
> alert("Please Enter Residence Phone Numbers Only");
> document.forms[0].residencePhone.value="";
> document.forms[0].residencePhone.focus(); return
> false; } if(isNaN(document.forms[0].officePhone.value)
> || document.forms[0].officePhone.value=="") {
> alert("Please Enter Office Phone Numbers Only");
> document.forms[0].officePhone.value="";
> document.forms[0].officePhone.focus(); return false; }
> if(document.forms[0].mobilePhone.value=="") {
> alert("Please Enter Mobile ");
> document.forms[0].mobilePhone.value="";
> document.forms[0].mobilePhone.focus(); return false; }
> if(isNaN(document.forms[0].mobilePhone.value)) {
> alert("Please Enter Mobile Phone Numbers Only ");
> document.forms[0].mobilePhone.value="";
> document.forms[0].mobilePhone.focus(); return false; }
> if(document.forms[0].noteToReader.value=="" ||
> !isNaN(document.forms[0].noteToReader.value)) {
> alert("Please Enter Note To Reader");
> document.forms[0].noteToReader.value="";
> document.forms[0].noteToReader.focus(); return false;
> } if(document.forms[0].noteToReader.value.length>150)
> { alert("Note to Reader should not be more than 150
> Characters"); document.forms[0].noteToReader.focus();
> return false; } var msg1=""; var focuson1="";
> for(i=0;i<document.forms[0].elements.length;i++) {
> if(document.forms[0].elements[i].type=="text" &&
> document.forms[0].elements[i].name=="technologyName" )
> { if(isNaN(document.forms[0].elements[i+1].value)) {
> if(msg1=="") { msg1=msg1+"Enter a Numerical value for
> Years."; } if(focuson1=="") { focuson1=i+1; } } else
> if(document.forms[0].elements[i].value=="" &&
> document.forms[0].elements[i+1].value!="") {
> if(msg1=="") { msg1=msg1+"Enter your Skills value."; }
> if(focuson1=="") { focuson1=i; } } else
> if(document.forms[0].elements[i].value!="" &&
> document.forms[0].elements[i+1].value=="") {
> if(msg1=="") { msg1=msg1+"Enter a value for Years."; }
> if(focuson1=="") { focuson1=i+1; } } } } if(msg1!="")
> { alert(msg1);
> document.forms[0].elements[focuson1].focus();
> document.forms[0].elements[focuson1].value=""; return
> false; } var msg2=""; var focuson2="";
> for(i=0;i<document.forms[0].elements.length;i++) {
> if(document.forms[0].elements[i].type=="text" &&
> document.forms[0].elements[i].name=="previousCompany"
> ) { if(isNaN(document.forms[0].elements[i+3].value)) {
> if(msg2=="") { msg2=msg2+"Enter a Numerical value for
> Number of Months."; } if(focuson2=="") { focuson2=i+3;
> } } else if(document.forms[0].elements[i].value!="") {
> if(document.forms[0].elements[i+2].value=="") {
> if(msg2=="") { msg2=msg2+"Enter a value for Job
> Title.\n"; } if(focuson2=="") { focuson2=i+2; } }
> if(document.forms[0].elements[i+3].value=="" ||
> isNaN(document.forms[0].elements[i+3].value)) {
> if(msg2=="") { msg2=msg2+"Enter a value for the number
> of Months.\n"; } if(focuson2=="") { focuson2=i+3; } }
> if(document.forms[0].elements[i+4].value=="") {
> if(msg2=="") { msg2=msg2+"Enter the Date Value.\n"; }
> if(focuson2=="") { focuson2=i+4; } } var ate1 =
> document.forms[0].elements[i+4].value;
> if(!(dates1.test(ate1))) { if(msg2=="") {
> msg2=msg2+"Enter the Date Value as : \n Mmm DD, YYYY";
> } if(focuson2=="") { focuson2=i+4; } } } else
> if(document.forms[0].elements[i+2].value!="") {
> if(document.forms[0].elements[i].value=="") {
> if(msg2=="") { msg2=msg2+"Enter the Previous Company
> Name.\n"; } if(focuson2=="") { focuson2=i; } }
> if(document.forms[0].elements[i+3].value=="" ||
> isNaN(document.forms[0].elements[i+3].value)) {
> if(msg2=="") { msg2=msg2+"Enter a value for the number
> of Months.\n"; } if(focuson2=="") { focuson2=i+3; } }
> if(document.forms[0].elements[i+4].value=="") {
> if(msg2=="") { msg2=msg2+"Enter the Date Value.\n"; }
> if(focuson2=="") { focuson2=i+4; } } } else
> if(document.forms[0].elements[i+3].value!="") {
> if(document.forms[0].elements[i].value=="") {
> if(msg2=="") { msg2=msg2+"Enter the Previous Company
> Name.\n"; } if(focuson2=="") { focuson2=i; } }
> if(document.forms[0].elements[i+2].value=="") {
> if(msg2=="") { msg2=msg2+"Enter a value for Job
> Title."; } if(focuson2=="") { focuson2=i+2; } }
> if(document.forms[0].elements[i+4].value=="") {
> if(msg2=="") { msg2=msg2+"Enter the Date Value.\n"; }
> if(focuson2=="") { focuson2=i+4; } } } else
> if(document.forms[0].elements[i+4].value!="") {
> if(document.forms[0].elements[i].value=="") {
> if(msg2=="") { msg2=msg2+"Enter the Previous Company
> Name.\n"; } if(focuson2=="") { focuson2=i; } }
> if(document.forms[0].elements[i+2].value=="") {
> if(msg2=="") { msg2=msg2+"Enter a value for Job
> Title."; } if(focuson2=="") { focuson2=i+2; } }
> if(document.forms[0].elements[i+3].value=="") {
> if(msg2=="") { msg2=msg2+"Enter the a value for Number
> of Months.\n"; } if(focuson2=="") { focuson2=i+3; } }
> } } } if(msg2!="") { alert(msg2);
> document.forms[0].elements[focuson2].value="";
> document.forms[0].elements[focuson2].focus(); return
> false; } var msg3=""; var focuson3="";
> for(i=0;i<document.forms[0].elements.length;i++) {
> if(document.forms[0].elements[i].type=="text" &&
> document.forms[0].elements[i].name=="otherSkills" ) {
> if(document.forms[0].elements[i].value=="" ||
> (!(isNaN(document.forms[0].elements[i].value)))) {
> if(msg3=="") { msg3=msg3+"Enter value for other
> Skills.\n"; } if(focuson3=="") { focuson3=i; } } }
> else if(document.forms[0].elements[i].type=="text" &&
> document.forms[0].elements[i].name=="commOfficeSkills"
> ) { if(document.forms[0].elements[i].value=="" ||
> (!(isNaN(document.forms[0].elements[i].value)))) {
> if(msg3=="") { msg3=msg3+"Enter your communication and
> other skills.\n"; } if(focuson3=="") { focuson3=i; } }
> } else if(document.forms[0].elements[i].type=="text"
> && document.forms[0].elements[i].name=="education" ) {
> if(document.forms[0].elements[i].value=="" ||
> (!(isNaN(document.forms[0].elements[i].value)))) {
> if(msg3=="") { msg3=msg3+"Enter Educational
> qualification .\n"; } if(focuson3=="") { focuson3=i; }
> } } else if(document.forms[0].elements[i].type=="text"
> && document.forms[0].elements[i].name=="degrees" ) {
> if(document.forms[0].elements[i].value=="" ||
> (!(isNaN(document.forms[0].elements[i].value)))) {
> if(msg3=="") { msg3=msg3+"Enter your Graduation
> information.\n"; } if(focuson3=="") { focuson3=i; } }
> } } if(msg3!="") { alert(msg3);
> document.forms[0].elements[focuson3].focus(); return
> false; } } function clearTableRows() { var tableName =
> document.getElementById('skillTable'); var lastRow =
> tableName.rows.length; while(lastRow>10) {
> tableName.deleteRow(lastRow-1); lastRow=lastRow-1; } }
> function errPop() {
> for(i=0;i<document.forms[0].elements.length;i++) {
> if(document.forms[0].elements[i].type=="text" &&
> document.forms[0].elements[i].name=="technicalExperiencePeriod"
> ) { if(isNaN(document.forms[0].elements[i].value)) {
> alert("Enter Numerical Value for Technical Skills.");
> document.forms[0].elements[i].value="";
> document.forms[0].elements[i].focus(); return false; }
> } } }, Step: ClickButton at
> C:\Canoo\tests\addnew.xml:15: with
> (resultFilename="response_1166001575189_clickButton.html",
> taskName="clickButton")"
> --- Marc Guillemot <mguillemot@yahoo.fr> wrote:
> 
>> Hi,
>>
>> seems that your js isn't ok for htmlunit. Can you
>> provide the whole 
>> stack trace you should see on the console?
>>
>> Marc.
> 
> 
> 
>  
> ____________________________________________________________________________________
> Any questions? Get answers on any topic at www.Answers.yahoo.com.  Try it now.