Class: Wrapybara::Content

Inherits:
Object
  • Object
show all
Includes:
Element
Defined in:
lib/wrapybara/elements/content.rb

Instance Method Summary collapse

Methods included from Element

#default_how, #default_scope, #disabled?, #element, #enabled?, #exists?, #focused?, #get_element, #parent_identifier, #path, #should_be_disabled, #should_be_enabled, #should_be_focused, #should_be_visible, #should_have_attribute, #should_not_be_disabled, #should_not_be_enabled, #should_not_be_focused, #should_not_be_visible, #should_not_have_attribute, #style, #visible?, #within

Constructor Details

#initialize(identifier, scope = default_scope) ⇒ Content

Returns a new instance of Content.



5
6
7
8
9
10
11
12
13
14
# File 'lib/wrapybara/elements/content.rb', line 5

def initialize(identifier, scope = default_scope)
	@identifier = identifier
	@scope = scope
	#xpath = XPath::HTML.content(identifier)
	# the %{} string notation is used so double quotes can offset identifier, allowing identifier to contain single quotes/apostrophes.
	# also important to note is that this xpath requires text to be contained in something (div, p, span). any text just floating around
	# on the page will show up with a path of //html, which is not terribly useful later on.
	xpath = %{//*[contains(text(), "#{identifier}")]}
	@element = get_element(xpath, scope)
end

Instance Method Details

#clickObject



16
17
18
19
# File 'lib/wrapybara/elements/content.rb', line 16

def click
	self.should_be_visible
	super
end

#element_identifierObject



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

def element_identifier
	"'#{@identifier}'#{self.within(@scope)}"
end

#should_existObject



21
22
23
# File 'lib/wrapybara/elements/content.rb', line 21

def should_exist
	super "Expected content #{self.element_identifier} to exist"
end

#should_not_existObject



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

def should_not_exist
	super "Did not expect content #{self.element_identifier} to exist"
end