-1
public class EditProfile {
// public static WebDriver driver;

 //public TestLogin login;
// public static String baseURL = Configuration.testsite;
 TestLogin login = new TestLogin();
 public static WebDriver driver; 

@BeforeClass 
@Parameters("browser")
public void LoginToAnalytics() throws Exception{
    //WebDriver driver = new FirefoxDriver();
    login.setup("Firefox");
    login.testLogin();
}

analyticsLoginPage mylogin = PageFactory.initElements(driver, analyticsLoginPage.class);

********//Edit Progile test that fails******

@Test//(dependsOnMethods = { "testLogin" })

///******** Edit profile code

public void verifyEditProfile() throws InterruptedException {

*******//Getting null pointer here. Please help me understand why.///////

    analyticsLandingPage landingpage = PageFactory.initElements(driver, analyticsLandingPage.class);

*******///This will work fine once it gets to this part

    analyticsEditProfilePage editprofile = PageFactory.initElements(driver, analyticsEditProfilePage.class);

*******waiting for page to load ///////////

    Thread.sleep(3000L);
    landingpage.gotoProfile();

    /////This part is not running because of the error***////

    editprofile.verifyEditFirstName();

}
}
sKhan
  • 9,694
  • 16
  • 55
  • 53
user16626
  • 25
  • 2
  • 7
  • Possible duplicate of [What is a Null Pointer Exception, and how do I fix it?](http://stackoverflow.com/questions/218384/what-is-a-null-pointer-exception-and-how-do-i-fix-it) – Paul Hicks Feb 28 '16 at 03:36
  • Is it because you've commented out the definition of `driver`? It's really hard to tell since we can't tell which bits of your code are commented for the purposes of this question and which bits are commented out "for real". – Paul Hicks Feb 28 '16 at 03:40
  • I tried to edit it to make it more readable but I couldn't make enough sense of it. The code as-is cannot compile and I can't tell where one piece ends and the next begins. – Paul Hicks Feb 28 '16 at 03:41
  • Your question and sample code are unclear. Please take the [tour](http://stackoverflow.com/tour) and visit the [help center](http://stackoverflow.com/help) for guidance on asking [good questions](http://stackoverflow.com/help/how-to-ask) and providing a [minimal, complete, and verifiable example](http://stackoverflow.com/help/mcve). – McMath Feb 28 '16 at 04:53
  • All good advices. Thanks Paul! – user16626 Feb 29 '16 at 18:00

1 Answers1

0

You are not initiated driver, it is null

 public static WebDriver driver; 

you may think starting firefox driver as below, but is it returning the driver?

  login.setup("Firefox");

Change this setup method to return driver and assign this to above static webdriver driver;

   driver= login.setup("Firefox");

Thank you, Murali

murali selenium
  • 3,847
  • 2
  • 11
  • 20
  • Thanks Murali, COuld you give me an example of what you mean "Change this setup method to return driver and assign this to above static webdriver driver". I'm new to this. Appreciate your help! – user16626 Feb 29 '16 at 22:15