Class: Crabfarm::Dsl::Surfer::SurfContext

Inherits:
SearchContext show all
Defined in:
lib/crabfarm/dsl/surfer/surf_context.rb

Constant Summary

Constants inherited from SearchContext

Crabfarm::Dsl::Surfer::SearchContext::TIMEOUT

Instance Attribute Summary collapse

Attributes inherited from SearchContext

#parent

Instance Method Summary collapse

Methods inherited from SearchContext

#[], #classes, #each, #element!, #fill, #first, #last, #method_missing, #respond_to?, #search, #webdriver_elements

Constructor Details

#initialize(_driver) ⇒ SurfContext

Returns a new instance of SurfContext.



10
11
12
13
# File 'lib/crabfarm/dsl/surfer/surf_context.rb', line 10

def initialize(_driver)
  super nil, self
  @driver = _driver
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Crabfarm::Dsl::Surfer::SearchContext

Instance Attribute Details

#driverObject (readonly)

Returns the value of attribute driver.



6
7
8
# File 'lib/crabfarm/dsl/surfer/surf_context.rb', line 6

def driver
  @driver
end

Instance Method Details

#cookiesObject



31
32
33
# File 'lib/crabfarm/dsl/surfer/surf_context.rb', line 31

def cookies
  driver.manage.all_cookies
end

#current_uriObject



27
28
29
# File 'lib/crabfarm/dsl/surfer/surf_context.rb', line 27

def current_uri
  URI.parse driver.current_url
end

#elementsObject



19
20
21
# File 'lib/crabfarm/dsl/surfer/surf_context.rb', line 19

def elements
  [driver]
end

#goto(_url, _params = nil) ⇒ Object



35
36
37
38
# File 'lib/crabfarm/dsl/surfer/surf_context.rb', line 35

def goto(_url, _params=nil)
  _url += "?#{_params.to_query}" if _params
  driver.get(_url)
end

#rootObject



15
16
17
# File 'lib/crabfarm/dsl/surfer/surf_context.rb', line 15

def root
  self
end

#to_htmlObject



23
24
25
# File 'lib/crabfarm/dsl/surfer/surf_context.rb', line 23

def to_html
  driver.page_source
end