Cannot resolve null pointer exception in Change Password test even after using Java script executor for finding navigation link for settings | Selenium Forum
D
Dipika Gupta Posted on 12/11/2018
java.lang.NullPointerException
at com.qtpselenium.facebook.pom.pages.common.TopMenu.gotoSettings(TopMenu.java:35)
at com.qtpselenium.facebook.pom.testcases.ChangePasswordTest.changePasswordTest(ChangePasswordTest.java:51)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.base/java.lang.reflect.Method.invoke(Unknown Source)
at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:104)
at org.testng.internal.Invoker.invokeMethod(Invoker.java:645)
at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:851)
at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1177)
at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:129)
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:112)
at org.testng.TestRunner.privateRun(TestRunner.java:756)
at org.testng.TestRunner.run(TestRunner.java:610)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:387)
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:382)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:340)
at org.testng.SuiteRunner.run(SuiteRunner.java:289)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1293)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1218)
at org.testng.TestNG.runSuites(TestNG.java:1133)
at org.testng.TestNG.run(TestNG.java:1104)
at org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:114)
at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:251)
at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:77)

D
Dipika Gupta Replied on 12/11/2018

The attachmet is with this message


A
Ashish Thakur Replied on 13/11/2018

test object is not getting initilized on line 35 in Test Base and so this line causes nullpointer
test.log(LogStatus.INFO, "Going to Settings");

Please debug it and check


D
Dipika Gupta Replied on 13/11/2018

Hi, But even Login test uses the Base test and there is no exception thrown. I cannot figure out why The "Settings' icon is not getting clicked in Change Password Test. I tried Java script executor but there is no positive response.


D
Dipika Gupta Replied on 13/11/2018

Sorry I meant to say that the user navigation icon is not getting clicked - "the down arrow"


D
Dipika Gupta Replied on 13/11/2018

Now there is another twist : when i remove the test.log messages from Top Menu , everything works. I can go to the user navigation icon to take me to the Settings page. Can you tell me why this is happening ?


A
Ashish Thakur Replied on 17/11/2018

your test object is not initialized
That is the reason 
Please initialize it
Running the project in debug mode will help you out