title: Cannot instantiate class
body: <p>iam facing a problem i have written a method navback, which i need to use regularily to navigate back.  when iam running it is throwing a error.</p>
  
  <p>below is the Code.</p>
  
  <pre><code>    package Examples;
  
  import java.util.concurrent.TimeUnit;
  
  //import org.junit.BeforeClass;
  import org.testng.annotations.BeforeClass;
  import org.openqa.selenium.By;
  import org.openqa.selenium.WebDriver;
  import org.openqa.selenium.WebElement;
  import org.openqa.selenium.firefox.FirefoxDriver;
  import org.openqa.selenium.interactions.Actions;
  import org.testng.annotations.AfterClass;
  import org.testng.annotations.DataProvider;
  import org.testng.annotations.Test;
  
  public class Flipkart {
      public static WebDriver driver;
      Actions action = new Actions(driver);
  //String ddd;
  //    public Example2() {
  //       super();
  //    }
  
      @BeforeClass
      public void beforeClass()
      {
      driver = new FirefoxDriver();
      driver.manage().timeouts().implicitlyWait(30000, TimeUnit.MILLISECONDS);
  
  
      }
  
      @Test
  
      public void mailSend() throws InterruptedException
      {
  
          driver.get("https://www.flipkart.com/");
          driver.manage().window().maximize();
  
  
          navback();
          driver.findElement(By.xpath("/html/body/div/div/div[2]/div/div/ul/li/div/div[2]/div/ul/li[2]/a")).click();
          driver.navigate().back();
  
  
          navback();
          driver.findElement(By.xpath("/html/body/div/div/div[2]/div/div/ul/li/div/div[2]/div/ul/li[3]/a")).click();
          driver.navigate().back();
  
          driver.navigate().refresh();
      }
  
      public void navback()
      {
            WebElement we = driver.findElement(By.xpath("//html/body/div/div/div[2]/div/div/ul/li/a/span"));
            action.moveToElement(we).build().perform();
      }
  
  
  
      @AfterClass
      public void tear()
      {
         // driver.quit();
     }
  }
  </code></pre>
  
  <p>Below is the Error.</p>
  
  <pre><code>org.testng.TestNGException: 
  Cannot instantiate class Examples.Flipkart
      at org.testng.internal.ObjectFactoryImpl.newInstance(ObjectFactoryImpl.java:38)
      at org.testng.internal.ClassHelper.createInstance1(ClassHelper.java:387)
      at org.testng.internal.ClassHelper.createInstance(ClassHelper.java:299)
      at org.testng.internal.ClassImpl.getDefaultInstance(ClassImpl.java:110)
      at org.testng.internal.ClassImpl.getInstances(ClassImpl.java:186)
      at org.testng.internal.TestNGClassFinder.&lt;init&gt;(TestNGClassFinder.java:120)
      at org.testng.TestRunner.initMethods(TestRunner.java:409)
      at org.testng.TestRunner.init(TestRunner.java:235)
      at org.testng.TestRunner.init(TestRunner.java:205)
      at org.testng.TestRunner.&lt;init&gt;(TestRunner.java:160)
      at org.testng.remote.RemoteTestNG$1.newTestRunner(RemoteTestNG.java:141)
      at org.testng.remote.RemoteTestNG$DelegatingTestRunnerFactory.newTestRunner(RemoteTestNG.java:271)
      at org.testng.SuiteRunner$ProxyTestRunnerFactory.newTestRunner(SuiteRunner.java:561)
      at org.testng.SuiteRunner.init(SuiteRunner.java:157)
      at org.testng.SuiteRunner.&lt;init&gt;(SuiteRunner.java:111)
      at org.testng.TestNG.createSuiteRunner(TestNG.java:1299)
      at org.testng.TestNG.createSuiteRunners(TestNG.java:1286)
      at org.testng.TestNG.runSuitesLocally(TestNG.java:1140)
      at org.testng.TestNG.run(TestNG.java:1057)
      at org.testng.remote.RemoteTestNG.run(RemoteTestNG.java:111)
      at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:204)
      at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:175)
  Caused by: java.lang.reflect.InvocationTargetException
      at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
      at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
      at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
      at java.lang.reflect.Constructor.newInstance(Unknown Source)
      at org.testng.internal.ObjectFactoryImpl.newInstance(ObjectFactoryImpl.java:29)
      ... 21 more
  Caused by: java.lang.NullPointerException
      at org.openqa.selenium.interactions.Actions.&lt;init&gt;(Actions.java:41)
      at Examples.Flipkart.&lt;init&gt;(Flipkart.java:18)
      ... 26 more
  </code></pre>
  
  <p>Please some one help me, iam not able to proceed further.</p>
  
  <p>Thanks</p>