Module: TerminusSpec
- Defined in:
- lib/terminus_spec.rb,
lib/terminus_spec/logger.rb,
lib/terminus_spec/factory.rb,
lib/terminus_spec/version.rb,
lib/terminus_spec/locators.rb,
lib/terminus_spec/matchers.rb,
lib/terminus_spec/platforms.rb,
lib/terminus_spec/generators.rb,
lib/terminus_spec/platform_watir.rb,
lib/terminus_spec/web_objects/all.rb,
lib/terminus_spec/web_objects/link.rb,
lib/terminus_spec/platform_selenium.rb,
lib/terminus_spec/web_objects/button.rb,
lib/terminus_spec/web_objects/text_field.rb,
lib/terminus_spec/platform_watir/platform_object.rb,
lib/terminus_spec/platform_watir/web_objects/all.rb,
lib/terminus_spec/platform_selenium/platform_object.rb,
lib/terminus_spec/platform_selenium/web_objects/all.rb,
lib/terminus_spec/platform_selenium/web_objects/link.rb,
lib/terminus_spec/platform_selenium/web_objects/button.rb,
lib/terminus_spec/platform_watir/web_objects/text_field.rb,
lib/terminus_spec/platform_selenium/web_objects/text_field.rb
Defined Under Namespace
Modules: Factory, Generators, Locators, Matchers, Platforms, WebObjects
Constant Summary collapse
- VERSION =
"0.5.0"
Instance Attribute Summary collapse
- #browser ⇒ Watir::Browser, Selenium::WebDriver::Driver readonly
- #platform ⇒ TerminusSpec::Platforms::WatirWebDriver::PlatformObject, TerminusSpec::Platforms::SeleniumWebDriver::PlatformObject readonly
Class Method Summary collapse
-
.included(caller) ⇒ Object
This makes sure that any page classes that include TerminusSpec will be given access to the generator methods based on web objects that are declared in the page class.
- .trace(message, level = 2) ⇒ Object
Instance Method Summary collapse
-
#attach_to_window(identifier, &block) ⇒ Object
Attaches to a displayed window.
-
#back ⇒ Object
Goes back to the preceding page in history.
-
#clear_cookies ⇒ Object
Clears the cookies from the browser.
-
#current_url ⇒ Object
Returns the current page URL.
-
#forward ⇒ Object
Goes forward to the succeeding page in history.
-
#html ⇒ Object
Returns the html of the current page.
-
#initialize(browser, visit = nil) ⇒ Object
Creates a platform object.
-
#navigate_to(url) ⇒ Object
Navigate to the specified URL.
-
#refresh ⇒ Object
Refreshes the current page.
-
#save_screenshot(file_name) ⇒ Object
Saves the current screenshot to a provided URL.
-
#text ⇒ Object
Returns the text of the current page.
-
#title ⇒ Object
Returns the title of the current page as displayed in the browser.
-
#wait_until(timeout = 15, message = nil, &block) ⇒ Object
Waits until a condition is found to be true or a timeout occurs.
-
#will_alert(&block) ⇒ String
Captures the execution of an alert popup.
-
#will_be_modal(&block) ⇒ Object
Captures the execution of a model dialog opens that dialog as a window.
-
#will_confirm(response, &block) ⇒ String
Captures the execution of a confirmation popup.
-
#will_prompt(response, &block) ⇒ Hash
Captures the execution of a prompt popup.
Methods included from Locators
#button_web_object, #link_web_object, #text_field_web_object
Methods included from Platforms
associate, list, #platform_for
Instance Attribute Details
#browser ⇒ Watir::Browser, Selenium::WebDriver::Driver (readonly)
15 16 17 |
# File 'lib/terminus_spec.rb', line 15 def browser @browser end |
#platform ⇒ TerminusSpec::Platforms::WatirWebDriver::PlatformObject, TerminusSpec::Platforms::SeleniumWebDriver::PlatformObject (readonly)
19 20 21 |
# File 'lib/terminus_spec.rb', line 19 def platform @platform end |
Class Method Details
.included(caller) ⇒ Object
This makes sure that any page classes that include TerminusSpec will be given access to the generator methods based on web objects that are declared in the page class.
24 25 26 |
# File 'lib/terminus_spec.rb', line 24 def self.included(caller) caller.extend TerminusSpec::Generators end |
.trace(message, level = 2) ⇒ Object
3 4 5 |
# File 'lib/terminus_spec/logger.rb', line 3 def self.trace(, level=2) puts("*" * level + " #{}") if ENV['TRACE'] == 'on' end |
Instance Method Details
#attach_to_window(identifier, &block) ⇒ Object
Attaches to a displayed window. The window can be located using either the title attribute of the window or a direct URL. The URL does not have to be the entire URL; it can just be a page name (like index.html). Since attaching to a window can be problematic due to race conditions, a second try will be attempted if any exceptions occur.
window that is being attached to
159 160 161 162 163 164 165 166 |
# File 'lib/terminus_spec.rb', line 159 def attach_to_window(identifier, &block) begin @platform.attach_to_window(identifier, &block) rescue sleep 2 @platform.attach_to_window(identifier, &block) end end |
#back ⇒ Object
Goes back to the preceding page in history.
70 71 72 |
# File 'lib/terminus_spec.rb', line 70 def back @platform.back end |
#clear_cookies ⇒ Object
Clears the cookies from the browser.
80 81 82 |
# File 'lib/terminus_spec.rb', line 80 def @platform. end |
#current_url ⇒ Object
Returns the current page URL.
60 61 62 |
# File 'lib/terminus_spec.rb', line 60 def current_url @platform.current_url end |
#forward ⇒ Object
Goes forward to the succeeding page in history.
75 76 77 |
# File 'lib/terminus_spec.rb', line 75 def forward @platform.forward end |
#html ⇒ Object
Returns the html of the current page
55 56 57 |
# File 'lib/terminus_spec.rb', line 55 def html @platform.html end |
#initialize(browser, visit = nil) ⇒ Object
Creates a platform object.
30 31 32 33 34 35 |
# File 'lib/terminus_spec.rb', line 30 def initialize(browser, visit=nil) @browser = browser establish_platform_driver_for browser setup_page if respond_to?(:setup_page) goto if visit && respond_to?(:goto) end |
#navigate_to(url) ⇒ Object
Navigate to the specified URL. The URL can be specified as a domain address or as a file-based link.
40 41 42 |
# File 'lib/terminus_spec.rb', line 40 def navigate_to(url) @platform.navigate_to url end |
#refresh ⇒ Object
Refreshes the current page.
65 66 67 |
# File 'lib/terminus_spec.rb', line 65 def refresh @platform.refresh end |
#save_screenshot(file_name) ⇒ Object
Saves the current screenshot to a provided URL. The file will be saved as a PNG file.
86 87 88 |
# File 'lib/terminus_spec.rb', line 86 def save_screenshot(file_name) @platform.save_screenshot file_name end |
#text ⇒ Object
Returns the text of the current page.
45 46 47 |
# File 'lib/terminus_spec.rb', line 45 def text @platform.text end |
#title ⇒ Object
Returns the title of the current page as displayed in the browser.
50 51 52 |
# File 'lib/terminus_spec.rb', line 50 def title @platform.title end |
#wait_until(timeout = 15, message = nil, &block) ⇒ Object
Waits until a condition is found to be true or a timeout occurs.
100 101 102 |
# File 'lib/terminus_spec.rb', line 100 def wait_until(timeout=15, =nil, &block) @platform.wait_until(timeout, , &block) end |
#will_alert(&block) ⇒ String
Captures the execution of an alert popup.
113 114 115 |
# File 'lib/terminus_spec.rb', line 113 def will_alert(&block) @platform.will_alert(&block) end |
#will_be_modal(&block) ⇒ Object
Captures the execution of a model dialog opens that dialog as a window. The new window can then be attached to.
177 178 179 180 181 182 183 184 185 186 187 188 |
# File 'lib/terminus_spec.rb', line 177 def will_be_modal(&block) script = %Q{ window.showModalDialog = function(sURL, vArguments, sFeatures) { window.dialogArguments = vArguments; modalWin = window.open(sURL, 'modal', sFeatures); return modalWin; } } browser.execute_script script yield if block_given? end |
#will_confirm(response, &block) ⇒ String
Captures the execution of a confirmation popup.
127 128 129 |
# File 'lib/terminus_spec.rb', line 127 def will_confirm(response, &block) @platform.will_confirm(response, &block) end |
#will_prompt(response, &block) ⇒ Hash
Captures the execution of a prompt popup.
:default_value contains the default value for the prompt if provided
142 143 144 |
# File 'lib/terminus_spec.rb', line 142 def will_prompt(response, &block) @platform.will_prompt(response, &block) end |