Module: Wrapybara

Defined in:
lib/wrapybara/ext/focus_tracking.rb,
lib/wrapybara/element.rb,
lib/wrapybara/methods.rb,
lib/wrapybara/elements/form.rb,
lib/wrapybara/elements/link.rb,
lib/wrapybara/elements/image.rb,
lib/wrapybara/elements/label.rb,
lib/wrapybara/elements/table.rb,
lib/wrapybara/elements/button.rb,
lib/wrapybara/elements/option.rb,
lib/wrapybara/elements/select.rb,
lib/wrapybara/elements/content.rb,
lib/wrapybara/elements/checkbox.rb,
lib/wrapybara/elements/attribute.rb,
lib/wrapybara/elements/text_area.rb,
lib/wrapybara/elements/file_field.rb,
lib/wrapybara/elements/table_body.rb,
lib/wrapybara/elements/table_cell.rb,
lib/wrapybara/elements/table_head.rb,
lib/wrapybara/elements/text_field.rb,
lib/wrapybara/elements/radio_button.rb,
lib/wrapybara/elements/fillable_field.rb,
lib/wrapybara/elements/password_field.rb

Overview

To use Wrapybara’s focus handling capabilities, require wrapybara/ext/focus_handling in some file that gets loaded (I use support/extras.rb so I don’t pollute env.rb) and then optionally set Wrapybara.focus_attribute to whatever the element attribute will be. As you can see below, Wrapybara checks the value of the attribute against what you say it should be when the element has focus.

Defined Under Namespace

Modules: Element, FillableField Classes: Attribute, Button, Checkbox, Content, FileField, Form, Image, Label, Link, Option, PasswordField, RadioButton, Select, Table, TableBody, TableCell, TableHead, TextArea, TextField, UnmetExpectation

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.focus_attributeObject



17
18
19
# File 'lib/wrapybara/ext/focus_tracking.rb', line 17

def self.focus_attribute
	@focus_attribute || 'has-focus'
end

.focus_attribute=(attribute) ⇒ Object



13
14
15
# File 'lib/wrapybara/ext/focus_tracking.rb', line 13

def self.focus_attribute=(attribute)
	@focus_attribute = attribute
end

.focus_valueObject



25
26
27
# File 'lib/wrapybara/ext/focus_tracking.rb', line 25

def self.focus_value
	@focus_value || 'true'
end

.focus_value=(value) ⇒ Object



21
22
23
# File 'lib/wrapybara/ext/focus_tracking.rb', line 21

def self.focus_value=(value)
	@focus_value = value
end

Instance Method Details

#current_pathObject



12
13
14
# File 'lib/wrapybara/methods.rb', line 12

def current_path
	Capybara.current_path
end

#current_path_is?(path) ⇒ Boolean

Returns:

  • (Boolean)


20
21
22
23
# File 'lib/wrapybara/methods.rb', line 20

def current_path_is?(path)
	path = path.gsub('/', '\/').gsub('?', '\?')
	(current_url || current_path) =~ /#{path}/
end

#current_path_should_be(path) ⇒ Object

Raises:



25
26
27
# File 'lib/wrapybara/methods.rb', line 25

def current_path_should_be(path)
	raise UnmetExpectation, "Expected the current path to be '#{path}'" unless current_path_is?(path)
end

#current_path_should_not_be(path) ⇒ Object

Raises:



29
30
31
# File 'lib/wrapybara/methods.rb', line 29

def current_path_should_not_be(path)
	raise UnmetExpectation, "Did not expect the current path to be '#{path}'" if current_path_is?(path)
end

#current_urlObject



16
17
18
# File 'lib/wrapybara/methods.rb', line 16

def current_url
	Capybara.current_url
end

#hostObject



8
9
10
# File 'lib/wrapybara/methods.rb', line 8

def host
	Capybara.app_host
end