webdriver-user-agent icon indicating copy to clipboard operation
webdriver-user-agent copied to clipboard

SafariTechnologyPreview defaults no longer available for setting?

Open samnissen opened this issue 3 years ago • 1 comments

2021-05-14 12:08:45.561 defaults[64685:3874397]
Domain (com.apple.SafariTechnologyPreview) not found.
Defaults have not been changed.

samnissen avatar May 14 '21 11:05 samnissen

The above error may not have been indicative of this issue, but it continues to not work.

if in BrowserOptions we document the command

      def safari_command_runner(setting, pref)
        raise "Safari requires a Mac" unless OS.mac?

        cmd = "defaults write com.apple.#{safari_version} #{pref} #{setting}"
        puts "cmd is 'defaults write com.apple.#{safari_version} #{pref} #{setting}'"
        output = `#{cmd}`

        raise prepare_safari_error_message(cmd, output) unless safari_command_success?(setting, safari_version, pref, $?)
      end

We can see the ... 'known' way (I don't know of any documentation that supports this) to modify the browser language programmatically is set as expected

cmd is 'defaults write com.apple.Safari CustomUserAgent "\"Mozilla/5.0 (iPhone; CPU iPhone OS 13_5 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.1.1 Mobile/15E148 Safari/604.1\""'
cmd is 'defaults write com.apple.Safari AppleLanguages '("es-ES", "es-MX;q=0.9", "es;q=0.5", "*;0.4")''

And we can confirm this by putting a read in our test:

defaults read com.apple.Safari AppleLanguages -> (
    "es-ES",
    "es-MX;q=0.9",
    "es;q=0.5",
    "*;0.4"
)

And yet the test will fail:

  1) webdriver user agent user-provided accept language string for safari can create a new webdriver driver
     Failure/Error: expect(driver.execute_script("return (navigator.language || navigator.userLanguage)")).to include("es-es")
       expected "en-us" to include "es-es"

I will include in upcoming changes commenting these tests out, but will leave the issue open to be resolved when we can find a way to reliably set and test this.

samnissen avatar May 18 '21 11:05 samnissen