Selenium Java Page object Model — at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source) error

Hi all,
I tried my selenium java automation framework similar to the page object model tutorial.
I could access and pass the element as driver object in the hoem page and login page.

But after clicking on another menu page, I’m not able to process to other pages element/drive parsing.
I’m getting the below error.

Capabilities [{applicationCacheEnabled=false, rotatable=false, mobileEmulationEnabled=false, networkConnectionEnabled=false, chrome={chromedriverVersion=2.23.409699 (49b0fa931cda1caad0ae15b7d1b68004acd05129), userDataDir=C:\Users\kowsalya\AppData\Local\Temp\scoped_dir10552_20166}, takesHeapSnapshot=true, databaseEnabled=false, handlesAlerts=true, hasTouchScreen=false, version=52.0.2743.116, platform=WIN8_1, browserConnectionEnabled=false, nativeEvents=true, acceptSslCerts=true, locationContextEnabled=true, webStorageEnabled=true, browserName=chrome, takesScreenshot=true, javascriptEnabled=true, cssSelectorsEnabled=true}]
Session ID: 33b66e0b1931edf4b9055b3c8d585346
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:206)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:158)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:678)
at org.openqa.selenium.remote.RemoteWebElement.execute(RemoteWebElement.java:327)
at org.openqa.selenium.remote.RemoteWebElement.click(RemoteWebElement.java:85)
at Automation_Framework.test_login_logout.main(test_login_logout.java:55)

***************************************************************

Ieally the case is like this:
had the below classes in page_objects package.
home_page.java
login_page.java
Accounts_page.java
Tools_page.java

then, my java class for testing.java in in another package and imports the above said packages.

All these page object model classes, has the below sample structure.

public class Account_Page {
private static WebElement element = null;

public static WebElement lnkHome(WebDriver driver){
element = driver.findElement(By.id(“lnkHome”));
return element;
}
}

One more page object model class
public class Tools_Page {
private static WebElement element = null;
public static WebElement lnkCertificate(WebDriver driver){

element =driver.findElement(By.cssSelector(“a[href*=’Certificate’]”));
return element;
}
}

main.java file will be like this:

public class test_login_logout {
private static WebDriver driver = null;
@Test
public static void main ( String[] args) throws InterruptedException,NoSuchElementException{



Account_Page.lnkTools(driver).click();
Tools_Page.lnkCertificate(driver).click();

}

I’m getting error at invoking the Tools_page method:
Tools_Page.lnkCertificate(driver).click(); ////Ideally my code not getting to this method.

Please help me solve this asap.

Thank you so much in advance.

kowsalya Default Asked on September 5, 2016 in Program QA Automation.
Add Comment
1 Answer(s)

Are you familiar with “API Testing Using Selenium WebDriver and Java”?  http://blog.testproject.io/2016/04/17/api-testing-using-selenium-webdriver-java/

DebbyStone Train Answered on October 13, 2016.
Add Comment

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.