[wtr-general] Tabs, PDFs, focus, and Chrome

2013-05-09 Thread Dan Meltz


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 
pagehttps://groups.google.com/forum/?fromgroups=#!topic/watir-general/gItPeAaWZWYseemed
 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.




[wtr-general] Tabs

2010-05-12 Thread Brad
Hello,

I want to click on all the links on a page, got it, I have this
working no problem. Some links have their target set to _blank which
in turns involves a new tab (a browser tab) inside the same browser
window. So if I only had one tab visible and active when the link is
clicked now I have two tabs.

So I have two questions:
How do I go back to the original tab?
How can I close the newly opened tab?

Please let me know if you need more information.

Thanks.

Brad

-- 
Before posting, please read http://watir.com/support. In short: search before 
you ask, be nice.

You received this message because you are subscribed to 
http://groups.google.com/group/watir-general
To post: watir-general@googlegroups.com
To unsubscribe: watir-general+unsubscr...@googlegroups.com


Re: [wtr-general] Tabs

2010-05-12 Thread Wesley Chen
ie = Watir::IE.attach(:title, xxx) can locate an existing IE window.
ie.close can close the ie window

Wesley.
For life, the easier, the better.


On Thu, May 13, 2010 at 4:26 AM, Brad bradask...@gmail.com wrote:

 Hello,

 I want to click on all the links on a page, got it, I have this
 working no problem. Some links have their target set to _blank which
 in turns involves a new tab (a browser tab) inside the same browser
 window. So if I only had one tab visible and active when the link is
 clicked now I have two tabs.

 So I have two questions:
 How do I go back to the original tab?
 How can I close the newly opened tab?

 Please let me know if you need more information.

 Thanks.

 Brad

 --
 Before posting, please read http://watir.com/support. In short: search
 before you ask, be nice.

 You received this message because you are subscribed to
 http://groups.google.com/group/watir-general
 To post: watir-general@googlegroups.com
 To unsubscribe: 
 watir-general+unsubscr...@googlegroups.comwatir-general%2bunsubscr...@googlegroups.com


-- 
Before posting, please read http://watir.com/support. In short: search before 
you ask, be nice.

You received this message because you are subscribed to 
http://groups.google.com/group/watir-general
To post: watir-general@googlegroups.com
To unsubscribe: watir-general+unsubscr...@googlegroups.com