Ruby学习笔记(23)_Capybara Actions
来源:互联网 发布:金亚洲软件下载 编辑:程序博客网 时间:2024/06/05 14:45
attach_file
语法:
#attach_file(locator, path, options = {}) ⇒ Capybara::Node::Element
Find a file field on the page and attach a file given its path. The file field can be found via its name, id or label text.
page.attach_file(locator, '/path/to/file.png')
Parameters:
- locator (String) — Which field to attach the file to
- path (String) — The path of the file that will be attached, or an array of paths
- options (Hash) (defaults to: {}) — a customizable set of options
Options Hash (options):
- wait (false, Numeric) — default: Capybara.default_max_wait_time — Maximum time to wait for matching element to appear.
- match (Symbol) — default: Capybara.match — The matching strategy to use (:one, :first, :prefer_exact, :smart).
- exact (Boolean) — default: Capybara.exact — Match the exact label name/contents or accept a partial match.
- multiple (Boolean) — Match field which allows multiple file selection
- id (String) — Match fields that match the id attribute
- name (String) — Match fields that match the name attribute
- :class (String, Array) — Match links that match the class(es) provided
- make_visible (true, Hash) — A Hash of CSS styles to change before attempting to attach the file, if
true
{ opacity: 1, display: ‘block’, visibility: ‘visible’ } is used (may not be supported by all drivers)
Returns:
(Capybara::Node::Element) — The file field element
check
语法:
#check([locator], options) ⇒ Capybara::Node::Element
Find a check box and mark it as checked. The check box can be found via name, id or label text.
page.check('German')
Options Hash (options):
- :option (String) — Value of the checkbox to select
- id (String) — Match fields that match the id attribute
- name (String) — Match fields that match the name attribute
- :class (String, Array) — Match links that match the class(es) provided
- :allow_label_click (Boolean) — default: Capybara.automatic_label_click — Attempt to click the label to toggle state if element is non-visible.
- wait (false, Numeric) — default: Capybara.default_max_wait_time — Maximum time to wait for matching element to appear.
Returns:
(Capybara::Node::Element) — The element checked or the label clicked
uncheck
page.uncheck('German')
choose
语法:
#choose([locator], options) ⇒ Capybara::Node::Element
Find a radio button and mark it as checked. The radio button can be found via name, id or label text.
page.choose('Male')
Options Hash (options):
- :option (String) — Value of the radio_button to choose
- :id (String) — Match fields that match the id attribute
- :name (String) — Match fields that match the name attribute
- :class (String, Array) — Match links that match the class(es) provided
- wait (false, Numeric) — default: Capybara.default_max_wait_time — Maximum time to wait for matching element to appear.
- :allow_label_click (Boolean) — default: Capybara.automatic_label_click — Attempt to click the label to toggle state if element is non-visible.
Returns:
(Capybara::Node::Element) — The element chosen or the label clicked
click_button
#click_button([locator], options) ⇒ Capybara::Node::Element
Finds a button on the page and clicks it. This can be any element of type submit, reset, image, button or it can be a element. All buttons can be found by their id, value, or title. elements can also be found by their text content, and image elements by their alt attribute
Options Hash (options):
wait (false, Numeric) — default: Capybara.default_max_wait_time — Maximum time to wait for matching element to appear.
click_link
语法:
#click_link([locator], options) ⇒ Capybara::Node::Element
Finds a link by id, text or title and clicks it. Also looks at image alt text inside the link.
Options Hash (options):
wait (false, Numeric) — default: Capybara.default_max_wait_time — Maximum time to wait for matching element to appear.
fill_in
语法:
#fill_in([locator], options = {}) ⇒ Capybara::Node::Element
Locate a text field or text area and fill it in with the given text The field can be found via its name, id or label text.
page.fill_in 'Name', with: 'Bob'
Options Hash (options):
wait (false, Numeric) — default: Capybara.default_max_wait_time —
Maximum time to wait for matching element to appear.:with (String) — The value to fill in - required
- :fill_options (Hash) — Driver specific options regarding how to fill fields
- :currently_with (String) — The current value property of the field to fill in
- :multiple (Boolean) — Match fields that can have multiple values?
- :id (String) — Match fields that match the id attribute
- :name (String) — Match fields that match the name attribute
- :placeholder (String) — Match fields that match the placeholder attribute
- :class (String, Array) — Match links that match the class(es) provided
select
语法:
#select(value, options = {}) ⇒ Capybara::Node::Element
If :from
option is present, select
finds a select box on the page and selects a particular option from it. Otherwise it finds an option inside current scope and selects it. If the select box is a multiple select, select can be called multiple times to select more than one option. The select box can be found via its name, id or label text. The option can be found by its text.
page.select 'March', from: 'Month'
Parameters:
- value (String) — Which option to select
- options (Hash) (defaults to: {}) — a customizable set of options
Options Hash (options):
- wait (false, Numeric) — default: Capybara.default_max_wait_time — Maximum time to wait for matching element to appear.
- :from (String) — The id, name or label of the select box
Returns:
(Capybara::Node::Element) — The option element selected
unselect
page.unselect 'March', from: 'Month'
- Ruby学习笔记(23)_Capybara Actions
- Ruby学习笔记(23)_Capybara Finders
- Ruby学习笔记(22)_capybara基础方法
- cocos2d-x学习笔记(7)--动作(Actions)
- Caliburn.Micro学习笔记(二)----Actions
- 【ruby学习笔记】初探ruby
- Ruby语法学习笔记
- Ruby学习笔记(入门)
- watir学习笔记/ruby
- ruby学习笔记一
- ruby学习笔记二
- ruby学习笔记三
- ruby学习笔记四
- ruby学习笔记
- Ruby学习笔记(1)
- Ruby学习笔记
- Ruby 学习笔记 Symbol
- ruby 学习笔记method
- PHP 中 new static 和 new self 的区别
- iOS定时器取消,用在socket断线重连
- 线性回归、岭回归、逻辑回归、信息量与熵、多类的分类问题softmax、链式法则与BP神经网络
- Vysor 破解
- 谈谈shuffle流程 细节就不说了
- Ruby学习笔记(23)_Capybara Actions
- 五金:常用电线规格标准统计(UL,AWG)
- 《C++ Primer》学习笔记 第9章:顺序容器
- 推荐10 个短小却超实用的 JavaScript 代码段
- 人机关系的哲学反思
- Apache Ignite
- Activiti 工作流 Zip方式部署 03
- C编程实现变量值交换、求最大值、顺序输出、最大公约数
- 专业智能IC-LED XT1511/SK6812编程IC智能灯