capybara-js_finders 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,153 @@
1
+ <html>
2
+ <head>
3
+ <script type="text/javascript" src="js/prototype.js"></script>
4
+ </head>
5
+
6
+ <body>
7
+ <table cellpadding="15" cellspacing="15" border="2">
8
+ <tr>
9
+ <td>
10
+ *
11
+ </td>
12
+
13
+ <td>
14
+ OneColumn
15
+ </td>
16
+
17
+ <td colspan="2">
18
+ TwoColumns
19
+ </td>
20
+
21
+ <td colspan="3">
22
+ ThreeColumns
23
+ </td>
24
+ </tr>
25
+
26
+ <tr>
27
+ <td>
28
+ OneRow
29
+ </td>
30
+
31
+ <td style="background-color: red;">
32
+ red
33
+ </td>
34
+
35
+ <td colspan="2" style="background-color: blue;">
36
+ hor
37
+ </td>
38
+
39
+ <td style="background-color: CadetBlue;">
40
+ CadetBlue
41
+ </td>
42
+ <td style="background-color: Chocolate;">
43
+ Chocolate
44
+ </td>
45
+ <td style="background-color: DarkGoldenRod;">
46
+ DarkGoldenRod
47
+ </td>
48
+ </tr>
49
+
50
+ <tr>
51
+ <td rowspan="2">
52
+ TwoRows
53
+ </td>
54
+
55
+ <td rowspan="2" style="background-color: Wheat ;">
56
+ ver
57
+ </td>
58
+
59
+ <td colspan="2" rowspan="2" style="background-color: YellowGreen ;">
60
+ sqr
61
+ </td>
62
+
63
+ <td style="background-color: Sienna ;">
64
+ Sienna
65
+ </td>
66
+
67
+ <td style="background-color: Silver ;">
68
+ Silver
69
+ </td>
70
+ <td style="background-color: Snow ;">
71
+ Snow
72
+ </td>
73
+ </tr>
74
+
75
+ <tr>
76
+ <td style="background-color: Tan;" rowspan="2">
77
+ Tan
78
+ </td>
79
+ <td style="background-color: Teal ;">
80
+ Teal
81
+ </td>
82
+ <td style="background-color: Tomato ;">
83
+ Tomato
84
+ </td>
85
+ </tr>
86
+
87
+ <tr>
88
+ <td rowspan="3">
89
+ ThreeRows
90
+ </td>
91
+
92
+ <td style="background-color: Crimson ;">
93
+ Crimson
94
+ </td>
95
+ <td style="background-color: DarkGray ;">
96
+ DarkGray
97
+ </td>
98
+ <td style="background-color: DarkKhaki ;">
99
+ DarkKhaki
100
+ </td>
101
+ <td style="background-color: DarkOliveGreen ;">
102
+ DarkOliveGreen
103
+ </td>
104
+ <td style="background-color: Darkorange ;">
105
+ Darkorange
106
+ </td>
107
+ </tr>
108
+
109
+ <tr>
110
+ <td style="background-color: DarkSalmon ;">
111
+ DarkSalmon
112
+ </td>
113
+ <td style="background-color: DarkSeaGreen;">
114
+ DarkSeaGreen
115
+ </td>
116
+ <td style="background-color: DeepPink ;" colspan="2">
117
+ DeepPink
118
+ </td>
119
+ <td style="background-color: Green ;">
120
+ Green
121
+ </td>
122
+ <td style="background-color: Lavender ;">
123
+ Lavender
124
+ </td>
125
+ </tr>
126
+
127
+ <tr>
128
+ <td style="background-color: MediumAquaMarine ;">
129
+ MediumAquaMarine
130
+ </td>
131
+ <td style="background-color: Maroon ;">
132
+ Maroon
133
+ </td>
134
+ <td style="background-color: NavajoWhite ;">
135
+ NavajoWhite
136
+ </td>
137
+
138
+ <td style="background-color: Orchid ;">
139
+ Orchid
140
+ </td>
141
+ <td style="background-color: Peru ;">
142
+ Peru
143
+ </td>
144
+ <td style="background-color: SandyBrown ;">
145
+ SandyBrown
146
+ </td>
147
+ </tr>
148
+
149
+ </table>
150
+
151
+ </body>
152
+
153
+ </html>
@@ -0,0 +1,93 @@
1
+ require 'test_helper'
2
+ require 'unit/find_cell_tests/app/app'
3
+
4
+ module FindCellTests
5
+
6
+ class BasicTest < Bbq::TestCase
7
+
8
+ attr_reader :user
9
+
10
+ setup do
11
+ Capybara.app = App
12
+ Capybara.default_wait_time = 0.1
13
+ @user = Bbq::TestUser.new(:driver => :selenium, :session_name => :default)
14
+ end
15
+
16
+ def test_respond_to
17
+ user.visit '/'
18
+ assert user.find('table').respond_to?(:find_cell)
19
+ assert user.respond_to?(:find_cell)
20
+ end
21
+
22
+ def test_find_cell
23
+ user.visit '/'
24
+
25
+ # First row
26
+ assert user.find_cell(:row => "OneRow", :column => "OneColumn").has_content?("red")
27
+ assert user.find_cell(:row => "OneRow", :column => "OneColumn", :text => "red").has_content?("red")
28
+
29
+ assert user.find_cell(:row => "OneRow", :column => "TwoColumns").has_content?("hor")
30
+ assert user.find_cell(:row => "OneRow", :column => "TwoColumns", :text => "hor").has_content?("hor")
31
+
32
+ assert user.find_cell(:row => "OneRow", :column => "ThreeColumns").has_content?("CadetBlue")
33
+ assert user.find_cell(:row => "OneRow", :column => "ThreeColumns", :text => "Chocolate").has_content?("Chocolate")
34
+
35
+ # Second row
36
+ assert user.find_cell(:row => "TwoRows", :column => "OneColumn").has_content?("ver")
37
+ assert user.find_cell(:row => "TwoRows", :column => "OneColumn", :text => "ver").has_content?("ver")
38
+
39
+ assert user.find_cell(:row => "TwoRows", :column => "TwoColumns").has_content?("sqr")
40
+ assert user.find_cell(:row => "TwoRows", :column => "TwoColumns", :text => "sqr").has_content?("sqr")
41
+
42
+ assert user.find_cell(:row => "TwoRows", :column => "ThreeColumns").has_content?("Sienna")
43
+ assert user.find_cell(:row => "TwoRows", :column => "ThreeColumns", :text => "Tan").has_content?("Tan")
44
+ assert user.find_cell(:row => "TwoRows", :column => "ThreeColumns", :text => "Tomato").has_content?("Tomato")
45
+
46
+ # Third row
47
+ assert user.find_cell(:row => "ThreeRows", :column => "OneColumn").has_content?("Crimson")
48
+ assert user.find_cell(:row => "ThreeRows", :column => "OneColumn", :text => "DarkSalmon").has_content?("DarkSalmon")
49
+
50
+ assert user.find_cell(:row => "ThreeRows", :column => "TwoColumns").has_content?("DarkGray")
51
+ assert user.find_cell(:row => "ThreeRows", :column => "TwoColumns", :text => "NavajoWhite").has_content?("NavajoWhite")
52
+ assert user.find_cell(:row => "ThreeRows", :column => "TwoColumns", :text => "DeepPink").has_content?("DeepPink")
53
+
54
+ assert user.find_cell(:row => "ThreeRows", :column => "ThreeColumns").has_content?("Tan")
55
+ assert user.find_cell(:row => "ThreeRows", :column => "ThreeColumns", :text => "Green").has_content?("Green")
56
+ assert user.find_cell(:row => "ThreeRows", :column => "ThreeColumns", :text => "SandyBrown").has_content?("SandyBrown")
57
+ assert user.find_cell(:row => "ThreeRows", :column => "ThreeColumns", :text => "DeepPink").has_content?("DeepPink")
58
+ assert user.find_cell(:row => "ThreeRows", :column => "ThreeColumns", :text => "Tan").has_content?("Tan")
59
+
60
+ # Test matching multiple rows and columns
61
+ assert user.find_cell(:multicolumn => true, :multirow => true, :row => "Row", :column => "Column").has_content?("red")
62
+ assert user.find_cell(:multicolumn => true, :multirow => true, :row => "Rows", :column => "Columns").has_content?("sqr")
63
+ assert user.find_cell(:multicolumn => true, :multirow => true, :row => "Rows", :column => "Columns", :text => "Tan").has_content?("Tan")
64
+ assert user.find_cell(:multicolumn => true, :multirow => true, :row => "Rows", :column => "Columns", :text => "DeepPink").has_content?("DeepPink")
65
+ assert user.find_cell(:multicolumn => true, :multirow => true, :row => "Rows", :column => "Columns", :text => "Peru").has_content?("Peru")
66
+ assert user.find_cell(:multicolumn => true, :multirow => true, :row => "Rows", :column => "Columns", :text => "Snow").has_content?("Snow")
67
+ end
68
+
69
+ def test_find_cell_not_found
70
+ assert_not_found{ user.find_cell(:row => "OneRow", :column => "OneColumn", :text => "hor") }
71
+ assert_not_found{ user.find_cell(:row => "OneRow", :column => "OneColumn", :text => "ver") }
72
+
73
+ assert_not_found{ user.find_cell(:row => "ThreeRows", :column => "OneColumn", :text => "DeepPink") }
74
+ assert_not_found{ user.find_cell(:row => "OneRow", :column => "ThreeColumns", :text => "Tan") }
75
+ assert_not_found{ user.find_cell(:multicolumn => false, :multirow => true, :row => "Rows", :column => "Columns", :text => "SandyBrown") }
76
+ assert_not_found{ user.find_cell(:multicolumn => true, :multirow => false, :row => "Rows", :column => "Columns", :text => "SandyBrown") }
77
+ end
78
+
79
+ def test_find_cell_without_row_or_column
80
+ assert user.find_cell(:row => "OneRow", :text => "red").has_content?("red")
81
+ assert user.find_cell(:column => "OneColumn", :text => "red").has_content?("red")
82
+ end
83
+
84
+
85
+ private
86
+
87
+
88
+ def assert_not_found(&block)
89
+ assert_raise(Capybara::ElementNotFound, &block)
90
+ end
91
+
92
+ end
93
+ end
metadata ADDED
@@ -0,0 +1,162 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: capybara-js_finders
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.2.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Robert Pankowecki
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2011-07-18 00:00:00.000000000Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: capybara
16
+ requirement: &79594120 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: 1.0.0
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: *79594120
25
+ - !ruby/object:Gem::Dependency
26
+ name: rake
27
+ requirement: &79593870 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ~>
31
+ - !ruby/object:Gem::Version
32
+ version: 0.9.0
33
+ type: :development
34
+ prerelease: false
35
+ version_requirements: *79593870
36
+ - !ruby/object:Gem::Dependency
37
+ name: rdoc
38
+ requirement: &79593610 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ! '>='
42
+ - !ruby/object:Gem::Version
43
+ version: 2.4.2
44
+ type: :development
45
+ prerelease: false
46
+ version_requirements: *79593610
47
+ - !ruby/object:Gem::Dependency
48
+ name: sinatra
49
+ requirement: &79593310 !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: 1.2.6
55
+ type: :development
56
+ prerelease: false
57
+ version_requirements: *79593310
58
+ - !ruby/object:Gem::Dependency
59
+ name: erubis
60
+ requirement: &79593010 !ruby/object:Gem::Requirement
61
+ none: false
62
+ requirements:
63
+ - - ~>
64
+ - !ruby/object:Gem::Version
65
+ version: 2.6.6
66
+ type: :development
67
+ prerelease: false
68
+ version_requirements: *79593010
69
+ - !ruby/object:Gem::Dependency
70
+ name: bbq
71
+ requirement: &79592650 !ruby/object:Gem::Requirement
72
+ none: false
73
+ requirements:
74
+ - - ~>
75
+ - !ruby/object:Gem::Version
76
+ version: 0.0.3
77
+ type: :development
78
+ prerelease: false
79
+ version_requirements: *79592650
80
+ - !ruby/object:Gem::Dependency
81
+ name: redcarpet
82
+ requirement: &79592230 !ruby/object:Gem::Requirement
83
+ none: false
84
+ requirements:
85
+ - - ~>
86
+ - !ruby/object:Gem::Version
87
+ version: '1.17'
88
+ type: :development
89
+ prerelease: false
90
+ version_requirements: *79592230
91
+ - !ruby/object:Gem::Dependency
92
+ name: ruby-debug19
93
+ requirement: &79592030 !ruby/object:Gem::Requirement
94
+ none: false
95
+ requirements:
96
+ - - ! '>='
97
+ - !ruby/object:Gem::Version
98
+ version: '0'
99
+ type: :development
100
+ prerelease: false
101
+ version_requirements: *79592030
102
+ description: ! " Additional finders for capybara that for some reason\n cannot
103
+ use only xpath for finding nodes but needs to\n execute js for some calculations.\n\n
104
+ \ Ex: I you want to find a table cell\n that is under or next to other cell
105
+ the easiest way to do it is to\n check their position on page and compare them.
106
+ This way you do not\n need to wory about calculating the effects of using colspan
107
+ \n and rowspan attributes.\n\n The downside is that you need to use capybara
108
+ driver that runs\n a browser like selenium.\n"
109
+ email:
110
+ - robert.pankowecki@gmail.com
111
+ - rpa@gavdi.com
112
+ executables: []
113
+ extensions: []
114
+ extra_rdoc_files: []
115
+ files:
116
+ - .gitignore
117
+ - Gemfile
118
+ - LICENSE
119
+ - README.md
120
+ - Rakefile
121
+ - capybara-js_finders.gemspec
122
+ - lib/capybara-js_finders.rb
123
+ - lib/capybara-js_finders/capybara_extensions.rb
124
+ - lib/capybara-js_finders/version.rb
125
+ - lib/capybara-js_finders/xpath_extensions.rb
126
+ - test/test_helper.rb
127
+ - test/unit/find_cell_tests/app/app.rb
128
+ - test/unit/find_cell_tests/app/public/js/prototype.js
129
+ - test/unit/find_cell_tests/app/views/table.erubis
130
+ - test/unit/find_cell_tests/basic_test.rb
131
+ homepage: https://github.com/paneq/capybara-js_finders
132
+ licenses: []
133
+ post_install_message:
134
+ rdoc_options: []
135
+ require_paths:
136
+ - lib
137
+ required_ruby_version: !ruby/object:Gem::Requirement
138
+ none: false
139
+ requirements:
140
+ - - ! '>='
141
+ - !ruby/object:Gem::Version
142
+ version: '0'
143
+ segments:
144
+ - 0
145
+ hash: -918427759
146
+ required_rubygems_version: !ruby/object:Gem::Requirement
147
+ none: false
148
+ requirements:
149
+ - - ! '>='
150
+ - !ruby/object:Gem::Version
151
+ version: '0'
152
+ segments:
153
+ - 0
154
+ hash: -918427759
155
+ requirements: []
156
+ rubyforge_project: capybara-js_finders
157
+ rubygems_version: 1.8.5
158
+ signing_key:
159
+ specification_version: 3
160
+ summary: Additional finders for capybara that for some reason cannot use only xpath
161
+ for finding nodes but needs to execute js for some calculations
162
+ test_files: []