title: How to resolve: cucumber.runtime.CucumberException: Failed to instantiate class com.philips.rs.ui.stepdefs.LoginSteps
body: <p>I am developing a page object model framework, but I am facing Failed to instantiate class cucumber exception.</p>
  
  <p>Please check my approach</p>
  
  <p>By following this approach I am facing cucumber exception as Failed to instantiate , but this exception will not occur for every first scenario, from second scenario the drive is not launched. Please let me know where I am going wrong </p>
  
  <p>I have @After in ScenarioCleanUp class where webDriver is closed.</p>
  
  <pre><code>public class ScenarioCleanUp  {
  
      public static final Logger logger = Logger.getLogger(BrowserTest.class);
      public WebDriver driver = UITestUtils.driver;
  
      @After()
      public void tearDown(Scenario scenario) throws Exception {
          System.out.println("---------Closing the Sceanrio-----------------");
          if (scenario.isFailed())
          {
              System.out.println("Came Inside Scenario Failed");
              DateFormat df = new SimpleDateFormat("ddMMyyHHmmss");
              Date dateobj = new Date();
              logger.info("CurrentDate used for concating the sceenshot: " + df.format(dateobj));
  
              logger.error("The Scenario is failed: " + scenario.getName());
              scenario.write("Current Page URL is " + driver.getCurrentUrl());
  
              String filename = scenario.getName();
              filename = filename.replaceAll("\"", "");
              filename = filename.replaceAll("\\s+", "_");
              filename = filename + df.format(dateobj) + ".jpg";
  
              new UITestUtils().takeSnapShot(driver,filename);
          }
          if(driver!= null)
          {
          System.out.println("Driver is not null");
          driver.close();
          }
  
      }
  }
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/2b2VK.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/2b2VK.png" alt="enter image description here"></a></p>
  
  <p><a href="https://i.stack.imgur.com/zgpQv.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/zgpQv.png" alt="enter image description here"></a></p>