Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 187 lines (153 sloc) 4.229 kb
456b93a @Stuk Added watirspec_helper to all
Stuk authored
1 # encoding: utf-8
459fdd3 Using single quotes in require argument
Andreas Tolf Tolfsen authored
2 require File.expand_path('../watirspec_helper', __FILE__)
456b93a @Stuk Added watirspec_helper to all
Stuk authored
3
7e760ad Single quotes
Andreas Tolf Tolfsen authored
4 describe 'Browser' do
6d798cb @jarib Use one browser instance for all specs + move specs to top level.
jarib authored
5
7e081da Using official method url=() instead.
Andreas Tolf Tolfsen authored
6 before :all do
7 browser.url = fixture('simple.html')
8 end
9
ed591cc Added spec for #desktop?
Andreas Tolf Tolfsen authored
10 describe '#new' do
11 it 'constructs a new instance' do
12 browser.exists?.should be_true
00de15a Massive work on browser_spec
Andreas Tolf Tolfsen authored
13 end
14 end
15
16 describe '#driver' do
17 it 'returns driver object' do
07f1ace Commented out tests that wil close the browser
Andreas Tolf Tolfsen authored
18 browser.driver.should be_instance_of Java::ComOperaCoreSystems::OperaDriver
00de15a Massive work on browser_spec
Andreas Tolf Tolfsen authored
19 end
20
21 it 'can access native driver methods' do
22 browser.driver.getCurrentUrl.should_not be_empty
ed591cc Added spec for #desktop?
Andreas Tolf Tolfsen authored
23 end
24 end
7e081da Using official method url=() instead.
Andreas Tolf Tolfsen authored
25
26 describe '#name' do
27 it 'is the name of a Watir implementation' do
00de15a Massive work on browser_spec
Andreas Tolf Tolfsen authored
28 browser.name.should_not be_empty
7e081da Using official method url=() instead.
Andreas Tolf Tolfsen authored
29 end
30 end
31
07f1ace Commented out tests that wil close the browser
Andreas Tolf Tolfsen authored
32 describe '#url=' do
7e081da Using official method url=() instead.
Andreas Tolf Tolfsen authored
33 it 'opens a new window' do
00de15a Massive work on browser_spec
Andreas Tolf Tolfsen authored
34 new_window = browser.url fixture('simple.html')
1bba674 Rewrote Browser#url tests
Andreas Tolf Tolfsen authored
35 new_window.exists?.should be_true
07f1ace Commented out tests that wil close the browser
Andreas Tolf Tolfsen authored
36 # new_window.close
7e081da Using official method url=() instead.
Andreas Tolf Tolfsen authored
37 end
6d798cb @jarib Use one browser instance for all specs + move specs to top level.
jarib authored
38
7e760ad Single quotes
Andreas Tolf Tolfsen authored
39 it 'navigates to a url' do
00de15a Massive work on browser_spec
Andreas Tolf Tolfsen authored
40 window.url = fixture('simple.html')
1bba674 Rewrote Browser#url tests
Andreas Tolf Tolfsen authored
41 window.url.should == fixture('simple.html')
7e081da Using official method url=() instead.
Andreas Tolf Tolfsen authored
42 end
43
44 it 'navigates to a url using goto alias' do
1bba674 Rewrote Browser#url tests
Andreas Tolf Tolfsen authored
45 browser.goto fixture('simple.html')
00de15a Massive work on browser_spec
Andreas Tolf Tolfsen authored
46 browser.active_window.url.should == fixture('simple.html')
5222d50 @Stuk Added browser.goto
Stuk authored
47 end
48 end
49
6b837db Browser#quit! has been renamed to Browser#quit, fixing tests
Andreas Tolf Tolfsen authored
50 describe '#quit' do
cf90433 Added basic test for Browser#quit
Wilhelm Joys Andersen authored
51 it 'exists' do
52 browser.should respond_to :quit
53 end
07f1ace Commented out tests that wil close the browser
Andreas Tolf Tolfsen authored
54 =begin
00de15a Massive work on browser_spec
Andreas Tolf Tolfsen authored
55 before :each do
6b837db Browser#quit! has been renamed to Browser#quit, fixing tests
Andreas Tolf Tolfsen authored
56 browser.quit
831b95a Renaming #is_connected? to #connected?, adding alias test
Andreas Tolf Tolfsen authored
57 end
58
00de15a Massive work on browser_spec
Andreas Tolf Tolfsen authored
59 it 'quits the browser' do
60 browser.connected?.should be_false
61 end
62
63 it 'window is closed upon quit' do
64 browser.active_window.exists?.should be_false
97cb469 Adding many more Browser tests
Andreas Tolf Tolfsen authored
65 end
66
00de15a Massive work on browser_spec
Andreas Tolf Tolfsen authored
67 it 'windows are closed upon quit' do
68 browser.windows.all? do |window|
69 window.exists? == false
70 end.should be_true
71 end
97cb469 Adding many more Browser tests
Andreas Tolf Tolfsen authored
72
00de15a Massive work on browser_spec
Andreas Tolf Tolfsen authored
73 it 'is not possible to access window properties after quit' do
74 # FIXME
75 browser.active_window.url.should raise_error NativeException
76 browser.active_window.title.should raise_error NativeException
77 end
97cb469 Adding many more Browser tests
Andreas Tolf Tolfsen authored
78
00de15a Massive work on browser_spec
Andreas Tolf Tolfsen authored
79 after :all do
07f1ace Commented out tests that wil close the browser
Andreas Tolf Tolfsen authored
80 OperaWatir::Helper.reconnect
00de15a Massive work on browser_spec
Andreas Tolf Tolfsen authored
81 end
07f1ace Commented out tests that wil close the browser
Andreas Tolf Tolfsen authored
82 =end
97cb469 Adding many more Browser tests
Andreas Tolf Tolfsen authored
83 end
84
6b837db Browser#quit! has been renamed to Browser#quit, fixing tests
Andreas Tolf Tolfsen authored
85 =begin
7e760ad Single quotes
Andreas Tolf Tolfsen authored
86 describe '#windows' do
00de15a Massive work on browser_spec
Andreas Tolf Tolfsen authored
87 before :all do
07f1ace Commented out tests that wil close the browser
Andreas Tolf Tolfsen authored
88 browser = OperaWatir::Browser.new
00de15a Massive work on browser_spec
Andreas Tolf Tolfsen authored
89 end
90
7e760ad Single quotes
Andreas Tolf Tolfsen authored
91 it 'is not empty' do
7ed3cd2 @Stuk Added basics to browser
Stuk authored
92 browser.windows.should_not be_empty
93 end
94
7e760ad Single quotes
Andreas Tolf Tolfsen authored
95 it 'is a list of open windows' do
7ed3cd2 @Stuk Added basics to browser
Stuk authored
96 browser.windows.all? do |window|
28385cd Added specification for getting and setting preferences
Andreas Tolf Tolfsen authored
97 window.respond_to? :find_elements_by_id
7ed3cd2 @Stuk Added basics to browser
Stuk authored
98 end.should be_true
99 end
28385cd Added specification for getting and setting preferences
Andreas Tolf Tolfsen authored
100
97cb469 Adding many more Browser tests
Andreas Tolf Tolfsen authored
101 it 'will close all open windows' do
102 open_windows = browser.windows.length
103 browser.windows.close_all
104 browser.windows.length.should < open_windows
41a9b4e Using be_zero and be_integer, which is more RSpec-ish
Andreas Tolf Tolfsen authored
105 browser.windows.length.should_not be_zero
97cb469 Adding many more Browser tests
Andreas Tolf Tolfsen authored
106 end
107
28385cd Added specification for getting and setting preferences
Andreas Tolf Tolfsen authored
108 # TODO: Window selectors
109
7ed3cd2 @Stuk Added basics to browser
Stuk authored
110 end
6b837db Browser#quit! has been renamed to Browser#quit, fixing tests
Andreas Tolf Tolfsen authored
111 =end
7ed3cd2 @Stuk Added basics to browser
Stuk authored
112
97cb469 Adding many more Browser tests
Andreas Tolf Tolfsen authored
113 describe '#platform' do
114 it 'fetches the platform the browser is running on' do
115 # TODO: Improve regexp
116 browser.platform.should match /linux|windows|mac os x|bsd/i
117 end
118 end
119
120 describe '#path' do
121 it 'fetches the full path to the binary of the attached browser' do
122 # TODO: Improve regexp
123 browser.path.should match /(\/|\\){2,}/
124 end
125 end
126
127 describe '#ua_string' do
128 it 'fetches the UA string of the browser' do
129 browser.ua_string.should_not be_empty
7ed3cd2 @Stuk Added basics to browser
Stuk authored
130 end
131 end
132
00de15a Massive work on browser_spec
Andreas Tolf Tolfsen authored
133 describe '#connected?' do
07f1ace Commented out tests that wil close the browser
Andreas Tolf Tolfsen authored
134 it 'returns a valid type' do
135 browser.connected?.should be_kind_of (TrueClass || FalseClass)
136 end
260b3c5 Merged
Andreas Tolf Tolfsen authored
137
00de15a Massive work on browser_spec
Andreas Tolf Tolfsen authored
138 it 'is attached to a browser instance' do
139 browser.connected?.should be_true
7ed3cd2 @Stuk Added basics to browser
Stuk authored
140 end
07f1ace Commented out tests that wil close the browser
Andreas Tolf Tolfsen authored
141 =begin
00de15a Massive work on browser_spec
Andreas Tolf Tolfsen authored
142 it 'is not attached to a browser instance' do
6b837db Browser#quit! has been renamed to Browser#quit, fixing tests
Andreas Tolf Tolfsen authored
143 browser.quit
00de15a Massive work on browser_spec
Andreas Tolf Tolfsen authored
144 browser.connected?.should be_false
97cb469 Adding many more Browser tests
Andreas Tolf Tolfsen authored
145 end
07f1ace Commented out tests that wil close the browser
Andreas Tolf Tolfsen authored
146 =end
7ed3cd2 @Stuk Added basics to browser
Stuk authored
147 end
148
ed591cc Added spec for #desktop?
Andreas Tolf Tolfsen authored
149 describe '#desktop?' do
150 it 'responds with boolean' do
00de15a Massive work on browser_spec
Andreas Tolf Tolfsen authored
151 (!!browser.desktop? == browser.desktop?).should be_true
ed591cc Added spec for #desktop?
Andreas Tolf Tolfsen authored
152 end
153 end
154
7ed3cd2 @Stuk Added basics to browser
Stuk authored
155 # configuration
7e760ad Single quotes
Andreas Tolf Tolfsen authored
156 describe '#speed' do
157 it 'is one of :fast, :medium or :slow' do
7ed3cd2 @Stuk Added basics to browser
Stuk authored
158 [:fast, :medium, :slow].any? do |speed|
159 browser.speed == speed
160 end.should be_true
161 end
162 end
163
7e760ad Single quotes
Andreas Tolf Tolfsen authored
164 describe '#speed=' do
165 it 'can be set to :fast' do
7ed3cd2 @Stuk Added basics to browser
Stuk authored
166 browser.speed = :fast
167 browser.speed.should == :fast
168 end
169
7e760ad Single quotes
Andreas Tolf Tolfsen authored
170 it 'can be set to :medium' do
7ed3cd2 @Stuk Added basics to browser
Stuk authored
171 browser.speed = :medium
172 browser.speed.should == :medium
173 end
174
7e760ad Single quotes
Andreas Tolf Tolfsen authored
175 it 'can be set to :slow' do
7ed3cd2 @Stuk Added basics to browser
Stuk authored
176 browser.speed = :slow
177 browser.speed.should == :slow
178 end
179
7e760ad Single quotes
Andreas Tolf Tolfsen authored
180 it 'cannot be set to other values' do
7ed3cd2 @Stuk Added basics to browser
Stuk authored
181 browser.speed = :hoobaflooba
182 browser.speed.should_not == :hoobaflooba
183 end
184 end
185
6d798cb @jarib Use one browser instance for all specs + move specs to top level.
jarib authored
186 end
Something went wrong with that request. Please try again.