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.
>
--
Alexander Mannsfeld
Quality Assurance
GD GameDuell GmbH
Ackerstraße 14/15, 10115 Berlin
( +49 (0)30 288 768 811
+ +49 (0)30 288 768 299
[EMAIL PROTECTED]
Richtig spielen: www.gameduell.de
---
Firmensitz: Berlin,
Deutschland|Handelsregister: Amtsgericht Berlin-Charlottenburg, HRB Nr.
90891|USt-Id-Nr.: DE 813829498, Steuernummer: 37 / 225 /
20926|Verantwortliche Geschäftsführer: Kai Bolik | Michael Kalkowski | Boris
Wasmuth
_______________________________________________
WebTest mailing list
[email protected]
http://lists.canoo.com/mailman/listinfo/webtest