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.

watir-general@googlegroups.com
http://groups.google.com/group/watir-general
watir-general+unsubscr...@googlegroups.com

--- 
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 watir-general+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to