java.lang.NullPointerException when running testcase via Selenium

后端 未结 2 398
礼貌的吻别
礼貌的吻别 2021-01-14 15:59

I am facing an issue with NullPointerException. I tried as much as possible but I\'m unable to resolve this. I am implementing a POM model(Selenium) for my project.

2条回答
  •  醉话见心
    2021-01-14 16:45

    Your driver seems to be null what you can do to avoid this situation is to instantiate your driver reference.

    In your test class you can instantiate your driver.

    public class VendorsHomePageTest {
        public WebDriver driver;
        @Test
        public void verifyVendorsHomePageTest() throws Exception {
            driver = new FirefoxDriver(); // or whatever browser you want.
            // Here you can initialise the elements in `PageObject` class.
            VendorsHomePageApp vhpapp= PageFactory.initElements(driver, VendorsHomePageApp.class);
            // Rest of your code
        }
    }
    

提交回复
热议问题