3

I'm trying to search a page for divs containing a specific class and then click on them. Each of these divs containing the class have a onclick event on them.

My current code looks like so,

home_page = agent.get('http://mysite.com')

home_page.search(".//div[@class='arrow up']").each do |i| 
  i.click
end

The div looks like so on the website.

<div class="arrow up" onclick="$(this).uparrow(u.config.places, null, event)" role="button" aria-label="uparrow" tabindex="0"></div>

Now there is obviously no click method for this because its a Nokogiri object, so I am here to ask is it possible for mechanize to click on a div like this? My current code can find all divs that match this class name, but I cannot figure out how to click on it.

randy newfield
  • 1,221
  • 3
  • 25
  • 38

1 Answers1

1

No there's no way to do that. You need to look at the onclick attribute and try to figure out what it's doing. That or use Watir.

pguardiario
  • 53,827
  • 19
  • 119
  • 159
  • Yea after a bit of searching I found Watir. Was hoping I didnt have to load a browser to manipulate, but at least it's working. – randy newfield Sep 04 '13 at 00:36