capybara 2.2.1 → 2.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/History.md +26 -0
- data/README.md +36 -14
- data/lib/capybara.rb +6 -3
- data/lib/capybara/driver/base.rb +37 -1
- data/lib/capybara/driver/node.rb +10 -2
- data/lib/capybara/helpers.rb +21 -13
- data/lib/capybara/node/base.rb +12 -7
- data/lib/capybara/node/element.rb +17 -1
- data/lib/capybara/node/finders.rb +22 -1
- data/lib/capybara/node/matchers.rb +26 -5
- data/lib/capybara/node/simple.rb +9 -2
- data/lib/capybara/rack_test/css_handlers.rb +3 -1
- data/lib/capybara/rack_test/form.rb +3 -2
- data/lib/capybara/rack_test/node.rb +3 -3
- data/lib/capybara/rspec.rb +1 -0
- data/lib/capybara/rspec/features.rb +2 -1
- data/lib/capybara/rspec/matchers.rb +50 -5
- data/lib/capybara/selenium/driver.rb +76 -12
- data/lib/capybara/selenium/node.rb +8 -0
- data/lib/capybara/server.rb +1 -1
- data/lib/capybara/session.rb +234 -29
- data/lib/capybara/spec/public/jquery.js +1 -1
- data/lib/capybara/spec/public/test.js +7 -0
- data/lib/capybara/spec/session/all_spec.rb +88 -17
- data/lib/capybara/spec/session/assert_selector.rb +6 -0
- data/lib/capybara/spec/session/attach_file_spec.rb +15 -15
- data/lib/capybara/spec/session/body_spec.rb +4 -4
- data/lib/capybara/spec/session/check_spec.rb +16 -16
- data/lib/capybara/spec/session/choose_spec.rb +5 -5
- data/lib/capybara/spec/session/click_button_spec.rb +93 -84
- data/lib/capybara/spec/session/click_link_or_button_spec.rb +8 -8
- data/lib/capybara/spec/session/click_link_spec.rb +26 -19
- data/lib/capybara/spec/session/current_scope_spec.rb +3 -3
- data/lib/capybara/spec/session/current_url_spec.rb +8 -8
- data/lib/capybara/spec/session/evaluate_script_spec.rb +1 -1
- data/lib/capybara/spec/session/execute_script_spec.rb +2 -2
- data/lib/capybara/spec/session/fill_in_spec.rb +22 -22
- data/lib/capybara/spec/session/find_button_spec.rb +4 -4
- data/lib/capybara/spec/session/find_by_id_spec.rb +3 -3
- data/lib/capybara/spec/session/find_field_spec.rb +7 -7
- data/lib/capybara/spec/session/find_link_spec.rb +4 -4
- data/lib/capybara/spec/session/find_spec.rb +46 -46
- data/lib/capybara/spec/session/first_spec.rb +23 -23
- data/lib/capybara/spec/session/go_back_spec.rb +3 -3
- data/lib/capybara/spec/session/go_forward_spec.rb +4 -4
- data/lib/capybara/spec/session/has_button_spec.rb +13 -13
- data/lib/capybara/spec/session/has_css_spec.rb +87 -87
- data/lib/capybara/spec/session/has_field_spec.rb +87 -87
- data/lib/capybara/spec/session/has_link_spec.rb +11 -11
- data/lib/capybara/spec/session/has_select_spec.rb +58 -58
- data/lib/capybara/spec/session/has_selector_spec.rb +48 -48
- data/lib/capybara/spec/session/has_table_spec.rb +7 -7
- data/lib/capybara/spec/session/has_text_spec.rb +73 -73
- data/lib/capybara/spec/session/has_title_spec.rb +10 -10
- data/lib/capybara/spec/session/has_xpath_spec.rb +44 -44
- data/lib/capybara/spec/session/headers.rb +1 -1
- data/lib/capybara/spec/session/html_spec.rb +9 -9
- data/lib/capybara/spec/session/node_spec.rb +81 -65
- data/lib/capybara/spec/session/reset_session_spec.rb +15 -15
- data/lib/capybara/spec/session/response_code.rb +1 -1
- data/lib/capybara/spec/session/save_and_open_screenshot_spec.rb +46 -0
- data/lib/capybara/spec/session/save_page_spec.rb +9 -9
- data/lib/capybara/spec/session/{screenshot.rb → screenshot_spec.rb} +4 -2
- data/lib/capybara/spec/session/select_spec.rb +22 -22
- data/lib/capybara/spec/session/text_spec.rb +15 -10
- data/lib/capybara/spec/session/title_spec.rb +2 -2
- data/lib/capybara/spec/session/uncheck_spec.rb +7 -7
- data/lib/capybara/spec/session/unselect_spec.rb +14 -14
- data/lib/capybara/spec/session/visit_spec.rb +24 -17
- data/lib/capybara/spec/session/window/become_closed_spec.rb +84 -0
- data/lib/capybara/spec/session/window/current_window_spec.rb +25 -0
- data/lib/capybara/spec/session/window/open_new_window_spec.rb +28 -0
- data/lib/capybara/spec/session/window/switch_to_window_spec.rb +114 -0
- data/lib/capybara/spec/session/window/window_opened_by_spec.rb +83 -0
- data/lib/capybara/spec/session/window/window_spec.rb +141 -0
- data/lib/capybara/spec/session/window/windows_spec.rb +31 -0
- data/lib/capybara/spec/session/window/within_window_spec.rb +188 -0
- data/lib/capybara/spec/session/within_frame_spec.rb +9 -9
- data/lib/capybara/spec/session/within_spec.rb +16 -16
- data/lib/capybara/spec/spec_helper.rb +14 -4
- data/lib/capybara/spec/views/form.erb +7 -0
- data/lib/capybara/spec/views/popup_one.erb +1 -1
- data/lib/capybara/spec/views/popup_two.erb +1 -1
- data/lib/capybara/spec/views/with_js.erb +2 -0
- data/lib/capybara/spec/views/with_windows.erb +38 -0
- data/lib/capybara/version.rb +1 -1
- data/lib/capybara/window.rb +123 -0
- data/spec/basic_node_spec.rb +32 -32
- data/spec/capybara_spec.rb +6 -7
- data/spec/dsl_spec.rb +48 -48
- data/spec/fixtures/selenium_driver_rspec_failure.rb +2 -2
- data/spec/fixtures/selenium_driver_rspec_success.rb +2 -2
- data/spec/rack_test_spec.rb +33 -19
- data/spec/result_spec.rb +13 -13
- data/spec/rspec/features_spec.rb +20 -15
- data/spec/rspec/matchers_spec.rb +109 -109
- data/spec/rspec_spec.rb +10 -10
- data/spec/selenium_spec.rb +31 -6
- data/spec/selenium_spec_chrome.rb +2 -2
- data/spec/server_spec.rb +13 -13
- metadata +51 -62
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/lib/capybara/spec/session/within_window_spec.rb +0 -45
- data/lib/capybara/spec/views/within_popups.erb +0 -25
- metadata.gz.sig +0 -0
@@ -4,15 +4,15 @@ Capybara::SpecHelper.spec '#has_link?' do
|
|
4
4
|
end
|
5
5
|
|
6
6
|
it "should be true if the given link is on the page" do
|
7
|
-
@session.
|
8
|
-
@session.
|
9
|
-
@session.
|
10
|
-
@session.
|
7
|
+
expect(@session).to have_link('foo')
|
8
|
+
expect(@session).to have_link('awesome title')
|
9
|
+
expect(@session).to have_link('A link', :href => '/with_simple_html')
|
10
|
+
expect(@session).to have_link(:'A link', :href => :'/with_simple_html')
|
11
11
|
end
|
12
12
|
|
13
13
|
it "should be false if the given link is not on the page" do
|
14
|
-
@session.
|
15
|
-
@session.
|
14
|
+
expect(@session).not_to have_link('monkey')
|
15
|
+
expect(@session).not_to have_link('A link', :href => '/non-existant-href')
|
16
16
|
end
|
17
17
|
end
|
18
18
|
|
@@ -22,13 +22,13 @@ Capybara::SpecHelper.spec '#has_no_link?' do
|
|
22
22
|
end
|
23
23
|
|
24
24
|
it "should be false if the given link is on the page" do
|
25
|
-
@session.
|
26
|
-
@session.
|
27
|
-
@session.
|
25
|
+
expect(@session).not_to have_no_link('foo')
|
26
|
+
expect(@session).not_to have_no_link('awesome title')
|
27
|
+
expect(@session).not_to have_no_link('A link', :href => '/with_simple_html')
|
28
28
|
end
|
29
29
|
|
30
30
|
it "should be true if the given link is not on the page" do
|
31
|
-
@session.
|
32
|
-
@session.
|
31
|
+
expect(@session).to have_no_link('monkey')
|
32
|
+
expect(@session).to have_no_link('A link', :href => '/non-existant-href')
|
33
33
|
end
|
34
34
|
end
|
@@ -2,60 +2,60 @@ Capybara::SpecHelper.spec '#has_select?' do
|
|
2
2
|
before { @session.visit('/form') }
|
3
3
|
|
4
4
|
it "should be true if the field is on the page" do
|
5
|
-
@session.
|
6
|
-
@session.
|
7
|
-
@session.
|
8
|
-
@session.
|
5
|
+
expect(@session).to have_select('Locale')
|
6
|
+
expect(@session).to have_select('form_region')
|
7
|
+
expect(@session).to have_select('Languages')
|
8
|
+
expect(@session).to have_select(:'Languages')
|
9
9
|
end
|
10
10
|
|
11
11
|
it "should be false if the field is not on the page" do
|
12
|
-
@session.
|
12
|
+
expect(@session).not_to have_select('Monkey')
|
13
13
|
end
|
14
14
|
|
15
15
|
context 'with selected value' do
|
16
16
|
it "should be true if a field with the given value is on the page" do
|
17
|
-
@session.
|
18
|
-
@session.
|
19
|
-
@session.
|
17
|
+
expect(@session).to have_select('form_locale', :selected => 'English')
|
18
|
+
expect(@session).to have_select('Region', :selected => 'Norway')
|
19
|
+
expect(@session).to have_select('Underwear', :selected => [
|
20
20
|
'Boxerbriefs', 'Briefs', 'Commando', "Frenchman's Pantalons", 'Long Johns'
|
21
21
|
])
|
22
22
|
end
|
23
23
|
|
24
24
|
it "should be false if the given field is not on the page" do
|
25
|
-
@session.
|
26
|
-
@session.
|
27
|
-
@session.
|
28
|
-
@session.
|
25
|
+
expect(@session).not_to have_select('Locale', :selected => 'Swedish')
|
26
|
+
expect(@session).not_to have_select('Does not exist', :selected => 'John')
|
27
|
+
expect(@session).not_to have_select('City', :selected => 'Not there')
|
28
|
+
expect(@session).not_to have_select('Underwear', :selected => [
|
29
29
|
'Boxerbriefs', 'Briefs', 'Commando', "Frenchman's Pantalons", 'Long Johns', 'Nonexistant'
|
30
30
|
])
|
31
|
-
@session.
|
31
|
+
expect(@session).not_to have_select('Underwear', :selected => [
|
32
32
|
'Boxerbriefs', 'Briefs', 'Boxers', 'Commando', "Frenchman's Pantalons", 'Long Johns'
|
33
33
|
])
|
34
|
-
@session.
|
34
|
+
expect(@session).not_to have_select('Underwear', :selected => [
|
35
35
|
'Boxerbriefs', 'Briefs','Commando', "Frenchman's Pantalons"
|
36
36
|
])
|
37
37
|
end
|
38
38
|
|
39
39
|
it "should be true after the given value is selected" do
|
40
40
|
@session.select('Swedish', :from => 'Locale')
|
41
|
-
@session.
|
41
|
+
expect(@session).to have_select('Locale', :selected => 'Swedish')
|
42
42
|
end
|
43
43
|
|
44
44
|
it "should be false after a different value is selected" do
|
45
45
|
@session.select('Swedish', :from => 'Locale')
|
46
|
-
@session.
|
46
|
+
expect(@session).not_to have_select('Locale', :selected => 'English')
|
47
47
|
end
|
48
48
|
|
49
49
|
it "should be true after the given values are selected" do
|
50
50
|
@session.select('Boxers', :from => 'Underwear')
|
51
|
-
@session.
|
51
|
+
expect(@session).to have_select('Underwear', :selected => [
|
52
52
|
'Boxerbriefs', 'Briefs', 'Boxers', 'Commando', "Frenchman's Pantalons", 'Long Johns'
|
53
53
|
])
|
54
54
|
end
|
55
55
|
|
56
56
|
it "should be false after one of the values is unselected" do
|
57
57
|
@session.unselect('Briefs', :from => 'Underwear')
|
58
|
-
@session.
|
58
|
+
expect(@session).not_to have_select('Underwear', :selected => [
|
59
59
|
'Boxerbriefs', 'Briefs', 'Commando', "Frenchman's Pantalons", 'Long Johns'
|
60
60
|
])
|
61
61
|
end
|
@@ -63,29 +63,29 @@ Capybara::SpecHelper.spec '#has_select?' do
|
|
63
63
|
|
64
64
|
context 'with exact options' do
|
65
65
|
it "should be true if a field with the given options is on the page" do
|
66
|
-
@session.
|
67
|
-
@session.
|
66
|
+
expect(@session).to have_select('Region', :options => ['Norway', 'Sweden', 'Finland'])
|
67
|
+
expect(@session).to have_select('Tendency', :options => [])
|
68
68
|
end
|
69
69
|
|
70
70
|
it "should be false if the given field is not on the page" do
|
71
|
-
@session.
|
72
|
-
@session.
|
73
|
-
@session.
|
74
|
-
@session.
|
75
|
-
@session.
|
71
|
+
expect(@session).not_to have_select('Locale', :options => ['Swedish'])
|
72
|
+
expect(@session).not_to have_select('Does not exist', :options => ['John'])
|
73
|
+
expect(@session).not_to have_select('City', :options => ['London', 'Made up city'])
|
74
|
+
expect(@session).not_to have_select('Region', :options => ['Norway', 'Sweden'])
|
75
|
+
expect(@session).not_to have_select('Region', :options => ['Norway', 'Norway', 'Norway'])
|
76
76
|
end
|
77
77
|
end
|
78
78
|
|
79
79
|
context 'with partial options' do
|
80
80
|
it "should be true if a field with the given partial options is on the page" do
|
81
|
-
@session.
|
82
|
-
@session.
|
81
|
+
expect(@session).to have_select('Region', :with_options => ['Norway', 'Sweden'])
|
82
|
+
expect(@session).to have_select('City', :with_options => ['London'])
|
83
83
|
end
|
84
84
|
|
85
85
|
it "should be false if a field with the given partial options is not on the page" do
|
86
|
-
@session.
|
87
|
-
@session.
|
88
|
-
@session.
|
86
|
+
expect(@session).not_to have_select('Locale', :with_options => ['Uruguayan'])
|
87
|
+
expect(@session).not_to have_select('Does not exist', :with_options => ['John'])
|
88
|
+
expect(@session).not_to have_select('Region', :with_options => ['Norway', 'Sweden', 'Finland', 'Latvia'])
|
89
89
|
end
|
90
90
|
end
|
91
91
|
end
|
@@ -94,59 +94,59 @@ Capybara::SpecHelper.spec '#has_no_select?' do
|
|
94
94
|
before { @session.visit('/form') }
|
95
95
|
|
96
96
|
it "should be false if the field is on the page" do
|
97
|
-
@session.
|
98
|
-
@session.
|
99
|
-
@session.
|
97
|
+
expect(@session).not_to have_no_select('Locale')
|
98
|
+
expect(@session).not_to have_no_select('form_region')
|
99
|
+
expect(@session).not_to have_no_select('Languages')
|
100
100
|
end
|
101
101
|
|
102
102
|
it "should be true if the field is not on the page" do
|
103
|
-
@session.
|
103
|
+
expect(@session).to have_no_select('Monkey')
|
104
104
|
end
|
105
105
|
|
106
106
|
context 'with selected value' do
|
107
107
|
it "should be false if a field with the given value is on the page" do
|
108
|
-
@session.
|
109
|
-
@session.
|
110
|
-
@session.
|
108
|
+
expect(@session).not_to have_no_select('form_locale', :selected => 'English')
|
109
|
+
expect(@session).not_to have_no_select('Region', :selected => 'Norway')
|
110
|
+
expect(@session).not_to have_no_select('Underwear', :selected => [
|
111
111
|
'Boxerbriefs', 'Briefs', 'Commando', "Frenchman's Pantalons", 'Long Johns'
|
112
112
|
])
|
113
113
|
end
|
114
114
|
|
115
115
|
it "should be true if the given field is not on the page" do
|
116
|
-
@session.
|
117
|
-
@session.
|
118
|
-
@session.
|
119
|
-
@session.
|
116
|
+
expect(@session).to have_no_select('Locale', :selected => 'Swedish')
|
117
|
+
expect(@session).to have_no_select('Does not exist', :selected => 'John')
|
118
|
+
expect(@session).to have_no_select('City', :selected => 'Not there')
|
119
|
+
expect(@session).to have_no_select('Underwear', :selected => [
|
120
120
|
'Boxerbriefs', 'Briefs', 'Commando', "Frenchman's Pantalons", 'Long Johns', 'Nonexistant'
|
121
121
|
])
|
122
|
-
@session.
|
122
|
+
expect(@session).to have_no_select('Underwear', :selected => [
|
123
123
|
'Boxerbriefs', 'Briefs', 'Boxers', 'Commando', "Frenchman's Pantalons", 'Long Johns'
|
124
124
|
])
|
125
|
-
@session.
|
125
|
+
expect(@session).to have_no_select('Underwear', :selected => [
|
126
126
|
'Boxerbriefs', 'Briefs','Commando', "Frenchman's Pantalons"
|
127
127
|
])
|
128
128
|
end
|
129
129
|
|
130
130
|
it "should be false after the given value is selected" do
|
131
131
|
@session.select('Swedish', :from => 'Locale')
|
132
|
-
@session.
|
132
|
+
expect(@session).not_to have_no_select('Locale', :selected => 'Swedish')
|
133
133
|
end
|
134
134
|
|
135
135
|
it "should be true after a different value is selected" do
|
136
136
|
@session.select('Swedish', :from => 'Locale')
|
137
|
-
@session.
|
137
|
+
expect(@session).to have_no_select('Locale', :selected => 'English')
|
138
138
|
end
|
139
139
|
|
140
140
|
it "should be false after the given values are selected" do
|
141
141
|
@session.select('Boxers', :from => 'Underwear')
|
142
|
-
@session.
|
142
|
+
expect(@session).not_to have_no_select('Underwear', :selected => [
|
143
143
|
'Boxerbriefs', 'Briefs', 'Boxers', 'Commando', "Frenchman's Pantalons", 'Long Johns'
|
144
144
|
])
|
145
145
|
end
|
146
146
|
|
147
147
|
it "should be true after one of the values is unselected" do
|
148
148
|
@session.unselect('Briefs', :from => 'Underwear')
|
149
|
-
@session.
|
149
|
+
expect(@session).to have_no_select('Underwear', :selected => [
|
150
150
|
'Boxerbriefs', 'Briefs', 'Commando', "Frenchman's Pantalons", 'Long Johns'
|
151
151
|
])
|
152
152
|
end
|
@@ -154,28 +154,28 @@ Capybara::SpecHelper.spec '#has_no_select?' do
|
|
154
154
|
|
155
155
|
context 'with exact options' do
|
156
156
|
it "should be false if a field with the given options is on the page" do
|
157
|
-
@session.
|
157
|
+
expect(@session).not_to have_no_select('Region', :options => ['Norway', 'Sweden', 'Finland'])
|
158
158
|
end
|
159
159
|
|
160
160
|
it "should be true if the given field is not on the page" do
|
161
|
-
@session.
|
162
|
-
@session.
|
163
|
-
@session.
|
164
|
-
@session.
|
165
|
-
@session.
|
161
|
+
expect(@session).to have_no_select('Locale', :options => ['Swedish'])
|
162
|
+
expect(@session).to have_no_select('Does not exist', :options => ['John'])
|
163
|
+
expect(@session).to have_no_select('City', :options => ['London', 'Made up city'])
|
164
|
+
expect(@session).to have_no_select('Region', :options => ['Norway', 'Sweden'])
|
165
|
+
expect(@session).to have_no_select('Region', :options => ['Norway', 'Norway', 'Norway'])
|
166
166
|
end
|
167
167
|
end
|
168
168
|
|
169
169
|
context 'with partial options' do
|
170
170
|
it "should be false if a field with the given partial options is on the page" do
|
171
|
-
@session.
|
172
|
-
@session.
|
171
|
+
expect(@session).not_to have_no_select('Region', :with_options => ['Norway', 'Sweden'])
|
172
|
+
expect(@session).not_to have_no_select('City', :with_options => ['London'])
|
173
173
|
end
|
174
174
|
|
175
175
|
it "should be true if a field with the given partial options is not on the page" do
|
176
|
-
@session.
|
177
|
-
@session.
|
178
|
-
@session.
|
176
|
+
expect(@session).to have_no_select('Locale', :with_options => ['Uruguayan'])
|
177
|
+
expect(@session).to have_no_select('Does not exist', :with_options => ['John'])
|
178
|
+
expect(@session).to have_no_select('Region', :with_options => ['Norway', 'Sweden', 'Finland', 'Latvia'])
|
179
179
|
end
|
180
180
|
end
|
181
181
|
end
|
@@ -4,67 +4,67 @@ Capybara::SpecHelper.spec '#has_selector?' do
|
|
4
4
|
end
|
5
5
|
|
6
6
|
it "should be true if the given selector is on the page" do
|
7
|
-
@session.
|
8
|
-
@session.
|
9
|
-
@session.
|
7
|
+
expect(@session).to have_selector(:xpath, "//p")
|
8
|
+
expect(@session).to have_selector(:css, "p a#foo")
|
9
|
+
expect(@session).to have_selector("//p[contains(.,'est')]")
|
10
10
|
end
|
11
11
|
|
12
12
|
it "should be false if the given selector is not on the page" do
|
13
|
-
@session.
|
14
|
-
@session.
|
15
|
-
@session.
|
13
|
+
expect(@session).not_to have_selector(:xpath, "//abbr")
|
14
|
+
expect(@session).not_to have_selector(:css, "p a#doesnotexist")
|
15
|
+
expect(@session).not_to have_selector("//p[contains(.,'thisstringisnotonpage')]")
|
16
16
|
end
|
17
17
|
|
18
18
|
it "should use default selector" do
|
19
19
|
Capybara.default_selector = :css
|
20
|
-
@session.
|
21
|
-
@session.
|
20
|
+
expect(@session).not_to have_selector("p a#doesnotexist")
|
21
|
+
expect(@session).to have_selector("p a#foo")
|
22
22
|
end
|
23
23
|
|
24
24
|
it "should respect scopes" do
|
25
25
|
@session.within "//p[@id='first']" do
|
26
|
-
@session.
|
27
|
-
@session.
|
26
|
+
expect(@session).to have_selector(".//a[@id='foo']")
|
27
|
+
expect(@session).not_to have_selector(".//a[@id='red']")
|
28
28
|
end
|
29
29
|
end
|
30
30
|
|
31
31
|
context "with count" do
|
32
32
|
it "should be true if the content is on the page the given number of times" do
|
33
|
-
@session.
|
34
|
-
@session.
|
35
|
-
@session.
|
33
|
+
expect(@session).to have_selector("//p", :count => 3)
|
34
|
+
expect(@session).to have_selector("//p//a[@id='foo']", :count => 1)
|
35
|
+
expect(@session).to have_selector("//p[contains(.,'est')]", :count => 1)
|
36
36
|
end
|
37
37
|
|
38
38
|
it "should be false if the content is on the page the given number of times" do
|
39
|
-
@session.
|
40
|
-
@session.
|
41
|
-
@session.
|
39
|
+
expect(@session).not_to have_selector("//p", :count => 6)
|
40
|
+
expect(@session).not_to have_selector("//p//a[@id='foo']", :count => 2)
|
41
|
+
expect(@session).not_to have_selector("//p[contains(.,'est')]", :count => 5)
|
42
42
|
end
|
43
43
|
|
44
44
|
it "should be false if the content isn't on the page at all" do
|
45
|
-
@session.
|
46
|
-
@session.
|
45
|
+
expect(@session).not_to have_selector("//abbr", :count => 2)
|
46
|
+
expect(@session).not_to have_selector("//p//a[@id='doesnotexist']", :count => 1)
|
47
47
|
end
|
48
48
|
end
|
49
49
|
|
50
50
|
context "with text" do
|
51
51
|
it "should discard all matches where the given string is not contained" do
|
52
|
-
@session.
|
53
|
-
@session.
|
52
|
+
expect(@session).to have_selector("//p//a", :text => "Redirect", :count => 1)
|
53
|
+
expect(@session).not_to have_selector("//p", :text => "Doesnotexist")
|
54
54
|
end
|
55
55
|
|
56
56
|
it "should respect visibility setting" do
|
57
|
-
@session.
|
58
|
-
@session.
|
57
|
+
expect(@session).to have_selector(:id, "hidden-text", :text => "Some of this text is hidden!", :visible => false)
|
58
|
+
expect(@session).not_to have_selector(:id, "hidden-text", :text => "Some of this text is hidden!", :visible => true)
|
59
59
|
Capybara.ignore_hidden_elements = false
|
60
|
-
@session.
|
60
|
+
expect(@session).to have_selector(:id, "hidden-text", :text => "Some of this text is hidden!", :visible => false)
|
61
61
|
Capybara.visible_text_only = true
|
62
|
-
@session.
|
62
|
+
expect(@session).not_to have_selector(:id, "hidden-text", :text => "Some of this text is hidden!", :visible => true)
|
63
63
|
end
|
64
64
|
|
65
65
|
it "should discard all matches where the given regexp is not matched" do
|
66
|
-
@session.
|
67
|
-
@session.
|
66
|
+
expect(@session).to have_selector("//p//a", :text => /re[dab]i/i, :count => 1)
|
67
|
+
expect(@session).not_to have_selector("//p//a", :text => /Red$/)
|
68
68
|
end
|
69
69
|
end
|
70
70
|
end
|
@@ -75,58 +75,58 @@ Capybara::SpecHelper.spec '#has_no_selector?' do
|
|
75
75
|
end
|
76
76
|
|
77
77
|
it "should be false if the given selector is on the page" do
|
78
|
-
@session.
|
79
|
-
@session.
|
80
|
-
@session.
|
78
|
+
expect(@session).not_to have_no_selector(:xpath, "//p")
|
79
|
+
expect(@session).not_to have_no_selector(:css, "p a#foo")
|
80
|
+
expect(@session).not_to have_no_selector("//p[contains(.,'est')]")
|
81
81
|
end
|
82
82
|
|
83
83
|
it "should be true if the given selector is not on the page" do
|
84
|
-
@session.
|
85
|
-
@session.
|
86
|
-
@session.
|
84
|
+
expect(@session).to have_no_selector(:xpath, "//abbr")
|
85
|
+
expect(@session).to have_no_selector(:css, "p a#doesnotexist")
|
86
|
+
expect(@session).to have_no_selector("//p[contains(.,'thisstringisnotonpage')]")
|
87
87
|
end
|
88
88
|
|
89
89
|
it "should use default selector" do
|
90
90
|
Capybara.default_selector = :css
|
91
|
-
@session.
|
92
|
-
@session.
|
91
|
+
expect(@session).to have_no_selector("p a#doesnotexist")
|
92
|
+
expect(@session).not_to have_no_selector("p a#foo")
|
93
93
|
end
|
94
94
|
|
95
95
|
it "should respect scopes" do
|
96
96
|
@session.within "//p[@id='first']" do
|
97
|
-
@session.
|
98
|
-
@session.
|
97
|
+
expect(@session).not_to have_no_selector(".//a[@id='foo']")
|
98
|
+
expect(@session).to have_no_selector(".//a[@id='red']")
|
99
99
|
end
|
100
100
|
end
|
101
101
|
|
102
102
|
context "with count" do
|
103
103
|
it "should be false if the content is on the page the given number of times" do
|
104
|
-
@session.
|
105
|
-
@session.
|
106
|
-
@session.
|
104
|
+
expect(@session).not_to have_no_selector("//p", :count => 3)
|
105
|
+
expect(@session).not_to have_no_selector("//p//a[@id='foo']", :count => 1)
|
106
|
+
expect(@session).not_to have_no_selector("//p[contains(.,'est')]", :count => 1)
|
107
107
|
end
|
108
108
|
|
109
109
|
it "should be true if the content is on the page the wrong number of times" do
|
110
|
-
@session.
|
111
|
-
@session.
|
112
|
-
@session.
|
110
|
+
expect(@session).to have_no_selector("//p", :count => 6)
|
111
|
+
expect(@session).to have_no_selector("//p//a[@id='foo']", :count => 2)
|
112
|
+
expect(@session).to have_no_selector("//p[contains(.,'est')]", :count => 5)
|
113
113
|
end
|
114
114
|
|
115
115
|
it "should be true if the content isn't on the page at all" do
|
116
|
-
@session.
|
117
|
-
@session.
|
116
|
+
expect(@session).to have_no_selector("//abbr", :count => 2)
|
117
|
+
expect(@session).to have_no_selector("//p//a[@id='doesnotexist']", :count => 1)
|
118
118
|
end
|
119
119
|
end
|
120
120
|
|
121
121
|
context "with text" do
|
122
122
|
it "should discard all matches where the given string is contained" do
|
123
|
-
@session.
|
124
|
-
@session.
|
123
|
+
expect(@session).not_to have_no_selector("//p//a", :text => "Redirect", :count => 1)
|
124
|
+
expect(@session).to have_no_selector("//p", :text => "Doesnotexist")
|
125
125
|
end
|
126
126
|
|
127
127
|
it "should discard all matches where the given regexp is matched" do
|
128
|
-
@session.
|
129
|
-
@session.
|
128
|
+
expect(@session).not_to have_no_selector("//p//a", :text => /re[dab]i/i, :count => 1)
|
129
|
+
expect(@session).to have_no_selector("//p//a", :text => /Red$/)
|
130
130
|
end
|
131
131
|
end
|
132
132
|
end
|