[wtr-general] After attaching a popup, how can I get back to the main window.

2011-03-04 Thread iamqa
Hi,
I have a main window. A popup(new window) comes up. I attach that
popup to my main window, then I verify some text in that popup. Now I
would like to close that popup and return to my Main window. In IE,
the below script works very well but in firefox, somehow the main
window is lost once I run the attach statement. Below is my code. Any
help is appreciated:
--
require 'rubygems'
require 'watir'
require 'firewatir'
Watir::Browser.default="firefox"
b=Watir::Browser.new
b.goto "http://citi.com";
if b.link(:text,"Privacy").exists?
b.link(:text,"Privacy").click
sleep 10
if (Watir::Browser.default) == "firefox"
b2=FireWatir::Firefox.attach(:title,"Citibank Online - Privacy")
else
if (b2=Watir::IE.find(:title,"Citibank Online - Privacy")) == 
nil
puts "couldn't find the browser"
else
b2=Watir::IE.attach(:title,"Citibank Online - Privacy")
end
end
if b2.title == "Citibank Online - Privacy"
puts "popup opened"
else
puts "couldnt find the popup"
end
b2.close
else
puts "privacy not found"
end
if b.link(:text,"Citi.com").exists?
b.link(:text,"Citi.com").click
puts "Main browser still active"
else
puts "Main browser is lost"
end


After I run this script, in IE, my output is
"popup opened
Main browser still active"
But if I run this script in firefox, my output is
"popup opened
Main browser is lost"

I would like to know, if I can close or ignore a popup in firefox and
come back to main window.
Thanks


-- 
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


[wtr-general] How to click on a div tag

2011-10-13 Thread iamqa
I am trying to automate some testing on yahoo email. I need to click
on the subject or from, so that the email content opens up. I am able
to select the first email by firing onmousedown but unable to go
forward from there.
This is my code:

@browser.div(:id,"shellcontent").div(:id,"inboxcontainer").div(:id,"msg-
list").div(:class,"list-view ").div(:class,"list-view-items
").div(:class=>"list-view-item  btn-msglist resize-
columns", :index=>1).div(:class,"subj").fire_event('onmousedown')

I tried firing onkeyup, onkeydown, onmouseup, onmousedown, onclick but
nothing is working. I also tried send_keys("{ENTER}") but was getting
an error as:

C:/Ruby187/lib/ruby/gems/1.8/gems/watir-1.8.1/lib/watir/element.rb:
378:in `method_missing': undefined method `send_keys' for # (NoMethodError)
from email_Agent_MonthlyNonMemberContent_Yahoo.rb:84

Thanks

-- 
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


[wtr-general] Re: How to click on a div tag

2011-10-14 Thread iamqa
Hi Chuck,

You are right in regards to the length of the id's used in
identification. Also there is lot of dynamic data. short description
should be beneficial. I will fix my script.

I ran my script in IRB, and found that .click is returning back a
value(time it took to execute), but I don't see any change in my
screen. Then I started using fire_events and got partial success with
onmousedown(highlights my email).
Wondered if another fire_event can trigger a 'enter'on that
highlighted email.

Thanks

On Oct 14, 9:01 am, Chuck van der Linden  wrote:
> Keeping in mind what Cliff and Orde both say below, if you need to
> push forward I might suggest a few things
>
> first, are you sure you need to fire the event against the 'subj'
> div?  The name of the class for the div above that makes me think it
> would be the one with the resize functionality attached to it, and any
> click within that area is what might be needed.
>
> Second, you're a really long chain there, and a bunch of it is almost
> certainly not needed in order to identify the element you are after.
> ID's should be unique on a page, so any time you are locating a chain
> like that, mostly by ID, you can generally omit the higher level
> items.   This isn't like xpath where you need to specify the entire
> path to the element, you just need enough info to uniquely identify an
> element, and outer containers are really not needed unless that's
> where you can make that identification (e.g. the inner item has no
> unique properties)
>
> This:
> @browser.div(:id,"shellcontent").div(:id,"inboxcontainer").div(:id,"msg-
> list").div(:class,"list-view ").div(:class,"list-view-items
> ").div(:class=>"list-view-item  btn-msglist resize-
> columns", :index=>1).div(:class,"subj").fire_event('onmousedown')
>
> Could be shortened to at the very least this
> @browser.div(:id,"msg-list").div(:class,"list-view ").div(:class,"list-
> view-items
> ").div(:class=>"list-view-item  btn-msglist resize-
> columns", :index=>1).div(:class,"subj").fire_event('onmousedown')
>
> And even more likely down to this:
> @browser.div(:class=>"list-view-item  btn-msglist resize-
> columns", :index=>1).div(:class,"subj").fire_event('onmousedown')
>
> Try using IRB along with .flash against the minimum you think you
> need, to see if you can properly locate the element.  This will make
> the code a lot more readable, remove a lot of potential for typos, and
> generally make the code a lot less brittle as a change to one of those
> outer containers won't break your code. It may also make the code run
> slightly faster.
>
> BTW if you are after a specific mail you expect to be on the page, it
> might be easier to locate the div by the subject text, and then if
> needed make use of .parent to work your way back to an outer container
> for that row
>
> On Oct 13, 8:00 pm, Cliff Cyphers  wrote:
>
>
>
> > And if you are using the yahoo and gmail accounts for test purposes,
> > pop them instead and much easier to automate with ruby('net/pop').
>
> > On Thu, Oct 13, 2011 at 8:34 PM, orde  wrote:
> > > I've seen this topic come up a few times in this forum (i.e.
> > > automating yahoo email or gmail), and I'd advise finding another
> > > option if possible.  They have tons of dynamic content and change
> > > frequently, so it's a serious challenge to maintain.
>
> > > Sorry it's not the answer that you're looking for, but that's my 2
> > > cents.
>
> > > HTH
>
> > > orde
>
> > > On Oct 13, 3:53 pm, iamqa  wrote:
> > >> I am trying to automate some testing on yahoo email. I need to click
> > >> on the subject or from, so that the email content opens up. I am able
> > >> to select the first email by firing onmousedown but unable to go
> > >> forward from there.
> > >> This is my code:
>
> > >> @browser.div(:id,"shellcontent").div(:id,"inboxcontainer").div(:id,"msg-
> > >> list").div(:class,"list-view ").div(:class,"list-view-items
> > >> ").div(:class=>"list-view-item  btn-msglist resize-
> > >> columns", :index=>1).div(:class,"subj").fire_event('onmousedown')
>
> > >> I tried firing onkeyup, onkeydown, onmouseup, onmousedown, onclick but
> > >> nothing is working. I also tried send_keys("{ENTER}") but was ge