Embedded video is not appearing in extent spark report - cucumber-jvm

I have an issue viewing attached videos to cucumber extent report. I can see the attached videos shown in cucumber report.
File video = new File("file_example_MP4_640_3MG.mp4");
byte[] videoAttachment = Files.toByteArray(video);
scenario.attach(videoAttachment, "video/mp4", "video");
But in extent spark report which is generated does not have the videos embedded. Only screenshots are displayed in that report. Has anyone tried this before?
<dependency>
<groupId>tech.grasshopper</groupId>
<artifactId>extentreports-cucumber7-adapter</artifactId>
<version>1.9.2</version>
</dependency>

Related

How do I include screenshots of the full page in my serenity report (and not only of the viewport)?

This question is a part of another question I asked. However, I already found the answer to this part and thought it would be useful for other people as well.
Part of my other question:
I am using serenity in combination with cucumber for automated screen tests and want to include full-page screenshots in my serenity report. The screenshots in the report are normally only a capture of the viewport. Oftentimes however, this doesn't provide enough information as this is only a part of the screen.
I found that the capturing of serenity screenshots is a part of driver implementation. As most drivers conform with the W3C definition of screenshots those drivers only capture the current viewport.
tl;dr: use FirefoxDriver
I contacted David Burns of W3C. He was very helpful and his answer cleared up a lot for me.
First of all, FirefoxDriver for now still takes screenshots of the full page. David said:
FirefoxDriver (and in Marionette our W3C webdriver implementation) on the otherhand does screenshots by dumping the Document into a canvas and calling a Firefox specific API on Canvas to get a screenshot. Since we dump the entire document we can do full page screenshots. This however may change when we start putting more of the Servo code into Firefox and the way we can access screenshots changes.
So unfortunately this will probably change in the future, but for now it is good (when you use FFdriver)..
He also explains why this choice has been made and references to a talk he gave about how the rendering of webpages works.
Later in our conversation he also referenced to the minutes of the discussion about how screenshots should be captured.
His full answer:
Hi
The tl;dr; is its really hard take fullscreen shots since not all browsers have the information to create a screenshot of the whole page.
Long version:
At Selenium Conf this year I did a talk about how #isDisplayed can sometimes lie to you and the reason is the same as the screenshots. To make browsers appear to make web pages load as fast as possible they workout what needs to be rendered in the view port and then render it, via doing calculations on the CPU or GPU.
Because of this approach it means that browsers build up a display list of certain areas and creates "tiles" to render. It starts from the viewport and works out. Now, a browser is not going to render a whole page at a time, it will have a few times above and below ready for when you scroll and calculate the rest when you scroll.
Now ChromeDriver and Microsoft's EdgeDriver both do their screenshots from the display list and have internal APIs that only give them the viewport. This is because their reference tests (or reftests as they are known to vendors) only care about that. They both don't feel its worth the effort to do the rest because of the edge cases.
FirefoxDriver (and in Marionette our W3C webdriver implementation) on the otherhand does screenshots by dumping the Document into a canvas and calling a Firefox specific API on Canvas to get a screenshot. Since we dump the entire document we can do full page screenshots. This however may change when we start putting more of the Servo code into Firefox and the way we can access screenshots changes.
Because we only know the viewport info it leads to us then having to stitch images together to get a full page screenshot. Both ChromeDriver and IEDriver do this and both development teams consider this an ugly hack because its not always right and there isnt much they can do to make it right.
I hope that helps and explains it well. I suggest watching my talk as I explain how renders and layout engines work in Browsers.
David

Show PDF in a Vaadin View

I want to show a PDF in a Vaadin view. I create a BrowserFrame and I pass the StreamResource of the PDF:
StreamResource streamResource = new StreamResource(
getPresenter().createPdfStreamSource(), report.getName() + ".pdf");
BrowserFrame pdf = new BrowserFrame(null, streamResource);
pdf.setSizeFull();
content.addComponent(pdf);
This code creates an iframe with the following source:
http://localhost:8080/my-app/vaadinServlet/APP/connector/0/134/source/mypdf.pdf
If I point the browser to this URL, it shows the PDF properly. However in my application the PDF view doesn't show. What am I doing wrong?
I am testing this in Google Chrome.
Edit: I downloaded the plugin PDF Viewer based on PDF.js and my app works fine. Does the Chrome PDF reader plugin need special configuration?
An iframe is probably not the best option to render a PDF, especially on mobile browsers. Check the WT PDF Viewer add-on which is based on pdf.js for a more compatible solution.

