Class: Browza::BrowzaMgr
- Inherits:
-
Object
- Object
- Browza::BrowzaMgr
- Defined in:
- lib/browza/base/browza_mgr.rb
Instance Attribute Summary collapse
-
#driverList ⇒ Object
Returns the value of attribute driverList.
Instance Method Summary collapse
- #add(device) ⇒ Object
- #clear ⇒ Object
- #get(id) ⇒ Object
- #getBrowsers ⇒ Object
- #getDriver(id = nil) ⇒ Object
-
#initialize ⇒ BrowzaMgr
constructor
A new instance of BrowzaMgr.
- #maximize ⇒ Object
- #set(id, prop, val) ⇒ Object
-
#setDimension(width = 1035, height = 768) ⇒ Object
Set innerWidth and innerHeight.
- #setSauceStatus(id, status) ⇒ Object
Constructor Details
#initialize ⇒ BrowzaMgr
Returns a new instance of BrowzaMgr.
12 13 14 15 16 |
# File 'lib/browza/base/browza_mgr.rb', line 12 def initialize @logger = Logging.logger(STDOUT) @logger.level = :debug @driverList = [] end |
Instance Attribute Details
#driverList ⇒ Object
Returns the value of attribute driverList.
9 10 11 |
# File 'lib/browza/base/browza_mgr.rb', line 9 def driverList @driverList end |
Instance Method Details
#add(device) ⇒ Object
26 27 28 29 30 31 32 33 34 35 |
# File 'lib/browza/base/browza_mgr.rb', line 26 def add(device) if !device.is_a?(Hash) @driverList << { :is_sauce => false, :drv => device } else @driverList << device end @driverList.last end |
#clear ⇒ Object
18 19 20 |
# File 'lib/browza/base/browza_mgr.rb', line 18 def clear @driverList=[] end |
#get(id) ⇒ Object
42 43 44 45 46 47 48 49 50 |
# File 'lib/browza/base/browza_mgr.rb', line 42 def get(id) @driverList.each do |elt| if elt.has_key?(:id) && elt[:id] == id return elt end end nil end |
#getBrowsers ⇒ Object
22 23 24 |
# File 'lib/browza/base/browza_mgr.rb', line 22 def getBrowsers() @driverList end |
#getDriver(id = nil) ⇒ Object
52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/browza/base/browza_mgr.rb', line 52 def getDriver(id=nil) if id.nil? && @driverList.length > 0 return @driverList.first elsif @driverList.length > 0 @driverList.each do |b| if b.has_key?(:id) && b[:id] == id return b[:drv] end end end nil end |
#maximize ⇒ Object
92 93 94 95 96 97 98 99 100 101 102 103 104 |
# File 'lib/browza/base/browza_mgr.rb', line 92 def maximize() begin @driverList.each do |b| target_size = Selenium::WebDriver::Dimension.new(width, height) b[:drv].manage.window.maximize end rescue => ex @logger.warn __FILE__ + (__LINE__).to_s + " #{ex.class}" @logger.warn "Error during processing: #{$!}" @logger.warn "Backtrace:\n\t#{ex.backtrace.join("\n\t")}" end end |
#set(id, prop, val) ⇒ Object
37 38 39 40 |
# File 'lib/browza/base/browza_mgr.rb', line 37 def set(id, prop, val) get(id)[prop] = val end |
#setDimension(width = 1035, height = 768) ⇒ Object
Set innerWidth and innerHeight
78 79 80 81 82 83 84 85 86 87 88 89 90 |
# File 'lib/browza/base/browza_mgr.rb', line 78 def setDimension(width = 1035, height = 768) begin @driverList.each do |b| target_size = Selenium::WebDriver::Dimension.new(width, height) b[:drv].manage.window.size = target_size end rescue => ex @logger.warn __FILE__ + (__LINE__).to_s + " #{ex.class}" @logger.warn "Error during processing: #{$!}" @logger.warn "Backtrace:\n\t#{ex.backtrace.join("\n\t")}" end end |
#setSauceStatus(id, status) ⇒ Object
68 69 70 71 72 73 74 |
# File 'lib/browza/base/browza_mgr.rb', line 68 def setSauceStatus(id, status) @driverList.each do |b| if b.has_key?(:id) && b[:id]==id b[:status] = status end end end |