Selenium Webdriver and Firefox print window

2,849 views
Skip to first unread message

Alex

unread,
Jan 3, 2013, 5:15:53 AM1/3/13
to seleniu...@googlegroups.com
I am wondering if anyone could help me figure out how to automate the native print window in Firefox.
Don't want to do anything fancy. Just want to check if it pops up then close it. Not sure if selenium supports this.
Do i have to use driver.switchto() as if it were a window? or is it treated as an element?
Thank you in advance and happy new year to all.

Karthik Kulkarni

unread,
Jan 3, 2013, 5:57:13 AM1/3/13
to seleniu...@googlegroups.com
alex search for how to capture a screen shot using selenium



--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To post to this group, send email to seleniu...@googlegroups.com.
To unsubscribe from this group, send email to selenium-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msg/selenium-users/-/3vnUZAtdo-QJ.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Alex

unread,
Jan 3, 2013, 6:22:04 AM1/3/13
to seleniu...@googlegroups.com
not sure how that would help. assuming that i would use said screenshot to check if the window is opened how would i close it? using an external script?. and maintaining image based tests is hell and very time consuming.

there must be something simpler. i found an old 2007 post in a forum about someone saying that firefox print window was not supported so he changed the code for selenium to support it. then a reply from someone saying the modification had been added to selenium. im assuming selenium must have some sort of basic support for firefox native windows by now.

Alex

unread,
Jan 7, 2013, 5:51:01 AM1/7/13
to seleniu...@googlegroups.com
anyone have any ideas?

Mark Collin

unread,
Jan 7, 2013, 6:18:46 AM1/7/13
to seleniu...@googlegroups.com, Alex
You can't with Selenium,

The browser dialogue is an OS level dialogue, Selenium can't interact with these.  The best you could hope for is clicking on a print link and having the dialogue pop open and then take a screenshot (as suggested previously) that you will need to check manually to ensure it is there (Not really an automated solution).

One other potential solution would be to use a java robot class to interact with the print dialogue, but thn you would need to know where it appears and if it didn't appear you probably wouldn't know anyway.

I guess the question is why are you doing this test?  I can guarantee that printing from browsers works if you have a valid print driver, this is something the browser manufacturers will test.  Why do you need to test it as well? 

  1. What would you do if your test failed? 
  2. Can you fix and patch the issue and get the code integrated into the next release of the browser that is causing problems?
  3. If you can do the above can you force your users to use a specific version of the browser that has your fix?
If the answer to the above questions is don't know and no then you are wasting your time.
To view this discussion on the web visit https://groups.google.com/d/msg/selenium-users/-/KXkhbQqZA5YJ.

Alex

unread,
Jan 7, 2013, 7:11:10 AM1/7/13
to seleniu...@googlegroups.com, Alex
The boss asked if it was possible to do this since in some past products they have had issues with the printing dialogue not showing up properly or other problems with it.

Mark Collin

unread,
Jan 7, 2013, 7:13:48 AM1/7/13
to seleniu...@googlegroups.com
Sounds like a good candidate for a manual test once per release IMHO.
To view this discussion on the web visit https://groups.google.com/d/msg/selenium-users/-/31TEWn6qsvoJ.

ANoQA

unread,
Sep 13, 2013, 10:26:01 AM9/13/13
to seleniu...@googlegroups.com
Two hurdles. 1. Firefox 2. Print Driver
NOTE: Selenium can only interact with 1.
 and you can't configure 2. from 1. (or Selenium)

1. In your attached Firefox Profile.
about:config
print.always_print_silent (true)
print_printer (PDFCreator)* [I couldn't get this to work, so see computer default below]

2. Set the computer's default printer to PDFCreator.
PDFCreator > Printer > Options > Auto-save (check Auto-save)

Check whether file exists.
Delete file.
Rinse and repeat.
Reply all
Reply to author
Forward
0 new messages