Images not showing up for nested spec directories
cyberjaime45 opened this issue · comments
Expected behavior
Images created by the new CustomScreenshotWriter should show up for for nested specs directories
Actual behavior
The images links are broken if:
specs specDirectory1 specDirectory2 My-Spec.spec
In the html-plugin the screenshot image links address is expected to be: <root_project>reports/staging/html-report/specs/specFolder1/specFolder1/images/screenshot-c7a2f422-bedc-4215-9d4d-94d004210b0a.png
Steps to reproduce
Create a project with nested spec directories
Gauge version
Gauge version: 1.0.7
Commit Hash: ed7b4fd6
Plugins
-------
flash (0.0.2)
html-report (4.0.9)
java (0.7.4)
json-report (0.3.3)
screenshot (0.0.1)
Waiting for this release. I am also having folder structure as
specs
- teamName
- regression
- ui
- file.spec
-api
- file.spec.
would be nice if it accepts for any folder structure under specs.
@Vishnu1067 I tested this branch (251_nested_dir_images). The bug has been fixed. I downloaded the source code and compiled myself. Let me know if you need the zip file for your machine. I hope they release soon.
I have checkout this branch (251_nested_dir_images)
and compiled go run build/make.go && go run build/make.go --install
and now gauge -v
Gauge version: 1.0.7
Plugins
-------
html-report (4.0.10)
java (0.7.4)
screenshot (0.0.1)
spectacle (0.1.3)
xml-report (0.2.1)
When i use ICustomScreenshotGrabber, screenshots are showing in the report (deprecated ICustomScreenshotGrabber)
public class CustomScreenGrabber implements ICustomScreenshotGrabber {
@Override
public byte[] takeScreenshot() {
return ((TakesScreenshot) driver).getScreenshotAs(OutputType.BYTES);
}
But if i use CustomScreenshotWriter, screenshot not placed in images and it is crashed.
public class CustomScreenGrabber implements CustomScreenshotWriter {
@Override
public String takeScreenshot() {
return ((TakesScreenshot) driver).getScreenshotAs(OutputType.FILE).getName();
}
Correct me if i am doing anything wrong here.
Also not sure i must put env gauge_screenshots_dir
as per this PR
getgauge/gauge-java#333
@sriv can you please consider to fix this issue or am i missing something? Please advise.
I have checkout this branch
(251_nested_dir_images)
and compiledgo run build/make.go && go run build/make.go --install
and now gauge -v
Gauge version: 1.0.7 Plugins ------- html-report (4.0.10) java (0.7.4) screenshot (0.0.1) spectacle (0.1.3) xml-report (0.2.1)
When i use ICustomScreenshotGrabber, screenshots are showing in the report (deprecated ICustomScreenshotGrabber)
public class CustomScreenGrabber implements ICustomScreenshotGrabber { @Override public byte[] takeScreenshot() { return ((TakesScreenshot) driver).getScreenshotAs(OutputType.BYTES); }
But if i use CustomScreenshotWriter, screenshot not placed in images and it is crashed.
public class CustomScreenGrabber implements CustomScreenshotWriter { @Override public String takeScreenshot() { return ((TakesScreenshot) driver).getScreenshotAs(OutputType.FILE).getName(); }
Correct me if i am doing anything wrong here.
Also not sure i must put env
gauge_screenshots_dir
as per this PR
getgauge/gauge-java#333
@Vishnu1067 - sure. will check this out as well.
@Vishnu1067 - your custom screengrabber imlpementation is incorrect. You need to write the file and then return the path. The location of screenshot should be read from gauge_screenshots_dir
. Something like this:
// Return a screenshot file name
@Override
public String takeScreenshot() {
TakesScreenshot driver = (TakesScreenshot) DriverFactory.getDriver();
String screenshotFileName = String.format("screenshot-%s.png", UUID.randomUUID().toString());
File screenshotFile = new File(Paths.get(System.getenv("gauge_screenshots_dir"), screenshotFileName).toString());
File tmpFile = driver.getScreenshotAs(OutputType.FILE);
try {
FileUtils.copyFile(tmpFile, screenshotFile);
} catch (IOException e) {
e.printStackTrace();
}
return screenshotFileName;
}
I tried this and am able to see the screenshots in all pages (even the nested ones).
PS - the docs mention this: https://docs.gauge.org/writing-specifications.html?os=windows&language=java&ide=vscode#taking-custom-screenshots