XPage - Open scans in browser

I need to display uploaded scans (JPG, PNG, TIFF, PDF, etc.) in the browser's window instead downloading them to a local pc and using external apps like Acrobat Reader.
I made some research in the web on that issue but wasn't really successful.
Does anyone have hints, code snippets, how to achieve that ?
EDIT :
Since I am not looking for a solution which supports viewing scans in a typical browser like Chrome, FireFox, etc. but supports viewing scans in an XPage view within Notes I need to ask my question again.
What is the best (recommended) way to view different types of scans, uploaded as PDF, JPG, TIFF, PNG, etc., in Notes within an XPage view ?
Take a look here, XPages: Embed PDF and possibly Office files
Here is some code that I have in an app for PDF's.
I tried using Bumpbox, and pdf.js and while I could get them working, iframes seemed to work best for me with using normal Domino attachment urls in xpages
I am not sure if this solution is right or not, but it works well for an app I have that only has PDFs. It does work on mobile too, at least on iOS.
<iframe
src="#{javascript:
var url = 'https://app.nsf/';
var doc = sessionScope.docID;
var atname = #RightBack(sessionScope.aname,'Body');
var end = '/$file'+atname;
return url+doc+end}"
width="800" height="1000">
</iframe>
If you are looking at using different file types you need to use a renderer, give it the attachment URL, and then display what the renderer returns with. I haven't looked at this in a while so things might have changed. Look for a lightbox clone that can display pdf. I think Orangebox was one, bumpbox looks to not be updated but I was able to get that working for me.
This method will display everything inline. I would love to see some type of renderer like pdf.js for xpages.

Export as PDF using Selenium Webdriver Screenshot

Does anyone know if it's possible to export HTML to PDF using the screenshot feature in Selenium Firefox WebDriver? I have a webpage which has print specific css which I need to download automatically. I understand that the screenshot feature takes a screenshot of the page as an image, but I was looking for a scalable PDF file which is good for print.
Screenshots in Selenium are saved as PNG. And PNG and PDF are different kind of formats. So Selenium cannot save your HTML page image directly as a PDF.
But, you could try to insert the PNG screenshot that Selenium takes and add it to a PDF.
Check this answer. Basically, you will need a library (like itext) and do something like:
// Take screenshot
driver.get("http://www.yourwebpage.com");
File screenshot = ((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE);
FileUtils.copyFile(screenshot, new File("screenshot.png"));
// Create the PDF
Document document = new Document(PageSize.A4, 20, 20, 20, 20);
PdfWriter.getInstance(document, new FileOutputStream("my_web.pdf"));
document.open();
Image image = Image.getInstance(getClass().getResource("screenshot.png"));
document.add(image);
document.close();
Hope it helps!
EDIT
Since webs can be pretty high, you will probably need to check the documentation to see how you want to set your image in a PDF file.
A quick and easy way is to build an HTML file and embed the images as base64 data. You can then use any converter to get the document as a PDF.
An example with Python:
from selenium import webdriver
driver = webdriver.Firefox()
driver.get("https://www.google.co.uk");
# open new file
file = open(r"C:\temp\captures.html", "w")
file.write("<!DOCTYPE html><html><head></head><body width=\"600px\">")
# write image
file.write("<img src=\"data:image/png;base64,")
file.write(driver.get_screenshot_as_base64())
file.write("\">")
# close file
file.write("</body></html>")
file.close()
driver.quit()
Webdriver doesn't support "Export As PDF" function.
When you are not bound to Firefox and Webdriver, phantomjs could be an alternative.
Phantomjs is a headless browser with the ability to take screenshots as PDF.
The browser can be controlled directly by javascript.
Example: http://phantomjs.org/screen-capture.html

Rally: IterationPlanningBoard

Any idea where the iteration planning board app's color palette is coming from? I looked at the code but didn't find the source of the color palette. I was able to see it for EpicProgress report but not for IterationPlanningBoard in Rally.
The css file of IterationPlanningBoard is here, from the same
github repo where the source of Rally App Catalog apps is available.
If you want to customize a catalog app and generate new deployment html see this post.