黄瓜,水痘和硒 - 提交没有按钮的表单 [英] Cucumber, capybara and selenium - Submiting a form without a button
本文介绍了黄瓜,水痘和硒 - 提交没有按钮的表单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个使用Cucumber,capybara和selenium驱动程序的测试。此测试应转到表单并提交。正常文本是
I have a test using Cucumber, capybara and selenium driver. This test should go to a form and submit it. The normal text would be
Scenario: Fill form
Given I am on the Form page
When I fill in "field1" with "value1"
And I fill in "field2" with "value2"
And I press "OK"
Then I should see "Form submited"
问题是我没有以下形式的确定按钮
我需要一种方法来做form.submit,而不单击任何按钮或链接 - 当你在使用浏览器在表单域中时按ENTER键时发生的一样。
The problem is that I don't have the OK button in the form I need a way to do the "form.submit", without clicking any button or link - the same as happens when you press ENTER when you are in a form field using the browser.
我不知道如何告诉capybara提交表格。
I don't know how to tell capybara to submit a form. How can I do it?
推荐答案
您可以访问selenium send_keys 方法来调用如
You can access the selenium send_keys method to invoke a return event like
find_field('field2').native.send_key(:enter)
这篇关于黄瓜,水痘和硒 - 提交没有按钮的表单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文