- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-19-2018 12:53 PM
Is there any way to write a script using server side step in ATF to make step case to wait for 10 seconds?
Solved! Go to Solution.
- Labels:
-
Automated Test Framework

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-03-2020 02:01 AM
Hi Jace,
Perhaps you'd like to consider using gs.sleep() instead of do nothing loop.
Performance 🙂
Have a good day!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-19-2018 03:32 PM
You can make a new custom step with this code.
(function executeStep(inputs, outputs, stepResult, timeout) {
var seconds = parseInt(inputs.u_seconds, 10) * 1000;
var start = parseInt(new Date().getTime()) + seconds;
while(start>parseInt(new Date().getTime())){
// do nothing
}
stepResult.setOutputMessage('Waited ' + inputs.u_seconds + ' seconds.');
stepResult.setSuccess();
}(inputs, outputs, stepResult, timeout));
If you want to see it in action clone this repo https://github.com/jacebenson/x_8821_atf/
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-20-2018 01:06 PM
Hi Jace,
I tried the above code but getting warning message as below. Tried to fix this error but I coudn't!
could you please provide any inputs related to this error?
____________________________________________________________________________________________________
Full logging from step execution:
02:28:36.755: Root cause of JavaScriptException: org.mozilla.javascript.NativeError
JavaScript evaluation error on:
var assertEqual = function(assertion) {
if (!(assertion.value == assertion.shouldbe)) {
gs.info("Assertion failed: " + assertion.name + " should have been " + assertion.shouldbe +
" but was " + assertion.value);
throw "Assertion failed";
}
}
try {
var steps = function(step_id){
return step.sibling(step_id);
};
(function executeStep(inputs, outputs, stepResult, timeout) {
var seconds = parseInt(inputs.u_seconds, 10) * 1000;
var start = parseInt(new Date().getTime()) + seconds;
while(start>parseInt(new Date().getTime())){
// do nothing
}
stepResult.setOutputMessage('Waited ' + inputs.u_seconds + ' seconds.');
stepResult.setSuccess();
}(inputs, outputs, stepResult, timeout));
} catch (e) {
if (e == 'Assertion failed')
glideTestResultBoolean = false;
else
throw e;
}
: no thrown error
02:28:36.756: JavaScript evaluation error on:
var assertEqual = function(assertion) {
if (!(assertion.value == assertion.shouldbe)) {
gs.info("Assertion failed: " + assertion.name + " should have been " + assertion.shouldbe +
" but was " + assertion.value);
throw "Assertion failed";
}
}
try {
var steps = function(step_id){
return step.sibling(step_id);
};
(function executeStep(inputs, outputs, stepResult, timeout) {
var seconds = parseInt(inputs.u_seconds, 10) * 1000;
var start = parseInt(new Date().getTime()) + seconds;
while(start>parseInt(new Date().getTime())){
// do nothing
}
stepResult.setOutputMessage('Waited ' + inputs.u_seconds + ' seconds.');
stepResult.setSuccess();
}(inputs, outputs, stepResult, timeout));
} catch (e) {
if (e == 'Assertion failed')
glideTestResultBoolean = false;
else
throw e;
}
: org.mozilla.javascript.JavaScriptException: ReferenceError: "inputs" is not defined. (sys_atf_step.30520017db31a340a7287bec0f9619da; line 25): org.mozilla.javascript.gen.sys_atf_step_30520017db31a340a7287bec0f9619da_6742._c_script_0(sys_atf_step.30520017db31a340a7287bec0f9619da:25)
org.mozilla.javascript.gen.sys_atf_step_30520017db31a340a7287bec0f9619da_6742.call(sys_atf_step.30520017db31a340a7287bec0f9619da)
org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:563)
org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:3421)
org.mozilla.javascript.gen.sys_atf_step_30520017db31a340a7287bec0f9619da_6742.call(sys_atf_step.30520017db31a340a7287bec0f9619da)
org.mozilla.javascript.gen.sys_atf_step_30520017db31a340a7287bec0f9619da_6742.exec(sys_atf_step.30520017db31a340a7287bec0f9619da)
com.glide.script.ScriptEvaluator.execute(ScriptEvaluator.java:263)
com.glide.script.ScriptEvaluator.evaluateString(ScriptEvaluator.java:110)
com.glide.script.ScriptEvaluator.evaluateString(ScriptEvaluator.java:76)
com.glide.script.fencing.GlideScopedEvaluator.evaluateScript(GlideScopedEvaluator.java:343)
com.glide.script.fencing.GlideScopedEvaluator.evaluateScript(GlideScopedEvaluator.java:306)
com.glide.automated_testing_framework.runner.step.JasmineScriptTestRunner.execute(JasmineScriptTestRunner.java:124)
com.glide.automated_testing_framework.runner.step_environment.AbstractServerStepEnvRunner.lambda$processStep$7(AbstractServerStepEnvRunner.java:127)
com.glide.rollback.recording.RollbackRecorder.execute(RollbackRecorder.java:63)
com.glide.automated_testing_framework.util.ATFRollbackUtil.recordOpsInRollbackContext(ATFRollbackUtil.java:80)
com.glide.automated_testing_framework.runner.step_environment.AbstractServerStepEnvRunner.processStep(AbstractServerStepEnvRunner.java:118)
com.glide.automated_testing_framework.runner.step_environment.AbstractServerStepEnvRunner.processSteps(AbstractServerStepEnvRunner.java:95)
com.glide.automated_testing_framework.runner.step_environment.AbstractServerStepEnvRunner.execute(AbstractServerStepEnvRunner.java:44)
com.glide.automated_testing_framework.worker.TestExecutionWorker.executeTestInOrderByBatch(TestExecutionWorker.java:257)
com.glide.automated_testing_framework.worker.TestExecutionWorker.execute(TestExecutionWorker.java:159)
com.glide.automated_testing_framework.TestExecutionProgressWorker.startWork(TestExecutionProgressWorker.java:34)
com.glide.worker.AbstractProgressWorker.startAndWait(AbstractProgressWorker.java:123)
com.glide.worker.HierarchicalProgressWorker.startAndWait(HierarchicalProgressWorker.java:34)
com.glide.worker.BackgroundProgressJob.execute(BackgroundProgressJob.java:54)
com.glide.schedule.JobExecutor.executeJob(JobExecutor.java:103)
com.glide.schedule.JobExecutor.execute(JobExecutor.java:89)
com.glide.schedule.GlideScheduleWorker.executeJob(GlideScheduleWorker.java:219)
com.glide.schedule.GlideScheduleWorker.lambda$process$48(GlideScheduleWorker.java:161)
com.glide.worker.TransactionalWorkerThread.executeInTransaction(TransactionalWorkerThread.java:35)
com.glide.schedule.GlideScheduleWorker.process(GlideScheduleWorker.java:161)
com.glide.schedule.GlideScheduleWorker.run(GlideScheduleWorker.java:72)
02:28:36.758: ReferenceError: "inputs" is not defined. (sys_atf_step.30520017db31a340a7287bec0f9619da; line 25): org.mozilla.javascript.JavaScriptException: ReferenceError: "inputs" is not defined. (sys_atf_step.30520017db31a340a7287bec0f9619da; line 25): org.mozilla.javascript.gen.sys_atf_step_30520017db31a340a7287bec0f9619da_6742._c_script_0(sys_atf_step.30520017db31a340a7287bec0f9619da:25)
org.mozilla.javascript.gen.sys_atf_step_30520017db31a340a7287bec0f9619da_6742.call(sys_atf_step.30520017db31a340a7287bec0f9619da)
org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:563)
org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:3421)
org.mozilla.javascript.gen.sys_atf_step_30520017db31a340a7287bec0f9619da_6742.call(sys_atf_step.30520017db31a340a7287bec0f9619da)
org.mozilla.javascript.gen.sys_atf_step_30520017db31a340a7287bec0f9619da_6742.exec(sys_atf_step.30520017db31a340a7287bec0f9619da)
com.glide.script.ScriptEvaluator.execute(ScriptEvaluator.java:263)
com.glide.script.ScriptEvaluator.evaluateString(ScriptEvaluator.java:110)
com.glide.script.ScriptEvaluator.evaluateString(ScriptEvaluator.java:76)
com.glide.script.fencing.GlideScopedEvaluator.evaluateScript(GlideScopedEvaluator.java:343)
com.glide.script.fencing.GlideScopedEvaluator.evaluateScript(GlideScopedEvaluator.java:306)
com.glide.automated_testing_framework.runner.step.JasmineScriptTestRunner.execute(JasmineScriptTestRunner.java:124)
com.glide.automated_testing_framework.runner.step_environment.AbstractServerStepEnvRunner.lambda$processStep$7(AbstractServerStepEnvRunner.java:127)
com.glide.rollback.recording.RollbackRecorder.execute(RollbackRecorder.java:63)
com.glide.automated_testing_framework.util.ATFRollbackUtil.recordOpsInRollbackContext(ATFRollbackUtil.java:80)
com.glide.automated_testing_framework.runner.step_environment.AbstractServerStepEnvRunner.processStep(AbstractServerStepEnvRunner.java:118)
com.glide.automated_testing_framework.runner.step_environment.AbstractServerStepEnvRunner.processSteps(AbstractServerStepEnvRunner.java:95)
com.glide.automated_testing_framework.runner.step_environment.AbstractServerStepEnvRunner.execute(AbstractServerStepEnvRunner.java:44)
com.glide.automated_testing_framework.worker.TestExecutionWorker.executeTestInOrderByBatch(TestExecutionWorker.java:257)
com.glide.automated_testing_framework.worker.TestExecutionWorker.execute(TestExecutionWorker.java:159)
com.glide.automated_testing_framework.TestExecutionProgressWorker.startWork(TestExecutionProgressWorker.java:34)
com.glide.worker.AbstractProgressWorker.startAndWait(AbstractProgressWorker.java:123)
com.glide.worker.HierarchicalProgressWorker.startAndWait(HierarchicalProgressWorker.java:34)
com.glide.worker.BackgroundProgressJob.execute(BackgroundProgressJob.java:54)
com.glide.schedule.JobExecutor.executeJob(JobExecutor.java:103)
com.glide.schedule.JobExecutor.execute(JobExecutor.java:89)
com.glide.schedule.GlideScheduleWorker.executeJob(GlideScheduleWorker.java:219)
com.glide.schedule.GlideScheduleWorker.lambda$process$48(GlideScheduleWorker.java:161)
com.glide.worker.TransactionalWorkerThread.executeInTransaction(TransactionalWorkerThread.java:35)
com.glide.schedule.GlideScheduleWorker.process(GlideScheduleWorker.java:161)
com.glide.schedule.GlideScheduleWorker.run(GlideScheduleWorker.java:72)
______________________________________________________________________________________________

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-25-2018 09:11 PM
You need to make a custom test step definition, with the input of `u_seconds`

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-05-2019 11:50 PM
As far as I understand the number of seconds is hardcoded into your script and set at 10 seconds. I can see that a field flashes for a fracture of a second to set exactly seconds when I add the custom step, but it gets hidden. I have tried to add an input but the output says Waited 0 seconds and the Client Test Runner keeps waiting before the next step, seemingly until I interrupt the test.
I suppose you meant with the above comment that in addition to the script you must create an input variable with the column name u_seconds. Not sure if the types I have tried so far are causing the step to output "Waited 0 seconds" (previously it was undefined) but can you please be more specific on how you set up the input variable for this code to work, including type?
Thanks in advance! 🙂