How implement method logout from another class?
<p>I read a lot about this problem but i can not find answer for my case.</p>

<p>I have class with Selenium method </p>

<pre><code>public class PrzesylkiPrzygotowane implements Tools{
private WebDriver driver;
private StringBuffer verificationErrors = new StringBuffer();

//Override
public Narzedzia getNarzedzia() {
    return new Narzedzia();  
  }

public void setUp() throws Exception {
  StartEN start = new StartEN(GetParams.getUser(),
            GetParams.getPassword());
    this.driver = start.getDriver();
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
}

@Test
public void testPrzesylkiPrzygotowane() throws Exception {
setUp();
driver.findElement(By.cssSelector("a[href*='?action=GetZbior&amp;arg1=220170'")).click();
driver.findElement(By.cssSelector("button.widgetButton")).click();
driver.findElement(By.id("nazwa")).clear();
Thread.sleep(1000);
driver.findElement(By.id("nazwa")).sendKeys("Mar");
driver.findElement(By.xpath("//body[@id='Body']/div[4]/ul/li/strong[3]")).click();
driver.findElement(By.id("submit_button")).click();
Thread.sleep(1000);
//NPE throw here    
getNarzedzia().logout();
}
</code></pre>

<p>... rest code.</p>

<p>I made interface for this class</p>

<pre><code>public interface Tools {
public Narzedzia getNarzedzia();
}
</code></pre>

<p>"Narzedzia" is a class with group of methods which i use like tools for aplication. </p>

<pre><code>public class Narzedzia{

public WebDriver driver;
boolean acceptNextAlert = true;

public void logout() throws InterruptedException{
      //Ustawienia driv = new Ustawienia();
      driver.findElement(By.linkText("Wyloguj")).click();
      Thread.sleep(1000);
      assertTrue(closeAlertAndGetItsText(driver).matches("^Czy na pewno chcesz wyjść z Elektronicznego Nadawcy[\\s\\S] Sprawdź czy wszystkie dane zostały przekazane do placówki\\.$"));
      driver.close();
  }
  public String closeAlertAndGetItsText(WebDriver driv) {
        try {
          Alert alert = driv.switchTo().alert();
          String alertText = alert.getText();
          if (acceptNextAlert) {
            alert.accept();
          } else {
            alert.dismiss();
          }
          return alertText;
        } finally {
          acceptNextAlert = true;
        }
      }
</code></pre>

<p>...rest code</p>

<p>When i run test rest od method in "Narzedzia" works fine but logout throw error:
<strong>java.lang.NullPointerException</strong></p>