[Chrome] Handle Print Preview window

5,218 views
Skip to first unread message

Yury Kryazhev

unread,
Apr 22, 2013, 10:01:15 AM4/22/13
to webd...@googlegroups.com

Mark Collin

unread,
Apr 23, 2013, 1:46:07 AM4/23/13
to webd...@googlegroups.com

You can’t.

 

Chrome is embedding a PDF reader into the page  and what you are seeing is actually a PDF.  You can’t access it through Selenium.

--
You received this message because you are subscribed to the Google Groups "webdriver" group.
To unsubscribe from this group and stop receiving emails from it, send an email to webdriver+...@googlegroups.com.
To post to this group, send email to webd...@googlegroups.com.
Visit this group at http://groups.google.com/group/webdriver?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Yury Kryazhev

unread,
Apr 23, 2013, 4:19:54 AM4/23/13
to webd...@googlegroups.com
I can see that, but PDF is inside some kind of html page or tab. So I just want to check that this Print Preview page was opened and then close it, to continue testing app.



вторник, 23 апреля 2013 г., 9:46:07 UTC+4 пользователь Mark Collin написал:

Mark Collin

unread,
Apr 23, 2013, 8:18:09 AM4/23/13
to webd...@googlegroups.com
I would suggest that this is a pointless test.

What are you going to do if chrome doesn't open the print preview page?О©╫
Can your dev team fix it (Bear in mind it will be an issue with chrome itself)?



On 23/04/2013 09:19, Yury Kryazhev wrote:
I can see that, but PDF is inside some kind of html page or tab. So I just want to check that this Print Preview page was opened and then close it, to continue testing app.



О©╫О©╫О©╫О©╫О©╫О©╫О©╫, 23 О©╫О©╫О©╫О©╫О©╫О©╫ 2013О©╫О©╫., 9:46:07 UTC+4 О©╫О©╫О©╫О©╫О©╫О©╫О©╫О©╫О©╫О©╫О©╫О©╫ Mark Collin О©╫О©╫О©╫О©╫О©╫О©╫О©╫:

You can’t.

О©╫

Chrome is embedding a PDF reader into the page О©╫and what you are seeing is actually a PDF.О©╫ You can’t access it through Selenium.

О©╫

From: webd...@googlegroups.com [mailto:webd...@googlegroups.com] On Behalf Of Yury Kryazhev
Sent: 22 April 2013 15:01
To: webd...@googlegroups.com
Subject: [webdriver] [Chrome] Handle Print Preview window

О©╫

Hi,О©╫

О©╫

I'm trying to work with Print Preview window in google chrome like this:

О©╫ О©╫ О©╫ О©╫ driver.findElement(By.xpath("//*[contains(@id, '-winBillingHistoryFull-print')]")).click(); // After clicking Print Preview window appears

О©╫ О©╫ О©╫ О©╫ driver.getWindowHandles(); // Browser crashes withО©╫UnreachableBrowserException: Error communicating with the remote browser. It may have died.

О©╫

О©╫

О©╫

Caused by: org.openqa.selenium.WebDriverException: org.apache.http.conn.HttpHostConnectException: Connection to http://localhost:29816 refused
Build info: version: '2.31.0', revision: '1bd294d185a80fa4206dfeab80ba773c04ac33c0', time: '2013-02-27 13:51:26'
System info: os.name: 'Windows 2003', os.arch: 'x86', os.version: '5.2', java.version: '1.6.0_31'
Driver info: driver.version: RemoteWebDriver

Caused by: org.apache.http.conn.HttpHostConnectException: Connection to http://localhost:29816 refused
Caused by: java.net.ConnectException: Connection refused: connect

О©╫

О©╫

Any ideas why this happens and how to switch to Print Preview window?

--
You received this message because you are subscribed to the Google Groups "webdriver" group.
To unsubscribe from this group and stop receiving emails from it, send an email to webdriver+...@googlegroups.com.
To post to this group, send email to webd...@googlegroups.com.
Visit this group at http://groups.google.com/group/webdriver?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.

О©╫
О©╫

--
You received this message because you are subscribed to the Google Groups "webdriver" group.
To unsubscribe from this group and stop receiving emails from it, send an email to webdriver+...@googlegroups.com.
To post to this group, send email to webd...@googlegroups.com.
Visit this group at http://groups.google.com/group/webdriver?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
О©╫
О©╫

Yury Kryazhev

unread,
Apr 23, 2013, 10:55:15 AM4/23/13
to webd...@googlegroups.com
Thx for a suggestion, but still I think it's not appropriate to throw UnreachableBrowserException when invoking driver.getWindowHandles();

