input submit click button capybara no id
Asked Answered
R

2

17

I'm trying to get a simple input submit to click using capybara. The submit button is actually on a modal. However, trying a few capybara still not working. Since I'm doing testing, I'm advise to not modify the code base. Adding an id would solve this easily but I have to do without it.

HTML code

<input type="submit" class="btn btn-primary text-uppercase" value="Create" form="new_tab">

Capybara commands tried

find("input[type=submit][value='Create']").click
find('input[type]="submit"]').click
find('input[class="btn btn-primary text-uppercase"]').click
Rhinarium answered 3/4, 2016 at 6:12 Comment(0)
P
16
click_button("Create")

should click it, assuming it is visible on the page. http://www.rubydoc.info/gems/capybara/Capybara%2FNode%2FActions%3Aclick_button

Pemberton answered 3/4, 2016 at 7:18 Comment(0)
W
21

Try to use this version:

find('input[name="commit"]').click

It helps me all time.

Waikiki answered 3/11, 2017 at 14:39 Comment(1)
saved me a lot of timeCountdown
P
16
click_button("Create")

should click it, assuming it is visible on the page. http://www.rubydoc.info/gems/capybara/Capybara%2FNode%2FActions%3Aclick_button

Pemberton answered 3/4, 2016 at 7:18 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.