Class: Polonium::Page
Constant Summary
collapse
- PAGE_LOADED_COMMAND =
<<-JS
(function(selenium) {
BrowserBot.prototype.bodyText = function() {
if (!this.getDocument().body) {
return "";
}
return getText(this.getDocument().body);
};
selenium.browserbot.bodyText = BrowserBot.prototype.bodyText;
return selenium.browserbot.getDocument().body ? true : false;
})(this);
JS
Instance Attribute Summary collapse
Attributes included from WaitFor
#default_timeout
Instance Method Summary
collapse
Methods included from WaitFor
#default_wait_for_time, #flunk, #time_class, #wait_for
#values_match?
Constructor Details
#initialize(driver) ⇒ Page
Returns a new instance of Page.
18
19
20
|
# File 'lib/polonium/page.rb', line 18
def initialize(driver)
@driver = driver
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_name, *args, &blk) ⇒ Object
89
90
91
92
93
94
95
|
# File 'lib/polonium/page.rb', line 89
def method_missing(method_name, *args, &blk)
if driver.respond_to?(method_name)
driver.__send__(method_name, *args, &blk)
else
super
end
end
|
Instance Attribute Details
#driver ⇒ Object
Returns the value of attribute driver.
4
5
6
|
# File 'lib/polonium/page.rb', line 4
def driver
@driver
end
|
Instance Method Details
#==(other) ⇒ Object
84
85
86
87
|
# File 'lib/polonium/page.rb', line 84
def ==(other)
return false unless other.is_a?(Page)
self.driver == other.driver
end
|
#assert_location_ends_with(ends_with, options = {}) ⇒ Object
76
77
78
|
# File 'lib/polonium/page.rb', line 76
def assert_location_ends_with(ends_with, options={})
driver.assert_location_ends_with(ends_with, options)
end
|
#assert_text_not_present(unexpected_text, options = {}) ⇒ Object
55
56
57
58
59
60
61
62
|
# File 'lib/polonium/page.rb', line 55
def assert_text_not_present(unexpected_text, options = {})
options = {
:message => "Expected '#{unexpected_text}' to be absent, but it wasn't"
}.merge(options)
wait_for(options) do
is_text_not_present? unexpected_text
end
end
|
#assert_text_present(expected_text, options = {}) ⇒ Object
38
39
40
41
42
43
44
45
|
# File 'lib/polonium/page.rb', line 38
def assert_text_present(expected_text, options = {})
options = {
:message => "Expected '#{expected_text}' to be present, but it wasn't"
}.merge(options)
wait_for(options) do
is_text_present? expected_text
end
end
|
#assert_title(expected_title, params = {}) ⇒ Object
27
28
29
30
31
32
33
|
# File 'lib/polonium/page.rb', line 27
def assert_title(expected_title, params = {})
wait_for(params) do |configuration|
actual_title = title
configuration.message = "Expected title '#{expected_title}' but was '#{actual_title}'"
values_match?(actual_title, expected_title)
end
end
|
#is_text_not_present?(unexpected_text) ⇒ Boolean
63
64
65
66
67
68
69
70
|
# File 'lib/polonium/page.rb', line 63
def is_text_not_present?(unexpected_text)
if unexpected_text.is_a?(Regexp)
text_finder = "regexp:#{unexpected_text.source}"
else
text_finder = unexpected_text
end
page_loaded? && !driver.is_text_present(text_finder)
end
|
#is_text_present?(expected_text) ⇒ Boolean
46
47
48
49
50
51
52
53
|
# File 'lib/polonium/page.rb', line 46
def is_text_present?(expected_text)
if expected_text.is_a?(Regexp)
text_finder = "regexp:#{expected_text.source}"
else
text_finder = expected_text
end
page_loaded? && driver.is_text_present(text_finder)
end
|
#location_ends_with?(ends_with) ⇒ Boolean
80
81
82
|
# File 'lib/polonium/page.rb', line 80
def location_ends_with?(ends_with)
driver.location_ends_with?(ends_with)
end
|
#open(url) ⇒ Object
Also known as:
open_and_wait
22
23
24
|
# File 'lib/polonium/page.rb', line 22
def open(url)
driver.open(url)
end
|
#page_loaded? ⇒ Boolean
72
73
74
|
# File 'lib/polonium/page.rb', line 72
def page_loaded?
driver.get_eval(PAGE_LOADED_COMMAND) == true.to_s
end
|
#title ⇒ Object
34
35
36
|
# File 'lib/polonium/page.rb', line 34
def title
driver.get_title
end
|