class Wrapybara::Content

Public Class Methods

new(identifier, scope = default_scope) click to toggle source
# 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

Public Instance Methods

click() click to toggle source
Calls superclass method Wrapybara::Element#click
# File lib/wrapybara/elements/content.rb, line 16
def click
        self.should_be_visible
        super
end
element_identifier() click to toggle source
# File lib/wrapybara/elements/content.rb, line 29
def element_identifier
        "'#{@identifier}'#{self.within(@scope)}"
end
should_exist() click to toggle source
Calls superclass method Wrapybara::Element#should_exist
# File lib/wrapybara/elements/content.rb, line 21
def should_exist
        super "Expected content #{self.element_identifier} to exist"
end
should_not_exist() click to toggle source
Calls superclass method Wrapybara::Element#should_not_exist
# File lib/wrapybara/elements/content.rb, line 25
def should_not_exist
        super "Did not expect content #{self.element_identifier} to exist"
end