Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

input submit click button capybara no id

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
like image 342
khoamle Avatar asked Apr 03 '16 06:04

khoamle


2 Answers

Try to use this version:

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

It helps me all time.

like image 147
AlexSh Avatar answered Sep 19 '22 17:09

AlexSh


click_button("Create")

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

like image 42
Thomas Walpole Avatar answered Sep 16 '22 17:09

Thomas Walpole