2019-07-25 01:27:42 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-10-16 04:37:53 -04:00
|
|
|
require 'io/console'
|
|
|
|
|
|
|
|
module LiveDebugger
|
|
|
|
def live_debug
|
2017-11-02 07:02:51 -04:00
|
|
|
puts
|
|
|
|
puts "Current example is paused for live debugging."
|
2019-12-10 07:07:55 -05:00
|
|
|
|
2021-06-22 20:07:53 -04:00
|
|
|
if is_headless_disabled?
|
|
|
|
puts "Switch to the browser window that was automatically opened to run the test in order to view current page"
|
2019-12-10 07:07:55 -05:00
|
|
|
else
|
|
|
|
puts "Opening #{current_url} in your default browser..."
|
|
|
|
end
|
|
|
|
|
2017-11-02 07:02:51 -04:00
|
|
|
puts "The current user credentials are: #{@current_user.username} / #{@current_user.password}" if @current_user
|
2017-10-26 12:03:33 -04:00
|
|
|
puts "Press any key to resume the execution of the example!!"
|
2017-10-16 04:37:53 -04:00
|
|
|
|
2021-06-22 20:07:53 -04:00
|
|
|
`open #{current_url}` if is_headless_disabled?
|
2017-10-17 11:42:21 -04:00
|
|
|
|
2017-10-26 12:03:33 -04:00
|
|
|
loop until $stdin.getch
|
2017-10-17 11:42:21 -04:00
|
|
|
|
2017-10-16 04:37:53 -04:00
|
|
|
puts "Back to the example!"
|
|
|
|
end
|
2021-06-22 20:07:53 -04:00
|
|
|
|
|
|
|
def is_headless_disabled?
|
|
|
|
ActiveSupport::Deprecation.warn("CHROME_HEADLESS is deprecated. Use WEBDRIVER_HEADLESS instead.") if ENV.key?('CHROME_HEADLESS')
|
|
|
|
|
|
|
|
ENV['WEBDRIVER_HEADLESS'] =~ /^(false|no|0)$/i || ENV['CHROME_HEADLESS'] =~ /^(false|no|0)$/i
|
|
|
|
end
|
2017-10-16 04:37:53 -04:00
|
|
|
end
|