I am working on an automation stuff in macOS Sierra (10.12.2). By using python's atomac support I can launch the safari browser and make the settings enabled via Safari -> Preferences -> Advanced -> check "enable Develop Menu" and then select "Develop -> Allow Remote Automation". Looks like this is not so consistent for automation perspective. I would like to know if there is any shell command to make this possible.
On your Mac, choose Apple menu > System Preferences, click Security & Privacy , then click Privacy. Select Automation. Select the checkbox next to an app to allow it to access and control other apps.
How do I enable Safari drivers on Mac? Step 1: Choose Safari > Preferences. Step 2: On the Advanced tab, select “Show Develop menu in menu bar.” Step 3: Choose Develop > Allow Remote Automation.
Hmm ok, so as per my comment:
You could do defaults write com.apple.Safari IncludeDevelopMenu YES
to activate the development menu via terminal. You could get python to execute this command for you using the subprocess module.
According to this this question it seems that one used to be able to simply do defaults write com.apple.Safari AllowRemoteAutomation 1
. However, since Safari 10 this option has apparently been subjected to a higher security protocol or something (maybe because of the System Integrity Protection that was introduced). I've been looking for the plistfile that now holds the setting, but I have not been able to find it. Maybe it's not even there in an actual plistfile anymore.
I guess this leaves you with 2 options:
I found the answer from: https://developer.apple.com/documentation/webkit/testing_with_webdriver_in_safari
safaridriver --enable
It will prompt for an admin password, so some people setup passwordless sudo (dangerous) or do another workaround like calling from an Applescript
I tested that this works with Mojave and Safari 12.0.3 and verified that it works regardless of if the Develop menu is enabled, though you probably want to save yourself the clicks and just enable that too:
defaults write com.apple.Safari IncludeDevelopMenu 1
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With