Search code examples
watiruser-agentfirewatirbrowser-automation

Watir :- click an image button?


I have am using firefox and i have modified its user agent to make it behave like iphone web browser. now when i open google.com using watir and now i want to click on the searh button which is an image in mobile view. how to do that.


Solution

  • To click an image

    <img id="logo">
    

    try this

    browser.image(:id => "logo").click
    

    If the image is actually a button

    <input type="image" id="logo">
    

    try this

    browser.button(:id => "logo").click
    

    The next time please provide relevant HTML.

    Also, take a look at HTML Elements Supported by Watir page.