title: How can I continue to run other steps when there is a failure using Serenity?
body: <p>I apologize for my bad English. I use google translate to post this question. I also searched many of my problems on the internet that did not resolve mine.</p>
  <p>My problem is as follows: <br>
  I have an excel file that allows the manual to import data. Each row in this excel file I use to create a new data (eg it looks like an account). It is not difficult.
  Since each row corresponds to a different data to create a new data, be sure to use a loop to get the data inside the file. For example as follows:</p>
  <p><strong>| Name | Email     | Tel    | .... | Result |</strong> <br>
  | A    | abc@email | 123456 | .... | accA   | <br>
  | B    | abc@email | 123456 | .... | accB   |</p>
  <p>Result column is generated based on the data of the other columns. <br>
  I don't use the Scenario Template because there are many fields. And using excel to make the manual easier to edit and read. <br>
  So I use the loop to <strong>repeat the step</strong> can mine the number of rows of data from excel files. <br></p>
  <p>My code: <br></p>
  <pre><code>public class TestClass {
  
      @Before
      public void set_the_stage() {
          OnStage.setTheStage(new OnlineCast());
      }
  
      @Given(&quot;{word} access Google&quot;)
      public void accessGoogle(String actor) {
          theActorCalled(actor).attemptsTo(Open.url(&quot;https://google.com&quot;));
      }
  
      @When(&quot;Input {word}&quot;)
      public void inputSearch(String value) {
          Target input_search = Target.the(&quot;Input Search&quot;).locatedBy(&quot;//input[@title='Tìm kiếm']&quot;);
          Target click_search = Target.the(&quot;Click Search&quot;).locatedBy(&quot;//*[@class='FPdoLc tfB0Bf']//*[ @value='Tìm với Google'] &quot;);
  
          theActorInTheSpotlight().attemptsTo(WaitUntil.the(input_search, WebElementStateMatchers.isVisible()));
          theActorInTheSpotlight().attemptsTo(Enter.theValue(value).into(input_search));
          // Failure step
          theActorInTheSpotlight().attemptsTo(WaitUntil.the(click_search, WebElementStateMatchers.isVisible()), Click.on(click_search));
      }
  
      @Then(&quot;Search successfully&quot;)
      public void searchSucess() {
          Target stackOverflow = Target.the(&quot;Stack Overflow&quot;).locatedBy(&quot;//*[contains(text(),'Stack Overflow')]&quot;);
          theActorInTheSpotlight().attemptsTo(Ensure.that(stackOverflow).isDisplayed());
      }
  
      @When(&quot;Read excel&quot;)
      public void readExcel() {
          int number = 5; // the number of records in the excel file
  
          for (int i = 0; i &lt; number; i++) {
              try {
                  System.out.println(&quot;Start Try: &quot; + i);
                  accessGoogle(&quot;Minato&quot;);
                  inputSearch(&quot;stackoverflow.com&quot;);
                  searchSucess();
                  System.out.println(&quot;End Try: &quot; + i);
              } catch (Exception e) {
                  System.out.println(&quot;Catch: &quot; + i);
                  ThucydidesWebDriverSupport.getDriver().quit();
                  ThucydidesWebDriverSupport.initialize();
                  set_the_stage();
                  e.getStackTrace();
              }
          }
      }
  }
  </code></pre>
  <p><em>feature file</em></p>
  <pre><code>@feature=searchGoogle
  Feature: A description
  
    @testSearch
    Scenario: A scenario
      When Read excel
  </code></pre>
  <p>In automation, every time there is a failure it throws an exception why the failure happens, and it stops the program.
  With original selenium, to continue running the code below I use try catch. <br>
  But when using <strong>Serenity</strong>, when there is a failure, it jumps to catch and continues the loop, but the following steps are <strong>skipped</strong>. I don't understand how this framework works yet. I have tried calling <em>ThucydidesWebDriverSupport.initialize();</em> again; But it still doesn't execute the steps. (It doesn't open the browser).</p>
  <p>Can anyone help me? I want when it has a failure on any line of code, it must keep running again from the first step until the loop ends. It is not that it skips all steps. <br>
  Thanks all!!! <br>
  <strong>Result:</strong><br></p>
  <pre><code>Start Try: 0
  
  Catch: 0
  Start Try: 1
  End Try: 1
  Start Try: 2
  End Try: 2
  Start Try: 3
  End Try: 3
  Start Try: 4
  End Try: 4
  18:07:20.542 [main] ERROR n.t.c.steps.ConsoleLoggingListener 
  </code></pre>
  <p>Image report: <br>
  <a href="https://i.stack.imgur.com/Gt0Cg.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Gt0Cg.png" alt="Report" /></a></p>
  <p><strong>Edit</strong><br>
  After 2 days I still could not find a way to initialize a new driver. But I have a way to fix my problem. <br>
  That combines Scenario Outline, like this:<br></p>
  <p><em>Feature</em><br></p>
  <pre><code>Scenario Outline: A scenario
      When Read excel &quot;test.xlsx&quot; by &lt;index&gt;
      Examples:
        | index |
        | 1     |
        | 2     |
        | 3     |
        |...    |
  </code></pre>
  <p>Edit code: <br></p>
  <pre><code>@When(&quot;Read excel {string} by {word}&quot;)
      public void readExcel(String fileName, String index) {
          Iterator&lt;Row&gt; iterator = getSheetExcel(fileName);
          List&lt;Row&gt; listRow = new ArrayList&lt;&gt;();
          int colName = 0;
          int colEmail = 1;
          // ....
          while (iterator.hasNext()) {
              listRow.add(iterator.next());
          }
          // example
          String name = listRow.get(Integer.parseInt(index)).getCell(colName).getStringCellValue();
          String email = listRow.get(Integer.parseInt(index)).getCell(colEmail).getStringCellValue();
  
          accessGoogle(name);
          inputSearch(email);
          inputSearch(&quot;stackoverflow.com&quot;);
          searchSucess();
      }
  
      public Iterator&lt;Row&gt; getSheetExcel(String fileName) {
          String path = System.getProperty(&quot;user.dir&quot;) + &quot;/src/test/resources/data/excel/&quot; + fileName;
          File file = new File(path);   //creating a new file instance
          FileInputStream fis;          //obtaining bytes from the file
          XSSFWorkbook wb;              //creating Workbook instance that refers to .xlsx file
          XSSFSheet sheet = null;
  
          try {
              fis = new FileInputStream(file);
              wb = new XSSFWorkbook(fis);
              sheet = wb.getSheetAt(0);   //creating a Sheet object to retrieve object
          } catch (IOException e) {
              e.printStackTrace();
          }
  
          assert sheet != null;
          return sheet.iterator();
      }
  </code></pre>
  <p>Result:<br>
  <a href="https://i.stack.imgur.com/f9CzM.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/f9CzM.png" alt="enter image description here" /></a></p>