导轨,将测试数据输入Capybara Systemtest中的条纹元素
我正在尝试使用Capybara/Minitest Systemtest测试结帐过程的条纹部分,但不知道如何将测试卡数据输入到条纹元素中。
这是输入字段之一:
<div class="CardNumberField-input-wrapper">
<span class="InputContainer" data-max="4242 4242 4242 4242 4240">
<input class="InputElement is-empty Input Input--empty" autocomplete="cc-number" autocorrect="off" spellcheck="false" type="tel" name="cardnumber" data-elements-stable-field-name="cardNumber" aria-label="Credit or debit card number" placeholder="Card number" aria-invalid="false" value=""></span></div>
..
我获得的最接近的是简单的:
fill_in('Card number', with: '4242424242424242')
这引起了:
Capybara::ElementNotFound: Unable to find field "Card number" that is not disabled
我怀疑,它可能不足以针对一个字段,但是您必须单击输入字段bevor。
当我尝试针对CSS类时:
find(class: 'CardNumberField-input-wrapper').fill_in('Card number', with: '4242424242424242')
我得到:
Capybara::ElementNotFound: Unable to find css nil with classes [CardNumberField-input-wrapper]
如何启用禁用字段?还有另一种方法吗?
I am trying to test the stripe part of a checkout process with a Capybara/Minitest Systemtest and do not know how to input the test card data into the stripe element.
This is one of the input fields:
<div class="CardNumberField-input-wrapper">
<span class="InputContainer" data-max="4242 4242 4242 4242 4240">
<input class="InputElement is-empty Input Input--empty" autocomplete="cc-number" autocorrect="off" spellcheck="false" type="tel" name="cardnumber" data-elements-stable-field-name="cardNumber" aria-label="Credit or debit card number" placeholder="Card number" aria-invalid="false" value=""></span></div>
..
The closest I got was with a simple:
fill_in('Card number', with: '4242424242424242')
which caused:
Capybara::ElementNotFound: Unable to find field "Card number" that is not disabled
I suspect, that it might not be enough to target a field, but that you have to click the input field bevor.
When I try to target the CSS class:
find(class: 'CardNumberField-input-wrapper').fill_in('Card number', with: '4242424242424242')
I get:
Capybara::ElementNotFound: Unable to find css nil with classes [CardNumberField-input-wrapper]
How can I enable the disabled field? Is there another way to do it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
多亏了托马斯·范·霍尔德(Thomas Van Holder)在选择器上工作的提示,我得到了以下方式与XPath一起工作的。
Thanks to Thomas Van Holder's hint to work on the selector, I got it working with Xpath in the following way.
尝试按名称查找输入元素:
Try finding the input element by name: