How To Hide Chrome Web Driver Icon (Python-Selenium) How To Hide Chrome Web Driver Icon (Python-Selenium) selenium selenium

How To Hide Chrome Web Driver Icon (Python-Selenium)


Update (this worked for me to hide the chromedriver icons at least on my Mac):

I was not able to find a Chrome Option to accomplish hiding the chromedriver icons that appear in the dock. However, I was able to edit the Info.plist file for Chrome as part of my program to do the trick (of hiding chromedriver icons) using the LSBackgroundOnly key.

In the Info.plist for Chrome, programmatically, I entered:

<key>LSBackgroundOnly</key><string>1</string>

On my Mac using python3 code I used os.system to execute a terminal command using defaults to enter the LSBackgroundOnly key when the program is executing and then at the end of program execution I delete the LSBackgroundOnly key from the Info.plist.

like this:

1)

defaults write /Applications/Google\ Chrome.app/Contents/Info.plist LSBackgroundOnly -string '1'

2)

defaults delete /Applications/Google\ Chrome.app/Contents/Info.plist LSBackgroundOnly

AS INFO: This is tricky because your normal chrome app may start up in background mode if you don't add/delete LSBackgroundOnly properly during program execution. In my experience, worst case scenario you may have to manually remove LSBackgroundOnly from the Info.plist file then restart your computer to get Chrome out of background mode.

I remove the LSBackgroundOnly key from the Info.plist file in my program after program execution because the key only needs to be in the file when the chromedrivers are launched. After that I want to be able to use regular Chrome app without issues of it opening in background mode. But, if you understand your program execution and handle your exceptions, this will definitely work to hide the icons correctly and there will be nothing different in using your regular Chrome app.

Happy hacking.


This is not possible using Selenium. I don't really understand why you want to do this. Is there a real purpose, or it's just you don't want it to show? Even if the Chrome app shows on the dock, in headless mode, it works pretty good.

However, if you want your icon to not appear in the dock when opened, then you need to disable it by modifying the Info.plist file for that application.

In your Info.plist for Chrome, add this

 <key>LSUIElement</key> <true/>

This will prevent your app icon from appearing in dock, when working. I found this out a long time ago and this is the post where I saw it.

PS - I have not tested it for Chrome app. Please test at your own peril.