Hi, despite my JS and Rhino knowledge, I don't use JS to script Java but I really prefer Groovy ;-)
1) no idea 2) is it possible that you use java 1.4? In this case Rhino seems to be configured to handle the string as java.lang.String, not as native js string and there is no method replace(String, String) in Java 1.4. Cheers, Marc. -- Blog: http://mguillem.wordpress.com Alexander Mannsfeld wrote: > Hi Marc, > > thanks for your answer and input; I did not know that verifyXPath can > used for actions like this too; meanwhile I've got a (within a browser) > working JavaScript-Snippet(this one changed slightly for use within > webtest): > > <scriptStep description="Calculate if deposit amount is correct" > language="javascript"> > amount_diff=0; > amount_old=0; > amount_new=0; > amount_dep=10; > amount_new=#{accountBalanceNew}; > amount_old=#{accountBalance}; > amount_new = amount_new.replace((/,/g), "."); > amount_old = amount_old.replace((/,/g), "."); > amount_diff=amount_new-amount_dep; > if(amount_diff-amount_old==0) { > step.setWebtestProperty('amountDiffers', 'false'); > } else { > step.setWebtestProperty('amountDiffers', 'true'); > } > </scriptStep> > > At the moment I've got two problems: > 1.) Accessing webTest's properties: > My first try was using: "step.webtestProperties.accountBalanceNew" > -> didn't work, failed with a JS-error(amount_new was still null). After > changing to "#{accountBalanceNew}" the webTests seems to get a bit > further, but.... > > 2.) now it fails with this statement: > [scriptStep] ERROR (org.apache.bsf.BSFManager) - Exception : > [scriptStep] java.security.PrivilegedActionException: > org.apache.bsf.BSFException: JavaScript Error: Internal Error: > org.mozilla.javascript.EcmaError: TypeError: Cannot find function replace. > [scriptStep] at > java.security.AccessController.doPrivileged(Native Method) > > My htmlUnit-lib seems to be quite new - updated it around a month ago. > > Perhaps you know a way around - if not I'm going to use your example for > verifyXPath, at the moment I'm really eager to get this embedded-JS to > work :-). > > Thanks, > > Alexander > > > > Marc Guillemot schrieb: >> Hi, >> >> "," is not good for numbers in scripts >> >> Why do you need a script for this purpose? What about following: >> >> <verifyXPath xpath="number(translate('#{accountBalanceNew}', ',', '.')) >> - number(translate('#{accountBalance}', ',', '.'))" text="0"/> >> >> (not sure if 0 is converted to "0" or "0.00" here, you have to check) >> >> This is shorter and would give you a better feedback when it fails. >> >> Marc. _______________________________________________ WebTest mailing list [email protected] http://lists.canoo.com/mailman/listinfo/webtest

