-1

When I try to run my POM(page object model) for my login page using Data Driven Framework, my application has been launched and data has been read but getting NullPointerException. The data is not being inputted in the username field.

Below is my exception, please help me out but the same code runs properly in my colleague system.

FAILED: entercredentials("3019", "India@123")
 java.lang.NullPointerException
        at org.openqa.selenium.support.pagefactory.DefaultElementLocator.findElement(DefaultElementLocator.java:69)
        at org.openqa.selenium.support.pagefactory.internal.LocatingElementHandler.invoke(LocatingElementHandler.java:38)
        at com.sun.proxy.$Proxy9.sendKeys(Unknown Source)
        at PageLibrary.LoginPageNew.Credential(LoginPageNew.java:51)
        at Test.ValidLogin.entercredentials(ValidLogin.java:54)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        at java.lang.reflect.Method.invoke(Unknown Source)
        at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:124)
        at org.testng.internal.Invoker.invokeMethod(Invoker.java:571)
        at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:707)
        at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:979)
        at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMe



 LoginPageNew.java:51>>> 
public  void Credential(String Ur, String Pd) throws InterruptedException
        {
            //Thread.sleep(20000);
        username.sendKeys(Ur);

    at Test.ValidLogin.entercredentials(ValidLogin.java:54)>>>>>
login.Credential(User,Password);
Ishita Shah
  • 3,955
  • 2
  • 27
  • 51
karthick
  • 19
  • 3

1 Answers1

0

By looking at the code and the stack trace, it seems that the User variable that is passed in login.Credential method is null.

Please try and initialize it with some value. Or for debugging purpose just pass some hardcode value in place of User