Skip to content
angupta edited this page Sep 13, 2010 · 5 revisions
  • Page Modules divide the Pages into groups of Elements
  • Page Modules are suitable for Pages that have many Elements
  • Filters can be created for an entire page-module
  • Page Module make tests more cleaner and readable

Page Modules can be created like:


class PageName < ::Taza::Page
    
    page_module :foo_module do
        element(:first_element) { browser.text_field(:id => 'first_name') }
        element(:second_element) { browser.text_field(:id => 'second_name') }
    end
 
    filter :foo_filter, :foo_module
    def foo_filter
        true
    end
end

The example shows a page module “foo_module” that contains elements “first_element” and “second_element”. If the page module’s name is given to a filter, it will be for all the elements of the page module.

Another module on the same page can look like:


class PageName < ::Taza::Page
    
    page_module :bar_module do
        element(:first_element) { browser.text_field(:id => 'first_name') }
    end

    filter :bar_filter, :bar_module
    def bar_filter
        true
    end
end

Elements inside the page-modules can be accessed like:


describe 'Some Page' do
    describe 'Foo Module' do
        SiteName.new do |site|
            site.page_name(:foo_module) do |f|
                f.first_element.set 'Foo'
            end
        end
    end
 
    describe 'Bar Module' do
        SiteName.new do |site|
            site.page_name(:bar_module) do |b|
                b.first_element.set 'Bar'
            end
        end
    end
end

Note: The elements on a page can have the same name only if the they belong to different Page Modules.

Clone this wiki locally