我正在包装定位器泛型并获取空指针异常。请找到下面的代码。
public class WebElementLocator {
WebDriver driver;
Properties prop;
private void getFile(String filePath)
{
try {
FileInputStream fs = new FileInputStream(filePath);
prop = new Properties();
prop.load(fs);
} catch (IOException e) {
e.getMessage();
}
}
public WebElement getElement(String wElement){
getFile("ment.properties");
String eValue = prop.getProperty(wElement);
String locatorType = eValue.split(":")[0];
String elementValue = eValue.split(":")[1];
WebElement we = null;
switch (locatorType) {
case "id": we = driver.findElement(By.id(elementValue));
break;
}
return we;
}
}
在下面的语句中获取Null指针异常
case "id": we = driver.findElement(By.id(elementValue));
break;