macOS Sierra - how to enable "Allow Remote Automation" using command line
Asked Answered
D

3

24

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.

Allow Remote Automation screen

Dorree answered 13/1, 2017 at 7:41 Comment(3)
Ok, short on time, but you could do defaults write com.apple.Safari IncludeDevelopMenu YES to activate the development menu via terminal. I could not easily locate the .plist file that houses the 'Allow Remote Automation' option, but there should be one and you should be able to use the defaults command on that as well. Or you could use Apple's osascript and simulate the mouse-clicks (would not recommend that). Using Python, I'd try using subprocess.Popen() on the defaults command. Will try later tonight unless your question is already answered by then.Rockbottom
anyone looking to see a working applescript solution to what's described in the above comment should check out: https://mcmap.net/q/583786/-how-to-enable-quot-allow-remote-automation-quot-in-safari-programmaticallyConcavoconvex
Hi @RianSanderson, probably you could add this is an answer. So that, I could recognize your contribution. Cheers!Dorree
R
9

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:

  1. Use apple's osascript to simulate the needed mouseclicks.
  2. Repost your question on AskDifferent or Apple's own developers forum, since you are more likely to find someone with in-depth knowledge of macOS.
Rockbottom answered 21/3, 2017 at 6:23 Comment(1)
Thanks for the answer but it didn't work. Will go with the suggested forums in leisure time. Thanks again!Dorree
C
3

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
Concavoconvex answered 2/4, 2019 at 20:58 Comment(0)
F
1

On MacBook Pro (Apple M2 Pro) ▪ select Safari ▪ Select Setting ▪ Select “Advanced” tab ▪ Check “Show features for web developers” ▪ Now you see “develop” option is on the MacOS menu ⁃ select develop ⁃ Select “Developer settings…” ⁃ check “Allow remote automation” Now you can run your tests against safari

Femininity answered 18/1, 2024 at 1:15 Comment(1)
This also worked for MacOS Sonoma. I was able to run my robot framework scripts without any errors on Safari immediately after doing this.Reluctant

© 2022 - 2025 — McMap. All rights reserved.