문제

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.

도움이 되었습니까?

해결책

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top