watir-webdriver 0.0.9 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (98) hide show
  1. data/README.rdoc +9 -1
  2. data/Rakefile +2 -1
  3. data/VERSION +1 -1
  4. data/lib/watir-webdriver.rb +6 -7
  5. data/lib/watir-webdriver/attribute_helper.rb +17 -10
  6. data/lib/watir-webdriver/browser.rb +1 -1
  7. data/lib/watir-webdriver/cell_container.rb +19 -0
  8. data/lib/watir-webdriver/container.rb +8 -0
  9. data/lib/watir-webdriver/element_collection.rb +2 -2
  10. data/lib/watir-webdriver/elements/button.rb +3 -2
  11. data/lib/watir-webdriver/elements/element.rb +41 -1
  12. data/lib/watir-webdriver/elements/generated.rb +3 -3
  13. data/lib/watir-webdriver/elements/input.rb +0 -52
  14. data/lib/watir-webdriver/elements/select.rb +0 -1
  15. data/lib/watir-webdriver/elements/table.rb +26 -4
  16. data/lib/watir-webdriver/elements/table_cell.rb +36 -0
  17. data/lib/watir-webdriver/elements/table_row.rb +23 -14
  18. data/lib/watir-webdriver/elements/table_section.rb +9 -0
  19. data/lib/watir-webdriver/extensions/alerts.rb +69 -0
  20. data/lib/watir-webdriver/extensions/performance.rb +54 -0
  21. data/lib/watir-webdriver/locators/button_locator.rb +3 -5
  22. data/lib/watir-webdriver/locators/{table_row_locator.rb → child_cell_locator.rb} +11 -6
  23. data/lib/watir-webdriver/locators/child_row_locator.rb +37 -0
  24. data/lib/watir-webdriver/locators/element_locator.rb +24 -14
  25. data/lib/watir-webdriver/row_container.rb +19 -0
  26. data/lib/watir-webdriver/window_switching.rb +37 -10
  27. data/spec/alert_spec.rb +49 -0
  28. data/spec/element_locator_spec.rb +15 -16
  29. data/spec/element_spec.rb +0 -32
  30. data/spec/html/alerts.html +11 -0
  31. data/spec/input_spec.rb +8 -46
  32. data/spec/locator_spec_helper.rb +19 -5
  33. data/spec/spec_helper.rb +3 -0
  34. data/spec/watirspec/areas_spec.rb +8 -0
  35. data/spec/watirspec/browser_spec.rb +4 -4
  36. data/spec/watirspec/button_spec.rb +3 -4
  37. data/spec/watirspec/buttons_spec.rb +8 -0
  38. data/spec/watirspec/checkboxes_spec.rb +8 -0
  39. data/spec/watirspec/dds_spec.rb +8 -0
  40. data/spec/watirspec/dels_spec.rb +8 -0
  41. data/spec/watirspec/divs_spec.rb +8 -0
  42. data/spec/watirspec/dls_spec.rb +8 -0
  43. data/spec/watirspec/dts_spec.rb +8 -0
  44. data/spec/watirspec/element_spec.rb +71 -2
  45. data/spec/watirspec/ems_spec.rb +8 -0
  46. data/spec/watirspec/filefield_spec.rb +16 -11
  47. data/spec/watirspec/filefields_spec.rb +8 -0
  48. data/spec/watirspec/font_spec.rb +21 -19
  49. data/spec/watirspec/form_spec.rb +5 -3
  50. data/spec/watirspec/forms_spec.rb +11 -5
  51. data/spec/watirspec/frames_spec.rb +8 -0
  52. data/spec/watirspec/hiddens_spec.rb +8 -0
  53. data/spec/watirspec/hns_spec.rb +8 -0
  54. data/spec/watirspec/images_spec.rb +8 -0
  55. data/spec/watirspec/inses_spec.rb +8 -0
  56. data/spec/watirspec/label_spec.rb +2 -0
  57. data/spec/watirspec/labels_spec.rb +8 -0
  58. data/spec/watirspec/lib/server.rb +19 -1
  59. data/spec/watirspec/lib/spec_helper.rb +1 -1
  60. data/spec/watirspec/links_spec.rb +8 -0
  61. data/spec/watirspec/lis_spec.rb +8 -0
  62. data/spec/watirspec/maps_spec.rb +8 -0
  63. data/spec/watirspec/metas_spec.rb +8 -0
  64. data/spec/watirspec/ols_spec.rb +8 -0
  65. data/spec/watirspec/pres_spec.rb +8 -0
  66. data/spec/watirspec/ps_spec.rb +8 -0
  67. data/spec/watirspec/radios_spec.rb +8 -0
  68. data/spec/watirspec/select_list_spec.rb +6 -6
  69. data/spec/watirspec/select_lists_spec.rb +8 -0
  70. data/spec/watirspec/spans_spec.rb +8 -0
  71. data/spec/watirspec/strongs_spec.rb +8 -0
  72. data/spec/watirspec/table_nesting_spec.rb +50 -0
  73. data/spec/watirspec/table_spec.rb +62 -102
  74. data/spec/watirspec/tables_spec.rb +8 -0
  75. data/spec/watirspec/{table_body_spec.rb → tbody_spec.rb} +21 -31
  76. data/spec/watirspec/{table_bodies_spec.rb → tbodys_spec.rb} +8 -0
  77. data/spec/watirspec/td_spec.rb +72 -0
  78. data/spec/watirspec/{table_cells_spec.rb → tds_spec.rb} +18 -25
  79. data/spec/watirspec/text_fields_spec.rb +8 -0
  80. data/spec/watirspec/{table_footer_spec.rb → tfoot_spec.rb} +21 -28
  81. data/spec/watirspec/{table_footers_spec.rb → tfoots_spec.rb} +8 -0
  82. data/spec/watirspec/{table_header_spec.rb → thead_spec.rb} +21 -29
  83. data/spec/watirspec/{table_headers_spec.rb → theads_spec.rb} +8 -0
  84. data/spec/watirspec/tr_spec.rb +88 -0
  85. data/spec/watirspec/trs_spec.rb +68 -0
  86. data/spec/watirspec/uls_spec.rb +8 -0
  87. data/spec/watirspec/window_switching_spec.rb +165 -0
  88. data/support/html5.html +884 -422
  89. data/watir-webdriver.gemspec +91 -85
  90. metadata +159 -161
  91. data/Gemfile.lock +0 -48
  92. data/spec/html/closeable.html +0 -13
  93. data/spec/html/data_attributes.html +0 -9
  94. data/spec/html/window_switching.html +0 -12
  95. data/spec/watirspec/table_cell_spec.rb +0 -74
  96. data/spec/watirspec/table_row_spec.rb +0 -99
  97. data/spec/watirspec/table_rows_spec.rb +0 -60
  98. data/spec/window_switching_spec.rb +0 -116
