0

When I try to call a method from another java class within same package, I get the below error:

PASSED: validateLogin

FAILED: test java.lang.NullPointerException at assembly.SlackInviteFlowValidation.selectManageSideNavbar(SlackInviteFlowValidation.java:130) at assembly.SlackUpgradeEditViewFlow.test(SlackUpgradeEditViewFlow.java:28) 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:583) at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:719) at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:989) 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:115) at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:251) at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:77)

I am using selenium Webdriver and TestNG framework. Here is my code where SlackInviteFlowValidation & SlackUpgradeEditViewFlow are from same package and extends Base class where in Base class has Chrome driver initailzation and login Functionality only.

// Class SlackInviteFlowValidation

// Function to validate landing page of Manage

public void selectManageSideNavbar() throws InterruptedException {
    slackobject.avatarIcon().click();
    slackobject.AdminText().click();
    slackobject.UsersText().click();
    slackobject.ManageText().click();
}

//Class SlackUpgradeEditViewFlow

// Creating object for class SlackInviteFlowValidation SlackInviteFlowValidation slackinvite = new SlackInviteFlowValidation();

public class SlackUpgradeEditViewFlow extends Base{

public static Logger log = LogManager.getLogger(SlackInviteFlowValidation.class.getName());

public SlackIdentityObjects slackobject;

SlackInviteFlowValidation slackinvite = new SlackInviteFlowValidation();

@BeforeTest
public void init() throws FileNotFoundException, IOException {
    driver = initializeDriver();
    slackobject = new SlackIdentityObjects(driver);
}

@Test
public void test() {
    try {
        slackinvite.selectManageSideNavbar();
    } catch (InterruptedException e) {
        e.printStackTrace();
    }
}
Hema Krishna
  • 117
  • 3
  • 14

0 Answers0