Facing issue with PageFactory

621 views
Skip to first unread message

Mounika V

unread,
Mar 17, 2017, 8:12:33 AM3/17/17
to Selenium Users
Hi All,

        I am getting the exception while entering the user name in Login page by using Page Factory annotation.Please find the java files in attachments.
        Can any one help me on this?


Exception:-

        FAILED: LoginTest
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.$Proxy6.sendKeys(Unknown Source)
at com.seleniummaster.pagefactory.example.LoginPage.EnterUserName(LoginPage.java:28)
at com.seleniummaster.pagefactory.example.TestRunner.LoginTest(TestRunner.java:33)
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: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:132)
at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:236)
at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:81)

Thanks in Advance,
Mounika

LoginPage.java
TestRunner.java
testng.xml

⇜Krishnan Mahadevan⇝

unread,
Mar 17, 2017, 10:30:25 AM3/17/17
to Selenium Users
Mounika,
In TestRunner.java

Change 

@BeforeClass
public void beforeClass() {
    System.setProperty("webdriver.chrome.driver", "D:/Selenium Workspace/Sample/drivers/chromedriver.exe");
    WebDriver driver = new ChromeDriver();  
    driver.navigate().to("http://demo.mahara.org");
    //driver.manage().window().maximize();
}

To 

@BeforeClass
public void beforeClass() {
    System.setProperty("webdriver.chrome.driver", "D:/Selenium Workspace/Sample/drivers/chromedriver.exe");
    //Krishnan : Notice that in the below line, I have removed the WebDriver declaration.
    driver = new ChromeDriver();  
    driver.navigate().to("http://demo.mahara.org");
    //driver.manage().window().maximize();
}



Thanks & Regards
Krishnan Mahadevan

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"
My Scribblings @ http://wakened-cognition.blogspot.com/
My Technical Scribbings @ http://rationaleemotions.wordpress.com/

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-users+unsubscribe@googlegroups.com.
To post to this group, send email to selenium-users@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/aabb0395-c85d-4d94-8be4-c053b877bdb2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages