diff --git a/images/macos/provision/configuration/configure-machine.sh b/images/macos/provision/configuration/configure-machine.sh index ce9eb3bb..a0794071 100644 --- a/images/macos/provision/configuration/configure-machine.sh +++ b/images/macos/provision/configuration/configure-machine.sh @@ -2,12 +2,6 @@ source ~/utils/utils.sh -echo "Enabling safari driver..." -# https://developer.apple.com/documentation/webkit/testing_with_webdriver_in_safari -# Safari’s executable is located at /usr/bin/safaridriver -# Configure Safari to Enable WebDriver Support -sudo safaridriver --enable - echo "Enabling developer mode..." sudo /usr/sbin/DevToolsSecurity --enable diff --git a/images/macos/provision/core/safari.sh b/images/macos/provision/core/safari.sh new file mode 100644 index 00000000..8001c39e --- /dev/null +++ b/images/macos/provision/core/safari.sh @@ -0,0 +1,16 @@ +#!/bin/bash -e -o pipefail + +echo "Enabling safari driver..." +# https://developer.apple.com/documentation/webkit/testing_with_webdriver_in_safari +# Safari’s executable is located at /usr/bin/safaridriver +# Configure Safari to Enable WebDriver Support +sudo safaridriver --enable + +echo "Enabling the 'Allow Remote Automation' option in Safari's Develop menu" +mkdir -p $HOME/Library/WebDriver +safari_plist="$HOME/Library/WebDriver/com.apple.Safari.plist" +# "|| true" is needed to suppress exit code 1 in case if property or file doesn't exist +/usr/libexec/PlistBuddy -c 'delete AllowRemoteAutomation' $safari_plist || true +/usr/libexec/PlistBuddy -c 'add AllowRemoteAutomation bool true' $safari_plist + +invoke_tests "Browsers" "Safari" \ No newline at end of file diff --git a/images/macos/templates/macOS-10.13.json b/images/macos/templates/macOS-10.13.json index 202e55bf..306997da 100644 --- a/images/macos/templates/macOS-10.13.json +++ b/images/macos/templates/macOS-10.13.json @@ -171,6 +171,7 @@ "./provision/core/postgresql.sh", "./provision/core/mongodb.sh", "./provision/core/miniconda.sh", + "./provision/core/safari.sh", "./provision/core/chrome.sh", "./provision/core/edge.sh", "./provision/core/firefox.sh", diff --git a/images/macos/templates/macOS-10.14.json b/images/macos/templates/macOS-10.14.json index a0fd2827..fd898aff 100644 --- a/images/macos/templates/macOS-10.14.json +++ b/images/macos/templates/macOS-10.14.json @@ -176,6 +176,7 @@ "./provision/core/postgresql.sh", "./provision/core/mongodb.sh", "./provision/core/audiodevice.sh", + "./provision/core/safari.sh", "./provision/core/chrome.sh", "./provision/core/edge.sh", "./provision/core/firefox.sh", diff --git a/images/macos/templates/macOS-10.15.json b/images/macos/templates/macOS-10.15.json index eeb578d1..5fe2b3bb 100644 --- a/images/macos/templates/macOS-10.15.json +++ b/images/macos/templates/macOS-10.15.json @@ -181,6 +181,7 @@ "./provision/core/audiodevice.sh", "./provision/core/vcpkg.sh", "./provision/core/miniconda.sh", + "./provision/core/safari.sh", "./provision/core/chrome.sh", "./provision/core/edge.sh", "./provision/core/firefox.sh", diff --git a/images/macos/templates/macOS-11.json b/images/macos/templates/macOS-11.json index cf8bcbc9..327b9dd5 100644 --- a/images/macos/templates/macOS-11.json +++ b/images/macos/templates/macOS-11.json @@ -185,6 +185,7 @@ "./provision/core/audiodevice.sh", "./provision/core/vcpkg.sh", "./provision/core/miniconda.sh", + "./provision/core/safari.sh", "./provision/core/chrome.sh", "./provision/core/edge.sh", "./provision/core/firefox.sh", diff --git a/images/macos/tests/Browsers.Tests.ps1 b/images/macos/tests/Browsers.Tests.ps1 index dead1396..7351c3f3 100644 --- a/images/macos/tests/Browsers.Tests.ps1 +++ b/images/macos/tests/Browsers.Tests.ps1 @@ -31,4 +31,15 @@ Describe "Firefox" { It "Geckodriver" { "geckodriver --version" | Should -ReturnZeroExitCode } +} + +Describe "Safari" { + It "'Allow Remote Automation' option is activated" { + $plistPath = "$env:HOME/Library/WebDriver/com.apple.Safari.plist" + $command = "/usr/libexec/PlistBuddy -c 'print AllowRemoteAutomation' $plistPath" + $plistPath | Should -Exist + $commandResult = Get-CommandResult $command + $commandResult.ExitCode | Should -Be 0 + $commandResult.Output | Should -Be "true" + } } \ No newline at end of file