watir-webdriver 0.0.7 → 0.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Gemfile +2 -0
- data/Gemfile.lock +48 -0
- data/Rakefile +23 -8
- data/VERSION +1 -1
- data/lib/watir-webdriver.rb +7 -5
- data/lib/watir-webdriver/browser.rb +9 -2
- data/lib/watir-webdriver/browserbot.js +5 -2
- data/lib/watir-webdriver/container.rb +6 -9
- data/lib/watir-webdriver/{collections/element_collection.rb → element_collection.rb} +5 -0
- data/lib/watir-webdriver/elements/button.rb +5 -4
- data/lib/watir-webdriver/{element.rb → elements/element.rb} +29 -5
- data/lib/watir-webdriver/elements/file_field.rb +21 -4
- data/lib/watir-webdriver/elements/frame.rb +1 -1
- data/lib/watir-webdriver/elements/generated.rb +750 -750
- data/lib/watir-webdriver/elements/image.rb +6 -0
- data/lib/watir-webdriver/elements/link.rb +0 -4
- data/lib/watir-webdriver/elements/select.rb +22 -24
- data/lib/watir-webdriver/elements/table_row.rb +11 -1
- data/lib/watir-webdriver/elements/text_field.rb +5 -15
- data/lib/watir-webdriver/extensions/wait.rb +107 -0
- data/lib/watir-webdriver/html/generator.rb +1 -1
- data/lib/watir-webdriver/html/util.rb +1 -10
- data/lib/watir-webdriver/html/visitor.rb +2 -14
- data/lib/watir-webdriver/locators/button_locator.rb +22 -3
- data/lib/watir-webdriver/locators/element_locator.rb +54 -28
- data/lib/watir-webdriver/locators/table_row_locator.rb +3 -1
- data/lib/watir-webdriver/locators/text_field_locator.rb +7 -3
- data/lib/watir-webdriver/window_switching.rb +78 -0
- data/spec/browser_spec.rb +43 -0
- data/spec/container_spec.rb +43 -0
- data/spec/element_locator_spec.rb +305 -0
- data/spec/element_spec.rb +34 -5
- data/spec/html/closeable.html +13 -0
- data/spec/html/data_attributes.html +9 -0
- data/spec/html/wait.html +27 -0
- data/spec/html/window_switching.html +12 -0
- data/spec/input_spec.rb +14 -2
- data/spec/locator_spec_helper.rb +37 -0
- data/spec/spec_helper.rb +3 -0
- data/spec/wait_spec.rb +98 -0
- data/spec/watirspec/area_spec.rb +4 -4
- data/spec/watirspec/browser_spec.rb +37 -35
- data/spec/watirspec/button_spec.rb +22 -17
- data/spec/watirspec/buttons_spec.rb +1 -1
- data/spec/watirspec/checkbox_spec.rb +4 -0
- data/spec/watirspec/checkboxes_spec.rb +1 -1
- data/spec/watirspec/collections_spec.rb +4 -2
- data/spec/watirspec/dd_spec.rb +4 -0
- data/spec/watirspec/dds_spec.rb +1 -1
- data/spec/watirspec/del_spec.rb +4 -0
- data/spec/watirspec/dels_spec.rb +1 -1
- data/spec/watirspec/div_spec.rb +38 -12
- data/spec/watirspec/divs_spec.rb +1 -1
- data/spec/watirspec/dl_spec.rb +20 -6
- data/spec/watirspec/dls_spec.rb +1 -1
- data/spec/watirspec/dt_spec.rb +4 -0
- data/spec/watirspec/dts_spec.rb +1 -1
- data/spec/watirspec/em_spec.rb +4 -0
- data/spec/watirspec/ems_spec.rb +1 -1
- data/spec/watirspec/filefield_spec.rb +37 -2
- data/spec/watirspec/filefields_spec.rb +1 -1
- data/spec/watirspec/font_spec.rb +4 -0
- data/spec/watirspec/form_spec.rb +4 -0
- data/spec/watirspec/forms_spec.rb +6 -4
- data/spec/watirspec/frame_spec.rb +6 -0
- data/spec/watirspec/hidden_spec.rb +5 -4
- data/spec/watirspec/hiddens_spec.rb +1 -1
- data/spec/watirspec/hn_spec.rb +4 -0
- data/spec/watirspec/image_spec.rb +4 -0
- data/spec/watirspec/images_spec.rb +1 -1
- data/spec/watirspec/ins_spec.rb +4 -0
- data/spec/watirspec/inses_spec.rb +1 -1
- data/spec/watirspec/label_spec.rb +4 -0
- data/spec/watirspec/labels_spec.rb +2 -2
- data/spec/watirspec/li_spec.rb +4 -0
- data/spec/watirspec/link_spec.rb +15 -10
- data/spec/watirspec/links_spec.rb +6 -0
- data/spec/watirspec/lis_spec.rb +1 -1
- data/spec/watirspec/map_spec.rb +4 -0
- data/spec/watirspec/maps_spec.rb +1 -1
- data/spec/watirspec/meta_spec.rb +4 -0
- data/spec/watirspec/metas_spec.rb +1 -1
- data/spec/watirspec/ol_spec.rb +23 -9
- data/spec/watirspec/option_spec.rb +19 -7
- data/spec/watirspec/p_spec.rb +4 -0
- data/spec/watirspec/pre_spec.rb +4 -0
- data/spec/watirspec/pres_spec.rb +1 -1
- data/spec/watirspec/ps_spec.rb +1 -1
- data/spec/watirspec/radio_spec.rb +22 -13
- data/spec/watirspec/radios_spec.rb +6 -0
- data/spec/watirspec/select_list_spec.rb +29 -17
- data/spec/watirspec/select_lists_spec.rb +6 -0
- data/spec/watirspec/span_spec.rb +10 -2
- data/spec/watirspec/spans_spec.rb +1 -1
- data/spec/watirspec/strong_spec.rb +14 -4
- data/spec/watirspec/table_body_spec.rb +4 -0
- data/spec/watirspec/table_cell_spec.rb +9 -3
- data/spec/watirspec/table_cells_spec.rb +0 -1
- data/spec/watirspec/table_footer_spec.rb +4 -0
- data/spec/watirspec/table_header_spec.rb +4 -0
- data/spec/watirspec/table_row_spec.rb +15 -7
- data/spec/watirspec/table_rows_spec.rb +2 -2
- data/spec/watirspec/table_spec.rb +13 -7
- data/spec/watirspec/tables_spec.rb +1 -1
- data/spec/watirspec/text_field_spec.rb +21 -12
- data/spec/watirspec/text_fields_spec.rb +6 -0
- data/spec/watirspec/ul_spec.rb +4 -0
- data/spec/window_switching_spec.rb +116 -0
- data/watir-webdriver.gemspec +38 -16
- metadata +51 -27
- data/lib/watir-webdriver/collections/table_row_collection.rb +0 -11
@@ -24,11 +24,17 @@ describe "SelectLists" do
|
|
24
24
|
|
25
25
|
describe "#each" do
|
26
26
|
it "iterates through the select lists correctly" do
|
27
|
+
count = 0
|
28
|
+
|
27
29
|
browser.select_lists.each_with_index do |l, index|
|
28
30
|
browser.select_list(:index, index).name.should == l.name
|
29
31
|
browser.select_list(:index, index).id.should == l.id
|
30
32
|
browser.select_list(:index, index).value.should == l.value
|
33
|
+
|
34
|
+
count += 1
|
31
35
|
end
|
36
|
+
|
37
|
+
count.should > 0
|
32
38
|
end
|
33
39
|
end
|
34
40
|
|
data/spec/watirspec/span_spec.rb
CHANGED
@@ -12,14 +12,22 @@ describe "Span" do
|
|
12
12
|
it "returns true if the 'span' exists" do
|
13
13
|
browser.span(:id, "lead").should exist
|
14
14
|
browser.span(:id, /lead/).should exist
|
15
|
-
|
16
|
-
|
15
|
+
|
16
|
+
bug "http://code.google.com/p/selenium/issues/detail?id=748", :webdriver do
|
17
|
+
browser.span(:text, "Dubito, ergo cogito, ergo sum.").should exist
|
18
|
+
browser.span(:text, /Dubito, ergo cogito, ergo sum/).should exist
|
19
|
+
end
|
20
|
+
|
17
21
|
browser.span(:class, "lead").should exist
|
18
22
|
browser.span(:class, /lead/).should exist
|
19
23
|
browser.span(:index, 0).should exist
|
20
24
|
browser.span(:xpath, "//span[@id='lead']").should exist
|
21
25
|
end
|
22
26
|
|
27
|
+
it "returns the first span if given no args" do
|
28
|
+
browser.span.should exist
|
29
|
+
end
|
30
|
+
|
23
31
|
it "returns false if the element doesn't exist" do
|
24
32
|
browser.span(:id, "no_such_id").should_not exist
|
25
33
|
browser.span(:id, /no_such_id/).should_not exist
|
@@ -12,14 +12,22 @@ describe "Strong" do
|
|
12
12
|
it "returns true if the element exists" do
|
13
13
|
browser.strong(:id, "descartes").should exist
|
14
14
|
browser.strong(:id, /descartes/).should exist
|
15
|
-
|
16
|
-
|
15
|
+
|
16
|
+
bug "http://code.google.com/p/selenium/issues/detail?id=748", :webdriver do
|
17
|
+
browser.strong(:text, "Dubito, ergo cogito, ergo sum.").should exist
|
18
|
+
browser.strong(:text, /Dubito, ergo cogito, ergo sum/).should exist
|
19
|
+
end
|
20
|
+
|
17
21
|
browser.strong(:class, "descartes").should exist
|
18
22
|
browser.strong(:class, /descartes/).should exist
|
19
23
|
browser.strong(:index, 0).should exist
|
20
24
|
browser.strong(:xpath, "//strong[@id='descartes']").should exist
|
21
25
|
end
|
22
26
|
|
27
|
+
it "returns the first strong if given no args" do
|
28
|
+
browser.strong.should exist
|
29
|
+
end
|
30
|
+
|
23
31
|
it "returns false if the element doesn't exist" do
|
24
32
|
browser.strong(:id, "no_such_id").should_not exist
|
25
33
|
browser.strong(:id, /no_such_id/).should_not exist
|
@@ -67,8 +75,10 @@ describe "Strong" do
|
|
67
75
|
end
|
68
76
|
|
69
77
|
describe "#text" do
|
70
|
-
|
71
|
-
|
78
|
+
bug "http://code.google.com/p/selenium/issues/detail?id=748", :webdriver do
|
79
|
+
it "returns the text of the element" do
|
80
|
+
browser.strong(:index, 0).text.should == "Dubito, ergo cogito, ergo sum."
|
81
|
+
end
|
72
82
|
end
|
73
83
|
|
74
84
|
it "raises UnknownObjectException if the element doesn't exist" do
|
@@ -22,6 +22,10 @@ describe "TableBody" do
|
|
22
22
|
browser.table(:index, 0).tbody(:xpath, "//tbody[@id='first']").should exist
|
23
23
|
end
|
24
24
|
|
25
|
+
it "returns the first table body if given no args" do
|
26
|
+
browser.table.tbody.should exist
|
27
|
+
end
|
28
|
+
|
25
29
|
it "returns false if the table body doesn't exist (page context)" do
|
26
30
|
browser.tbody(:id, 'no_such_id').should_not exist
|
27
31
|
browser.tbody(:id, /no_such_id/).should_not exist
|
@@ -18,6 +18,10 @@ describe "TableCell" do
|
|
18
18
|
browser.cell(:xpath, "//td[@id='t1_r2_c1']").should exist
|
19
19
|
end
|
20
20
|
|
21
|
+
it "returns the first cell if given no args" do
|
22
|
+
browser.cell.should exist
|
23
|
+
end
|
24
|
+
|
21
25
|
it "returns false when the table cell does not exist" do
|
22
26
|
browser.cell(:id, 'no_such_id').should_not exist
|
23
27
|
browser.cell(:id, /no_such_id/).should_not exist
|
@@ -52,9 +56,11 @@ describe "TableCell" do
|
|
52
56
|
end
|
53
57
|
|
54
58
|
describe "#colspan" do
|
55
|
-
|
56
|
-
|
57
|
-
|
59
|
+
bug "http://github.com/jarib/watir-webdriver/issues#issue/25", :webdriver do
|
60
|
+
it "gets the colspan attribute" do
|
61
|
+
browser.cell(:id, 'colspan_2').colspan.should == 2
|
62
|
+
browser.cell(:id, 'no_colspan').colspan.should == 1
|
63
|
+
end
|
58
64
|
end
|
59
65
|
end
|
60
66
|
|
@@ -21,6 +21,10 @@ describe "TableFooter" do
|
|
21
21
|
browser.table(:index, 0).tfoot(:xpath, "//tfoot[@id='tax_totals']").should exist
|
22
22
|
end
|
23
23
|
|
24
|
+
it "returns the first tfoot if given no args" do
|
25
|
+
browser.tfoot.should exist
|
26
|
+
end
|
27
|
+
|
24
28
|
it "returns false if the table tfoot doesn't exist (page context)" do
|
25
29
|
browser.tfoot(:id, 'no_such_id').should_not exist
|
26
30
|
browser.tfoot(:id, /no_such_id/).should_not exist
|
@@ -15,6 +15,10 @@ describe "TableHeader" do
|
|
15
15
|
browser.thead(:xpath, "//thead[@id='tax_headers']").should exist
|
16
16
|
end
|
17
17
|
|
18
|
+
it "returns the first thead if given no args" do
|
19
|
+
browser.thead.should exist
|
20
|
+
end
|
21
|
+
|
18
22
|
it "returns true if the table theader exists (table context)" do
|
19
23
|
browser.table(:index, 0).thead(:id, 'tax_headers').should exist
|
20
24
|
browser.table(:index, 0).thead(:id, /tax_headers/).should exist
|
@@ -15,6 +15,10 @@ describe "TableRow" do
|
|
15
15
|
browser.row(:xpath, "//tr[@id='outer_first']")
|
16
16
|
end
|
17
17
|
|
18
|
+
it "returns the first row if given no args" do
|
19
|
+
browser.row.should exist
|
20
|
+
end
|
21
|
+
|
18
22
|
it "returns false if the table row doesn't exist" do
|
19
23
|
browser.row(:id, "no_such_id").should_not exist
|
20
24
|
browser.row(:id, /no_such_id/).should_not exist
|
@@ -32,9 +36,11 @@ describe "TableRow" do
|
|
32
36
|
end
|
33
37
|
|
34
38
|
describe "#click" do
|
35
|
-
|
36
|
-
|
37
|
-
|
39
|
+
bug "http://github.com/jarib/watir-webdriver/issues/issue/32", [:webdriver, :ie] do
|
40
|
+
it "fires the rows's onclick event" do
|
41
|
+
browser.row(:id, 'inner_first').click
|
42
|
+
messages.should include('tr')
|
43
|
+
end
|
38
44
|
end
|
39
45
|
end
|
40
46
|
|
@@ -57,9 +63,11 @@ describe "TableRow" do
|
|
57
63
|
browser.table(:id, 'outer')[2][0].text.should == "Table 1, Row 3, Cell 1"
|
58
64
|
end
|
59
65
|
|
60
|
-
|
61
|
-
|
62
|
-
|
66
|
+
bug "http://github.com/jarib/watir-webdriver/issues/issue/26", :webdriver do
|
67
|
+
it "raises UnknownCellException if the index is out of bounds" do
|
68
|
+
lambda { browser.table(:id, 'outer').row(:index, 0)[1337] }.should raise_error(UnknownCellException)
|
69
|
+
lambda { browser.table(:id, 'outer')[0][1337] }.should raise_error(UnknownCellException)
|
70
|
+
end
|
63
71
|
end
|
64
72
|
end
|
65
73
|
|
@@ -81,7 +89,7 @@ describe "TableRow" do
|
|
81
89
|
bug "http://github.com/jarib/watir-webdriver/issues/#issue/2", :webdriver do
|
82
90
|
describe "#each" do
|
83
91
|
it "iterates correctly through the cells of the row" do
|
84
|
-
browser.table(:id, 'outer')[1].each_with_index do |cell,idx|
|
92
|
+
browser.table(:id, 'outer')[1].each_with_index do |cell, idx|
|
85
93
|
cell.id.should == "t1_r2_c#{idx + 1}"
|
86
94
|
end
|
87
95
|
end
|
@@ -38,7 +38,7 @@ describe "TableRows" do
|
|
38
38
|
r.id.should == inner_table.row(:index, index).id
|
39
39
|
r.value.should == inner_table.row(:index, index).value
|
40
40
|
|
41
|
-
|
41
|
+
count += 1
|
42
42
|
end
|
43
43
|
|
44
44
|
count.should > 0
|
@@ -50,7 +50,7 @@ describe "TableRows" do
|
|
50
50
|
r.id.should == outer_table.row(:index, index).id
|
51
51
|
r.value.should == outer_table.row(:index, index).value
|
52
52
|
|
53
|
-
|
53
|
+
count += 1
|
54
54
|
end
|
55
55
|
|
56
56
|
count.should > 0
|
@@ -16,6 +16,10 @@ describe "Table" do
|
|
16
16
|
browser.table(:xpath, "//table[@id='axis_example']").should exist
|
17
17
|
end
|
18
18
|
|
19
|
+
it "returns the first table if given no args" do
|
20
|
+
browser.table.should exist
|
21
|
+
end
|
22
|
+
|
19
23
|
it "returns false if the table does not exist" do
|
20
24
|
browser.table(:id, 'no_such_id').should_not exist
|
21
25
|
browser.table(:id, /no_such_id/).should_not exist
|
@@ -23,11 +27,9 @@ describe "Table" do
|
|
23
27
|
browser.table(:xpath, "//table[@id='no_such_id']").should_not exist
|
24
28
|
end
|
25
29
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
browser.table(:xpath, "//table").should exist
|
30
|
-
end
|
30
|
+
it "checks the tag name when locating by xpath" do
|
31
|
+
browser.table(:xpath, "//table//td").should_not exist
|
32
|
+
browser.table(:xpath, "//table").should exist
|
31
33
|
end
|
32
34
|
|
33
35
|
it "raises TypeError when 'what' argument is invalid" do
|
@@ -117,8 +119,12 @@ describe "Table" do
|
|
117
119
|
browser.table(:id, 'inner')[0].id.should == "inner_first"
|
118
120
|
browser.table(:id, 'outer')[2].id.should == "outer_last"
|
119
121
|
end
|
120
|
-
|
121
|
-
|
122
|
+
|
123
|
+
|
124
|
+
bug "http://github.com/jarib/watir-webdriver/issues/issue/26", :webdriver do
|
125
|
+
it "raises UnknownRowException if the index is out of bounds" do
|
126
|
+
lambda { browser.table(:id, 'outer')[1337] }.should raise_error(UnknownRowException)
|
127
|
+
end
|
122
128
|
end
|
123
129
|
end
|
124
130
|
|
@@ -16,6 +16,7 @@ describe "TextField" do
|
|
16
16
|
browser.text_field(:name, /new_user_email/).should exist
|
17
17
|
browser.text_field(:value, 'Developer').should exist
|
18
18
|
browser.text_field(:value, /Developer/).should exist
|
19
|
+
browser.text_field(:value, "Default comment.").should exist # textarea
|
19
20
|
browser.text_field(:text, 'Developer').should exist
|
20
21
|
browser.text_field(:text, /Developer/).should exist
|
21
22
|
browser.text_field(:class, 'name').should exist
|
@@ -24,7 +25,11 @@ describe "TextField" do
|
|
24
25
|
browser.text_field(:xpath, "//input[@id='new_user_email']").should exist
|
25
26
|
browser.text_field(:label, "First name").should exist
|
26
27
|
browser.text_field(:label, /(Last|First) name/).should exist
|
27
|
-
|
28
|
+
end
|
29
|
+
|
30
|
+
it "returns the first text field if given no args" do
|
31
|
+
browser.text_field.should exist
|
32
|
+
end
|
28
33
|
|
29
34
|
it "returns true if the element exists (no type attribute)" do
|
30
35
|
browser.text_field(:id, 'new_user_first_name').should exist
|
@@ -179,16 +184,20 @@ describe "TextField" do
|
|
179
184
|
|
180
185
|
# Manipulation methods
|
181
186
|
describe "#append" do
|
182
|
-
|
183
|
-
|
184
|
-
|
187
|
+
bug "http://code.google.com/p/selenium/issues/detail?id=698", [:webdriver, :ie] do
|
188
|
+
it "appends the text to the text field" do
|
189
|
+
browser.text_field(:name, "new_user_occupation").append(" Append This")
|
190
|
+
browser.text_field(:name, "new_user_occupation").value.should == "Developer Append This"
|
191
|
+
end
|
185
192
|
end
|
186
193
|
|
187
|
-
|
188
|
-
|
189
|
-
|
194
|
+
bug "http://code.google.com/p/selenium/issues/detail?id=698", [:webdriver, :ie] do
|
195
|
+
it "appends multi-byte characters" do
|
196
|
+
browser.text_field(:name, "new_user_occupation").append(" ijij")
|
197
|
+
browser.text_field(:name, "new_user_occupation").value.should == "Developer ijij"
|
198
|
+
end
|
190
199
|
end
|
191
|
-
|
200
|
+
|
192
201
|
it "raises ObjectReadOnlyException if the object is read only" do
|
193
202
|
lambda { browser.text_field(:id, "new_user_code").append("Append This") }.should raise_error(ObjectReadOnlyException)
|
194
203
|
end
|
@@ -253,13 +262,13 @@ describe "TextField" do
|
|
253
262
|
end
|
254
263
|
|
255
264
|
it "sets the value of a password field" do
|
256
|
-
browser.text_field(:name
|
257
|
-
browser.text_field(:name
|
265
|
+
browser.text_field(:name, 'new_user_password').set('secret')
|
266
|
+
browser.text_field(:name, 'new_user_password').value.should == 'secret'
|
258
267
|
end
|
259
268
|
|
260
269
|
it "sets the value when accessed through the enclosing Form" do
|
261
|
-
browser.form(:id, 'new_user').text_field(:name
|
262
|
-
browser.form(:id, 'new_user').text_field(:name
|
270
|
+
browser.form(:id, 'new_user').text_field(:name, 'new_user_password').set('secret')
|
271
|
+
browser.form(:id, 'new_user').text_field(:name, 'new_user_password').value.should == 'secret'
|
263
272
|
end
|
264
273
|
|
265
274
|
it "is able to set multi-byte characters" do
|
@@ -23,11 +23,17 @@ describe "TextFields" do
|
|
23
23
|
|
24
24
|
describe "#each" do
|
25
25
|
it "iterates through text fields correctly" do
|
26
|
+
count = 0
|
27
|
+
|
26
28
|
browser.text_fields.each_with_index do |r, index|
|
27
29
|
r.name.should == browser.text_field(:index, index).name
|
28
30
|
r.id.should == browser.text_field(:index, index).id
|
29
31
|
r.value.should == browser.text_field(:index, index).value
|
32
|
+
|
33
|
+
count += 1
|
30
34
|
end
|
35
|
+
|
36
|
+
count.should > 0
|
31
37
|
end
|
32
38
|
end
|
33
39
|
|
data/spec/watirspec/ul_spec.rb
CHANGED
@@ -16,6 +16,10 @@ describe "Ul" do
|
|
16
16
|
browser.ul(:xpath, "//ul[@id='navbar']").should exist
|
17
17
|
end
|
18
18
|
|
19
|
+
it "returns the first ul if given no args" do
|
20
|
+
browser.ul.should exist
|
21
|
+
end
|
22
|
+
|
19
23
|
it "returns false if the 'ul' doesn't exist" do
|
20
24
|
browser.ul(:id, "no_such_id").should_not exist
|
21
25
|
browser.ul(:id, /no_such_id/).should_not exist
|
@@ -0,0 +1,116 @@
|
|
1
|
+
require File.expand_path('watirspec/spec_helper', File.dirname(__FILE__))
|
2
|
+
|
3
|
+
|
4
|
+
describe Watir::Browser do
|
5
|
+
|
6
|
+
before do
|
7
|
+
url = "file://" + File.expand_path("html/window_switching.html", File.dirname(__FILE__))
|
8
|
+
browser.goto url
|
9
|
+
browser.a(:id => "open").click
|
10
|
+
end
|
11
|
+
|
12
|
+
after do
|
13
|
+
win = browser.window(:title => "closeable window")
|
14
|
+
win && win.close
|
15
|
+
end
|
16
|
+
|
17
|
+
describe "#windows" do
|
18
|
+
it "returns an array of window handles" do
|
19
|
+
wins = browser.windows
|
20
|
+
wins.should_not be_empty
|
21
|
+
wins.each { |win| win.should be_kind_of(Watir::Window) }
|
22
|
+
end
|
23
|
+
|
24
|
+
it "only returns windows matching the given selector" do
|
25
|
+
browser.windows(:title => "closeable window").size.should == 1
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
describe "#window" do
|
30
|
+
it "finds window by :url" do
|
31
|
+
w = browser.window(:url => /closeable\.html/)
|
32
|
+
w.should be_kind_of(Watir::Window)
|
33
|
+
end
|
34
|
+
|
35
|
+
it "finds window by :title" do
|
36
|
+
w = browser.window(:title => "closeable window")
|
37
|
+
w.should be_kind_of(Watir::Window)
|
38
|
+
end
|
39
|
+
|
40
|
+
it "it executes the given block in the window" do
|
41
|
+
browser.window(:title => "closeable window") do
|
42
|
+
link = browser.a(:id => "close")
|
43
|
+
link.should exist
|
44
|
+
link.click
|
45
|
+
end
|
46
|
+
|
47
|
+
browser.windows.size.should == 1
|
48
|
+
end
|
49
|
+
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
describe Watir::Window do
|
54
|
+
before do
|
55
|
+
url = "file://" + File.expand_path("html/window_switching.html", File.dirname(__FILE__))
|
56
|
+
browser.goto url
|
57
|
+
browser.a(:id => "open").click
|
58
|
+
end
|
59
|
+
|
60
|
+
after do
|
61
|
+
browser.window(:title => "closeable window").close
|
62
|
+
end
|
63
|
+
|
64
|
+
describe "#close" do
|
65
|
+
it "closes the window" do
|
66
|
+
pending
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
describe "#use" do
|
71
|
+
it "switches to the window" do
|
72
|
+
pending
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
describe "#current?" do
|
77
|
+
it "returns true if it is the current window" do
|
78
|
+
browser.window(:title => browser.title).should be_current
|
79
|
+
end
|
80
|
+
|
81
|
+
it "returns false if it is not the current window" do
|
82
|
+
browser.window(:title => "closeable window").should_not be_current
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
describe "#title" do
|
87
|
+
it "returns the title of the window" do
|
88
|
+
titles = browser.windows.map { |e| e.title }
|
89
|
+
titles.size.should == 2
|
90
|
+
|
91
|
+
["window switching", "closeable window"].each do |title|
|
92
|
+
titles.should include(title)
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
it "does not change the current window" do
|
97
|
+
browser.title.should == "window switching"
|
98
|
+
browser.windows.find { |w| w.title == "closeable window" }.should_not be_nil
|
99
|
+
browser.title.should == "window switching"
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
describe "#url" do
|
104
|
+
it "returns the url of the window" do
|
105
|
+
browser.windows.size.should == 2
|
106
|
+
browser.windows.select { |w| w.url =~ /window_switching\.html/ }.size.should == 1
|
107
|
+
browser.windows.select { |w| w.url =~ /closeable\.html$/ }.size.should == 1
|
108
|
+
end
|
109
|
+
|
110
|
+
it "does not change the current window" do
|
111
|
+
browser.url.should =~ /window_switching\.html/
|
112
|
+
browser.windows.find { |w| w.url =~ /closeable\.html/ }.should_not be_nil
|
113
|
+
browser.url.should =~ /window_switching/
|
114
|
+
end
|
115
|
+
end
|
116
|
+
end
|