commonwatir 1.9.2 → 2.0.0.rc2

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGES CHANGED
@@ -1,3 +1,30 @@
1
+ == Version 2.0.0 - 2011/07/XX
2
+
3
+ * RIP FireWatir - there won't be any new releases
4
+ * all elements are using 0-based indexing instead of old 1-based indexing:
5
+ - disable it temporarily: require "watir"; Watir.options[:zero_based_indexing] = false
6
+ * #radio and #checkbox methods doesn't allow 3 parameters anymore for locating with "value"
7
+ - use browser.radio(:name => "something", :value => "some value") syntax instead for locating with "value"
8
+ * all element methods accept now multiple-specifiers with hash syntax, for example:
9
+ - browser.element(:class => "someclass", :name => "somename")
10
+ * all elements are searchable by :xpath and :css now (note that it's usually slower than searching by other specifiers)
11
+ * #button, #form and #frame doesn't accept single string as a specifier anymore to search by name:
12
+ - use browser.frame(:name => "name") or browser.frame(:name, "name") syntax instead
13
+ * :index => 0 is used as a default specifier if nothing is specified:
14
+ - browser.div(:id => "id").table.tr is same as browser.div(:id => "id").table(:index => 0).tr(:index => 0)
15
+ * all collection methods accept now specifiers too:
16
+ - browser.divs(:class => "someclass").each {|div| puts div.class_name} # => "someclass"
17
+ * removed FormElement class
18
+ * renamed CheckBox class to Checkbox
19
+ * renamed CheckBoxes class to Checkboxes
20
+ * added aliases:
21
+ - tr => row
22
+ - trs => rows
23
+ - td => cell
24
+ - tds => cells
25
+ - a => link
26
+ - as => links
27
+
1
28
  == Version 1.9.2 - 2011/07/11
2
29
 
3
30
  === IE improvements
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.9.2
1
+ 2.0.0.rc2
@@ -84,6 +84,10 @@ before you invoke Browser.new.
84
84
  klass.options
85
85
  end
86
86
 
87
+ def base_index
88
+ options[:zero_based_indexing] ? 0 : 1
89
+ end
90
+
87
91
  def klass
88
92
  key = Watir.options[:browser]
89
93
  eval @@browser_classes[key] # this triggers the autoload
@@ -4,7 +4,7 @@
4
4
 
5
5
  Watir::Browser.support :name => 'ie', :class => 'Watir::IE',
6
6
  :library => 'watir/ie', :gem => 'watir',
7
- :options => [:speed, :visible]
7
+ :options => [:speed, :visible, :zero_based_indexing]
8
8
 
9
9
  Watir::Browser.support :name => 'firefox', :class => 'FireWatir::Firefox',
10
10
  :library => 'firewatir'
@@ -44,6 +44,9 @@ module Watir
44
44
  :default => 'fast'
45
45
  builder.add_choice :visible,
46
46
  :type => :boolean
47
+ builder.add_choice :zero_based_indexing,
48
+ :type => :boolean,
49
+ :default => true
47
50
  end
48
51
  def execute
49
52
  @user_choices[:speed] = @user_choices[:speed].to_sym
@@ -18,10 +18,6 @@ class TC_Button < Test::Unit::TestCase
18
18
  assert_raises(UnknownObjectException) { browser.button(:name, "noName").value }
19
19
  end
20
20
 
21
- def test_exception_when_one_argument
22
- assert_raises(UnknownObjectException) { browser.button( "Missing Caption").click }
23
- end
24
-
25
21
  def test_exceptions_with_click
26
22
  assert_raises(UnknownObjectException) { browser.button(:caption, "Missing Caption").click }
27
23
  assert_raises(UnknownObjectException) { browser.button(:id, "missingID").click }
@@ -35,6 +31,7 @@ class TC_Button < Test::Unit::TestCase
35
31
  assert_raises(UnknownObjectException) { browser.button(:name, "noName").enabled? }
36
32
  end
37
33
 
34
+ tag_method :test_properties, :fails_on_ie
38
35
  def test_properties
39
36
  assert_equal("b1", browser.button(:index, 1).name)
40
37
  assert_equal("b2", browser.button(:index, 1).id)
@@ -57,10 +54,29 @@ class TC_Button < Test::Unit::TestCase
57
54
  assert_equal("", browser.button(:index, 2).title)
58
55
  assert_equal("this is button1", browser.button(:index, 1).title)
59
56
  end
60
-
61
- def test_default_how
62
- browser.button("Click Me").click
63
- assert(browser.text.include?("PASS"))
57
+
58
+ tag_method :test_properties_ie, :fails_on_firefox
59
+ def test_properties_ie
60
+ assert_equal("b1", browser.button(:index, 0).name)
61
+ assert_equal("b2", browser.button(:index, 0).id)
62
+ assert_equal("button", browser.button(:index, 0).type)
63
+ assert_equal("Click Me", browser.button(:index, 0).value)
64
+ assert_equal(false, browser.button(:index, 0).disabled)
65
+ assert_equal("italic_button", browser.button(:name, "b1").class_name)
66
+ assert_equal("", browser.button(:name , "b4").class_name)
67
+
68
+ assert_equal("b1", browser.button(:id, "b2").name)
69
+ assert_equal("b2", browser.button(:id, "b2").id)
70
+ assert_equal("button", browser.button(:id, "b2").type)
71
+
72
+ assert_equal("b4", browser.button(:index, 1).name)
73
+ assert_equal("b5", browser.button(:index, 1).id)
74
+ assert_equal("button", browser.button(:index, 1).type)
75
+ assert_equal("Disabled Button", browser.button(:index, 1).value)
76
+ assert_equal(true, browser.button(:index, 1).disabled)
77
+
78
+ assert_equal("", browser.button(:index, 1).title)
79
+ assert_equal("this is button1", browser.button(:index, 0).title)
64
80
  end
65
81
 
66
82
  def test_click_and_caption
@@ -135,12 +151,12 @@ class TC_Button2 < Test::Unit::TestCase
135
151
  assert(browser.text.include?("PASS"))
136
152
  end
137
153
 
138
- tag_method :test_buttons_length, :fails_on_ie
139
154
  def test_buttons_length
140
155
  arrButtons = browser.buttons
141
156
  assert_equal(7, arrButtons.length)
142
157
  end
143
158
 
159
+ tag_method :test_buttons, :fails_on_ie
144
160
  def test_buttons
145
161
  arrButtons = browser.buttons
146
162
  assert_equal("b2", arrButtons[1].id)
@@ -152,7 +168,19 @@ class TC_Button2 < Test::Unit::TestCase
152
168
  assert_equal("Sign In", arrButtons[7].value)
153
169
  end
154
170
 
155
- # Tests collection class
171
+ tag_method :test_buttons_ie, :fails_on_firefox
172
+ def test_buttons_ie
173
+ arrButtons = browser.buttons
174
+ assert_equal("b2", arrButtons[0].id)
175
+ assert_equal("b5", arrButtons[1].id)
176
+ assert_equal("Submit", arrButtons[2].value)
177
+ assert_equal("sub3", arrButtons[3].name)
178
+ assert_equal("b7", arrButtons[4].id)
179
+ assert_equal("b9", arrButtons[5].id)
180
+ assert_equal("Sign In", arrButtons[6].value)
181
+ end
182
+
183
+ tag_method :test_class_buttons, :fails_on_ie
156
184
  def test_class_buttons
157
185
  arr_buttons = browser.buttons
158
186
  arr_buttons.each do |b|
@@ -182,15 +210,52 @@ class TC_Button2 < Test::Unit::TestCase
182
210
  assert_equal("Sign In", arr_buttons[7].value)
183
211
  end
184
212
 
213
+ tag_method :test_class_buttons_ie, :fails_on_firefox
214
+ def test_class_buttons_ie
215
+ arr_buttons = browser.buttons
216
+ arr_buttons.each do |b|
217
+ assert_class b, 'Button'
218
+ end
219
+ # test properties
220
+ assert_equal("b2", arr_buttons[0].id)
221
+ assert_equal("b1", arr_buttons[0].name)
222
+ assert_equal("button", arr_buttons[0].type)
223
+ assert_equal("Click Me", arr_buttons[0].value)
224
+ assert_equal(false, arr_buttons[0].disabled)
225
+ assert_equal("italic_button", arr_buttons[0].class_name)
226
+ assert_equal( "this is button1", arr_buttons[0].title)
227
+
228
+ assert_equal("b5", arr_buttons[1].id)
229
+ assert_equal("b4", arr_buttons[1].name)
230
+ assert_equal("button", arr_buttons[1].type)
231
+ assert_equal("Disabled Button", arr_buttons[1].value)
232
+ assert_equal(true, arr_buttons[1].disabled)
233
+ assert_equal( "", arr_buttons[1].title)
234
+ assert_equal("", arr_buttons[1].class_name)
235
+
236
+ assert_equal("Submit", arr_buttons[2].value)
237
+ assert_equal("sub3", arr_buttons[3].name)
238
+ assert_equal("b7", arr_buttons[4].id)
239
+ assert_equal("b9", arr_buttons[5].id)
240
+ assert_equal("Sign In", arr_buttons[6].value)
241
+ end
242
+
185
243
  def test_hash_syntax
186
244
  assert_equal('Click Me2', browser.button(:id => 'b7').value)
187
245
  end
188
246
 
247
+ tag_method :test_class_and_index, :fails_on_ie
189
248
  def test_class_and_index
190
249
  assert_equal('Click Me2',
191
250
  browser.button(:class => 'italic_button', :index => 2).value)
192
251
  end
193
252
 
253
+ tag_method :test_class_and_index_ie, :fails_on_firefox
254
+ def test_class_and_index_ie
255
+ assert_equal('Click Me2',
256
+ browser.button(:class => 'italic_button', :index => 1).value)
257
+ end
258
+
194
259
  def test_name_and_id #sick, but what the hell
195
260
  assert_equal('Disabled Button2',
196
261
  browser.button(:name => 'b8', :id => 'b9').value)
@@ -213,7 +278,7 @@ class TC_Button_Frame < Test::Unit::TestCase
213
278
  end
214
279
 
215
280
  def test_in_frame
216
- assert(browser.frame("buttonFrame").button(:caption, "Click Me").enabled?)
281
+ assert(browser.frame(:name, "buttonFrame").button(:caption, "Click Me").enabled?)
217
282
  end
218
283
 
219
284
  def test_error_in_frame
@@ -55,6 +55,7 @@ class TC_Dd < Test::Unit::TestCase
55
55
  end
56
56
  end
57
57
 
58
+ tag_method :test_dd_iterator, :fails_on_ie
58
59
  def test_dd_iterator
59
60
  assert_equal(11, browser.dds.length)
60
61
  assert_equal("education", browser.dds[2].title)
@@ -66,5 +67,18 @@ class TC_Dd < Test::Unit::TestCase
66
67
  assert_equal(browser.dd(:index,idx+1).title, dd.title)
67
68
  end
68
69
  end
70
+
71
+ tag_method :test_dd_iterator_ie, :fails_on_firefox
72
+ def test_dd_iterator_ie
73
+ assert_equal(11, browser.dds.length)
74
+ assert_equal("education", browser.dds[1].title)
75
+
76
+ browser.dds.each_with_index do |dd, idx|
77
+ assert_equal(browser.dd(:index,idx).text, dd.text)
78
+ assert_equal(browser.dd(:index,idx).id, dd.id)
79
+ assert_equal(browser.dd(:index,idx).class_name , dd.class_name)
80
+ assert_equal(browser.dd(:index,idx).title, dd.title)
81
+ end
82
+ end
69
83
 
70
- end
84
+ end
@@ -53,6 +53,7 @@ class TC_Dl < Test::Unit::TestCase
53
53
  end
54
54
  end
55
55
 
56
+ tag_method :test_dls_iterator, :fails_on_ie
56
57
  def test_dls_iterator
57
58
  assert_equal(3, browser.dls.length)
58
59
  assert_equal("experience-list", browser.dls[1].id)
@@ -65,4 +66,17 @@ class TC_Dl < Test::Unit::TestCase
65
66
  end
66
67
  end
67
68
 
68
- end
69
+ tag_method :test_dls_iterator_ie, :fails_on_firefox
70
+ def test_dls_iterator_ie
71
+ assert_equal(3, browser.dls.length)
72
+ assert_equal("experience-list", browser.dls[0].id)
73
+
74
+ browser.dls.each_with_index do |dl, idx|
75
+ assert_equal(browser.dl(:index,idx).text, dl.text)
76
+ assert_equal(browser.dl(:index,idx).id, dl.id)
77
+ assert_equal(browser.dl(:index,idx).class_name , dl.class_name)
78
+ assert_equal(browser.dl(:index,idx).title, dl.title)
79
+ end
80
+ end
81
+
82
+ end
@@ -53,6 +53,7 @@ class TC_Dt < Test::Unit::TestCase
53
53
  end
54
54
  end
55
55
 
56
+ tag_method :test_dts_iterator, :fails_on_ie
56
57
  def test_dts_iterator
57
58
  assert_equal(11, browser.dts.length)
58
59
  assert_equal("experience", browser.dts[1].id)
@@ -65,4 +66,17 @@ class TC_Dt < Test::Unit::TestCase
65
66
  end
66
67
  end
67
68
 
68
- end
69
+ tag_method :test_dts_iterator_ie, :fails_on_firefox
70
+ def test_dts_iterator_ie
71
+ assert_equal(11, browser.dts.length)
72
+ assert_equal("experience", browser.dts[0].id)
73
+
74
+ browser.dts.each_with_index do |dt, idx|
75
+ assert_equal(browser.dt(:index,idx).text, dt.text)
76
+ assert_equal(browser.dt(:index,idx).id, dt.id)
77
+ assert_equal(browser.dt(:index,idx).class_name , dt.class_name)
78
+ assert_equal(browser.dt(:index,idx).title, dt.title)
79
+ end
80
+ end
81
+
82
+ end
@@ -52,6 +52,7 @@ class TC_Em < Test::Unit::TestCase
52
52
  end
53
53
  end
54
54
 
55
+ tag_method :test_em_iterator, :fails_on_ie
55
56
  def test_em_iterator
56
57
  assert_equal(3, browser.ems.length)
57
58
  assert_equal("two text", browser.ems[2].text)
@@ -64,4 +65,17 @@ class TC_Em < Test::Unit::TestCase
64
65
  end
65
66
  end
66
67
 
67
- end
68
+ tag_method :test_em_iterator_ie, :fails_on_firefox
69
+ def test_em_iterator_ie
70
+ assert_equal(3, browser.ems.length)
71
+ assert_equal("two text", browser.ems[1].text)
72
+
73
+ browser.ems.each_with_index do |em, idx|
74
+ assert_equal browser.em(:index, idx).text, em.text
75
+ assert_equal browser.em(:index, idx).id, em.id
76
+ assert_equal browser.em(:index, idx).class_name, em.class_name
77
+ assert_equal browser.em(:index, idx).title, em.title
78
+ end
79
+ end
80
+
81
+ end
@@ -17,6 +17,7 @@ class TC_Strong < Test::Unit::TestCase
17
17
  assert browser.strong(:text, /this is a/).exists?, "Could not finr <strong> by :text"
18
18
  end
19
19
 
20
+ tag_method :test_strong_iterator, :fails_on_ie
20
21
  def test_strong_iterator
21
22
  assert_equal(2, browser.strongs.length)
22
23
  assert_equal("this is a strong", browser.strongs[1].text)
@@ -29,4 +30,17 @@ class TC_Strong < Test::Unit::TestCase
29
30
  end
30
31
  end
31
32
 
32
- end
33
+ tag_method :test_strong_iterator_ie, :fails_on_firefox
34
+ def test_strong_iterator_ie
35
+ assert_equal(2, browser.strongs.length)
36
+ assert_equal("this is a strong", browser.strongs[0].text)
37
+
38
+ browser.strongs.each_with_index do |strong, idx|
39
+ assert_equal(browser.strong(:index,idx).text, strong.text)
40
+ assert_equal(browser.strong(:index,idx).id, strong.id)
41
+ assert_equal(browser.strong(:index,idx).class_name , strong.class_name)
42
+ assert_equal(browser.strong(:index,idx).title, strong.title)
43
+ end
44
+ end
45
+
46
+ end
@@ -10,10 +10,16 @@ class TC_WhiteSpace < Test::Unit::TestCase
10
10
  uses_page "whitespace.html"
11
11
  end
12
12
 
13
+ tag_method :test_text_with_nbsp, :fails_on_ie
13
14
  def test_text_with_nbsp
14
15
  assert_equal 'Login', browser.link(:index => 1).text
15
16
  end
16
17
 
18
+ tag_method :test_text_with_nbsp_ie, :fails_on_firefox
19
+ def test_text_with_nbsp_ie
20
+ assert_equal 'Login', browser.link(:index => 0).text
21
+ end
22
+
17
23
  def test_nbsp_beginning_and_end
18
24
  assert browser.link(:text, 'Login').exists?
19
25
  end
metadata CHANGED
@@ -1,13 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: commonwatir
3
3
  version: !ruby/object:Gem::Version
4
- hash: 55
5
- prerelease:
4
+ hash: 15424081
5
+ prerelease: 6
6
6
  segments:
7
- - 1
8
- - 9
9
7
  - 2
10
- version: 1.9.2
8
+ - 0
9
+ - 0
10
+ - rc
11
+ - 2
12
+ version: 2.0.0.rc2
11
13
  platform: ruby
12
14
  authors:
13
15
  - Bret Pettichord
@@ -15,7 +17,7 @@ autorequire:
15
17
  bindir: bin
16
18
  cert_chain: []
17
19
 
18
- date: 2011-07-11 00:00:00 Z
20
+ date: 2011-07-24 00:00:00 Z
19
21
  dependencies:
20
22
  - !ruby/object:Gem::Dependency
21
23
  name: user-choices
@@ -123,12 +125,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
123
125
  required_rubygems_version: !ruby/object:Gem::Requirement
124
126
  none: false
125
127
  requirements:
126
- - - ">="
128
+ - - ">"
127
129
  - !ruby/object:Gem::Version
128
- hash: 3
130
+ hash: 25
129
131
  segments:
130
- - 0
131
- version: "0"
132
+ - 1
133
+ - 3
134
+ - 1
135
+ version: 1.3.1
132
136
  requirements: []
133
137
 
134
138
  rubyforge_project: wtr