Seeing null pointer exception at addscreenshot | Selenium Forum
M
Posted on 04/01/2017
public void takeScreenShot(){
// fileName of the screenshot
Date d=new Date();
String screenshotFile=d.toString().replace(":", "_").replace(" ", "_")+".png";
// store screenshot in that file
File scrFile = ((org.openqa.selenium.TakesScreenshot)driver).getScreenshotAs(OutputType.FILE);

try {

FileUtils.copyFile(scrFile, new File(System.getProperty("user.dir")+"//screenshots//"+screenshotFile));

} catch (IOException e) {
// TODO Auto-generated catch block

e.printStackTrace();
}

String fileAt = System.getProperty("user.dir") + File.separator + "screenshots" + File.separator + screenshotFile;
System.out.println("the file at " + fileAt);
[color=#FF0040:zchvsg51]test.addScreenCapture(fileAt);[/color:zchvsg51]


}

The screenshot is taken and present as the location fileAt.
It is still throwing null pointer exception

M
Replied on 05/01/2017

send a screen shot of the project after running it.