【问题标题】:Null pointer exception is coming空指针异常来了
【发布时间】:2017-11-13 21:54:38
【问题描述】:
public static WebDriver getscreenshot(String path) throws Exception 
{
    WebDriver driver = null;
    TakesScreenshot ts = (TakesScreenshot)driver;
    File scrFile = ts.getScreenshotAs(OutputType.FILE);
    FileUtils.copyFile(scrFile, new File(path));
    return driver;
}

我收到上述代码的空指针异常。

【问题讨论】:

    标签: pointers exception null


    【解决方案1】:

    这很正常。您已经声明了 webdriver 变量,但您根本没有初始化它。尝试初始化它或从某个地方获取它,使其不能为空。

    WebDriver driver = new WebDriver(some parameters here if any);
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2016-11-07
      • 1970-01-01
      • 2015-07-12
      相关资源
      最近更新 更多