mirror of
https://github.com/discourse/discourse.git
synced 2025-01-18 12:53:17 +08:00
DEV: Add remove debugging URLs to system spec helper (#29722)
These URLs allow the state of a headless browser to be viewed and debugged using any other browser, without needing to restart the test with `SELENIUM_HEADLESS=0`.
This commit is contained in:
parent
f1edc20a50
commit
86a2558f5f
|
@ -1030,6 +1030,7 @@ def apply_base_chrome_options(options)
|
|||
options.add_argument("--no-sandbox")
|
||||
options.add_argument("--disable-dev-shm-usage")
|
||||
options.add_argument("--mute-audio")
|
||||
options.add_argument("--remote-allow-origins=*")
|
||||
|
||||
# A file that contains just a list of paths like so:
|
||||
#
|
||||
|
|
|
@ -5,11 +5,23 @@ module SystemHelpers
|
|||
PLATFORM_KEY_MODIFIER = RUBY_PLATFORM =~ /darwin/i ? :meta : :control
|
||||
|
||||
def pause_test
|
||||
result =
|
||||
ask(
|
||||
"\n\e[33mTest paused, press enter to resume, type `d` and press enter to start debugger.\e[0m",
|
||||
)
|
||||
msg = "Test paused. Press enter to resume, or `d` + enter to start debugger.\n\n"
|
||||
msg += "Browser inspection URLs:\n"
|
||||
|
||||
# Fetch devtools urls
|
||||
base_url = page.driver.browser.send(:devtools_address)
|
||||
uri = URI(base_url)
|
||||
response = Net::HTTP.get(uri.hostname, "/json/list", uri.port)
|
||||
JSON
|
||||
.parse(response)
|
||||
.each do |result|
|
||||
msg +=
|
||||
" - (#{result["type"]}) #{base_url}#{result["devtoolsFrontendUrl"]} (#{URI(result["url"]).path})\n"
|
||||
end
|
||||
|
||||
result = ask("\n\e[33m#{msg}\e[0m")
|
||||
binding.pry if result == "d" # rubocop:disable Lint/Debugger
|
||||
puts "\e[33mResuming...\e[0m"
|
||||
self
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user