Class: Crabfarm::Dsl::Surfer::SurfContext
Constant Summary
Crabfarm::Dsl::Surfer::SearchContext::TIMEOUT
Instance Attribute Summary
#parent
Instance Method Summary
collapse
#[], #classes, #each, #element!, #fill, #first, #last, #method_missing, #respond_to?, #search
Constructor Details
#initialize(_bucket) ⇒ SurfContext
Returns a new instance of SurfContext.
9
10
11
12
|
# File 'lib/crabfarm/dsl/surfer/surf_context.rb', line 9
def initialize(_bucket)
super nil, self
@bucket = _bucket
end
|
Instance Method Details
#cookies ⇒ Object
38
39
40
|
# File 'lib/crabfarm/dsl/surfer/surf_context.rb', line 38
def cookies
driver.manage.all_cookies
end
|
#current_uri ⇒ Object
34
35
36
|
# File 'lib/crabfarm/dsl/surfer/surf_context.rb', line 34
def current_uri
URI.parse driver.current_url
end
|
#driver ⇒ Object
26
27
28
|
# File 'lib/crabfarm/dsl/surfer/surf_context.rb', line 26
def driver
@bucket.original
end
|
#elements ⇒ Object
18
19
20
|
# File 'lib/crabfarm/dsl/surfer/surf_context.rb', line 18
def elements
[driver]
end
|
#goto(_url, _params = nil) ⇒ Object
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
# File 'lib/crabfarm/dsl/surfer/surf_context.rb', line 42
def goto(_url, _params=nil)
_url += "?#{_params.to_query}" if _params
retries = 0
loop do
begin
@bucket.reset if retries > 0
driver.get(_url)
break
rescue Timeout::Error raise if retries >= max_retries
retries += 1
sleep 1.0
end
end
end
|
#quit ⇒ Object
30
31
32
|
# File 'lib/crabfarm/dsl/surfer/surf_context.rb', line 30
def quit
@bucket.reset
end
|
#root ⇒ Object
14
15
16
|
# File 'lib/crabfarm/dsl/surfer/surf_context.rb', line 14
def root
self
end
|
#to_html ⇒ Object
22
23
24
|
# File 'lib/crabfarm/dsl/surfer/surf_context.rb', line 22
def to_html
driver.page_source
end
|