capybara 2.6.2 → 2.7.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 +40 -15
- data/README.md +45 -38
- data/lib/capybara.rb +86 -10
- data/lib/capybara/cucumber.rb +1 -0
- data/lib/capybara/driver/base.rb +5 -2
- data/lib/capybara/driver/node.rb +1 -0
- data/lib/capybara/dsl.rb +1 -0
- data/lib/capybara/helpers.rb +3 -2
- data/lib/capybara/node/actions.rb +6 -0
- data/lib/capybara/node/base.rb +1 -0
- data/lib/capybara/node/document.rb +1 -0
- data/lib/capybara/node/document_matchers.rb +1 -0
- data/lib/capybara/node/element.rb +1 -0
- data/lib/capybara/node/finders.rb +3 -2
- data/lib/capybara/node/matchers.rb +72 -2
- data/lib/capybara/node/simple.rb +6 -3
- data/lib/capybara/queries/base_query.rb +1 -0
- data/lib/capybara/queries/current_path_query.rb +1 -0
- data/lib/capybara/queries/match_query.rb +21 -0
- data/lib/capybara/queries/selector_query.rb +138 -0
- data/lib/capybara/queries/text_query.rb +1 -0
- data/lib/capybara/queries/title_query.rb +1 -0
- data/lib/capybara/query.rb +3 -131
- data/lib/capybara/rack_test/browser.rb +1 -0
- data/lib/capybara/rack_test/css_handlers.rb +1 -0
- data/lib/capybara/rack_test/driver.rb +6 -4
- data/lib/capybara/rack_test/form.rb +1 -0
- data/lib/capybara/rack_test/node.rb +1 -0
- data/lib/capybara/rails.rb +2 -1
- data/lib/capybara/result.rb +1 -0
- data/lib/capybara/rspec.rb +1 -0
- data/lib/capybara/rspec/features.rb +1 -0
- data/lib/capybara/rspec/matchers.rb +54 -3
- data/lib/capybara/selector.rb +175 -75
- data/lib/capybara/selector/filter.rb +48 -0
- data/lib/capybara/selenium/driver.rb +24 -7
- data/lib/capybara/selenium/node.rb +1 -0
- data/lib/capybara/server.rb +38 -6
- data/lib/capybara/session.rb +30 -14
- data/lib/capybara/session/matchers.rb +2 -1
- data/lib/capybara/spec/public/test.js +6 -0
- data/lib/capybara/spec/session/accept_alert_spec.rb +2 -1
- data/lib/capybara/spec/session/accept_confirm_spec.rb +2 -1
- data/lib/capybara/spec/session/accept_prompt_spec.rb +2 -1
- data/lib/capybara/spec/session/all_spec.rb +1 -0
- data/lib/capybara/spec/session/assert_current_path.rb +1 -0
- data/lib/capybara/spec/session/assert_selector.rb +1 -0
- data/lib/capybara/spec/session/assert_text.rb +1 -0
- data/lib/capybara/spec/session/assert_title.rb +1 -0
- data/lib/capybara/spec/session/attach_file_spec.rb +1 -0
- data/lib/capybara/spec/session/body_spec.rb +1 -0
- data/lib/capybara/spec/session/check_spec.rb +1 -0
- data/lib/capybara/spec/session/choose_spec.rb +1 -0
- data/lib/capybara/spec/session/click_button_spec.rb +1 -0
- data/lib/capybara/spec/session/click_link_or_button_spec.rb +1 -0
- data/lib/capybara/spec/session/click_link_spec.rb +1 -0
- data/lib/capybara/spec/session/current_scope_spec.rb +2 -1
- data/lib/capybara/spec/session/current_url_spec.rb +1 -0
- data/lib/capybara/spec/session/dismiss_confirm_spec.rb +2 -1
- data/lib/capybara/spec/session/dismiss_prompt_spec.rb +2 -1
- data/lib/capybara/spec/session/element/assert_match_selector.rb +31 -0
- data/lib/capybara/spec/session/element/match_css_spec.rb +17 -0
- data/lib/capybara/spec/session/element/match_xpath_spec.rb +23 -0
- data/lib/capybara/spec/session/element/matches_selector_spec.rb +63 -0
- data/lib/capybara/spec/session/evaluate_script_spec.rb +1 -0
- data/lib/capybara/spec/session/execute_script_spec.rb +1 -0
- data/lib/capybara/spec/session/fill_in_spec.rb +1 -0
- data/lib/capybara/spec/session/find_button_spec.rb +1 -0
- data/lib/capybara/spec/session/find_by_id_spec.rb +1 -0
- data/lib/capybara/spec/session/find_field_spec.rb +1 -0
- data/lib/capybara/spec/session/find_link_spec.rb +1 -0
- data/lib/capybara/spec/session/find_spec.rb +1 -0
- data/lib/capybara/spec/session/first_spec.rb +1 -0
- data/lib/capybara/spec/session/go_back_spec.rb +1 -0
- data/lib/capybara/spec/session/go_forward_spec.rb +1 -0
- data/lib/capybara/spec/session/has_button_spec.rb +1 -0
- data/lib/capybara/spec/session/has_css_spec.rb +1 -0
- data/lib/capybara/spec/session/has_current_path_spec.rb +1 -0
- data/lib/capybara/spec/session/has_field_spec.rb +13 -0
- data/lib/capybara/spec/session/has_link_spec.rb +1 -0
- data/lib/capybara/spec/session/has_select_spec.rb +19 -0
- data/lib/capybara/spec/session/has_selector_spec.rb +6 -0
- data/lib/capybara/spec/session/has_table_spec.rb +1 -0
- data/lib/capybara/spec/session/has_text_spec.rb +1 -0
- data/lib/capybara/spec/session/has_title_spec.rb +1 -0
- data/lib/capybara/spec/session/has_xpath_spec.rb +1 -0
- data/lib/capybara/spec/session/headers.rb +1 -0
- data/lib/capybara/spec/session/html_spec.rb +1 -0
- data/lib/capybara/spec/session/node_spec.rb +29 -0
- data/lib/capybara/spec/session/reset_session_spec.rb +35 -1
- data/lib/capybara/spec/session/response_code.rb +1 -0
- data/lib/capybara/spec/session/save_and_open_page_spec.rb +1 -0
- data/lib/capybara/spec/session/save_and_open_screenshot_spec.rb +3 -2
- data/lib/capybara/spec/session/save_page_spec.rb +34 -2
- data/lib/capybara/spec/session/save_screenshot_spec.rb +31 -1
- data/lib/capybara/spec/session/screenshot_spec.rb +3 -1
- data/lib/capybara/spec/session/select_spec.rb +1 -0
- data/lib/capybara/spec/session/selectors_spec.rb +35 -0
- data/lib/capybara/spec/session/text_spec.rb +1 -0
- data/lib/capybara/spec/session/title_spec.rb +2 -1
- data/lib/capybara/spec/session/uncheck_spec.rb +1 -0
- data/lib/capybara/spec/session/unselect_spec.rb +1 -0
- data/lib/capybara/spec/session/visit_spec.rb +1 -0
- data/lib/capybara/spec/session/window/become_closed_spec.rb +1 -0
- data/lib/capybara/spec/session/window/current_window_spec.rb +1 -0
- data/lib/capybara/spec/session/window/open_new_window_spec.rb +1 -0
- data/lib/capybara/spec/session/window/switch_to_window_spec.rb +1 -0
- data/lib/capybara/spec/session/window/window_opened_by_spec.rb +1 -0
- data/lib/capybara/spec/session/window/window_spec.rb +1 -8
- data/lib/capybara/spec/session/window/windows_spec.rb +1 -0
- data/lib/capybara/spec/session/window/within_window_spec.rb +2 -3
- data/lib/capybara/spec/session/within_frame_spec.rb +1 -0
- data/lib/capybara/spec/session/within_spec.rb +1 -0
- data/lib/capybara/spec/spec_helper.rb +2 -0
- data/lib/capybara/spec/test_app.rb +1 -0
- data/lib/capybara/spec/views/buttons.erb +1 -0
- data/lib/capybara/spec/views/fieldsets.erb +2 -1
- data/lib/capybara/spec/views/form.erb +24 -0
- data/lib/capybara/spec/views/frame_child.erb +2 -1
- data/lib/capybara/spec/views/frame_one.erb +2 -1
- data/lib/capybara/spec/views/frame_parent.erb +2 -1
- data/lib/capybara/spec/views/frame_two.erb +2 -1
- data/lib/capybara/spec/views/header_links.erb +1 -0
- data/lib/capybara/spec/views/host_links.erb +1 -0
- data/lib/capybara/spec/views/path.erb +1 -0
- data/lib/capybara/spec/views/popup_one.erb +1 -0
- data/lib/capybara/spec/views/popup_two.erb +1 -0
- data/lib/capybara/spec/views/postback.erb +2 -1
- data/lib/capybara/spec/views/tables.erb +1 -0
- data/lib/capybara/spec/views/with_base_tag.erb +1 -0
- data/lib/capybara/spec/views/with_count.erb +2 -1
- data/lib/capybara/spec/views/with_hover.erb +2 -1
- data/lib/capybara/spec/views/with_html.erb +3 -0
- data/lib/capybara/spec/views/with_html_entities.erb +1 -0
- data/lib/capybara/spec/views/with_js.erb +5 -0
- data/lib/capybara/spec/views/with_scope.erb +1 -0
- data/lib/capybara/spec/views/with_simple_html.erb +2 -1
- data/lib/capybara/spec/views/with_slow_unload.erb +17 -0
- data/lib/capybara/spec/views/with_title.erb +2 -1
- data/lib/capybara/spec/views/with_unload_alert.erb +12 -0
- data/lib/capybara/spec/views/with_windows.erb +1 -0
- data/lib/capybara/spec/views/within_frames.erb +2 -1
- data/lib/capybara/version.rb +2 -1
- data/lib/capybara/window.rb +1 -0
- data/spec/basic_node_spec.rb +1 -0
- data/spec/capybara_spec.rb +28 -1
- data/spec/dsl_spec.rb +1 -0
- data/spec/fixtures/selenium_driver_rspec_failure.rb +1 -0
- data/spec/fixtures/selenium_driver_rspec_success.rb +1 -0
- data/spec/rack_test_spec.rb +1 -0
- data/spec/result_spec.rb +1 -0
- data/spec/rspec/features_spec.rb +1 -0
- data/spec/rspec/matchers_spec.rb +1 -0
- data/spec/rspec/scenarios_spec.rb +1 -0
- data/spec/rspec/views_spec.rb +1 -0
- data/spec/rspec_spec.rb +1 -0
- data/spec/selector_spec.rb +55 -1
- data/spec/selenium_spec.rb +6 -2
- data/spec/selenium_spec_chrome.rb +1 -0
- data/spec/server_spec.rb +101 -13
- data/spec/spec_helper.rb +1 -0
- metadata +16 -6
@@ -0,0 +1,48 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
module Capybara
|
3
|
+
class Selector
|
4
|
+
class Filter
|
5
|
+
def initialize(name, block, options={})
|
6
|
+
@name = name
|
7
|
+
@block = block
|
8
|
+
@options = options
|
9
|
+
@options[:valid_values] = [true,false] if options[:boolean]
|
10
|
+
end
|
11
|
+
|
12
|
+
def default?
|
13
|
+
@options.has_key?(:default)
|
14
|
+
end
|
15
|
+
|
16
|
+
def default
|
17
|
+
@options[:default]
|
18
|
+
end
|
19
|
+
|
20
|
+
def matches?(node, value)
|
21
|
+
return true if skip?(value)
|
22
|
+
|
23
|
+
if !valid_value?(value)
|
24
|
+
msg = "Invalid value #{value.inspect} passed to filter #{@name} - "
|
25
|
+
if default?
|
26
|
+
warn msg + "defaulting to #{default}"
|
27
|
+
value = default
|
28
|
+
else
|
29
|
+
warn msg + "skipping"
|
30
|
+
return true
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
@block.call(node, value)
|
35
|
+
end
|
36
|
+
|
37
|
+
def skip?(value)
|
38
|
+
@options.has_key?(:skip_if) && value == @options[:skip_if]
|
39
|
+
end
|
40
|
+
|
41
|
+
private
|
42
|
+
|
43
|
+
def valid_value?(value)
|
44
|
+
!@options.has_key?(:valid_values) || Array(@options[:valid_values]).include?(value)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
@@ -1,3 +1,4 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
require "uri"
|
2
3
|
|
3
4
|
class Capybara::Selenium::Driver < Capybara::Driver::Base
|
@@ -91,20 +92,35 @@ class Capybara::Selenium::Driver < Capybara::Driver::Base
|
|
91
92
|
def reset!
|
92
93
|
# Use instance variable directly so we avoid starting the browser just to reset the session
|
93
94
|
if @browser
|
95
|
+
navigated = false
|
96
|
+
start_time = Capybara::Helpers.monotonic_time
|
94
97
|
begin
|
95
|
-
|
96
|
-
|
97
|
-
#
|
98
|
-
|
99
|
-
|
98
|
+
if !navigated
|
99
|
+
# Only trigger a navigation if we haven't done it already, otherwise it
|
100
|
+
# can trigger an endless series of unload modals
|
101
|
+
begin
|
102
|
+
@browser.manage.delete_all_cookies
|
103
|
+
rescue Selenium::WebDriver::Error::UnhandledError
|
104
|
+
# delete_all_cookies fails when we've previously gone
|
105
|
+
# to about:blank, so we rescue this error and do nothing
|
106
|
+
# instead.
|
107
|
+
end
|
108
|
+
@browser.navigate.to("about:blank")
|
109
|
+
end
|
110
|
+
navigated = true
|
111
|
+
|
112
|
+
#Ensure the page is empty and trigger an UnhandledAlertError for any modals that appear during unload
|
113
|
+
until find_xpath("/html/body/*").empty? do
|
114
|
+
raise Capybara::ExpectationNotMet.new('Timed out waiting for Selenium session reset') if (Capybara::Helpers.monotonic_time - start_time) >= 10
|
115
|
+
sleep 0.05
|
100
116
|
end
|
101
|
-
@browser.navigate.to("about:blank")
|
102
117
|
rescue Selenium::WebDriver::Error::UnhandledAlertError
|
103
118
|
# This error is thrown if an unhandled alert is on the page
|
104
119
|
# Firefox appears to automatically dismiss this alert, chrome does not
|
105
120
|
# We'll try to accept it
|
106
121
|
begin
|
107
122
|
@browser.switch_to.alert.accept
|
123
|
+
sleep 0.25 # allow time for the modal to be handled
|
108
124
|
rescue Selenium::WebDriver::Error::NoAlertPresentError
|
109
125
|
# The alert is now gone - nothing to do
|
110
126
|
end
|
@@ -247,8 +263,9 @@ class Capybara::Selenium::Driver < Capybara::Driver::Base
|
|
247
263
|
Selenium::WebDriver::Error::NoSuchWindowError
|
248
264
|
end
|
249
265
|
|
266
|
+
# @deprecated This method is being removed
|
250
267
|
def browser_initialized?
|
251
|
-
!@browser.nil?
|
268
|
+
super && !@browser.nil?
|
252
269
|
end
|
253
270
|
|
254
271
|
private
|
data/lib/capybara/server.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
require 'uri'
|
2
3
|
require 'net/http'
|
3
4
|
require 'rack'
|
@@ -5,21 +6,46 @@ require 'rack'
|
|
5
6
|
module Capybara
|
6
7
|
class Server
|
7
8
|
class Middleware
|
9
|
+
class Counter
|
10
|
+
attr_reader :value
|
11
|
+
|
12
|
+
def initialize
|
13
|
+
@value = 0
|
14
|
+
@mutex = Mutex.new
|
15
|
+
end
|
16
|
+
|
17
|
+
def increment
|
18
|
+
@mutex.synchronize { @value += 1 }
|
19
|
+
end
|
20
|
+
|
21
|
+
def decrement
|
22
|
+
@mutex.synchronize { @value -= 1 }
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
8
26
|
attr_accessor :error
|
9
27
|
|
10
28
|
def initialize(app)
|
11
29
|
@app = app
|
30
|
+
@counter = Counter.new
|
31
|
+
end
|
32
|
+
|
33
|
+
def pending_requests?
|
34
|
+
@counter.value > 0
|
12
35
|
end
|
13
36
|
|
14
37
|
def call(env)
|
15
38
|
if env["PATH_INFO"] == "/__identify__"
|
16
39
|
[200, {}, [@app.object_id.to_s]]
|
17
40
|
else
|
41
|
+
@counter.increment
|
18
42
|
begin
|
19
43
|
@app.call(env)
|
20
44
|
rescue *Capybara.server_errors => e
|
21
45
|
@error = e unless @error
|
22
46
|
raise e
|
47
|
+
ensure
|
48
|
+
@counter.decrement
|
23
49
|
end
|
24
50
|
end
|
25
51
|
end
|
@@ -38,8 +64,8 @@ module Capybara
|
|
38
64
|
@middleware = Middleware.new(@app)
|
39
65
|
@server_thread = nil # suppress warnings
|
40
66
|
@host, @port = host, port
|
41
|
-
@port ||= Capybara::Server.ports[@app.object_id]
|
42
|
-
@port ||= find_available_port
|
67
|
+
@port ||= Capybara::Server.ports[Capybara.reuse_server ? @app.object_id : @middleware.object_id]
|
68
|
+
@port ||= find_available_port(host)
|
43
69
|
end
|
44
70
|
|
45
71
|
def reset_error!
|
@@ -62,12 +88,18 @@ module Capybara
|
|
62
88
|
return false
|
63
89
|
end
|
64
90
|
|
91
|
+
def wait_for_pending_requests
|
92
|
+
Timeout.timeout(60) { sleep(0.01) while @middleware.pending_requests? }
|
93
|
+
rescue Timeout::Error
|
94
|
+
raise "Requests did not finish in 60 seconds"
|
95
|
+
end
|
96
|
+
|
65
97
|
def boot
|
66
98
|
unless responsive?
|
67
|
-
Capybara::Server.ports[@app.object_id] = @port
|
99
|
+
Capybara::Server.ports[Capybara.reuse_server ? @app.object_id : @middleware.object_id] = @port
|
68
100
|
|
69
101
|
@server_thread = Thread.new do
|
70
|
-
Capybara.server.call(@middleware, @port)
|
102
|
+
Capybara.server.call(@middleware, @port, @host)
|
71
103
|
end
|
72
104
|
|
73
105
|
Timeout.timeout(60) { @server_thread.join(0.1) until responsive? }
|
@@ -80,8 +112,8 @@ module Capybara
|
|
80
112
|
|
81
113
|
private
|
82
114
|
|
83
|
-
def find_available_port
|
84
|
-
server = TCPServer.new(
|
115
|
+
def find_available_port(host)
|
116
|
+
server = TCPServer.new(host, 0)
|
85
117
|
server.addr[1]
|
86
118
|
ensure
|
87
119
|
server.close if server
|
data/lib/capybara/session.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
require 'capybara/session/matchers'
|
2
3
|
|
3
4
|
module Capybara
|
@@ -106,9 +107,9 @@ module Capybara
|
|
106
107
|
def reset!
|
107
108
|
if @touched
|
108
109
|
driver.reset!
|
109
|
-
assert_no_selector :xpath, "/html/body/*" if driver.browser_initialized?
|
110
110
|
@touched = false
|
111
111
|
end
|
112
|
+
@server.wait_for_pending_requests if @server
|
112
113
|
raise_server_error!
|
113
114
|
end
|
114
115
|
alias_method :cleanup!, :reset!
|
@@ -402,7 +403,7 @@ module Capybara
|
|
402
403
|
driver.switch_to_window(window.handle)
|
403
404
|
window
|
404
405
|
else
|
405
|
-
wait_time = Capybara::
|
406
|
+
wait_time = Capybara::Queries::SelectorQuery.new(options).wait
|
406
407
|
document.synchronize(wait_time, errors: [Capybara::WindowError]) do
|
407
408
|
original_window_handle = driver.current_window_handle
|
408
409
|
begin
|
@@ -499,7 +500,7 @@ module Capybara
|
|
499
500
|
old_handles = driver.window_handles
|
500
501
|
block.call
|
501
502
|
|
502
|
-
wait_time = Capybara::
|
503
|
+
wait_time = Capybara::Queries::SelectorQuery.new(options).wait
|
503
504
|
document.synchronize(wait_time, errors: [Capybara::WindowError]) do
|
504
505
|
opened_handles = (driver.window_handles - old_handles)
|
505
506
|
if opened_handles.size != 1
|
@@ -619,8 +620,11 @@ module Capybara
|
|
619
620
|
# Save a snapshot of the page. If `Capybara.asset_host` is set it will inject `base` tag
|
620
621
|
# pointing to `asset_host`.
|
621
622
|
#
|
622
|
-
# If invoked without arguments it will save file to `Capybara.
|
623
|
-
# and file will be given randomly generated filename.
|
623
|
+
# If invoked without arguments it will save file to `Capybara.save_path`
|
624
|
+
# and file will be given randomly generated filename. If invoked with a relative path
|
625
|
+
# the path will be relative to `Capybara.save_path`, which is different from
|
626
|
+
# the previous behavior with `Capybara.save_and_open_page_path` where the relative path was
|
627
|
+
# relative to Dir.pwd
|
624
628
|
#
|
625
629
|
# @param [String] path the path to where it should be saved
|
626
630
|
# @return [String] the path to which the file was saved
|
@@ -635,8 +639,11 @@ module Capybara
|
|
635
639
|
#
|
636
640
|
# Save a snapshot of the page and open it in a browser for inspection.
|
637
641
|
#
|
638
|
-
# If invoked without arguments it will save file to `Capybara.
|
639
|
-
# and file will be given randomly generated filename.
|
642
|
+
# If invoked without arguments it will save file to `Capybara.save_path`
|
643
|
+
# and file will be given randomly generated filename. If invoked with a relative path
|
644
|
+
# the path will be relative to `Capybara.save_path`, which is different from
|
645
|
+
# the previous behavior with `Capybara.save_and_open_page_path` where the relative path was
|
646
|
+
# relative to Dir.pwd
|
640
647
|
#
|
641
648
|
# @param [String] path the path to where it should be saved
|
642
649
|
#
|
@@ -649,8 +656,11 @@ module Capybara
|
|
649
656
|
#
|
650
657
|
# Save a screenshot of page.
|
651
658
|
#
|
652
|
-
# If invoked without
|
653
|
-
# and file will be given randomly generated filename.
|
659
|
+
# If invoked without arguments it will save file to `Capybara.save_path`
|
660
|
+
# and file will be given randomly generated filename. If invoked with a relative path
|
661
|
+
# the path will be relative to `Capybara.save_path`, which is different from
|
662
|
+
# the previous behavior with `Capybara.save_and_open_page_path` where the relative path was
|
663
|
+
# relative to Dir.pwd
|
654
664
|
#
|
655
665
|
# @param [String] path the path to where it should be saved
|
656
666
|
# @param [Hash] options a customizable set of options
|
@@ -665,8 +675,11 @@ module Capybara
|
|
665
675
|
#
|
666
676
|
# Save a screenshot of the page and open it for inspection.
|
667
677
|
#
|
668
|
-
# If invoked without
|
669
|
-
# and file will be given randomly generated filename.
|
678
|
+
# If invoked without arguments it will save file to `Capybara.save_path`
|
679
|
+
# and file will be given randomly generated filename. If invoked with a relative path
|
680
|
+
# the path will be relative to `Capybara.save_path`, which is different from
|
681
|
+
# the previous behavior with `Capybara.save_and_open_page_path` where the relative path was
|
682
|
+
# relative to Dir.pwd
|
670
683
|
#
|
671
684
|
# @param [String] path the path to where it should be saved
|
672
685
|
# @param [Hash] options a customizable set of options
|
@@ -714,15 +727,18 @@ module Capybara
|
|
714
727
|
end
|
715
728
|
|
716
729
|
def prepare_path(path, extension)
|
717
|
-
|
730
|
+
if Capybara.save_path || Capybara.save_and_open_page_path.nil?
|
731
|
+
path = File.expand_path(path || default_fn(extension), Capybara.save_path)
|
732
|
+
else
|
733
|
+
path = File.expand_path(default_fn(extension), Capybara.save_and_open_page_path) if path.nil?
|
734
|
+
end
|
718
735
|
FileUtils.mkdir_p(File.dirname(path))
|
719
736
|
path
|
720
737
|
end
|
721
738
|
|
722
|
-
def
|
739
|
+
def default_fn(extension)
|
723
740
|
timestamp = Time.new.strftime("%Y%m%d%H%M%S")
|
724
741
|
path = "capybara-#{timestamp}#{rand(10**10)}.#{extension}"
|
725
|
-
File.expand_path(path, Capybara.save_and_open_page_path)
|
726
742
|
end
|
727
743
|
|
728
744
|
def scopes
|
@@ -117,4 +117,10 @@ $(function() {
|
|
117
117
|
$('#with-key-events').keydown(function(e){
|
118
118
|
$('#key-events-output').append('keydown:'+e.which+' ')
|
119
119
|
});
|
120
|
+
$('#disable-on-click').click(function(e){
|
121
|
+
var input = this
|
122
|
+
setTimeout(function() {
|
123
|
+
input.disabled = true;
|
124
|
+
}, 500)
|
125
|
+
})
|
120
126
|
});
|
@@ -1,3 +1,4 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
Capybara::SpecHelper.spec '#accept_alert', :requires => [:modals] do
|
2
3
|
before do
|
3
4
|
@session.visit('/with_js')
|
@@ -54,4 +55,4 @@ Capybara::SpecHelper.spec '#accept_alert', :requires => [:modals] do
|
|
54
55
|
expect(@session).to have_xpath("//a[@id='open-slow-alert' and @opened='true']")
|
55
56
|
end
|
56
57
|
end
|
57
|
-
end
|
58
|
+
end
|
@@ -1,3 +1,4 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
Capybara::SpecHelper.spec '#accept_confirm', :requires => [:modals] do
|
2
3
|
before do
|
3
4
|
@session.visit('/with_js')
|
@@ -27,4 +28,4 @@ Capybara::SpecHelper.spec '#accept_confirm', :requires => [:modals] do
|
|
27
28
|
}.not_to raise_error
|
28
29
|
expect(@session).to have_xpath("//a[@id='open-twice' and @confirmed='false']")
|
29
30
|
end
|
30
|
-
end
|
31
|
+
end
|
@@ -1,3 +1,4 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
Capybara::SpecHelper.spec '#accept_prompt', :requires => [:modals] do
|
2
3
|
before do
|
3
4
|
@session.visit('/with_js')
|
@@ -46,4 +47,4 @@ Capybara::SpecHelper.spec '#accept_prompt', :requires => [:modals] do
|
|
46
47
|
end
|
47
48
|
expect(message).to eq('Prompt opened')
|
48
49
|
end
|
49
|
-
end
|
50
|
+
end
|