extent-framework / extentreports-cucumber4-adapter

Cucumber4 Adapter for Extent Framework
http://extentreports.com/docs/versions/4/java/cucumber2.html
Apache License 2.0
39 stars 22 forks source link

Screenshot folder is created with %20 in name when space is present #66

Closed grasshopper7 closed 4 years ago

grasshopper7 commented 4 years ago

Have a space in screenshot.dir setting, then it creates a folder with name 'test%20output'.

screenshot.dir=test output/

This is due to the below line of code in URLOutputStream which does not interpret the URI correctly.

https://github.com/extent-framework/extentreports-cucumber4-adapter/blob/26b6451dfee50f241f592c53a337ea55a62b6fc9/src/main/java/com/aventstack/extentreports/cucumber/adapter/URLOutputStream.java#L41

It works when this is changed to

File file = new File(url.toURI().getPath());

Let me know if this is correct, will make the same changes in the 5 and 6 versions

anshooarora commented 4 years ago

@grasshopper7 Another user reported this issue here:

https://github.com/extent-framework/extentreports-cucumber4-adapter/issues/48#issuecomment-613152077

I referred to your screenshots above and this happens because the default way to save screenshots is by writing against a URL. See the official Cucumber HTML formatter. Any space would be replaced by %20 so I would advise you to not have any spaces, use - or _ where necessary. This is also why I was unable to reproduce the behavior you are.

anshooarora commented 4 years ago

Ability to add plain local path can be added via configuration, this will also ensure existing usage does not break for users who are using direct HTTP links to display images.

grasshopper7 commented 4 years ago

There is a check for 'file' or 'http' protocol before the File object is created. Any http linked images should work as before.

https://github.com/extent-framework/extentreports-cucumber4-adapter/blob/26b6451dfee50f241f592c53a337ea55a62b6fc9/src/main/java/com/aventstack/extentreports/cucumber/adapter/URLOutputStream.java#L40

https://github.com/extent-framework/extentreports-cucumber4-adapter/blob/26b6451dfee50f241f592c53a337ea55a62b6fc9/src/main/java/com/aventstack/extentreports/cucumber/adapter/URLOutputStream.java#L45

anshooarora commented 4 years ago

Ah. Thanks for reminding me. Yes, this would work. Can you send a pull request?

grasshopper7 commented 4 years ago

Done - https://github.com/extent-framework/extentreports-cucumber4-adapter/pull/67

anshooarora commented 4 years ago

Thank you, merged PR.