[Celerity-users] click_and_attach and popup ads

George Dinwiddie lists at iDIAcomputing.com
Mon May 3 14:07:43 EDT 2010


doridori Jo wrote:
> aye you are right jason. but i dont know Java ! :(

You can use JRuby and work directly with HtmlUnit.  See the way that 
Celerity does so.

  - George

> 
> On Mon, May 3, 2010 at 4:02 AM, jason franklin-stokes <
> jasoninclass at googlemail.com> wrote:
> 
>> you need to set the @page variable
>>
>> - in general it looks like you want to scrape pages from different websites
>> - if you are celerity is not the right tool.
>> you should consider getting rid of it and using HtmlUnit directly.
>>
>> best Jason.
>>
>>
>> On May 3, 2010, at 11:36 AM, doridori Jo wrote:
>>
>> okay, so i have the page i want....not clear exactly what web_window_event
>> listener is doing...
>>
>> how to set it to browser.page ?
>>
>> i ended up with Java::ComGargoylesoftwareHtmlunitHtml::HtmlPage but how can
>> i set this into browser.page ?
>>             browser = Celerity::Browser.new()
>>             browser.add_listener(:web_window_event) { |window|
>>             if window.getNewPage == nil #this might be a popup window
>>             else
>>                 browser.page = window.getNewPage #Got the page i need
>> here....
>>                 puts window
>>             end
>>             }
>>             puts browser
>>             linkz = browser.element_by_xpath(someXpath)
>>             newbrowser = linkz.click_and_attach
>>
>> newbrowser should now contain the filtered page....but it doesn't
>>
>>
>> On Fri, Apr 30, 2010 at 12:58 PM, doridori Jo <dorikick at gmail.com> wrote:
>>
>>> 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 <tomasz2k at 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 <dorikick at gmail.com>
>>>> 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
>>>>
>>>
>> _______________________________________________
>> Celerity-users mailing list
>> Celerity-users at rubyforge.org
>> http://rubyforge.org/mailman/listinfo/celerity-users
>>
>>
>>
>> _______________________________________________
>> Celerity-users mailing list
>> Celerity-users at rubyforge.org
>> http://rubyforge.org/mailman/listinfo/celerity-users
>>
>>
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> Celerity-users mailing list
> Celerity-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/celerity-users

-- 
  ----------------------------------------------------------------------
   * George Dinwiddie *                      http://blog.gdinwiddie.com
   Software Development                    http://www.idiacomputing.com
   Consultant and Coach                    http://www.agilemaryland.org
  ----------------------------------------------------------------------



More information about the Celerity-users mailing list