Class: PageMaker
- Inherits:
-
Object
show all
- Defined in:
- lib/sakai-cle-test-api/page_maker.rb
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(browser, visit = false) ⇒ PageMaker
Returns a new instance of PageMaker.
3
4
5
6
7
8
|
# File 'lib/sakai-cle-test-api/page_maker.rb', line 3
def initialize browser, visit = false
@browser = browser
goto if visit
expected_element if respond_to? :expected_element
has_expected_title? if respond_to? :has_expected_title?
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(sym, *args, &block) ⇒ Object
10
11
12
|
# File 'lib/sakai-cle-test-api/page_maker.rb', line 10
def method_missing sym, *args, &block
@browser.send sym, *args, &block
end
|
Class Method Details
.element(element_name) ⇒ Object
Also known as:
value, action, thing
35
36
37
38
39
40
|
# File 'lib/sakai-cle-test-api/page_maker.rb', line 35
def element element_name
raise "#{element_name} is being defined twice in #{self}!" if self.instance_methods.include?(element_name.to_sym)
define_method element_name.to_s do
yield self
end
end
|
.expected_element(element_name, timeout = 30) ⇒ Object
22
23
24
25
26
|
# File 'lib/sakai-cle-test-api/page_maker.rb', line 22
def expected_element element_name, timeout=30
define_method 'expected_element' do
self.send(element_name).wait_until_present timeout
end
end
|
.expected_title(expected_title) ⇒ Object
28
29
30
31
32
33
|
# File 'lib/sakai-cle-test-api/page_maker.rb', line 28
def expected_title expected_title
define_method 'has_expected_title?' do
has_expected_title = expected_title.kind_of?(Regexp) ? expected_title =~ @browser.title : expected_title == @browser.title
raise "Expected title '#{expected_title}' instead of '#{@browser.title}'" unless has_expected_title
end
end
|
.page_url(url) ⇒ Object
16
17
18
19
20
|
# File 'lib/sakai-cle-test-api/page_maker.rb', line 16
def page_url url
define_method 'goto' do
@browser.goto url
end
end
|