Assert / Screenshot of non-HTML page

34 views
Skip to first unread message

daniel.c...@gmail.com

unread,
May 24, 2016, 5:49:11 PM5/24/16
to Coypu
Hello,

Is it possible to Assert and / or capture a screenshot of a non-html based page in the web browser? Specifically, I have a case where clicking a link on the site opens a new window which displays a PDF file (personally I would convert it to a pure HTML page instead of using PDF, but unfortunately it isn't my call). When I right-click the resulting page I am unable to view the source, but if I inspect the element via Chrome tools I do see a title within the appropriate <title> tags, which I assume the browser is generating somehow. 

When I run my test it opens the page as expected on screen, but the saved screenshot is a blank 815px x 908px jpg and the Assert of the title fails. I've included a sanitized version of the test method below; using this method on HTML based pages work just fine, so I know that my setup and tear down are ok.

        [Test]
        public void VerifyPdfWindowOpens() 
        {
            var saveFilePath = "FOLDER_PATH";
            browser.Visit("https://www.foo.com/bar.pdf");
            browser.SaveScreenshot(saveFilePath, ImageFormat.Jpeg);
            Assert.That(browser.Title == "PAGE_TITLE");
        }

"PDF isn't supported" is of course an acceptable answer; I just want to make certain I'm not doing it wrong if it is supported. :)

Thanks for you time,
Dan

Adrian Longley

unread,
May 25, 2016, 1:39:52 AM5/25/16
to co...@googlegroups.com
On Tue, May 24, 2016 at 10:48 PM, <daniel.c...@gmail.com> wrote:
Hello,

Is it possible to Assert and / or capture a screenshot of a non-html based page in the web browser?

No, I don't think this will work with Selenium. Perhaps you could just download the PDF directly from the expected location?
 

--
You received this message because you are subscribed to the Google Groups "Coypu" group.
To unsubscribe from this group and stop receiving emails from it, send an email to coypu+un...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages