0
votes

Problem: Cant click on this element named 'BT_SEARCH'

<tr>
    <td ...>
        <input type="submit" name="BT_SEARCH" value="Hae" onclick="document.forms['DForm'].elements['LPAGE'].value=1">
    </td>
</tr>
  1. click 'Hae' returns: undefined method `click' for #Object:...

  2. click_button 'Hae' returns: Unable to find button "Hae"...

  3. click_link 'Hae' returns: Unable to find link "Hae"...

  4. find(:xpath, "//input[@name='BT_SEARCH']").click doesnt seem to find the element.

I'm unable to modify the source, and there's no id or class tags available. Additionally the page uses ASP which I assume is causing the problem.

3

3 Answers

0
votes

You can try below mentioned ways to click the element:

  1. find("input[name=\"BT_SEARCH\"]").click
  2. page.execute_script("$('input[name=\"BT_SEARCH\"]').trigger('click')")

Hope this Helps :)

0
votes

Going through your attempts -

  1. #click is only on elements returned from a find so calling it not on an element will never work

  2. #click_button clicks on button elements and input elements with type submit, reset, image, or button. It will match all of those against id or value - so given your example this should have worked

  3. #click_link clicks on links - an input element isn't a link so this should have failed

  4. assuming the xpath matches the element (which it appears to do) this should have worked

So your attempts #2 and #4 should both have worked if the page is as specified. You didn't give the exact error you're getting for #4, but since #2 gave you an "Unable to find..." error I'm assuming #4 did too. In that case there are two likely possibilities - 1. The element isn't actually on the page - If the element is supposed to be added to the page by JS make sure there are no JS errors that are blocking the addition of the element. 2. The element isn't visible on the page - Perform whatever user actions are necessary to make the input visible before attempting to click it

0
votes

The problem was that the element was inside an iframe.

within_frame solved the issue:

within_frame (frame_id) do
  click "Hae"
end

Confusing thing was that click could find the element without within_frame (but it was not clickable), while click_on or find could not.