@@ -1,48 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- watir-webdriver (0.0.7)
5
- selenium-webdriver (>= 0.0.26)
6
-
7
- GEM
8
- remote: http://rubygems.org/
9
- specs:
10
- activesupport (3.0.0)
11
- ffi (0.6.3)
12
- rake (>= 0.8.7)
13
- json_pure (1.4.6)
14
- nokogiri (1.4.3.1)
15
- polyglot (0.3.1)
16
- rack (1.2.1)
17
- rake (0.8.7)
18
- rspec (1.3.0)
19
- ruby2ruby (1.2.4)
20
- ruby_parser (~> 2.0)
21
- sexp_processor (~> 3.0)
22
- ruby_parser (2.0.4)
23
- sexp_processor (~> 3.0)
24
- rubyzip (0.9.4)
25
- selenium-webdriver (0.0.28)
26
- ffi (>= 0.6.1)
27
- json_pure
28
- rubyzip
29
- sexp_processor (3.0.4)
30
- sinatra (1.0)
31
- rack (>= 1.0)
32
- treetop (1.4.8)
33
- polyglot (>= 0.3.1)
34
- webidl (0.0.5)
35
- ruby2ruby
36
- treetop
37
-
38
- PLATFORMS
39
- ruby
40
-
41
- DEPENDENCIES
42
- activesupport (>= 2.3.5)
43
- nokogiri
44
- rspec
45
- selenium-webdriver (>= 0.0.26)
46
- sinatra (>= 1.0)
47
- watir-webdriver!
48
- webidl (>= 0.0.4)
@@ -1,13 +0,0 @@
1
- <!DOCTYPE HTML>
2
- <html>
3
- <head>
4
- <title>closeable window</title>
5
- </head>
6
-
7
- <body>
8
- <p>
9
- Click <a id="close" href="#" onclick="window.close()">here</a> to close this window.
10
- </p>
11
- </body>
12
-
13
- </html>
@@ -1,9 +0,0 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <head>
4
- <title>data-* attributes</title>
5
- </head>
6
- <body>
7
- <p data-type=ruby-library>watir-webdriver</p>
8
- </body>
9
- </html>
@@ -1,12 +0,0 @@
1
- <!DOCTYPE HTML>
2
- <html>
3
- <head>
4
- <title>window switching</title>
5
- </head>
6
-
7
- <body>
8
- <p>
9
- Click <a id="open" href="#" onclick='window.open("closeable.html", "closeable-window")'>here</a> to open a new window.
10
- </p>
11
- </body>
12
- </html>
@@ -1,74 +0,0 @@
1
- # encoding: utf-8
2
- require File.expand_path('spec_helper', File.dirname(__FILE__))
3
-
4
- describe "TableCell" do
5
-
6
- before :each do
7
- browser.goto(WatirSpec.files + "/tables.html")
8
- end
9
-
10
- # Exists
11
- describe "#exists?" do
12
- it "returns true when the table cell exists" do
13
- browser.cell(:id, 't1_r2_c1').should exist
14
- browser.cell(:id, /t1_r2_c1/).should exist
15
- browser.cell(:text, 'Table 1, Row 3, Cell 1').should exist
16
- browser.cell(:text, /Table 1/).should exist
17
- browser.cell(:index, 0).should exist
18
- browser.cell(:xpath, "//td[@id='t1_r2_c1']").should exist
19
- end
20
-
21
- it "returns the first cell if given no args" do
22
- browser.cell.should exist
23
- end
24
-
25
- it "returns false when the table cell does not exist" do
26
- browser.cell(:id, 'no_such_id').should_not exist
27
- browser.cell(:id, /no_such_id/).should_not exist
28
- browser.cell(:text, 'no_such_text').should_not exist
29
- browser.cell(:text, /no_such_text/).should_not exist
30
- browser.cell(:index, 1337).should_not exist
31
- browser.cell(:xpath, "//td[@id='no_such_id']").should_not exist
32
- end
33
-
34
- it "raises TypeError when 'what' argument is invalid" do
35
- lambda { browser.cell(:id, 3.14).exists? }.should raise_error(TypeError)
36
- end
37
-
38
- it "raises MissingWayOfFindingObjectException when 'how' argument is invalid" do
39
- lambda { browser.cell(:no_such_how, 'some_value').exists? }.should raise_error(MissingWayOfFindingObjectException)
40
- end
41
- end
42
-
43
- describe "#click" do
44
- it "fires the table's onclick event" do
45
- browser.cell(:id, 't2_r1_c1').click
46
- messages.should include('td')
47
- end
48
- end
49
-
50
- # Attribute methods
51
- describe "#text" do
52
- it "returns the text inside the table cell" do
53
- browser.cell(:id, 't1_r2_c1').text.should == 'Table 1, Row 2, Cell 1'
54
- browser.cell(:id, 't2_r1_c1').text.should == 'Table 2, Row 1, Cell 1'
55
- end
56
- end
57
-
58
- describe "#colspan" do
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
64
- end
65
- end
66
-
67
- describe "#respond_to?" do
68
- it "returns true for all attribute methods" do
69
- browser.cell(:index, 0).should respond_to(:text)
70
- browser.cell(:index, 0).should respond_to(:colspan)
71
- end
72
- end
73
-
74
- end
@@ -1,99 +0,0 @@
1
- # encoding: utf-8
2
- require File.expand_path('spec_helper', File.dirname(__FILE__))
3
-
4
- describe "TableRow" do
5
-
6
- before :each do
7
- browser.goto(WatirSpec.files + "/tables.html")
8
- end
9
-
10
- describe "#exists?" do
11
- it "returns true if the table row exists" do
12
- browser.row(:id, "outer_first").should exist
13
- browser.row(:id, /outer_first/).should exist
14
- browser.row(:index, 0).should exist
15
- browser.row(:xpath, "//tr[@id='outer_first']")
16
- end
17
-
18
- it "returns the first row if given no args" do
19
- browser.row.should exist
20
- end
21
-
22
- it "returns false if the table row doesn't exist" do
23
- browser.row(:id, "no_such_id").should_not exist
24
- browser.row(:id, /no_such_id/).should_not exist
25
- browser.row(:index, 1337).should_not exist
26
- browser.row(:xpath, "//tr[@id='no_such_id']")
27
- end
28
-
29
- it "raises TypeError when 'what' argument is invalid" do
30
- lambda { browser.row(:id, 3.14).exists? }.should raise_error(TypeError)
31
- end
32
-
33
- it "raises MissingWayOfFindingObjectException when 'how' argument is invalid" do
34
- lambda { browser.row(:no_such_how, 'some_value').exists? }.should raise_error(MissingWayOfFindingObjectException)
35
- end
36
- end
37
-
38
- describe "#click" do
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
44
- end
45
- end
46
-
47
- bug "http://github.com/jarib/watir-webdriver/issues/#issue/2", :webdriver do
48
- describe "#column_count" do
49
- it "returns the number of columns (cells) in the row" do
50
- browser.table(:id, 'outer').rows[0].column_count.should == 2
51
- browser.table(:id, 'outer')[1].column_count.should == 2
52
- browser.table(:id, 'colspan')[0].column_count.should == 1
53
- browser.table(:id, 'colspan').rows[1].column_count.should == 2
54
- browser.rows[0].column_count.should == 4
55
- end
56
- end
57
- end
58
-
59
- describe "#[]" do
60
- it "returns the nth cell of the parent row" do
61
- browser.table(:id, 'outer').row(:index, 0)[0].text.should == "Table 1, Row 1, Cell 1"
62
- browser.table(:id, 'outer')[0][0].text.should == "Table 1, Row 1, Cell 1"
63
- browser.table(:id, 'outer')[2][0].text.should == "Table 1, Row 3, Cell 1"
64
- end
65
-
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
71
- end
72
- end
73
-
74
- bug "http://github.com/jarib/watir-webdriver/issues/#issue/2", :webdriver do
75
- describe "#child_cell" do
76
- it "returns the nth cell of the parent row" do
77
- browser.table(:id, 'outer').row(:index, 0).child_cell(0).text.should == "Table 1, Row 1, Cell 1"
78
- browser.table(:id, 'outer')[0].child_cell(0).text.should == "Table 1, Row 1, Cell 1"
79
- browser.table(:id, 'outer')[2].child_cell(0).text.should == "Table 1, Row 3, Cell 1"
80
- end
81
-
82
- it "raises UnknownCellException if the index is out of bounds" do
83
- lambda { browser.table(:id, 'outer').row(:index, 0).child_cell(1337) }.should raise_error(UnknownCellException)
84
- lambda { browser.table(:id, 'outer')[0].child_cell(1337) }.should raise_error(UnknownCellException)
85
- end
86
- end
87
- end
88
-
89
- bug "http://github.com/jarib/watir-webdriver/issues/#issue/2", :webdriver do
90
- describe "#each" do
91
- it "iterates correctly through the cells of the row" do
92
- browser.table(:id, 'outer')[1].each_with_index do |cell, idx|
93
- cell.id.should == "t1_r2_c#{idx + 1}"
94
- end
95
- end
96
- end
97
- end
98
-
99
- end
@@ -1,60 +0,0 @@
1
- # encoding: utf-8
2
- require File.expand_path('spec_helper', File.dirname(__FILE__))
3
-
4
- describe "TableRows" do
5
-
6
- before :each do
7
- browser.goto(WatirSpec.files + "/tables.html")
8
- end
9
-
10
- describe "#length" do
11
- it "returns the correct number of cells (table context)" do
12
- browser.table(:id, 'inner').rows.length.should == 1
13
- browser.table(:id, 'outer').rows.length.should == 3
14
- end
15
-
16
- it "returns the correct number of cells (page context)" do
17
- browser.rows.length.should == 14
18
- end
19
- end
20
-
21
- describe "#[]" do
22
- it "returns the row at the given index (table context)" do
23
- browser.table(:id, 'outer').rows[0].id.should == "outer_first"
24
- end
25
-
26
- it "returns the row at the given index (page context)" do
27
- browser.rows[0].id.should == "thead_row_1"
28
- end
29
- end
30
-
31
- describe "#each" do
32
- it "iterates through rows correctly" do
33
- # rows inside a table
34
- inner_table = browser.table(:id, 'inner')
35
- count = 0
36
-
37
- inner_table.rows.each_with_index do |r, index|
38
- r.id.should == inner_table.row(:index, index).id
39
- r.value.should == inner_table.row(:index, index).value
40
-
41
- count += 1
42
- end
43
-
44
- count.should > 0
45
- # rows inside a table (should not include rows inside a table inside a table)
46
- outer_table = browser.table(:id, 'outer')
47
- count = 0
48
-
49
- outer_table.rows.each_with_index do |r, index|
50
- r.id.should == outer_table.row(:index, index).id
51
- r.value.should == outer_table.row(:index, index).value
52
-
53
- count += 1
54
- end
55
-
56
- count.should > 0
57
- end
58
- end
59
-
60
- end
@@ -1,116 +0,0 @@
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