webdriver - Null Ponter while running selenium code in JUNIT 4 -


i trying run code null pointer exception. using junit 4.10 , selenium 2.24.1 jars.

the exception in @after " driver.quit(); "

when run same code in home desktop seems work fine. difference run eclipse indigo @ home , run eclipse ganymede here. dont think should issue, unless mistaken.

stack trace: java.lang.nullpointerexception @ framework.ford.teardown(ford.java:36) @ sun.reflect.nativemethodaccessorimpl.invoke0(native method) @ sun.reflect.nativemethodaccessorimpl.invoke(unknown source) @ sun.reflect.delegatingmethodaccessorimpl.invoke(unknown source) @ java.lang.reflect.method.invoke(unknown source) at
org.junit.runners.model.frameworkmethod$1.runreflectivecall(frameworkmethod.java:45)

thanks.

public class ford {      static private webdriver driver;     static private string baseurl;     static private stringbuffer verificationerrors = new stringbuffer();      @before     public void setup() throws exception {         driver = new firefoxdriver();         baseurl = "http://www.google.com/";         driver.manage().timeouts().implicitlywait(30, timeunit.seconds);     }      @test     public void testford() throws exception {         driver.get(baseurl + "/finance");         driver.findelement(by.linktext("aa")).click();         driver.findelement(by.id("gbqfq")).click();         driver.findelement(by.id("gbqfq")).clear();         driver.findelement(by.id("gbqfq")).sendkeys("f");         driver.findelement(by.id(":1")).click();     }      @after     public void teardown() throws exception {         driver.quit();         string verificationerrorstring = verificationerrors.tostring();         if (!"".equals(verificationerrorstring)) {             fail(verificationerrorstring);         }     }  } 

can try after making change in teardown() method -

@after public void teardown() throws exception {     if (driver != null)     driver.quit();     string verificationerrorstring = verificationerrors.tostring();     if (!"".equals(verificationerrorstring)) {         fail(verificationerrorstring);     } } 

this might solve problem.


Comments

Popular posts from this blog

c# - SVN Error : "svnadmin: E205000: Too many arguments" -

c++ - Using OpenSSL in a multi-threaded application -

All overlapping substrings matching a java regex -