TestProject Forum

Unable to take screenShot when the test is executed via TestProject SDK jar

I have a normal flow of the test in eclipse and have used the “TakesScreenshot” Interface to take the screenshot.
After building the maven project , then used the “test-jar-with-dependencies.jar” to be uploaded as test in Test project.
Now when i am running my test via Test project , test is executed successfully but no screenshot is taken or attached.

Used the below code:

@Override
public void onTestFailure(ITestResult result) {
// TODO Auto-generated method stub
ITestListener.super.onTestFailure(result);
System.out.println(“onTestFailure”);
if(!result.isSuccess()) {
try {
TakesScreenshot ts=((TakesScreenshot) driver);
File Source =ts.getScreenshotAs(OutputType.FILE);
FileUtils.copyFile(Source, new File(“target/failsafe-reports/screenshots/”+result.getTestClass().getName()+".jpg"));
System.out.println(“Screenshot taken”);
}catch(Exception e){
System.out.println(“Uh oh !, An exception occurred while capturing screenshot!”);
e.printStackTrace();
}
}
}

Hello @gauravsaini5689
Just to check, the screenshot is not saved locally?

I ran the following code from the platform:

@Test
public void testScreenshot() throws IOException, AgentConnectException, ObsoleteVersionException, InvalidTokenException {
    ChromeDriver driver = new ChromeDriver(new ChromeOptions());

    // Navigate to TestProject Example website
    driver.navigate().to("https://example.testproject.io/web/");

    File source = ((TakesScreenshot) driver).getScreenshotAs(OutputType.FILE);
    FileUtils.copyFile(source, new File("C:\\Test\\screenshot-from-code.jpg"));

    // Login using provided credentials
    driver.findElement(By.cssSelector("#name")).sendKeys("TestProject");
    driver.findElement(By.cssSelector("#password")).sendKeys("12345");
    driver.findElement(By.cssSelector("#login")).click();
    driver.quit();
}
}

And I did get.a screenshot generated at the given path, on both local and uploaded execution.

Getting below error(No Screenshot attached)

Thanks, Indeed I see the same behvaiour.
I have opened a bug on this issue, and we will fix as soon as possible.

Thanks…Do let me know once the issue is resolved

@ran.tzur Is this issue resolved?