capybara 2.9.0 → 2.10.0
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.
- checksums.yaml +4 -4
- data/History.md +23 -0
- data/README.md +37 -30
- data/lib/capybara/node/actions.rb +18 -15
- data/lib/capybara/node/base.rb +2 -2
- data/lib/capybara/node/element.rb +1 -1
- data/lib/capybara/node/finders.rb +37 -32
- data/lib/capybara/node/matchers.rb +187 -171
- data/lib/capybara/queries/match_query.rb +1 -3
- data/lib/capybara/queries/selector_query.rb +48 -19
- data/lib/capybara/rack_test/driver.rb +3 -3
- data/lib/capybara/rails.rb +1 -1
- data/lib/capybara/rspec/features.rb +1 -1
- data/lib/capybara/rspec/matchers.rb +31 -22
- data/lib/capybara/selector/css.rb +30 -0
- data/lib/capybara/selector/selector.rb +24 -1
- data/lib/capybara/selector.rb +22 -23
- data/lib/capybara/session.rb +4 -4
- data/lib/capybara/spec/session/accept_alert_spec.rb +4 -4
- data/lib/capybara/spec/session/accept_confirm_spec.rb +1 -1
- data/lib/capybara/spec/session/accept_prompt_spec.rb +5 -5
- data/lib/capybara/spec/session/all_spec.rb +27 -27
- data/lib/capybara/spec/session/assert_current_path.rb +2 -2
- data/lib/capybara/spec/session/assert_selector.rb +28 -28
- data/lib/capybara/spec/session/assert_text.rb +20 -20
- data/lib/capybara/spec/session/assert_title.rb +2 -2
- data/lib/capybara/spec/session/attach_file_spec.rb +2 -2
- data/lib/capybara/spec/session/check_spec.rb +19 -10
- data/lib/capybara/spec/session/choose_spec.rb +4 -4
- data/lib/capybara/spec/session/click_button_spec.rb +18 -5
- data/lib/capybara/spec/session/click_link_or_button_spec.rb +6 -6
- data/lib/capybara/spec/session/click_link_spec.rb +13 -13
- data/lib/capybara/spec/session/current_url_spec.rb +2 -2
- data/lib/capybara/spec/session/dismiss_confirm_spec.rb +1 -1
- data/lib/capybara/spec/session/dismiss_prompt_spec.rb +1 -1
- data/lib/capybara/spec/session/element/matches_selector_spec.rb +21 -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 +30 -30
- data/lib/capybara/spec/session/find_button_spec.rb +5 -5
- data/lib/capybara/spec/session/find_by_id_spec.rb +2 -2
- data/lib/capybara/spec/session/find_field_spec.rb +11 -7
- data/lib/capybara/spec/session/find_link_spec.rb +2 -2
- data/lib/capybara/spec/session/find_spec.rb +57 -48
- data/lib/capybara/spec/session/first_spec.rb +9 -9
- data/lib/capybara/spec/session/go_back_spec.rb +1 -1
- data/lib/capybara/spec/session/go_forward_spec.rb +1 -1
- data/lib/capybara/spec/session/has_button_spec.rb +12 -12
- data/lib/capybara/spec/session/has_css_spec.rb +73 -73
- data/lib/capybara/spec/session/has_current_path_spec.rb +2 -2
- data/lib/capybara/spec/session/has_field_spec.rb +78 -68
- data/lib/capybara/spec/session/has_link_spec.rb +8 -8
- data/lib/capybara/spec/session/has_select_spec.rb +70 -61
- data/lib/capybara/spec/session/has_selector_spec.rb +28 -28
- data/lib/capybara/spec/session/has_text_spec.rb +6 -6
- data/lib/capybara/spec/session/has_title_spec.rb +2 -2
- data/lib/capybara/spec/session/has_xpath_spec.rb +26 -26
- data/lib/capybara/spec/session/headers.rb +1 -1
- data/lib/capybara/spec/session/html_spec.rb +3 -3
- data/lib/capybara/spec/session/node_spec.rb +15 -15
- data/lib/capybara/spec/session/reset_session_spec.rb +4 -4
- data/lib/capybara/spec/session/response_code.rb +1 -1
- data/lib/capybara/spec/session/save_and_open_screenshot_spec.rb +3 -3
- data/lib/capybara/spec/session/screenshot_spec.rb +1 -1
- data/lib/capybara/spec/session/select_spec.rb +30 -30
- data/lib/capybara/spec/session/selectors_spec.rb +6 -2
- data/lib/capybara/spec/session/uncheck_spec.rb +2 -2
- data/lib/capybara/spec/session/unselect_spec.rb +14 -14
- data/lib/capybara/spec/session/visit_spec.rb +2 -2
- data/lib/capybara/spec/session/within_frame_spec.rb +2 -2
- data/lib/capybara/spec/session/within_spec.rb +6 -6
- data/lib/capybara/spec/spec_helper.rb +1 -1
- data/lib/capybara/spec/test_app.rb +1 -1
- data/lib/capybara/spec/views/form.erb +6 -3
- data/lib/capybara/version.rb +1 -1
- data/lib/capybara.rb +2 -2
- data/spec/basic_node_spec.rb +5 -5
- data/spec/capybara_spec.rb +1 -1
- data/spec/dsl_spec.rb +1 -1
- data/spec/rack_test_spec.rb +7 -7
- data/spec/rspec/matchers_spec.rb +6 -6
- data/spec/rspec_spec.rb +1 -1
- data/spec/selector_spec.rb +94 -3
- data/spec/selenium_firefox_spec.rb +1 -1
- data/spec/selenium_spec_chrome.rb +1 -1
- data/spec/shared_selenium_session.rb +10 -10
- metadata +3 -2
|
@@ -19,7 +19,7 @@ module Capybara
|
|
|
19
19
|
module SpecHelper
|
|
20
20
|
class << self
|
|
21
21
|
def configure(config)
|
|
22
|
-
config.filter_run_excluding :
|
|
22
|
+
config.filter_run_excluding requires: method(:filter).to_proc
|
|
23
23
|
config.before { Capybara::SpecHelper.reset! }
|
|
24
24
|
config.after { Capybara::SpecHelper.reset! }
|
|
25
25
|
# Test in 3.5+ where metadata doesn't autotrigger shared context inclusion - will be only behavior in RSpec 4
|
|
@@ -5,9 +5,9 @@
|
|
|
5
5
|
|
|
6
6
|
<p>
|
|
7
7
|
<label for="form_title">Title</label>
|
|
8
|
-
<select name="form[title]" id="form_title">
|
|
9
|
-
<option>Mrs</option>
|
|
10
|
-
<option>Mr</option>
|
|
8
|
+
<select name="form[title]" id="form_title" class="title">
|
|
9
|
+
<option class="title">Mrs</option>
|
|
10
|
+
<option class="title">Mr</option>
|
|
11
11
|
<option>Miss</option>
|
|
12
12
|
<option disabled="disabled">Other</option>
|
|
13
13
|
</select>
|
|
@@ -183,6 +183,8 @@ New line after and before textarea tag
|
|
|
183
183
|
<label for="form_cars_tesla">Tesla</label>
|
|
184
184
|
<input type="checkbox" value="ferrari" name="form[cars][]" id="form_cars_ferrari" checked="checked" style="display: none"/>
|
|
185
185
|
<label for="form_cars_ferrari">Ferrari</label>
|
|
186
|
+
<input type="checkbox" value="pagani" name="form[cars][]" id="form_cars_pagani" style="position: absolute; left: -9999px"/>
|
|
187
|
+
<label for="form_cars_pagani">Pagani</label>
|
|
186
188
|
<input type="checkbox" value="ariel" name="form[cars][]" id="form_cars_ariel" style="display: none"/>
|
|
187
189
|
<label>
|
|
188
190
|
McLaren
|
|
@@ -349,6 +351,7 @@ New line after and before textarea tag
|
|
|
349
351
|
<button type="submit" id="click_me_123" title="Click Title button" value="click_me">Click me!</button>
|
|
350
352
|
<button type="submit" name="form[no_value]">No Value!</button>
|
|
351
353
|
<button id="no_type">No Type!</button>
|
|
354
|
+
<button><img alt="A horse eating hay"/></button>
|
|
352
355
|
<input type="button" disabled="disabled" value="Disabled button"/>
|
|
353
356
|
</p>
|
|
354
357
|
|
data/lib/capybara/version.rb
CHANGED
data/lib/capybara.rb
CHANGED
|
@@ -225,7 +225,7 @@ module Capybara
|
|
|
225
225
|
# HTML
|
|
226
226
|
#
|
|
227
227
|
# node.find('#projects').text # => 'Projects'
|
|
228
|
-
# node.has_selector?('li#home', :
|
|
228
|
+
# node.has_selector?('li#home', text: 'Home')
|
|
229
229
|
# node.has_selector?('#projects')
|
|
230
230
|
# node.find('ul').find('li:first-child').text # => 'Home'
|
|
231
231
|
#
|
|
@@ -475,7 +475,7 @@ end
|
|
|
475
475
|
|
|
476
476
|
Capybara.register_server :webrick do |app, port, host|
|
|
477
477
|
require 'rack/handler/webrick'
|
|
478
|
-
Rack::Handler::WEBrick.run(app, :
|
|
478
|
+
Rack::Handler::WEBrick.run(app, Host: host, Port: port, AccessLog: [], Logger: WEBrick::Log::new(nil, 0))
|
|
479
479
|
end
|
|
480
480
|
|
|
481
481
|
Capybara.register_server :puma do |app, port, host|
|
data/spec/basic_node_spec.rb
CHANGED
|
@@ -69,13 +69,13 @@ RSpec.describe Capybara do
|
|
|
69
69
|
end
|
|
70
70
|
|
|
71
71
|
it "allows using matchers with text option" do
|
|
72
|
-
expect(string).to have_css('h1', :
|
|
73
|
-
expect(string).not_to have_css('h1', :
|
|
72
|
+
expect(string).to have_css('h1', text: 'Totally awesome')
|
|
73
|
+
expect(string).not_to have_css('h1', text: 'Not so awesome')
|
|
74
74
|
end
|
|
75
75
|
|
|
76
76
|
it "allows finding only visible nodes" do
|
|
77
|
-
expect(string.all(:css, '#secret', :
|
|
78
|
-
expect(string.all(:css, '#secret', :
|
|
77
|
+
expect(string.all(:css, '#secret', visible: true)).to be_empty
|
|
78
|
+
expect(string.all(:css, '#secret', visible: false).size).to eq(1)
|
|
79
79
|
end
|
|
80
80
|
|
|
81
81
|
it "allows finding elements and extracting text from them" do
|
|
@@ -101,7 +101,7 @@ RSpec.describe Capybara do
|
|
|
101
101
|
|
|
102
102
|
it "allows finding elements and checking if they are visible" do
|
|
103
103
|
expect(string.find('//h1')).to be_visible
|
|
104
|
-
expect(string.find(:css, "#secret", :
|
|
104
|
+
expect(string.find(:css, "#secret", visible: false)).not_to be_visible
|
|
105
105
|
end
|
|
106
106
|
|
|
107
107
|
it "allows finding elements and checking if they are disabled" do
|
data/spec/capybara_spec.rb
CHANGED
|
@@ -47,7 +47,7 @@ RSpec.describe Capybara do
|
|
|
47
47
|
|
|
48
48
|
it "should add a new server" do
|
|
49
49
|
Capybara.register_server :blob do |app, port, host|
|
|
50
|
-
Rack::Handler::WEBrick.run(app, :
|
|
50
|
+
Rack::Handler::WEBrick.run(app, Host: host, Port: port, AccessLog: [], Logger: WEBrick::Log::new(nil, 0))
|
|
51
51
|
end
|
|
52
52
|
Capybara.server = :blob
|
|
53
53
|
session = Capybara::Session.new(:selenium, TestApp.dup)
|
data/spec/dsl_spec.rb
CHANGED
data/spec/rack_test_spec.rb
CHANGED
|
@@ -5,7 +5,7 @@ module TestSessions
|
|
|
5
5
|
RackTest = Capybara::Session.new(:rack_test, TestApp)
|
|
6
6
|
end
|
|
7
7
|
|
|
8
|
-
Capybara::SpecHelper.run_specs TestSessions::RackTest, "RackTest", :
|
|
8
|
+
Capybara::SpecHelper.run_specs TestSessions::RackTest, "RackTest", capybara_skip: [
|
|
9
9
|
:js,
|
|
10
10
|
:modals,
|
|
11
11
|
:screenshot,
|
|
@@ -122,27 +122,27 @@ RSpec.describe Capybara::RackTest::Driver do
|
|
|
122
122
|
|
|
123
123
|
describe ':headers option' do
|
|
124
124
|
it 'should always set headers' do
|
|
125
|
-
@driver = Capybara::RackTest::Driver.new(TestApp, :
|
|
125
|
+
@driver = Capybara::RackTest::Driver.new(TestApp, headers: {'HTTP_FOO' => 'foobar'})
|
|
126
126
|
@driver.visit('/get_header')
|
|
127
127
|
expect(@driver.html).to include('foobar')
|
|
128
128
|
end
|
|
129
129
|
|
|
130
130
|
it 'should keep headers on link clicks' do
|
|
131
|
-
@driver = Capybara::RackTest::Driver.new(TestApp, :
|
|
131
|
+
@driver = Capybara::RackTest::Driver.new(TestApp, headers: {'HTTP_FOO' => 'foobar'})
|
|
132
132
|
@driver.visit('/header_links')
|
|
133
133
|
@driver.find_xpath('.//a').first.click
|
|
134
134
|
expect(@driver.html).to include('foobar')
|
|
135
135
|
end
|
|
136
136
|
|
|
137
137
|
it 'should keep headers on form submit' do
|
|
138
|
-
@driver = Capybara::RackTest::Driver.new(TestApp, :
|
|
138
|
+
@driver = Capybara::RackTest::Driver.new(TestApp, headers: {'HTTP_FOO' => 'foobar'})
|
|
139
139
|
@driver.visit('/header_links')
|
|
140
140
|
@driver.find_xpath('.//input').first.click
|
|
141
141
|
expect(@driver.html).to include('foobar')
|
|
142
142
|
end
|
|
143
143
|
|
|
144
144
|
it 'should keep headers on redirects' do
|
|
145
|
-
@driver = Capybara::RackTest::Driver.new(TestApp, :
|
|
145
|
+
@driver = Capybara::RackTest::Driver.new(TestApp, headers: {'HTTP_FOO' => 'foobar'})
|
|
146
146
|
@driver.visit('/get_header_via_redirect')
|
|
147
147
|
expect(@driver.html).to include('foobar')
|
|
148
148
|
end
|
|
@@ -158,7 +158,7 @@ RSpec.describe Capybara::RackTest::Driver do
|
|
|
158
158
|
end
|
|
159
159
|
|
|
160
160
|
it "is possible to not follow redirects" do
|
|
161
|
-
@driver = Capybara::RackTest::Driver.new(TestApp, :
|
|
161
|
+
@driver = Capybara::RackTest::Driver.new(TestApp, follow_redirects: false)
|
|
162
162
|
|
|
163
163
|
@driver.visit('/redirect')
|
|
164
164
|
expect(@driver.response.header['Location']).to match %r{/redirect_again$}
|
|
@@ -186,7 +186,7 @@ RSpec.describe Capybara::RackTest::Driver do
|
|
|
186
186
|
|
|
187
187
|
context "with 21 redirect limit" do
|
|
188
188
|
before do
|
|
189
|
-
@driver = Capybara::RackTest::Driver.new(TestApp, :
|
|
189
|
+
@driver = Capybara::RackTest::Driver.new(TestApp, redirect_limit: 21)
|
|
190
190
|
end
|
|
191
191
|
|
|
192
192
|
it "should follow 21 redirects" do
|
data/spec/rspec/matchers_spec.rb
CHANGED
|
@@ -25,7 +25,7 @@ RSpec.describe Capybara::RSpecMatchers do
|
|
|
25
25
|
end
|
|
26
26
|
|
|
27
27
|
it "passes if matched node count equals expected count" do
|
|
28
|
-
expect("<h1>Text</h1>").to have_css('h1', :
|
|
28
|
+
expect("<h1>Text</h1>").to have_css('h1', count: 1)
|
|
29
29
|
end
|
|
30
30
|
|
|
31
31
|
it "fails if matched node count does not equal expected count" do
|
|
@@ -66,12 +66,12 @@ RSpec.describe Capybara::RSpecMatchers do
|
|
|
66
66
|
end
|
|
67
67
|
|
|
68
68
|
it "passes if matched node count does not equal expected count" do
|
|
69
|
-
expect("<h1>Text</h1>").not_to have_css('h1', :
|
|
69
|
+
expect("<h1>Text</h1>").not_to have_css('h1', count: 2)
|
|
70
70
|
end
|
|
71
71
|
|
|
72
72
|
it "fails if matched node count equals expected count" do
|
|
73
73
|
expect do
|
|
74
|
-
expect("<h1>Text</h1>").not_to have_css('h1', :
|
|
74
|
+
expect("<h1>Text</h1>").not_to have_css('h1', count: 1)
|
|
75
75
|
end.to raise_error(/expected not to find css "h1"/)
|
|
76
76
|
end
|
|
77
77
|
end
|
|
@@ -220,7 +220,7 @@ RSpec.describe Capybara::RSpecMatchers do
|
|
|
220
220
|
|
|
221
221
|
context "with should" do
|
|
222
222
|
it "passes if has_selector? returns true" do
|
|
223
|
-
expect(page).to have_selector('//h1', :
|
|
223
|
+
expect(page).to have_selector('//h1', text: 'test')
|
|
224
224
|
end
|
|
225
225
|
|
|
226
226
|
it "fails if has_selector? returns false" do
|
|
@@ -231,7 +231,7 @@ RSpec.describe Capybara::RSpecMatchers do
|
|
|
231
231
|
|
|
232
232
|
it "includes text in error message" do
|
|
233
233
|
expect do
|
|
234
|
-
expect(page).to have_selector("//h1", :
|
|
234
|
+
expect(page).to have_selector("//h1", text: 'wrong text')
|
|
235
235
|
end.to raise_error(%r(expected to find xpath "//h1" with text "wrong text" but there were no matches))
|
|
236
236
|
end
|
|
237
237
|
end
|
|
@@ -243,7 +243,7 @@ RSpec.describe Capybara::RSpecMatchers do
|
|
|
243
243
|
|
|
244
244
|
it "fails if has_no_selector? returns false" do
|
|
245
245
|
expect do
|
|
246
|
-
expect(page).not_to have_selector(:css, 'h1', :
|
|
246
|
+
expect(page).not_to have_selector(:css, 'h1', text: 'test')
|
|
247
247
|
end.to raise_error(%r(expected not to find css "h1" with text "test"))
|
|
248
248
|
end
|
|
249
249
|
end
|
data/spec/rspec_spec.rb
CHANGED
|
@@ -29,7 +29,7 @@ RSpec.describe 'capybara/rspec', :type => :feature do
|
|
|
29
29
|
end
|
|
30
30
|
end
|
|
31
31
|
|
|
32
|
-
it "switches to the javascript driver when giving it as metadata", :
|
|
32
|
+
it "switches to the javascript driver when giving it as metadata", js: true do
|
|
33
33
|
expect(Capybara.current_driver).to eq(Capybara.javascript_driver)
|
|
34
34
|
end
|
|
35
35
|
|
data/spec/selector_spec.rb
CHANGED
|
@@ -18,10 +18,14 @@ RSpec.describe Capybara do
|
|
|
18
18
|
<p class="b">Some Content</p>
|
|
19
19
|
<p class="b"></p>
|
|
20
20
|
</div>
|
|
21
|
-
<
|
|
21
|
+
<div id="#special">
|
|
22
|
+
</div>
|
|
23
|
+
<input id="2checkbox" class="2checkbox" type="checkbox"/>
|
|
22
24
|
<input type="radio"/>
|
|
23
|
-
<
|
|
24
|
-
<input type="
|
|
25
|
+
<label for="my_text_input">My Text Input</label>
|
|
26
|
+
<input type="text" name="form[my_text_input]" placeholder="my text" id="my_text_input"/>
|
|
27
|
+
<input type="file" id="file" class=".special file"/>
|
|
28
|
+
<input type="hidden" id="hidden_field" value="this is hidden"/>
|
|
25
29
|
<a href="#">link</a>
|
|
26
30
|
<fieldset></fieldset>
|
|
27
31
|
<select>
|
|
@@ -42,6 +46,22 @@ RSpec.describe Capybara do
|
|
|
42
46
|
css { |css_class| "div.#{css_class}" }
|
|
43
47
|
filter(:not_empty, boolean: true, default: true, skip_if: :all) { |node, value| value ^ (node.text == '') }
|
|
44
48
|
end
|
|
49
|
+
|
|
50
|
+
Capybara.add_selector :custom_css_selector do
|
|
51
|
+
css { |selector| selector }
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
describe "adding a selector" do
|
|
56
|
+
it "can set default visiblity" do
|
|
57
|
+
Capybara.add_selector :hidden_field do
|
|
58
|
+
visible :hidden
|
|
59
|
+
css { |sel| 'input[type="hidden"]' }
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
expect(string).to have_no_css('input[type="hidden"]')
|
|
63
|
+
expect(string).to have_selector(:hidden_field)
|
|
64
|
+
end
|
|
45
65
|
end
|
|
46
66
|
|
|
47
67
|
describe "modify_selector" do
|
|
@@ -89,6 +109,77 @@ RSpec.describe Capybara do
|
|
|
89
109
|
end
|
|
90
110
|
end
|
|
91
111
|
|
|
112
|
+
context "with :id option" do
|
|
113
|
+
it "works with compound css selectors" do
|
|
114
|
+
expect(string.all(:custom_css_selector, "div, h1", id: 'page').size).to eq 1
|
|
115
|
+
expect(string.all(:custom_css_selector, "h1, div", id: 'page').size).to eq 1
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
it "works with 'special' characters" do
|
|
119
|
+
skip "We support old Nokogiris but they have their limits" if Gem::Version.new(Nokogiri::VERSION) < Gem::Version.new('1.6.8')
|
|
120
|
+
expect(string.find(:custom_css_selector, "div", id: "#special")[:id]).to eq '#special'
|
|
121
|
+
expect(string.find(:custom_css_selector, "input", id: "2checkbox")[:id]).to eq '2checkbox'
|
|
122
|
+
end
|
|
123
|
+
end
|
|
124
|
+
|
|
125
|
+
context "with :class option" do
|
|
126
|
+
it "works with compound css selectors" do
|
|
127
|
+
expect(string.all(:custom_css_selector, "div, h1", class: 'a').size).to eq 2
|
|
128
|
+
expect(string.all(:custom_css_selector, "h1, div", class: 'a').size).to eq 2
|
|
129
|
+
end
|
|
130
|
+
|
|
131
|
+
it "works with 'special' characters" do
|
|
132
|
+
skip "We support old Nokogiris but they have their limits" if Gem::Version.new(Nokogiri::VERSION) < Gem::Version.new('1.6.8')
|
|
133
|
+
expect(string.find(:custom_css_selector, "input", class: ".special")[:id]).to eq 'file'
|
|
134
|
+
expect(string.find(:custom_css_selector, "input", class: "2checkbox")[:id]).to eq '2checkbox'
|
|
135
|
+
end
|
|
136
|
+
end
|
|
137
|
+
|
|
138
|
+
# :css, :xpath, :id, :field, :fieldset, :link, :button, :link_or_button, :fillable_field, :radio_button, :checkbox, :select,
|
|
139
|
+
# :option, :file_field, :label, :table, :frame
|
|
140
|
+
|
|
141
|
+
describe ":css selector" do
|
|
142
|
+
it "finds by CSS locator" do
|
|
143
|
+
expect(string.find(:css, "input#my_text_input")[:name]).to eq 'form[my_text_input]'
|
|
144
|
+
end
|
|
145
|
+
end
|
|
146
|
+
|
|
147
|
+
describe ":xpath selector" do
|
|
148
|
+
it "finds by XPath locator" do
|
|
149
|
+
expect(string.find(:xpath, './/input[@id="my_text_input"]')[:name]).to eq 'form[my_text_input]'
|
|
150
|
+
end
|
|
151
|
+
end
|
|
152
|
+
|
|
153
|
+
describe ":id selector" do
|
|
154
|
+
it "finds by locator" do
|
|
155
|
+
expect(string.find(:id, "my_text_input")[:name]).to eq 'form[my_text_input]'
|
|
156
|
+
end
|
|
157
|
+
end
|
|
158
|
+
|
|
159
|
+
describe ":field selector" do
|
|
160
|
+
it "finds by locator" do
|
|
161
|
+
expect(string.find(:field, 'My Text Input')[:id]).to eq 'my_text_input'
|
|
162
|
+
expect(string.find(:field, 'my_text_input')[:id]).to eq 'my_text_input'
|
|
163
|
+
expect(string.find(:field, 'form[my_text_input]')[:id]).to eq 'my_text_input'
|
|
164
|
+
end
|
|
165
|
+
|
|
166
|
+
it "finds by id" do
|
|
167
|
+
expect(string.find(:field, id: 'my_text_input')[:name]).to eq 'form[my_text_input]'
|
|
168
|
+
end
|
|
169
|
+
|
|
170
|
+
it "finds by name" do
|
|
171
|
+
expect(string.find(:field, name: 'form[my_text_input]')[:id]).to eq 'my_text_input'
|
|
172
|
+
end
|
|
173
|
+
|
|
174
|
+
it "finds by placeholder" do
|
|
175
|
+
expect(string.find(:field, placeholder: 'my text')[:id]).to eq 'my_text_input'
|
|
176
|
+
end
|
|
177
|
+
|
|
178
|
+
it "finds by type" do
|
|
179
|
+
expect(string.find(:field, type: 'file')[:id]).to eq 'file'
|
|
180
|
+
end
|
|
181
|
+
end
|
|
182
|
+
|
|
92
183
|
describe ":option selector" do
|
|
93
184
|
it "finds disabled options" do
|
|
94
185
|
expect(string.find(:option, disabled: true).value).to eq 'b'
|
|
@@ -21,7 +21,7 @@ skipped_tests = [
|
|
|
21
21
|
]
|
|
22
22
|
skipped_tests << :windows if ENV['TRAVIS'] && !ENV['WINDOW_TEST']
|
|
23
23
|
|
|
24
|
-
Capybara::SpecHelper.run_specs TestSessions::Selenium, "selenium", :
|
|
24
|
+
Capybara::SpecHelper.run_specs TestSessions::Selenium, "selenium", capybara_skip: skipped_tests
|
|
25
25
|
|
|
26
26
|
RSpec.describe "Capybara::Session with firefox" do
|
|
27
27
|
include_examples "Capybara::Session", TestSessions::Selenium, :selenium_focus
|
|
@@ -12,7 +12,7 @@ module TestSessions
|
|
|
12
12
|
Chrome = Capybara::Session.new(:selenium_chrome, TestApp)
|
|
13
13
|
end
|
|
14
14
|
|
|
15
|
-
Capybara::SpecHelper.run_specs TestSessions::Chrome, "selenium_chrome", :
|
|
15
|
+
Capybara::SpecHelper.run_specs TestSessions::Chrome, "selenium_chrome", capybara_skip: [
|
|
16
16
|
:response_headers,
|
|
17
17
|
:status_code,
|
|
18
18
|
:trigger
|
|
@@ -62,37 +62,37 @@ RSpec.shared_examples "Capybara::Session" do |session, mode|
|
|
|
62
62
|
end
|
|
63
63
|
end
|
|
64
64
|
|
|
65
|
-
context "#fill_in with { :clear => :backspace } fill_option", :
|
|
65
|
+
context "#fill_in with { :clear => :backspace } fill_option", requires: [:js] do
|
|
66
66
|
it 'should fill in a field, replacing an existing value' do
|
|
67
67
|
@session.visit('/form')
|
|
68
|
-
@session.fill_in('form_first_name', :
|
|
68
|
+
@session.fill_in('form_first_name', with: 'Harry',
|
|
69
69
|
fill_options: { clear: :backspace} )
|
|
70
70
|
expect(@session.find(:fillable_field, 'form_first_name').value).to eq('Harry')
|
|
71
71
|
end
|
|
72
72
|
|
|
73
73
|
it 'should only trigger onchange once' do
|
|
74
74
|
@session.visit('/with_js')
|
|
75
|
-
@session.fill_in('with_change_event', :
|
|
76
|
-
:
|
|
75
|
+
@session.fill_in('with_change_event', with: 'some value',
|
|
76
|
+
fill_options: { :clear => :backspace })
|
|
77
77
|
# click outside the field to trigger the change event
|
|
78
78
|
@session.find(:css, 'body').click
|
|
79
|
-
expect(@session.find(:css, '.change_event_triggered', :
|
|
79
|
+
expect(@session.find(:css, '.change_event_triggered', match: :one)).to have_text 'some value'
|
|
80
80
|
end
|
|
81
81
|
|
|
82
82
|
it 'should trigger change when clearing field' do
|
|
83
83
|
@session.visit('/with_js')
|
|
84
|
-
@session.fill_in('with_change_event', :
|
|
85
|
-
:
|
|
84
|
+
@session.fill_in('with_change_event', with: '',
|
|
85
|
+
fill_options: { :clear => :backspace })
|
|
86
86
|
# click outside the field to trigger the change event
|
|
87
87
|
@session.find(:css, 'body').click
|
|
88
|
-
expect(@session).to have_selector(:css, '.change_event_triggered', :
|
|
88
|
+
expect(@session).to have_selector(:css, '.change_event_triggered', match: :one)
|
|
89
89
|
end
|
|
90
90
|
end
|
|
91
91
|
|
|
92
92
|
context "#fill_in with { clear: :none } fill_options" do
|
|
93
93
|
it 'should append to content in a field' do
|
|
94
94
|
@session.visit('/form')
|
|
95
|
-
@session.fill_in('form_first_name', :
|
|
95
|
+
@session.fill_in('form_first_name', with: 'Harry',
|
|
96
96
|
fill_options: { clear: :none} )
|
|
97
97
|
expect(@session.find(:fillable_field, 'form_first_name').value).to eq('JohnHarry')
|
|
98
98
|
end
|
|
@@ -102,7 +102,7 @@ RSpec.shared_examples "Capybara::Session" do |session, mode|
|
|
|
102
102
|
it 'should pass the array through to the element' do
|
|
103
103
|
#this is mainly for use with [[:ctrl, 'a'], :backspace] - however since that is platform dependant I'm testing with something less useful
|
|
104
104
|
@session.visit('/form')
|
|
105
|
-
@session.fill_in('form_first_name', :
|
|
105
|
+
@session.fill_in('form_first_name', with: 'Harry',
|
|
106
106
|
fill_options: { clear: [[:shift, 'abc'], :backspace] } )
|
|
107
107
|
expect(@session.find(:fillable_field, 'form_first_name').value).to eq('JohnABHarry')
|
|
108
108
|
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: capybara
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 2.
|
|
4
|
+
version: 2.10.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Thomas Walpole
|
|
@@ -10,7 +10,7 @@ autorequire:
|
|
|
10
10
|
bindir: bin
|
|
11
11
|
cert_chain:
|
|
12
12
|
- gem-public_cert.pem
|
|
13
|
-
date: 2016-
|
|
13
|
+
date: 2016-10-05 00:00:00.000000000 Z
|
|
14
14
|
dependencies:
|
|
15
15
|
- !ruby/object:Gem::Dependency
|
|
16
16
|
name: nokogiri
|
|
@@ -284,6 +284,7 @@ files:
|
|
|
284
284
|
- lib/capybara/rspec/features.rb
|
|
285
285
|
- lib/capybara/rspec/matchers.rb
|
|
286
286
|
- lib/capybara/selector.rb
|
|
287
|
+
- lib/capybara/selector/css.rb
|
|
287
288
|
- lib/capybara/selector/filter.rb
|
|
288
289
|
- lib/capybara/selector/filter_set.rb
|
|
289
290
|
- lib/capybara/selector/selector.rb
|