Module: Parfait
- Defined in:
- lib/parfait.rb,
lib/parfait/page.rb,
lib/parfait/region.rb,
lib/parfait/control.rb,
lib/parfait/artifact.rb,
lib/parfait/application.rb
Overview
- cat
-
something
something else
-
Top level comment about Parfait
Defined Under Namespace
Classes: Application, Control, Page, ParfaitArtifact, Region
Constant Summary collapse
- PAGES =
Global hash containing each Parfait::Page object indexed by page name (and alias)
Hash.new
Class Method Summary collapse
-
.browser ⇒ Object
Get the current browser object (for the current thread) from Parfait.
-
.filter_browser(object) ⇒ Object
Store a Watir object as a filtered browser to be used by controls called within a Region.
-
.log(string, opts = {}) ⇒ Object
Write to the Parfait log.
-
.set_browser(browser) ⇒ Object
Set the browser object (for the current thread) for Parfait to use.
-
.set_logroutine(&block) ⇒ Object
Configure the logging routine to be used by Parfait for this thread.
Class Method Details
.browser ⇒ Object
Get the current browser object (for the current thread) from Parfait
Note that inside regions, this may be a Selenium object and not the selenium browser pointer (i.e. a subset of the page instead of the whole page)
Options
none
Example
Parfait::browser
85 86 87 |
# File 'lib/parfait.rb', line 85 def Parfait.browser() Thread.current[:parfait_region] end |
.filter_browser(object) ⇒ Object
Store a Watir object as a filtered browser to be used by controls called within a Region
Options
none
Example
user_region = Parfait::Region.new(:name => "User")
user_region.add_filter { |username|
user_list = Parfait::browser.div(:id => "users")
users = user_list.lis
users.each do |li|
if li.text == username
Parfait::filter_browser li
break
end
end
}
110 111 112 |
# File 'lib/parfait.rb', line 110 def Parfait.filter_browser(object)() Thread.current[:parfait_region] = object end |
.log(string, opts = {}) ⇒ Object
Write to the Parfait log
The log can be predefined by Parfait.set_logroutine
Options
string-
specifies the string to write to the Parfait log
opts-
specifies a hash containing parameters to the Parfait logging function
Example
Parfait.log("Everything is fine - no bugs here.",:style => fatal_error)
50 51 52 |
# File 'lib/parfait.rb', line 50 def Parfait.log(string,opts = {}) return Thread.current[:parfait_logroutine].call(string,opts) end |
.set_browser(browser) ⇒ Object
Set the browser object (for the current thread) for Parfait to use
Options
browser-
specifies the browser to store
Example
Parfait::set_browser(browser)
65 66 67 68 |
# File 'lib/parfait.rb', line 65 def Parfait.set_browser(browser) Thread.current[:parfait_browser] = browser Thread.current[:parfait_region] = browser end |
.set_logroutine(&block) ⇒ Object
Configure the logging routine to be used by Parfait for this thread.
The routine you store here can be invoked by Parfait.log
Options
- &block
-
specifies the code block to be called whenever Parfait needs to invoke a logger. This block should take a string followed by an optional hash as its parameters.
Example
Parfait.set_logroutine { |string,opts|
MyLogger::write(string,opts)
}
33 34 35 |
# File 'lib/parfait.rb', line 33 def Parfait.set_logroutine(&block) Thread.current[:parfait_logroutine] = block end |