0

Kindly can anyone help about the root cause of below exception.

Exception:

java.lang.NullPointerException at Test_Automation.TC_Invoice_Printing.TC_input_fields_validation(TC_Invoice_Printing.java:37) 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:124) at org.testng.internal.Invoker.invokeMethod(Invoker.java:580) at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:716) at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:988) at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:125) at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:109) at org.testng.TestRunner.privateRun(TestRunner.java:648) at org.testng.TestRunner.run(TestRunner.java:505) at org.testng.SuiteRunner.runTest(SuiteRunner.java:455) at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:450) at org.testng.SuiteRunner.privateRun(SuiteRunner.java:415) at org.testng.SuiteRunner.run(SuiteRunner.java:364) at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52) at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:84) at org.testng.TestNG.runSuitesSequentially(TestNG.java:1208) at org.testng.TestNG.runSuitesLocally(TestNG.java:1137) at org.testng.TestNG.runSuites(TestNG.java:1049) at org.testng.TestNG.run(TestNG.java:1017) 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)

Script:

@Test
public void TC_input_fields_validation() {

        int default_input_fields_count = Invoke_Test_Instance.driver.findElements(By.xpath("//input[contains(@class,'input-lg form-control')]")).size();
        System.out.println("default field count" + default_input_fields_count);
        System.out.println(Invoke_Test_Instance.driver.findElement(By.xpath("/html/body/div[1]/div/div[2]/div[2]/div/div[2]/div/form/div/div/div[2]/div/div/a")).isDisplayed());
        Invoke_Test_Instance.driver.findElement(By.xpath("/html/body/div[1]/div/div[2]/div[2]/div/div[2]/div/form/div/div/div[2]/div/div/a")).click();
        Invoke_Test_Instance.driver.findElement(By.xpath("/html/body/div[1]/div/div[2]/div[2]/div/div[2]/div/form/div/div/div[2]/div/div/a")).click();
        Invoke_Test_Instance.driver.findElement(By.xpath("/html/body/div[1]/div/div[2]/div[2]/div/div[2]/div/form/div/div/div[2]/div/div/a")).click();
}
3
  • driver is null. What is the code in Invoke_Test_Instance to initialize the driver variable? Commented Apr 26, 2018 at 8:04
  • Dear Grasshopper- thanks for your reply. Infact the issue got resolved by inserting method related to web driver initialisation within method defined under @BeforeClass Commented Apr 26, 2018 at 17:46
  • @Ali - Please add what worked for you as an answer to your question and please accept it, so that the question gets closed. Commented May 1, 2018 at 6:06

1 Answer 1

0

My issue got resolved by inserting method related to web driver initialisation within method defined under @BeforeClass

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.