Class: Test::Right::Widget

Inherits:
Object
  • Object
show all
Extended by:
Utils::SubclassTracking
Defined in:
lib/test/right/widget.rb

Defined Under Namespace

Modules: ClassMethods

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Utils::SubclassTracking

inherited, subclasses, wipe!

Constructor Details

#initialize(driver, name = nil) ⇒ Widget

Returns a new instance of Widget.



78
79
80
81
# File 'lib/test/right/widget.rb', line 78

def initialize(driver, name=nil)
  @driver = driver
  @name = name
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *args) ⇒ Object



106
107
108
# File 'lib/test/right/widget.rb', line 106

def method_missing(name, *args)
  raise WidgetActionNotImplemented, "#{self.class.to_s}##{name.to_s} not implemented"
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



76
77
78
# File 'lib/test/right/widget.rb', line 76

def name
  @name
end

Class Method Details

.inherited(subclass) ⇒ Object



65
66
67
68
69
70
71
72
73
74
# File 'lib/test/right/widget.rb', line 65

def self.inherited(subclass)
  @subclasses ||= [] 
  @subclasses << subclass 
  subclass.instance_eval do
    @selectors = {}
    @location = nil
  end

  subclass.extend(ClassMethods)
end

Instance Method Details

#exists?Boolean

Returns:

  • (Boolean)


87
88
89
90
91
92
93
94
# File 'lib/test/right/widget.rb', line 87

def exists?
  begin
    root
    return true
  rescue WidgetNotPresentError
    return false
  end
end

#validate!(timeout = 15) ⇒ Object



96
97
98
99
100
101
102
103
104
# File 'lib/test/right/widget.rb', line 96

def validate!(timeout=15)
  timeout = Time.now + timeout
  while Time.now < timeout
    if self.exists?
      return
    end
  end
  raise WidgetNotPresentError
end

#visitObject



83
84
85
# File 'lib/test/right/widget.rb', line 83

def visit
  @driver.get(self.class.location, :relative => true)
end