вторник, 23 апреля 2013 г., 16:18:09 UTC+4 пользователь Mark Collin написал:

Mark Collin

unread,
Apr 23, 2013, 2:11:45 PM4/23/13
to webd...@googlegroups.com
It is if you have done something that blocks access to the browser (which you have done by opening a print preview box) because the browser is no longer reachable.

The solution is to modify your test so that it does not perform a pointless action to test something that you have no control over and will be able to do nothing about if it fails.О©╫ Every test you perform should have a valid reason behind it, and each one should give you confidence that functionality your team has written works as expected.О©╫

Your team did not write the print preview functionality, it is baked into the browser, what benefit does this test give to your team?О©╫ Do you also test that you can show/hide the bookmark bar on your browser?

Performing tests just "because you can" when they they have no value is a bit of a bugbear of mine.О©╫ All it does it waste time and increase the amount of time it takes to run your test suites, ask yourself the following:О©╫
  • How much time have you wasted trying to find a solution to this problem?
  • What useful tasks could you have performed during this time (I can think of one going through your test code and refactoring it to make it better, I'm sure there are many others).
This is really something you do not want to do.


On 23/04/2013 15:55, Yury Kryazhev wrote:
Thx for a suggestion, but still I think it's not appropriate to throw UnreachableBrowserException when invoking driver.getWindowHandles();

О©╫О©╫О©╫О©╫О©╫О©╫О©╫, 23 О©╫О©╫О©╫О©╫О©╫О©╫ 2013О©╫О©╫., 16:18:09 UTC+4 О©╫О©╫О©╫О©╫О©╫О©╫О©╫О©╫О©╫О©╫О©╫О©╫ Mark Collin О©╫О©╫О©╫О©╫О©╫О©╫О©╫:
I would suggest that this is a pointless test.

What are you going to do if chrome doesn't open the print preview page?О©╫
Can your dev team fix it (Bear in mind it will be an issue with chrome itself)?

Richard Lavoie

unread,
Apr 23, 2013, 4:58:15 PM4/23/13
to webd...@googlegroups.com
How would you guys go about testing the fact that a button click trigger the "Open the print dialog" action ?


On 2013-04-23, at 14:11, Mark Collin <mark....@lazeryattack.com> wrote:

It is if you have done something that blocks access to the browser (which you have done by opening a print preview box) because the browser is no longer reachable.

The solution is to modify your test so that it does not perform a pointless action to test something that you have no control over and will be able to do nothing about if it fails.  Every test you perform should have a valid reason behind it, and each one should give you confidence that functionality your team has written works as expected. 

Your team did not write the print preview functionality, it is baked into the browser, what benefit does this test give to your team?  Do you also test that you can show/hide the bookmark bar on your browser?

Performing tests just "because you can" when they they have no value is a bit of a bugbear of mine.  All it does it waste time and increase the amount of time it takes to run your test suites, ask yourself the following: 
  • How much time have you wasted trying to find a solution to this problem?
  • What useful tasks could you have performed during this time (I can think of one going through your test code and refactoring it to make it better, I'm sure there are many others).
This is really something you do not want to do.

On 23/04/2013 15:55, Yury Kryazhev wrote:
Thx for a suggestion, but still I think it's not appropriate to throw UnreachableBrowserException when invoking driver.getWindowHandles();

вторник, 23 апреля 2013 г., 16:18:09 UTC+4 пользователь Mark Collin написал:
I would suggest that this is a pointless test.


What are you going to do if chrome doesn't open the print preview page?О©╫
Can your dev team fix it (Bear in mind it will be an issue with chrome itself)?

--
You received this message because you are subscribed to the Google Groups "webdriver" group.
To unsubscribe from this group and stop receiving emails from it, send an email to webdriver+...@googlegroups.com.
To post to this group, send email to webd...@googlegroups.com.
Visit this group at http://groups.google.com/group/webdriver?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

darrell

unread,
Apr 24, 2013, 10:40:42 PM4/24/13
to webd...@googlegroups.com
Realistically, this isn't a Selenium question. There should be a unit test to ensure the code is making the appropriate call. If the appropriate call is made and it fails to work, this means all applications (not just our team) in the world will be affected by this defect. It would be a defect in the browser. I only test for things my team can fix.

A good unit test would be that the correct call to the browser engine exists is really what needs to be tested. If I get a new version of the browser I might manually test the print dialog. It is good to know if a certain version of the browser fails to open a print dialog. However, I'd never automate a test of the browser's capabilities unless I worked for the browser company.

Bill Ross

unread,
Apr 25, 2013, 1:45:15 AM4/25/13
to webd...@googlegroups.com
Maybe AutoIt would work? Is there a java Robot library for controlling
desktops like Webdriver controls browsers?

It seems valid to verify that an on-page control is working, assuming
that's where the 'button' is, and with browsers updating frequently,
reasonable to automate.

Bill

darrell <darrell....@gmail.com> wrote:

> Realistically, this isn't a Selenium question. There should be a unit test
> to ensure the code is making the appropriate call. If the appropriate call
> is made and it fails to work, this means all applications (not just our
> team) in the world will be affected by this defect. It would be a defect in
> the browser. I only test for things my team can fix.
>
> A good unit test would be that the correct call to the browser engine
> exists is really what needs to be tested. If I get a new version of the
> browser I might manually test the print dialog. It is good to know if a
> certain version of the browser fails to open a print dialog. However, I'd
> never automate a test of the browser's capabilities unless I worked for the
> browser company.
>
>
> On Tuesday, 23 April 2013 16:58:15 UTC-4, DarkRift wrote:
> >
> > How would you guys go about testing the fact that a button click trigger
> > the "Open the print dialog" action ?
> >
> > On 2013-04-23, at 14:11, Mark Collin <mark....@lazeryattack.com<javascript:>>
> > wrote:
> >
> > It is if you have done something that blocks access to the browser (which
> > you have done by opening a print preview box) because the browser is no
> > longer reachable.
> >
> > The solution is to modify your test so that it does not perform a
> > pointless action to test something that you have no control over and will
> > be able to do nothing about if it fails. Every test you perform should
> > have a valid reason behind it, and each one should give you confidence that
> > functionality your team has written works as expected.
> >
> > Your team did not write the print preview functionality, it is baked into
> > the browser, what benefit does this test give to your team? Do you also
> > test that you can show/hide the bookmark bar on your browser?
> >
> > Performing tests just "because you can" when they they have no value is a
> > bit of a bugbear of mine. All it does it waste time and increase the
> > amount of time it takes to run your test suites, ask yourself the
> > following:
> >
> > - How much time have you wasted trying to find a solution to this
> > problem?
> > - What useful tasks could you have performed during this time (I can
> > think of one going through your test code and refactoring it to make it
> > better, I'm sure there are many others).
> >
> > This is really something you do not want to do.
> >
> > On 23/04/2013 15:55, Yury Kryazhev wrote:
> >
> > Thx for a suggestion, but still I think it's not appropriate to throw
> > UnreachableBrowserException when invoking driver.getWindowHandles();
> >
> > вторник, 23 апреля 2013 г., 16:18:09 UTC+4 пользователь Mark Collin
> > написал:
> >>
> >> I would suggest that this is a pointless test.
> >>
> >> What are you going to do if chrome doesn't open the print preview
> >> page?О©╫
> >> Can your dev team fix it (Bear in mind it will be an issue with chrome
> >> itself)?
> >>
> >> --
> > You received this message because you are subscribed to the Google Groups
> > "webdriver" group.
> > To unsubscribe from this group and stop receiving emails from it, send an
> > email to webdriver+...@googlegroups.com <javascript:>.
> > To post to this group, send email to webd...@googlegroups.com<javascript:>
> > .
> > Visit this group at http://groups.google.com/group/webdriver?hl=en.
> > For more options, visit https://groups.google.com/groups/opt_out.
> >
> >
> >
> >
> > --
> > You received this message because you are subscribed to the Google Groups
> > "webdriver" group.
> > To unsubscribe from this group and stop receiving emails from it, send an
> > email to webdriver+...@googlegroups.com <javascript:>.
> > To post to this group, send email to webd...@googlegroups.com<javascript:>
> > .

Yury Kryazhev

unread,
Apr 25, 2013, 11:42:44 AM4/25/13
to webd...@googlegroups.com
I've started this thread based on http://code.google.com/p/chromedriver/issues/detail?id=19

>> 3) Return a window handle for the print preview tab. A client could switch to it and take a screenshot.


Project Member #10 kka...@chromium.org
This has been implemented in ChromeDriver 19.0.1068.0.


вторник, 23 апреля 2013 г., 22:11:45 UTC+4 пользователь Mark Collin написал:

Wesley Moura

unread,
Sep 24, 2016, 9:48:11 PM9/24/16
to webdriver, kryaz...@googlemail.com
i have found one way, make a loop in the windows in selenium, get some element name in the print page, check if element is present to confirm the correct windows, after this um can handle the print page
Reply all
Reply to author
Forward
0 new messages