Class: SK::Page

Inherits:
Object
  • Object
show all
Defined in:
lib/page.rb

Overview

TODO: move some of the browser methods to page

Instance Method Summary collapse

Constructor Details

#initialize(base, page) ⇒ Page

Returns a new instance of Page.



5
6
7
# File 'lib/page.rb', line 5

def initialize(base,page)
  @url = "#{base}/#{page}"
end

Instance Method Details

#goto(opts = {}) ⇒ Object

def goto

SK::Browser.gotox(url)

end



17
18
19
20
21
22
23
# File 'lib/page.rb', line 17

def goto(opts={})
  query = opts.map { |k,v| k.to_s+"="+v.to_s }.join("&")
  url = @url 
  url += "?" + query unless query == ""
  trace("goto: url=#{url}")
  SK::Browser.gotox(url)
end

#has_content?(content) ⇒ Boolean

Returns:

  • (Boolean)


42
43
44
45
46
# File 'lib/page.rb', line 42

def has_content?(content)
  result = SK::Browser.source.include? content
  # trace "missing content = #{content}" unless result
  return result
end

#here?(text) ⇒ Boolean

Returns:

  • (Boolean)


48
49
50
51
52
# File 'lib/page.rb', line 48

def here?(text)
  return false unless urls_match?
  # urls do match, but also require that
  has_content? text
end

#present?Boolean

Returns:

  • (Boolean)


26
27
28
# File 'lib/page.rb', line 26

def present?
  urls_match?
end

#sourceObject



54
55
56
# File 'lib/page.rb', line 54

def source
  SK::Browser.source
end

#titleObject



58
59
60
# File 'lib/page.rb', line 58

def title
  SK::Browser.title
end

#urlObject



9
10
11
# File 'lib/page.rb', line 9

def url
  @url
end

#urls_match?Boolean

Returns:

  • (Boolean)


30
31
32
33
34
35
36
37
38
39
40
# File 'lib/page.rb', line 30

def urls_match?
  # change to the looser include instead of equal
  return true if SK::Browser.url.include? self.url

  # return true if SK::Browser.url == self.url # old code

  # because we almost always need to see some clues when the expected page is 
  # not present we trace some outpout the the tester
  trace "SK::Page url_match? expected: #{url} did not match current: #{SK::Browser.url}"
  false # returned    
end