How do you run Chrome while selenium headless script is executing on mac?

I have a python selenium script that uses chromedriver in headless mode to test links on a website. I'm running this script on MacOS High Sierra.

If I have Chrome open prior to running the script, I can continue to use the browser normally. Headless mode appears to isolate me from the testing. However, if Chrome is closed first, I cannot launch the browser while the selenium script is running.

Looking at Activity monitor in the first scenario, it appears to me that chromedriver creates a new process for Chrome to run. So I (perhaps incorrectly) assumed I should be able to launch the browser manually while the script is running.

What am I missing?
How do I launch Chrome while selenium is running on Mac?

1 answer

  • answered 2018-12-05 20:47 Marcel Wilson

    Ah-HA!
    This post I stumbled upon made it possible to open Chrome while selenium is running (although I don't understand why it works one way but not the other).

    For most applications, launching with open -naF "App Name" or open -nF /path/to/application.app should be sufficient (see Safari, Forklift, Office apps, etc.).

    • -n opens a new instance
    • -a tells open to look in the list of registered apps (no need to specify the full path, but can go wrong if you have multiple versions of an app. I sometimes see issues on my system with differentiating between macOS apps and apps installed by Parallels OSes… I prefer to specify the path directly.)
    • -F opens a fresh instance (ignores an app save state left over from previous instances)