我试图从基类中调用此类,并且发生以下空指针异常。
java.lang.NullPointerException
at
SeleniumProject.ReadExcelInput.inputlogin(ReadExcelInput.java:39)
代码:
public class ReadExcelInput extends SearchItem {
static WebDriver driver;
static String email= null;
static String password = null;
String ProjectPath = System.getProperty("user.dir");
String filepath = ProjectPath + "/src/testdata";
String filename = "Login.xls";
String sheetname ="logincredentials";
@Test
public void inputlogin() throws InterruptedException{
line 39--- Exception--driver.findElement(By.xpath("//*[@id=\'header\']/div[2]/div/div/nav/div[1]/a")).click();
Thread.sleep(2000);
try {
FileInputStream inputStream = new FileInputStream(filepath +"/" + filename);
// Create workbook instance referencing the file created above
HSSFWorkbook workbook = new HSSFWorkbook (inputStream);
// Get your first or desired sheet from the workbook
Sheet sheet = workbook.getSheetAt(0);