Class: Citronella::Wrapper::PageDecorator

Inherits:
Object
  • Object
show all
Defined in:
lib/page_decorator.rb

Instance Method Summary collapse

Constructor Details

#initialize(driver, webdriver_wait, page, logger) ⇒ PageDecorator

A wrapper for page object class.

Parameters:

  • driver (Webdriver)

    The web driver object.

  • webdriver_wait (Integer)

    The timeout for webdriver wait.

  • page (PageObject)

    The page object class.

  • logger (Boolean)

    A flag indicating whether to log actions.



36
37
38
39
40
41
# File 'lib/page_decorator.rb', line 36

def initialize(driver, webdriver_wait, page, logger)
  @driver = driver
  @webdriver_wait = webdriver_wait
  @page = page
  @logger = logger
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(attr) ⇒ PageDecorator, WebUi

Looks up the attribute/method name inside the page object.

Returns:



47
48
49
50
51
52
53
54
55
# File 'lib/page_decorator.rb', line 47

def method_missing(attr)
  original_method = @page.new.method(attr)
  args = original_method.call
  if args.instance_of?(Class)
    return PageDecorator.new(@driver, @webdriver_wait, args, @logger)
  end
  Citronella::Ui::WebUi.new(@driver, @webdriver_wait, @logger,
                            args, attr, @page.name)
end