Clicking image with mechanize

风格不统一 提交于 2019-12-12 01:29:22

问题


clicking a text agent.click(page.link_with(:text => 'some_text') with mechainze is piece of cake. How to click an image with mechanize?


回答1:


It is rather similar. You just need to grab one of the attributes of your image. have a look below..:

agent.click(page.image_with(:alt=> 'your image')




回答2:


Clicking on a pure HTML image will typically have no effect. If the image has an onclick handler, you will not be able to click on it with Mechanize as it does not support javascript.

You may want to use something like Capybara with the Webkit, PhantomJS or Selenium driver instead.



来源:https://stackoverflow.com/questions/11895973/clicking-image-with-mechanize

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!