这是我为takeScreenshot获得的例外...正确路径
我甚至不知道路由导致甚至知道nullpointerexception 对于截图,我提供了正确的截图 请帮我这个
java.lang.NullPointerException
at com.testing.core.ddf.base.BaseTest.takeScreenshot(BaseTest.java:167)
at com.testing.core.ddf.testcases.DummyTestB.TestB(DummyTestB.java:39)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
-----------------------------------------------
public void takeScreenshot()
{
Date d =new Date();
//String screenshotFile = d.toString().replace(":", "_").replace(" ", "_")+".png";
String screenshotFile = d.toString().replace(":", "_").replace(" ", "_")+".png";
File scrFile =((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE);
try
{
FileUtils.copyFile(scrFile, new File(System.getProperty("user.dir")+"\\Screenshots\\"+screenshotFile));
}
catch(Exception ex)
{
ex.printStackTrace();
}
//test.log(LogStatus.INFO,"Screenshot-> "+ test.addScreenCapture("E:\\selenium_practice\\Maven_Workspace\\Data_Driven_core_Framework\\Screenshots"+screenshotFile));
第167行。
test.log(LogStatus.INFO,"Screenshots -> "+test.addScreenCapture(System.getProperty("user.dir")+"//Screenshots//"+screenshotFile));
}
DummyTestB .java
public class DummyTestB extends BaseTest {
ExtentReports rep =ExtentManager.getInstance();
ExtentTest test ;
@Test
public void TestB() throws IOException
{
test = rep.startTest("DummmyTestB");
test.log(LogStatus.INFO, "Starting the DummyTest");
OpenBrowser("Mozilla");
test.log(LogStatus.INFO, "Opened the Browser");
//driver.System.out.println("This is Test B1");
Navigate("FBURL");
test.log(LogStatus.INFO, "Navigated to URL");
type("FBUser_id","FB_username");
test.log(LogStatus.INFO, "Entered username");
type("FBPass_id","FB_password");
test.log(LogStatus.INFO, "Entered Password");
Click("Login_Button_Xpath");
test.log(LogStatus.INFO, "clicked to Login");
test.log(LogStatus.PASS, "Test Case B Pass");
//
Line no 39 takeScreenshot();
}