Class: AutomationObject::Driver::NokogiriAdapter::Window
- Inherits:
-
Object
- Object
- AutomationObject::Driver::NokogiriAdapter::Window
- Defined in:
- lib/automation_object/driver/nokogiri_adapter/window.rb
Overview
Window class
Instance Attribute Summary collapse
-
#handle ⇒ Object
Returns the value of attribute handle.
-
#xml ⇒ Object
Returns the value of attribute xml.
Instance Method Summary collapse
- #back ⇒ void
- #current_url ⇒ String
- #forward ⇒ void
-
#initialize ⇒ Window
constructor
A new instance of Window.
- #refresh ⇒ void
-
#request(type, url, params = {}) ⇒ Object
Get url, will set xml to current window handle.
Constructor Details
#initialize ⇒ Window
Returns a new instance of Window
16 17 18 19 20 21 22 |
# File 'lib/automation_object/driver/nokogiri_adapter/window.rb', line 16 def initialize self.handle = SecureRandom.hex(16) # Use to control history @position = 0 @history = [] end |
Instance Attribute Details
#handle ⇒ Object
Returns the value of attribute handle
14 15 16 |
# File 'lib/automation_object/driver/nokogiri_adapter/window.rb', line 14 def handle @handle end |
#xml ⇒ Object
Returns the value of attribute xml
14 15 16 |
# File 'lib/automation_object/driver/nokogiri_adapter/window.rb', line 14 def xml @xml end |
Instance Method Details
#back ⇒ void
This method returns an undefined value.
41 42 43 44 45 46 |
# File 'lib/automation_object/driver/nokogiri_adapter/window.rb', line 41 def back raise UnableToNavigateBackward if @position.zero? @position -= 1 make_request(@history.at(@position)) end |
#current_url ⇒ String
35 36 37 38 |
# File 'lib/automation_object/driver/nokogiri_adapter/window.rb', line 35 def current_url request = @history.at(@position) !request.nil? ? request.url : nil end |
#forward ⇒ void
This method returns an undefined value.
49 50 51 52 53 54 |
# File 'lib/automation_object/driver/nokogiri_adapter/window.rb', line 49 def forward raise UnableToNavigateForward if @position >= @history.length - 2 @position += 1 make_request(@history.at(@position)) end |
#refresh ⇒ void
This method returns an undefined value.
57 58 59 |
# File 'lib/automation_object/driver/nokogiri_adapter/window.rb', line 57 def refresh make_request(@history.at(@position)) end |
#request(type, url, params = {}) ⇒ Object
Get url, will set xml to current window handle
27 28 29 30 31 32 |
# File 'lib/automation_object/driver/nokogiri_adapter/window.rb', line 27 def request(type, url, params = {}) request = Request.new(type, url, params) make_request(request) update_history(request) end |