0

I have a requirement where I need to add the time stamp for the screenshot image that is saved in /img folder. When I see AssertionService.java(https://github.com/qmetry/qaf/blob/master/src/com/qmetry/qaf/automation/ui/selenium/AssertionService.java), I See it is adding some random string at the end.

How to remove this random string added and add time stamp? Thanks for the help in advance!

private String captureScreenShot() {
        String filename = StringUtil.createRandomString(getTestCaseName()) + ".png";
        try {
            selenium.captureEntirePageScreenshot(getScreenShotDir() + filename, "");
        } catch (Exception e) {
            try {
                selenium.windowFocus();
            } catch (Throwable t) {
                logger.error(t);
            }
            selenium.captureScreenshot(getScreenShotDir() + filename);
        }
        lastCapturedScreenShot = filename;
        logger.info("Captured screen shot: " + lastCapturedScreenShot);
        return filename;
    }
user861594
  • 5,733
  • 3
  • 29
  • 45

1 Answers1

0

Are you using selenium 1 or 2 api? Selenium 2 uses following code https://github.com/qmetry/qaf/blob/d58b1d1ca01b2df1a916bcd6d555df4f51a13b12/src/com/qmetry/qaf/automation/core/QAFTestBase.java#L351. Regardless of API, you can't change naming strategy for automatic screenshots. As alternate you may disable auto capturing of screenshot, capture as and when needed and set calling setLastCapturedScreenShot

user861594
  • 5,733
  • 3
  • 29
  • 45