Class: BrowserContext
- Inherits:
-
Object
- Object
- BrowserContext
- Includes:
- Test::Unit::Assertions, Watir, Watir::Simple
- Defined in:
- lib/IEContext.rb
Instance Attribute Summary collapse
-
#logger ⇒ Object
readonly
Readonly access to logger.
-
#testName ⇒ Object
Returns the value of attribute testName.
Instance Method Summary collapse
-
#attach(windowTitle) ⇒ Object
Attaches to a titled browser window.
-
#browser ⇒ Object
Provides access to the browser class variable.
-
#currentUrl ⇒ Object
Returns the browser url.
-
#initialize(testName = nil, logFile = nil) ⇒ BrowserContext
constructor
Initialises a new BrowserContext object.
-
#tagsInContext ⇒ Object
The tags which are valid within the browser context.
Constructor Details
#initialize(testName = nil, logFile = nil) ⇒ BrowserContext
Initialises a new BrowserContext object. Essentially this is inherits from Watir.Simple, and uses it’s class variable ‘@@browser’.
testName: The name you want to give the test. logFile: The file you want to log to. Defaults to a log file with the same name as the script in the logs directory.
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/IEContext.rb', line 23 def initialize(testName=nil, logFile=nil) # Set the test name. @testName = testName # Put the log file in the logs directory. if logFile == nil then logFile = $0.to_s.split("/")[-1].chomp(".rb") + ".log" end logFile = "logs/" + logFile # Create the logger. @logger = Wsl::CustomLogger.new(logFile) # Output name if passed in. @logger.logTestName(testName) if testName != nil end |
Instance Attribute Details
#logger ⇒ Object (readonly)
Readonly access to logger.
12 13 14 |
# File 'lib/IEContext.rb', line 12 def logger @logger end |
#testName ⇒ Object
Returns the value of attribute testName.
11 12 13 |
# File 'lib/IEContext.rb', line 11 def testName @testName end |
Instance Method Details
#attach(windowTitle) ⇒ Object
Attaches to a titled browser window.
62 63 64 |
# File 'lib/IEContext.rb', line 62 def attach(windowTitle) @@browser = Watir::IE.attach(:title, windowTitle) end |
#browser ⇒ Object
Provides access to the browser class variable.
55 56 57 |
# File 'lib/IEContext.rb', line 55 def browser return @@browser end |
#currentUrl ⇒ Object
Returns the browser url.
44 45 46 47 48 49 50 |
# File 'lib/IEContext.rb', line 44 def currentUrl if defined? @@browser then return @@browser.url() else return "" end end |
#tagsInContext ⇒ Object
The tags which are valid within the browser context. Note: Ordering of the tags is important.
70 71 72 |
# File 'lib/IEContext.rb', line 70 def () %w[button link image div span text_field checkbox radio select_list] end |