Module: Capybara::UI::DSL
- Included in:
- Role
- Defined in:
- lib/capybara/ui/dsl.rb
Instance Attribute Summary collapse
Instance Method Summary collapse
-
#click(name, *args) ⇒ Object
Clicks the widget defined by
name
and optionalargs
. -
#document ⇒ Document
The current document with the class of the current object set as the widget lookup scope.
-
#double_click(name, *args) ⇒ Object
Double clicks the widget defined by
name
and optionalargs
. -
#eventually(wait_time = Capybara.default_max_wait_time, &block) ⇒ Object
re-run one or more assertions until either they all pass, or Capybara::UI times out, which will result in a test failure.
-
#has_widget?(name, *args) ⇒ Boolean
(also: #widget?)
Whether one or more widgets exist in the current document.
-
#hover(name, *args) ⇒ Object
Hovers the widget defined by
name
and optionalargs
. - #not_visible?(name, *args) ⇒ Boolean
-
#right_click(name, *args) ⇒ Object
Right clicks the widget defined by
name
and optionalargs
. - #set(name, fields) ⇒ Object
- #submit(name, fields = {}) ⇒ Object
- #value(name, *args) ⇒ Object
- #values(name, *args) ⇒ Object
- #visible?(name, *args) ⇒ Boolean
- #visit(path) ⇒ Object
-
#widget(name, *args) ⇒ Object
Returns a widget instance for the given name.
-
#widgets(name, *args) ⇒ Object
Returns a list of widget instances for the given name.
Instance Attribute Details
#widget_lookup_scope ⇒ Object
92 93 94 |
# File 'lib/capybara/ui/dsl.rb', line 92 def @widget_lookup_scope ||= end |
Instance Method Details
#click(name, *args) ⇒ Object
Clicks the widget defined by name
and optional args
.
Makes no distinction between links or buttons.
class MyWidget < Capybara::UI::Widget
root { |text| ['.my-widget', text: text] }
end
# <a href="#one" class="my-widget">One</li>
# <a href="#two" class="my-widget">Two</li> <!-- clicks this node -->
click :my_widget, 'Two'
17 18 19 |
# File 'lib/capybara/ui/dsl.rb', line 17 def click(name, *args) (name, *args).click end |
#document ⇒ Document
Returns the current document with the class of the current object set as the widget lookup scope.
38 39 40 |
# File 'lib/capybara/ui/dsl.rb', line 38 def document Document.new() end |
#double_click(name, *args) ⇒ Object
Double clicks the widget defined by name
and optional args
.
27 28 29 |
# File 'lib/capybara/ui/dsl.rb', line 27 def double_click(name, *args) (name, *args).double_click end |
#eventually(wait_time = Capybara.default_max_wait_time, &block) ⇒ Object
re-run one or more assertions until either they all pass, or Capybara::UI times out, which will result in a test failure.
98 99 100 |
# File 'lib/capybara/ui/dsl.rb', line 98 def eventually(wait_time = Capybara.default_max_wait_time, &block) Checkpoint.wait_for wait_time, &block end |
#has_widget?(name, *args) ⇒ Boolean Also known as: widget?
Returns Whether one or more widgets exist in the current document.
44 45 46 |
# File 'lib/capybara/ui/dsl.rb', line 44 def (name, *args) document.(name, *args) end |
#hover(name, *args) ⇒ Object
Hovers the widget defined by name
and optional args
.
22 23 24 |
# File 'lib/capybara/ui/dsl.rb', line 22 def hover(name, *args) (name, *args).hover end |
#not_visible?(name, *args) ⇒ Boolean
54 55 56 |
# File 'lib/capybara/ui/dsl.rb', line 54 def not_visible?(name, *args) document.not_visible?(name, *args) end |
#right_click(name, *args) ⇒ Object
Right clicks the widget defined by name
and optional args
.
32 33 34 |
# File 'lib/capybara/ui/dsl.rb', line 32 def right_click(name, *args) (name, *args).right_click end |
#set(name, fields) ⇒ Object
58 59 60 |
# File 'lib/capybara/ui/dsl.rb', line 58 def set(name, fields) (name).set fields end |
#submit(name, fields = {}) ⇒ Object
62 63 64 |
# File 'lib/capybara/ui/dsl.rb', line 62 def submit(name, fields = {}) (name).submit_with fields end |
#value(name, *args) ⇒ Object
66 67 68 |
# File 'lib/capybara/ui/dsl.rb', line 66 def value(name, *args) (name, *args).value end |
#values(name, *args) ⇒ Object
70 71 72 |
# File 'lib/capybara/ui/dsl.rb', line 70 def values(name, *args) (name, *args).map(&:value) end |
#visible?(name, *args) ⇒ Boolean
50 51 52 |
# File 'lib/capybara/ui/dsl.rb', line 50 def visible?(name, *args) document.visible?(name, *args) end |
#visit(path) ⇒ Object
74 75 76 |
# File 'lib/capybara/ui/dsl.rb', line 74 def visit(path) Capybara.current_session.visit path end |
#widget(name, *args) ⇒ Object
Returns a widget instance for the given name.
81 82 83 |
# File 'lib/capybara/ui/dsl.rb', line 81 def (name, *args) eventually { document.(name, *args) } end |
#widgets(name, *args) ⇒ Object
Returns a list of widget instances for the given name.
88 89 90 |
# File 'lib/capybara/ui/dsl.rb', line 88 def (name, *args) document.(name, *args) end |