Screenshot capture in Java Selenium
While attempting to take a screenshot with Selenium, I keep getting this error? Since fileUtils isn't working for me, I'm using the FileHandler function. Do I need to make any changes?My Code :
ts.getScreenshotAs(OutputType.FILE); ///---> line 54 File src=((TakesScreenshot) driver).getScreenshotAs(OutputType.FILE); File n = new File ("D:\\Failed_Test_Cases\\accessdeniedlogin.png"); FileHandler.copy(src, n); My Result :
java.lang.NullPointerException: Cannot invoke "org.openqa.selenium.TakesScreenshot.getScreenshotAs(org.openqa.selenium.OutputType)" because "this.ts" is null at StepDefinitions.loginStep.user_clicks_login_button(loginStep.java:54) at ✽.User clicks login button(file:///D:/coach-outlet/src/test/resources/Feature/login.feature:8)