I have page objects classes which I used for test scripts. I usually assign these classes sessions to variables as I need to use them in multiple places. I'm getting null exception in some test scripts while running the code. The same script sometime getting passed without showing an error too. Why does session variable throwing a null exception?
TestCommonLandingPage.java
public class TestCommonLandingPage extends PageObject{
public TestCommonLandingPage(Session session) {
super(session);
}
public TestCommonLandingPage stepOpenWindowByShortcut() throws FrameworkException {
this.test_step_initiation();
this.TestCommonLandingPagePanel.action_perform_shortcuts_window();
log.info("Step: OpenWindowByShortcut");
return this;
}
}
TestScript.java
public class TC1614 extends VerificationsWidget {
public void viewingWidgetParameters() throws FrameworkException, InterruptedException {
final TestCommonLandingPage testCommonLandingPage = new TestCommonLandingPage (getSession());
testCommonLandingPage
.stepOpenWindowByShortcut());
The code("testCommonLandingPage.stepOpenWindowByShortcut());") most of the time throws a null exception, why is that? When I'm using session without assign to a variable this is working properly as well