Class: Actir::BasicPage
- Inherits:
-
Object
- Object
- Actir::BasicPage
- Defined in:
- lib/actir/basic_page.rb
Instance Method Summary collapse
- #data_driven(hash, &blk) ⇒ Object
-
#initialize(driver) ⇒ BasicPage
constructor
include PageObject.
- #method_missing(m, *args, &blk) ⇒ Object
- #turn_to(kls) ⇒ Object
Constructor Details
#initialize(driver) ⇒ BasicPage
include PageObject
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 #Appium TO-DO 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 #if end #each class_eval &blk if block_given? end |