From rasputnik at hellooperator.net Fri Apr 16 09:20:09 2010 From: rasputnik at hellooperator.net (Dick Davies) Date: Fri, 16 Apr 2010 14:20:09 +0100 Subject: [Celerity-users] celerity can't decide if a button is there or not :) Message-ID: Just discovered celerity and I love it, mainly for messing around in 'jirb' when building functional tests. But I'm confused by one bit of behaviour; can't tell if it's a bug or just me being a n00b. I can only click() on a button if I refer to it by buttons[n], rather than buttons("name"). Any ideas why? ....skip loading the page.... irb(main):009:0* loginform = browser.frame("content").form("login") => #"login"} @object=nil> irb(main):010:0> loginform.buttons.length => 1 irb(main):011:0> loginform.buttons[0].name => "login" irb(main):012:0> loginform.buttons[0].exists? => true So far so good, but I can't understand why this doesn't work: irb(main):013:0> loginform.button('login').exists? => false here's the form in question (I've added linebreaks to make it less annoying): irb(main):014:0> loginform.html => "
\n \n
\n

\n Please enter your credentials and click the \n \n Login\n \n button below.\n \n

\n
\n
\n
    \n
  • \n \n \n
  • \n
  • \n \n \n
  • \n
  • \n \n
  • \n
\n
\n \n \n \n \n \n \n \n
\n" irb(main):015:0> quit From jari.bakken at gmail.com Fri Apr 16 09:37:44 2010 From: jari.bakken at gmail.com (Jari Bakken) Date: Fri, 16 Apr 2010 15:37:44 +0200 Subject: [Celerity-users] celerity can't decide if a button is there or not :) In-Reply-To: References: Message-ID: On Fri, Apr 16, 2010 at 3:20 PM, Dick Davies wrote: > irb(main):013:0> loginform.button('login').exists? > => false > The default selector for buttons is :value, so button('login') is equivalent to button(:value => 'login') I prefer to use explicit selectors everywhere, since (a) I can never remember what the defaults are, and (b) they will be removed in future versions (of both Watir and Celerity, I believe). So in your case, you want to do button(:name => 'login') From dorikick at gmail.com Fri Apr 30 05:14:48 2010 From: dorikick at gmail.com (doridori Jo) Date: Fri, 30 Apr 2010 02:14:48 -0700 Subject: [Celerity-users] click_and_attach and popup ads Message-ID: hi gang, i brought this up a while back, but it seems like Celerity has no support for choosing between multiple popup or main window. for instance, i link.click_and_attach, if the site has Popup ads, it will load the popup ad, instead of the page. browser.url will show the main page's URL. however, browser.html outputs a popup ad html. So any way to deal with this ? i would very much prefer to use click_and_attach, and be able to filter windows (like if URL contains, ad.doubleclick, ignore it) thank you ! -------------- next part -------------- An HTML attachment was scrubbed... URL: From jari.bakken at gmail.com Fri Apr 30 05:32:35 2010 From: jari.bakken at gmail.com (Jari Bakken) Date: Fri, 30 Apr 2010 11:32:35 +0200 Subject: [Celerity-users] click_and_attach and popup ads In-Reply-To: References: Message-ID: On Fri, Apr 30, 2010 at 11:14 AM, doridori Jo wrote: > > So any way to deal with this ? i would very much prefer to use > click_and_attach, and be able to filter windows (like if URL contains, > ad.doubleclick, ignore it) > That sounds like a sensible feature request, even though it's rarely requested. Could you add an issue to the tracker on GitHub? Or even better, write a patch :) From tomasz2k at poczta.onet.pl Fri Apr 30 06:16:59 2010 From: tomasz2k at poczta.onet.pl (Tomasz =?utf-8?q?Kalkosi=C5=84ski?=) Date: Fri, 30 Apr 2010 12:16:59 +0200 Subject: [Celerity-users] click_and_attach and popup ads In-Reply-To: References: Message-ID: <201004301216.59802.tomasz2k@poczta.onet.pl> On Friday 30 of April 2010 11:32:35 Jari Bakken wrote: > On Fri, Apr 30, 2010 at 11:14 AM, doridori Jo wrote: > > > > So any way to deal with this ? i would very much prefer to use > > click_and_attach, and be able to filter windows (like if URL contains, > > ad.doubleclick, ignore it) > > > > That sounds like a sensible feature request, even though it's rarely requested. > Could you add an issue to the tracker on GitHub? Or even better, write > a patch :) I've dealt with it in my project. You have to look up for windows collection. Something like snippet below, you have to experiment for yourself. def new_browser @browser = Celerity::Browser.new @browser.add_listener(:web_window_event) { |window| if window.getWebWindow.is_a?(Java::ComGargoylesoftwareHtmlunit::TopLevelWindow) && window.getEventType == Java::ComGargoylesoftwareHtmlunit::WebWindowEvent::OPEN @old_top_window = window.getWebWindow.getParentWindow set_actual_page window.page end if window.getWebWindow.getName == "YourPreferredName" && window.getEventType == Java::ComGargoylesoftwareHtmlunit::WebWindowEvent::CHANGE ... end } def set_actual_page(page) # Add to collection on top @pages << @browser.page # Set actual page @browser.page = page end Greetings, Tomasz Kalkosi?ski From dorikick at gmail.com Fri Apr 30 15:58:50 2010 From: dorikick at gmail.com (doridori Jo) Date: Fri, 30 Apr 2010 12:58:50 -0700 Subject: [Celerity-users] click_and_attach and popup ads In-Reply-To: <201004301216.59802.tomasz2k@poczta.onet.pl> References: <201004301216.59802.tomasz2k@poczta.onet.pl> Message-ID: Jari, i've submitted a new issue ticket on github. Tomasz, how will i use new_browser ? do i just declare it in the very beginning, and just continue using browser.link.click_and_attach ? kinda confused. For now, i think best thing is if i just don't use click_and_attach, maybe just use click....but click_and_attach is very useful ! 2010/4/30 Tomasz Kalkosi?ski > On Friday 30 of April 2010 11:32:35 Jari Bakken wrote: > > On Fri, Apr 30, 2010 at 11:14 AM, doridori Jo > wrote: > > > > > > So any way to deal with this ? i would very much prefer to use > > > click_and_attach, and be able to filter windows (like if URL contains, > > > ad.doubleclick, ignore it) > > > > > > > That sounds like a sensible feature request, even though it's rarely > requested. > > Could you add an issue to the tracker on GitHub? Or even better, write > > a patch :) > > I've dealt with it in my project. You have to look up for windows > collection. Something like snippet below, you have to experiment for > yourself. > > def new_browser > > @browser = Celerity::Browser.new > > @browser.add_listener(:web_window_event) { |window| > > if > window.getWebWindow.is_a?(Java::ComGargoylesoftwareHtmlunit::TopLevelWindow) > && > window.getEventType == > Java::ComGargoylesoftwareHtmlunit::WebWindowEvent::OPEN > > @old_top_window = window.getWebWindow.getParentWindow > set_actual_page window.page > > end > > if window.getWebWindow.getName == "YourPreferredName" && > window.getEventType == > Java::ComGargoylesoftwareHtmlunit::WebWindowEvent::CHANGE > > ... > > > end > > } > > def set_actual_page(page) > # Add to collection on top > @pages << @browser.page > > # Set actual page > @browser.page = page > end > > > Greetings, > Tomasz Kalkosi?ski > _______________________________________________ > Celerity-users mailing list > Celerity-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/celerity-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: