Class: SK::Page
- Inherits:
-
Object
- Object
- SK::Page
- Defined in:
- lib/page.rb
Overview
TODO: move some of the browser methods to page
Instance Method Summary collapse
-
#goto(opts = {}) ⇒ Object
def goto SK::Browser.gotox(url) end.
- #has_content?(content) ⇒ Boolean
- #here?(text) ⇒ Boolean
-
#initialize(base, page) ⇒ Page
constructor
A new instance of Page.
- #present? ⇒ Boolean
- #source ⇒ Object
- #title ⇒ Object
- #url ⇒ Object
- #urls_match? ⇒ Boolean
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
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
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
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
26 27 28 |
# File 'lib/page.rb', line 26 def present? urls_match? end |
#url ⇒ Object
9 10 11 |
# File 'lib/page.rb', line 9 def url @url end |
#urls_match? ⇒ 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 |