Class: Actir::BasicPage
- Inherits:
-
Object
show all
- Defined in:
- lib/actir/basic_page.rb
Instance Method Summary
collapse
Constructor Details
#initialize(driver) ⇒ BasicPage
7
8
9
10
11
12
13
14
15
16
17
18
|
# File 'lib/actir/basic_page.rb', line 7
def initialize(driver)
case driver
when Watir::Browser, Browser
@browser = driver
when Appium::Driver
@appium = driver
else
raise "wrong driver"
end
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(m, *args, &blk) ⇒ Object
20
21
22
23
24
25
26
27
28
|
# File 'lib/actir/basic_page.rb', line 20
def method_missing(m, *args, &blk)
if @browser.respond_to? m
@browser.send(m, *args, &blk)
elsif @appium.respond_to? m
@appium.send(m, *args, &blk)
else
super
end
end
|
Instance Method Details
#data_driven(hash, &blk) ⇒ Object
35
36
37
38
39
40
41
42
43
44
45
46
|
# File 'lib/actir/basic_page.rb', line 35
def data_driven hash, &blk
raise "Argument Error" unless hash.is_a?(Hash)
hash.each do |mtd, data|
m_with_eql = (mtd.to_s + '=').to_sym
if respond_to?(m_with_eql)
eval "self.#{m_with_eql.to_s}(data)"
elsif respond_to?(mtd.to_sym)
self.send(mtd.to_sym).send(data.to_sym)
end
end
class_eval &blk if block_given?
end
|
#turn_to(kls) ⇒ Object
30
31
32
33
|
# File 'lib/actir/basic_page.rb', line 30
def turn_to kls
raise "Invalid Page Error" unless kls <= Actir::BasicPage
kls.new(@browser)
end
|