4

When developing in Selenium you frequently open a new browser and if the test fails/doesn't tear down as it should you manually have to quit the browser. By default, Chrome doesn't quit immediately if you use the keyboard shortcut, instead you have to press and hold the keys for a while. This feature makes sense when the user is a human but as a Selenium developer it gets old very fast to wait for Chrome to quit when you want get back to your IDE as fast a possible.

Can this feature Warn before quitting in Chrome be disabled from Java/Selenium? Even programmatically sending a click to open a menu and disabling it that way is a valid solution.

d-b
  • 695
  • 3
  • 14
  • 43

1 Answers1

0

This bothered me as well. It seems like there's no such entry for it in the Chrome Preferences JSON, I assume because it's a macOS-only feature. I've resolved this by creating a Karabiner Elements config which selects the Quit menu item on Command-Q in Chrome. Here's the config in YAML:

- manipulators:
  - from:
      key_code: q
      modifiers:
        mandatory:
          - command
    to:
      - shell_command: >-
          osascript
          -e 'tell application "Google Chrome for Testing" to activate'
          -e 'tell application "System Events"'
          -e '  tell process "Google Chrome for Testing"'
          -e '    click menu item "Quit Chromium" of menu "Google Chrome for Testing" of menu bar 1'
          -e '  end tell'
          -e 'end tell'
    conditions:
      - type: frontmost_application_if
        bundle_identifiers:
          - chrome.for.testing
    type: basic
sarimarton
  • 151
  • 1
  • 7