Module: SeleniumPlus::Container

Included in:
Iframe, Page, Section
Defined in:
lib/selenium_plus/page_obj/container.rb

Instance Method Summary collapse

Instance Method Details

#element(name, *find_args) ⇒ Selenium::WebDriver::Element

Define a new method with the name of the symbol and return an element

Examples:

class DemoPage < SeleniumPlus::Page
  element(:username_tb, :id, 'username')
end

Parameters:

  • name (Symbol)

    The name of new element

  • find_args (Array)

Returns:



16
17
18
19
20
21
# File 'lib/selenium_plus/page_obj/container.rb', line 16

def element(name, *find_args)
  define_method(name) do
    find(*find_args)
  end
  add_existence_checker(name, *find_args)
end

#elements(name, *find_args) ⇒ Array<Selenium::WebDriver::Element>

Define a new method with the name of the symbol and return elements

Examples:

class DemoPage < SeleniumPlus::Page
  elements(:results_list, :css, 'li.view')
end

Parameters:

  • name (Symbol)

    The name of new elements array

  • find_args (Array)

Returns:



34
35
36
37
38
# File 'lib/selenium_plus/page_obj/container.rb', line 34

def elements(name, *find_args)
  define_method(name) do
    find_all(*find_args)
  end
end

#iframe(name, iframe_class, *find_args) ⇒ Object



57
58
59
60
61
# File 'lib/selenium_plus/page_obj/container.rb', line 57

def iframe(name, iframe_class, *find_args)
  define_method(name) do
    iframe_class.new(find(*find_args))
  end
end

#section(name, section_class, *find_args) ⇒ SeleniumPlus::Section

Define partial section of the page

Examples:

class DemoPage < SeleniumPlus::Page
  Section(:search_section, SearchSection, :id, 'div#search_me')
end

Parameters:

  • name (Symbol)

    The name of new section

  • find_args (Array)

Returns:



51
52
53
54
55
# File 'lib/selenium_plus/page_obj/container.rb', line 51

def section(name, section_class, *find_args)
  define_method(name) do
    section_class.new(find(*find_args))
  end
end