2016-03-07 19:52:19 -05:00
|
|
|
# frozen_string_literal: true
|
2018-01-08 15:23:54 -05:00
|
|
|
|
2009-12-09 15:43:40 -05:00
|
|
|
class Capybara::Driver::Base
|
2017-04-29 12:58:03 -04:00
|
|
|
attr_writer :session
|
2016-12-15 12:04:01 -05:00
|
|
|
|
2009-12-16 09:16:52 -05:00
|
|
|
def current_url
|
2009-12-29 23:43:14 -05:00
|
|
|
raise NotImplementedError
|
2009-12-16 09:16:52 -05:00
|
|
|
end
|
|
|
|
|
2009-12-09 15:43:40 -05:00
|
|
|
def visit(path)
|
2009-12-29 23:43:14 -05:00
|
|
|
raise NotImplementedError
|
2009-12-09 15:43:40 -05:00
|
|
|
end
|
2009-12-29 23:43:14 -05:00
|
|
|
|
2017-07-04 18:14:55 -04:00
|
|
|
def refresh
|
|
|
|
raise NotImplementedError
|
|
|
|
end
|
|
|
|
|
2013-02-19 12:03:26 -05:00
|
|
|
def find_xpath(query)
|
|
|
|
raise NotImplementedError
|
|
|
|
end
|
2013-10-05 14:23:51 -04:00
|
|
|
|
2013-02-19 12:03:26 -05:00
|
|
|
def find_css(query)
|
2009-12-29 23:43:14 -05:00
|
|
|
raise NotImplementedError
|
2009-12-09 15:43:40 -05:00
|
|
|
end
|
2009-12-29 23:43:14 -05:00
|
|
|
|
2012-09-09 21:05:17 -04:00
|
|
|
def html
|
2010-07-09 21:11:54 -04:00
|
|
|
raise NotImplementedError
|
2009-12-14 09:30:29 -05:00
|
|
|
end
|
2009-12-29 23:43:14 -05:00
|
|
|
|
2013-10-05 14:23:51 -04:00
|
|
|
def go_back
|
2013-10-29 05:04:32 -04:00
|
|
|
raise Capybara::NotSupportedByDriverError, 'Capybara::Driver::Base#go_back'
|
2013-10-05 14:23:51 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def go_forward
|
2013-10-29 05:04:32 -04:00
|
|
|
raise Capybara::NotSupportedByDriverError, 'Capybara::Driver::Base#go_forward'
|
2013-10-05 14:23:51 -04:00
|
|
|
end
|
|
|
|
|
2016-12-22 19:22:46 -05:00
|
|
|
def execute_script(script, *args)
|
2013-03-08 22:44:40 -05:00
|
|
|
raise Capybara::NotSupportedByDriverError, 'Capybara::Driver::Base#execute_script'
|
2009-12-09 15:43:40 -05:00
|
|
|
end
|
2009-12-29 23:43:14 -05:00
|
|
|
|
2016-12-22 19:22:46 -05:00
|
|
|
def evaluate_script(script, *args)
|
2013-03-08 22:44:40 -05:00
|
|
|
raise Capybara::NotSupportedByDriverError, 'Capybara::Driver::Base#evaluate_script'
|
2010-02-25 17:51:51 -05:00
|
|
|
end
|
|
|
|
|
2017-10-20 18:18:00 -04:00
|
|
|
def evaluate_async_script(script, *args)
|
|
|
|
raise Capybara::NotSupportedByDriverError, 'Capybara::Driver::Base#evaluate_script_asnyc'
|
|
|
|
end
|
|
|
|
|
2016-11-13 21:32:23 -05:00
|
|
|
def save_screenshot(path, **options)
|
2013-03-08 22:44:40 -05:00
|
|
|
raise Capybara::NotSupportedByDriverError, 'Capybara::Driver::Base#save_screenshot'
|
2012-07-10 00:50:15 -04:00
|
|
|
end
|
|
|
|
|
2009-12-18 12:50:55 -05:00
|
|
|
def response_headers
|
2013-03-08 22:44:40 -05:00
|
|
|
raise Capybara::NotSupportedByDriverError, 'Capybara::Driver::Base#response_headers'
|
2009-12-18 12:50:55 -05:00
|
|
|
end
|
2010-10-29 07:41:49 -04:00
|
|
|
|
2010-06-06 23:14:40 -04:00
|
|
|
def status_code
|
2013-03-08 22:44:40 -05:00
|
|
|
raise Capybara::NotSupportedByDriverError, 'Capybara::Driver::Base#status_code'
|
2010-06-06 21:13:57 -04:00
|
|
|
end
|
2009-12-29 23:43:14 -05:00
|
|
|
|
2016-07-15 14:00:14 -04:00
|
|
|
##
|
|
|
|
#
|
|
|
|
# @param frame [Capybara::Node::Element, :parent, :top] The iframe element to switch to
|
|
|
|
#
|
|
|
|
def switch_to_frame(frame)
|
|
|
|
raise Capybara::NotSupportedByDriverError, 'Capybara::Driver::Base#switch_to_frame'
|
2010-01-12 14:40:10 -05:00
|
|
|
end
|
|
|
|
|
2018-03-19 16:43:41 -04:00
|
|
|
def frame_title
|
2018-03-23 12:07:08 -04:00
|
|
|
find_xpath('/html/head/title').map(&:all_text).first.to_s
|
2018-03-19 16:43:41 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def frame_url
|
|
|
|
evaluate_script('document.location.href')
|
|
|
|
rescue Capybara::NotSupportedByDriverError
|
|
|
|
raise Capybara::NotSupportedByDriverError, 'Capybara::Driver::Base#frame_title'
|
|
|
|
end
|
|
|
|
|
2014-04-08 17:28:16 -04:00
|
|
|
def current_window_handle
|
|
|
|
raise Capybara::NotSupportedByDriverError, 'Capybara::Driver::Base#current_window_handle'
|
|
|
|
end
|
|
|
|
|
2014-04-24 18:38:42 -04:00
|
|
|
def window_size(handle)
|
2014-04-08 17:28:16 -04:00
|
|
|
raise Capybara::NotSupportedByDriverError, 'Capybara::Driver::Base#window_size'
|
|
|
|
end
|
|
|
|
|
2014-04-24 18:38:42 -04:00
|
|
|
def resize_window_to(handle, width, height)
|
2014-04-08 17:28:16 -04:00
|
|
|
raise Capybara::NotSupportedByDriverError, 'Capybara::Driver::Base#resize_window_to'
|
|
|
|
end
|
|
|
|
|
2014-04-24 18:38:42 -04:00
|
|
|
def maximize_window(handle)
|
2018-06-21 14:30:26 -04:00
|
|
|
raise Capybara::NotSupportedByDriverError, 'Capybara::Driver::Base#maximize_window'
|
|
|
|
end
|
|
|
|
|
|
|
|
def fullscreen_window(handle)
|
|
|
|
raise Capybara::NotSupportedByDriverError, 'Capybara::Driver::Base#fullscreen_window'
|
2014-04-10 03:20:27 -04:00
|
|
|
end
|
|
|
|
|
2014-04-24 18:38:42 -04:00
|
|
|
def close_window(handle)
|
2014-04-08 17:28:16 -04:00
|
|
|
raise Capybara::NotSupportedByDriverError, 'Capybara::Driver::Base#close_window'
|
|
|
|
end
|
|
|
|
|
|
|
|
def window_handles
|
|
|
|
raise Capybara::NotSupportedByDriverError, 'Capybara::Driver::Base#window_handles'
|
|
|
|
end
|
|
|
|
|
|
|
|
def open_new_window
|
|
|
|
raise Capybara::NotSupportedByDriverError, 'Capybara::Driver::Base#open_new_window'
|
|
|
|
end
|
|
|
|
|
|
|
|
def switch_to_window(handle)
|
|
|
|
raise Capybara::NotSupportedByDriverError, 'Capybara::Driver::Base#switch_to_window'
|
|
|
|
end
|
|
|
|
|
|
|
|
def no_such_window_error
|
|
|
|
raise Capybara::NotSupportedByDriverError, 'Capybara::Driver::Base#no_such_window_error'
|
|
|
|
end
|
2016-03-30 14:27:29 -04:00
|
|
|
|
2014-06-30 20:50:41 -04:00
|
|
|
##
|
|
|
|
#
|
|
|
|
# Execute the block, and then accept the modal opened.
|
|
|
|
# @param type [:alert, :confirm, :prompt]
|
|
|
|
# @option options [Numeric] :wait How long to wait for the modal to appear after executing the block.
|
|
|
|
# @option options [String, Regexp] :text Text to verify is in the message shown in the modal
|
|
|
|
# @option options [String] :with Text to fill in in the case of a prompt
|
|
|
|
# @return [String] the message shown in the modal
|
|
|
|
# @raise [Capybara::ModalNotFound] if modal dialog hasn't been found
|
|
|
|
#
|
2016-08-17 19:14:39 -04:00
|
|
|
def accept_modal(type, **options, &blk)
|
2013-04-01 18:41:55 -04:00
|
|
|
raise Capybara::NotSupportedByDriverError, 'Capybara::Driver::Base#accept_modal'
|
|
|
|
end
|
|
|
|
|
2014-06-30 20:50:41 -04:00
|
|
|
##
|
|
|
|
#
|
|
|
|
# Execute the block, and then dismiss the modal opened.
|
|
|
|
# @param type [:alert, :confirm, :prompt]
|
|
|
|
# @option options [Numeric] :wait How long to wait for the modal to appear after executing the block.
|
|
|
|
# @option options [String, Regexp] :text Text to verify is in the message shown in the modal
|
|
|
|
# @return [String] the message shown in the modal
|
|
|
|
# @raise [Capybara::ModalNotFound] if modal dialog hasn't been found
|
|
|
|
#
|
2016-08-17 19:14:39 -04:00
|
|
|
def dismiss_modal(type, **options, &blk)
|
2013-04-01 18:41:55 -04:00
|
|
|
raise Capybara::NotSupportedByDriverError, 'Capybara::Driver::Base#dismiss_modal'
|
|
|
|
end
|
2014-04-08 17:28:16 -04:00
|
|
|
|
2011-07-13 09:39:17 -04:00
|
|
|
def invalid_element_errors
|
|
|
|
[]
|
|
|
|
end
|
|
|
|
|
2010-07-09 21:11:54 -04:00
|
|
|
def wait?
|
|
|
|
false
|
|
|
|
end
|
|
|
|
|
2018-01-08 15:23:54 -05:00
|
|
|
def reset!; end
|
2012-07-13 07:29:02 -04:00
|
|
|
|
|
|
|
def needs_server?
|
|
|
|
false
|
|
|
|
end
|
2016-04-04 15:49:44 -04:00
|
|
|
|
2016-12-15 12:04:01 -05:00
|
|
|
def session_options
|
2018-08-06 16:44:28 -04:00
|
|
|
session&.config || Capybara.session_options
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def session
|
|
|
|
@session ||= nil
|
2016-12-15 12:04:01 -05:00
|
|
|
end
|
2009-12-29 23:43:14 -05:00
|
|
|
end
|