Module: Watirloo::Browsers
- Defined in:
- lib/watirloo/browsers.rb
Overview
manage references to browsers. Currently IE or Firefox. Safari? Other Browser? not yet
Constant Summary collapse
- @@target =
by default we talk to IE on Windows.
:ie
- @@targets =
[:ie, :firefox]
Class Method Summary collapse
- .ff ⇒ Object
-
.ie(key = 'default') ⇒ Object
provides browser instance to client.
-
.target ⇒ Object
set and get the target.
- .target=(indicator) ⇒ Object
Class Method Details
.ff ⇒ Object
60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/watirloo/browsers.rb', line 60 def ff require 'watirloo/firewatir_ducktape' # this is a cruch for quick work with pages. # in reality you want to create a browser and pass it as argument to initialize Page class begin FireWatir::Firefox.attach #this attach is a crutch rescue puts 'got to start browser ff dude' end end |
.ie(key = 'default') ⇒ Object
provides browser instance to client. attaches to the existing ‘default’ test session browser on the desktop By convention the mental model here is that we are working with one browser on the desktop. This is how a person would typically work
48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/watirloo/browsers.rb', line 48 def ie(key='default') begin Locker.browser key rescue #XXX it's probably a bad practice to use exception for logic control # TODO logger here ie = Watir::IE.start sleep 3 Locker.add(ie, key) ie #return newly created browser for the test session and store it for laterusage end end |
.target ⇒ Object
set and get the target. by default we talk to :ie.
31 32 33 |
# File 'lib/watirloo/browsers.rb', line 31 def target return @@target end |
.target=(indicator) ⇒ Object
35 36 37 38 39 40 41 |
# File 'lib/watirloo/browsers.rb', line 35 def target=(indicator) if @@targets.include? indicator @@target = indicator else raise Exception, "target indicator #{indicator} is not valid: use :ie or :firefox" end end |