Rodreegez
Rodreegez

Reputation: 576

Using selenium-client to click a button that is part of a form

Hey, this should be pretty simple, but it's causing me a lot of grief! I have lots of buttons like this:

<form class="general" method="post" action="/password">
  <div style="margin: 0pt; padding: 0pt; display: inline;">
    <input type="hidden" value="Yg4EweyWwXO8RAF9nd3RZKNmQw8Yk+f2vefLQ/IENyg=" name="authenticity_token"/>
  </div>
   <fieldset>
      <ol>
    </ol>
  </fieldset>
  <div class="submit save">
    <span class="submit">
      <input type="submit" value="Submit" name="commit"/>
    </span>
  </div>
</form>

so, the question is... how do I click the button?

I should point out that I am not using Webrat with selenium, just straight up selenium. I've tried "selenium.click"-ing just about everything I can think of. It seems that the click method want's an ID, but I don't know what ID to give it...

Any sugestions?

Upvotes: 1

Views: 2964

Answers (3)

Rodreegez
Rodreegez

Reputation: 576

selenium.click("//input[@name='commit' and @value='#{button}']")

(told you it was simple)

Upvotes: 2

Dave Hunt
Dave Hunt

Reputation: 8223

I might be missing some obvious reason why you can't use this but why not use:

name=commit

Upvotes: 1

Santi
Santi

Reputation: 4468

Try the following locator:

css=form.general input[type=submit]

Upvotes: 1

Related Questions