开发者

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?


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

(told you it was simple)


Try the following locator:

css=form.general input[type=submit]


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

name=commit
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