How to enable "Allow Remote Automation" in Safari programmatically
It is not possible to toggle the setting using the method you described.
Starting in Safari 11, you can force safaridriver to authenticate by using the --enable command line option. After authenticating, this menu item will be set. This will also cache the authentication for the rest of your login session. Subsequent invocations of safaridriver (say, by the Selenium libraries) will not need further setup.
It can also be done using AppleScript if it is not possible by modifying the plist. To do that, first enable develop from Safari preferences and then choose Allow Remote Automation from the Develop menu.Here is the AppleScript that I wrote to enable Allow Remote Automation (this covers both the steps mentioned above).
tell application "Safari" to activatedelay 2tell application "System Events" tell application process "Safari" keystroke "," using command down set frontmost to true tell window 1 click button "Advanced" of toolbar 1 delay 2 set theCheckbox to checkbox 4 of group 1 of group 1 of it tell theCheckbox if not (its value as boolean) then click theCheckbox end tell delay 2 keystroke "w" using command down delay 2 end tell tell menu bar item "Develop" of menu bar 1 click delay 2 click menu item "Allow Remote Automation" of menu 1 delay 2 end tell end tellend telltell application "Safari" to quit
Note: Here I enabled develop menu from safari preferences only if it is unchecked.
Hope this helps..