Can't seem to edit my post, but the example should be
profile = Selenium::WebDriver::Chrome::Profile.new
profile['plugins.enabled_internal_pdf3'] = false
b = Watir::Browser.new :chrome, :profile => profile
b.goto("http://www.aisb.org.uk/convention/aisb08/AISB08.pdf")
On Thursday, May 9, 2013 9:06:56 AM UTC-4, Dan wrote:
>
> Seems like the best thing to do would be to disable the chrome pfd viewer
> so it downloads it instead of trying to open it. I think technically you
> should be able to pass a switch to chrome to disable the
> viewer programmatically, but I tried and it didn't work for me, but maybe
> this will lead you in the right direction.
>
> http://watirwebdriver.com/chrome/
>
> profile = Selenium::WebDriver::Chrome::Profile.new
> b = Watir::Browser.new :chrome, :profile => profile
> b.goto("http://www.aisb.org.uk/convention/aisb08/AISB08.pdf")
>
> Although, if you're not validating anything in the file, it might not even
> be worth the trouble to download it. See below for some thoughts on that.
> The examples there are in java, but the concept is much the same in ruby.
>
>
> http://ardesco.lazerycode.com/index.php/2012/07/how-to-download-files-with-selenium-and-why-you-shouldnt/
>
> On Wednesday, May 8, 2013 5:45:53 PM UTC-4, Dan Meltz wrote:
>>
>>
>> Short version: new tabs in Chromeprevent old tabs from being used, fixing
>> that means that opened tabs with PDFs in them get reused before a human can
>> examine the PDFs.
>>
>> Originally it worked like this:
>> 1. open new Chrome window to main page of the app (tab #1)
>> 2. [do process A and then] click the button and a new tab (tab #2) opens
>> with PDF A in it.
>> 3. Go back to tab #1 [do process B and then] click the button and a new
>> tab (tab #3) opens with PDF B in it.
>> 4. Go back to tab #1 [do process C and then] click the button and a new
>> tab (tab #4) opens and Word document C document gets downloaded.
>> 6. Go back to tab #1 [do process D and then] click the button and a new
>> tab (tab #5) opens and Word document D document gets downloaded.
>>
>> All tabs stay open and PDFs can be viewed. Not perfect, but workable.
>>
>> But then things changed. I pulled frequently used stuff out, put them in
>> methods in another file so all of the various tests could use them, which
>> seemed like a good idea. But that seems to have caused problems with losing
>> focus on the original window. (I may be wrong) now I'm stuck with:
>> 1. open new Chrome window to main page of the app (tab #1)
>> 2. [do process A and then] click the button and a new tab (tab #2) opens
>> with PDF A in it.
>> 3. Stay in tab #2 [do process B and then] click the button and a new tab
>> (tab #3) opens with PDF B in it. PDF A is now lost
>> 4. Stay in tab #3 [do process C and then] click the button and a new tab
>> (tab #4) opens and Word document C document gets downloaded. PDF B is now
>> lost
>> 6. Stay in tab #4 [do process D and then] click the button and a new tab
>> (tab #5) opens and Word document D document gets downloaded.
>>
>> This was caused by using "b.windows.last.use"
>> So I tried using "b.windows.first.use"
>> But that fails, because focus isn't going back to tab #1, and watir can't
>> find the object in the modal that it needs to click.
>> (in `assert_ok': Element is not clickable at point (737.5, -373)
>> (Selenium::WebDriver::Error::UnknownError))
>>
>> So far as I can tell, I would be fine if I could do any one of the
>> following
>> 1) get PDFs to download. I cannot. This
>> page<https://groups.google.com/forum/?fromgroups=#!topic/watir-general/gItPeAaWZWY>seemed
>> promising, but the code didn't work and I couldn't fix it.
>> 2) get watir to go back to the first page, "for realsies", and find the
>> buttons it needs
>> 3) perhaps open a new tab for every section of the test (I'm going to
>> look into this one, but I'm not overly hopeful)
>>
>> Any ideas?
>> I updated Watir and Ruby both within the last two months. I'm using
>> Chrome on OSX. Moving to Windows or IE are not viable options.
>>
>> Here is a section of the code. No, I'm not a programmer first and
>> foremost.
>>
>> # print Inventory Report .PDF
>> b.goto currenturl
>> b.div(:id, 'page').a(:text, 'Inventory Report').click
>> sleep 1
>> b.div(:id, 'printInventoryReportModal').a(:text, 'A4').click
>> b.link(:id => "submitBTNprint-inventory-report").fire_event "onclick"
>> status = page_status(currenturl) # these are the methods that I pulled
>> out
>> passtest = section_results(currenturl,b) # and put in a shared file
>>
>> # print General List .PDF
>> b.goto [main page URL]
>> b.div(:id, 'page').a(:text, 'General List').click
>> sleep 1
>> b.div(:id, 'printGeneralInventoryListModal').a(:text, 'A4').click
>> b.link(:id => "submitBTNprint-general-list").fire_event "onclick"
>> status = page_status(currenturl)
>> passtest = section_results(currenturl,b)
>>
>> # print General List .DOC
>> b.goto [main page URL]
>> b.div(:id, 'page').a(:text, 'General List').click
>> sleep 1
>> b.div(:id, 'printGeneralInventoryListModal').a(:text, '.DOC').click
>> b.div(:id, 'printGeneralInventoryListModal').a(:text, 'A4').click
>> b.link(:id => "submitBTNprint-general-list").fire_event "onclick"
>> status = page_status(currenturl)
>> passtest = section_results(currenturl,b)
>>
>> # print Inventory Report .XLS
>> b.goto [main page URL]
>> b.div(:id, 'page').a(:text, 'Inventory Report').click
>> sleep 1
>> b.div(:id, 'printInventoryReportModal').a(:text, 'A4').click
>> b.div(:id, 'printInventoryReportModal').a(:text, '.XLS').click
>> b.link(:id => "submitBTNprint-inventory-report").fire_event "onclick"
>> status = page_status(currenturl)
>> passtest = section_results(currenturl,b)
>>
>
--
--
Before posting, please read http://watir.com/support. In short: search before
you ask, be nice.
[email protected]
http://groups.google.com/group/watir-general
[email protected]
---
You received this message because you are subscribed to the Google Groups
"Watir General" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.