Cabybara根据元素名称查找元素 [英] Cabybara find element based on element name

查看:77
本文介绍了Cabybara根据元素名称查找元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,我正在尝试选择输入字段,并根据元素名称为Stripe的iframe添加值。
这不起作用

Hi i am trying to select input field and add value into stripe's iframe, based on element name. this won't work

page.find(:name, 'exp-date')

我能够使用id选择器选择root div,但是我无法选择输入字段,它是位于root div

i was able to select root div with id selector, but i can't select input field which is child node somewhere in root div

  find(:id, "root")

任何想法如何定位这些字段

Any idea how to target those fields

推荐答案

使用水豚 find_field 方法来查找字段输入。在此处签出文档:
http:/ /www.rubydoc.info/github/jnicklas/capybara/Capybara/Node/Finders#find_field-instance_method

Use the capybara find_field method to find field inputs. Checkout the docs here: http://www.rubydoc.info/github/jnicklas/capybara/Capybara/Node/Finders#find_field-instance_method

看起来像: find_field('attributes [form_field_attribute_you_need]')

这篇关于Cabybara根据元素名称查找元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