Retry Cucumber failed steps (not the whole scenario)

1,538 views
Skip to first unread message

Ess Kay

unread,
Jan 9, 2018, 10:32:35 AM1/9/18
to qaf users
I am using Cucumber with QAF (in Perfecto Mobile devices). I have added listeners to retry failed scenarios. However, I was wondering if we could try failed scenario STEPS only vs. the entire scenario from the beginning. Thanks very much for your help.

cjayswal

unread,
Jan 10, 2018, 11:05:41 AM1/10/18
to qaf-...@googlegroups.com
You can try by using step listener like below:
@Override
   
public void onFailure(StepExecutionTracker stepExecutionTracker) {
       
//check whether to retry
        stepExecutionTracker
.setException(null);
        stepExecutionTracker
.setNextStepIndex(stepExecutionTracker.getStepIndex());
   
}


I am not sure retrying step is practically applicable or not. Better is using command retry feature through element/driver listener. Below is basic example where recovery logic for element commands:

@Override
   
public void onFailure(QAFExtendedWebElement element, CommandTracker commandTracker) {
       
//check recovery
       
if($("popup.loc").isPresent()){
            $
("popup.close.loc").click();
           
//clear exception
            commandTracker
.setException(null);
           
//request retry
            commandTracker
.setRetry(true);
       
}
   
}

In either case you need to take care of possible infinite loop.

Ess Kay

unread,
Jan 10, 2018, 1:13:49 PM1/10/18
to qaf users
Will try...thanks very much.

Ess Kay

unread,
Jan 12, 2018, 2:40:47 PM1/12/18
to qaf users
Hi, which listener method would this be overriding? Can you please point me the right direction? Thanks very much.

cjayswal

unread,
Jan 13, 2018, 10:34:49 AM1/13/18
to qaf users

Ess Kay

unread,
Jan 16, 2018, 4:36:28 PM1/16/18
to qaf users
Hi Chirag, I reviewed the listener docs. Pretty informative. I have a question. Between the two onFailure, which triggers when. One is related to the step listener and the other element listener. What is the call stack sequence? Please advise. Thanks very much.

Ess Kay

unread,
Jan 16, 2018, 4:44:02 PM1/16/18
to qaf users
The reason i am asking is, the following lines of code do not seem to work i.e. not really retrying the command. I was able to handle the popup (your example was spot on as that is one failure I was struggling with on how to handle). The code handles the popup but does not retry the failed step but moves on to the next step which obviously fails the test.

commandTracker.setException(null);
//request retry
commandTracker.setRetry(true);

is there any way I can check the command index like you showed with the stepExecutionTracker? Are the 2 onFailure methods work in tandem (which goes back to my original question above)?

Ess Kay

unread,
Jan 16, 2018, 4:50:03 PM1/16/18
to qaf users
I registered the listener as qaf.listeners = <myretrylistener>. I am assuming from the listener documentation...this is correct.
Reply all
Reply to author
Forward
0 new messages