webdriver-user-agent 7.8 → 7.9

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1f103f486777f7dffc40b6177cbd52c1ed13826daf41c500f8f69f1869e71c6f
4
- data.tar.gz: 4844156cef409e1c77d5e4610b3e51e1c995954edc3e0823fd4651255b5372fd
3
+ metadata.gz: c8f285c93bdc6daea5d101e3a61b973a82c9e25152ec14fbd90223ea382cd4ab
4
+ data.tar.gz: ff356f5cf939d1ea35ec8197ec9ccbc455c203458729da220016f7d861961b20
5
5
  SHA512:
6
- metadata.gz: 1f297ddcf8064c4c6a37c550f0bf2ea57e4d3ca6cc60856315f9656b15426ca36357173ac87b246dde72d8f9d9f05d929f35aa82ee6f72461d47409556bdfa23
7
- data.tar.gz: 69368f91ffb7b262a7b45161dc4099fa80230d4bca0792b7d1baf80d130e1876850a970dce3b79b2dbae926eddd257dcf7a2ca0584a8cf329f27966941c1b978
6
+ metadata.gz: da7de1ce472978582caf214a2588dfe2b6248179076e221f7797a9fc218212bb4793682923ab42d3a229d5c8c9f9f1e002e0a18c823f5cd9f185923c73d33232
7
+ data.tar.gz: e191c01c8ed048d4b1812ebc78a45a0a6cab912848ea9c789a0b7a68f5481b5e51f66d4fe41c4388da590db7ccdf7a8b8d80f6947b562585efd15bbbd15a22ee
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- ruby-2.4.1
1
+ ruby-3.1.2
data/ChangeLog CHANGED
@@ -1,3 +1,23 @@
1
+ === Version 7.9 / 2022-5-25
2
+ * Enhancements (Thanks samnissen)
3
+ * Fixed yaml load issues with latest psych gem (Thanks samnissen)
4
+ * Fixed a bug with Safari browser (Thanks samnissen)
5
+ * Updated to Ruby 3.1.2 (Thanks sandeepnagra)
6
+
7
+ === Version 7.8 / 2020-7-10
8
+ * Enhancements (Thanks samnissen)
9
+ * Updated devices
10
+ * Fixed provided options and updated unit tests
11
+
12
+ === Version 7.7 / 2020-7-10
13
+ * version yanked
14
+
15
+ === Version 7.6 / 2019-2-11
16
+ * Enhancements (Thanks samnissen)
17
+ * Added support for setting browswer language
18
+ * Replaced deprecated selenium switches
19
+ * Allowed Safari browser and updated requirements to support it
20
+
1
21
  === Version 7.5 / 2017-8-22
2
22
  * Enhancements
3
23
  * Added support for modern iPhone and iPad sizes
data/README.md CHANGED
@@ -25,7 +25,7 @@ provides a UserAgent.driver method to return a new web-driver with user agent an
25
25
  * :browser
26
26
  * :firefox (default)
27
27
  * :chrome
28
- * :safari
28
+ * :safari
29
29
  * :agent
30
30
  * :iphone (default)
31
31
  * :ipad
@@ -61,6 +61,12 @@ provides a UserAgent.driver method to return a new web-driver with user agent an
61
61
  browser.goto 'tiffany.com'
62
62
  browser.url.should == 'http://m.tiffany.com/International.aspx'
63
63
 
64
+ ### A note on Safari
65
+
66
+ In our testing, it doesn't work well. Sometimes Safari Technology Preview works better, sometimes
67
+ only Safari works at all. And as of May 2021, our ability to write user agent strings
68
+ and languages for either flavor of Safari seems not to work on macOS Big Sur/Safari 14.
69
+
64
70
  ## Contributing
65
71
 
66
72
  1. Fork it
@@ -13,161 +13,162 @@
13
13
  # so these figures are necessarily larger than what will be true
14
14
  # on those devices. Please feel free to submit a pull request
15
15
  # with corrected and/or expanded device values.
16
- :desktop:
17
- :user_agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_4) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.1 Safari/605.1.15
18
- :portrait:
19
- :width: 768
20
- :height: 1024
21
- :landscape:
22
- :width: 1366
23
- :height: 768
24
- :iphone_default: &iphone_default
25
- :user_agent: 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
26
- :portrait:
27
- :width: 414
28
- :height: 719
29
- :landscape:
30
- :width: 808
31
- :height: 414
32
- :iphone: &iphone
16
+ ---
17
+ desktop:
18
+ user_agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_4) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.1 Safari/605.1.15
19
+ portrait:
20
+ width: 768
21
+ height: 1024
22
+ landscape:
23
+ width: 1366
24
+ height: 768
25
+ iphone_default: &iphone_default
26
+ user_agent: 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
27
+ portrait:
28
+ width: 414
29
+ height: 719
30
+ landscape:
31
+ width: 808
32
+ height: 414
33
+ iphone: &iphone
33
34
  <<: *iphone_default
34
- :iphone11pro:
35
+ iphone11pro:
35
36
  <<: *iphone_default
36
- :portrait:
37
- :width: 375
38
- :height: 635
39
- :landscape:
40
- :width: 724
41
- :height: 375
42
- :iphone11promax:
37
+ portrait:
38
+ width: 375
39
+ height: 635
40
+ landscape:
41
+ width: 724
42
+ height: 375
43
+ iphone11promax:
43
44
  <<: *iphone_default
44
- :iphone11:
45
+ iphone11:
45
46
  <<: *iphone_default
46
- :iphonese: &iphonese
47
+ iphonese: &iphonese
47
48
  <<: *iphone_default
48
- :portrait:
49
- :width: 375
50
- :height: 553
51
- :landscape:
52
- :width: 667
53
- :height: 375
54
- :iphonexr: &iphonexr
49
+ portrait:
50
+ width: 375
51
+ height: 553
52
+ landscape:
53
+ width: 667
54
+ height: 375
55
+ iphonexr: &iphonexr
55
56
  <<: *iphone_default
56
- :iphonexsmax:
57
+ iphonexsmax:
57
58
  <<: *iphonexr
58
- :iphonexs: &iphonexs
59
+ iphonexs: &iphonexs
59
60
  <<: *iphone_default
60
- :portrait:
61
- :width: 375
62
- :height: 635
63
- :landscape:
64
- :width: 724
65
- :height: 375
66
- :iphonex:
61
+ portrait:
62
+ width: 375
63
+ height: 635
64
+ landscape:
65
+ width: 724
66
+ height: 375
67
+ iphonex:
67
68
  <<: *iphonexs
68
- :iphone8plus: &iphone8plus
69
+ iphone8plus: &iphone8plus
69
70
  <<: *iphone_default
70
- :portrait:
71
- :width: 414
72
- :height: 622
73
- :landscape:
74
- :width: 736
75
- :height: 414
76
- :iphone8: &iphone8
71
+ portrait:
72
+ width: 414
73
+ height: 622
74
+ landscape:
75
+ width: 736
76
+ height: 414
77
+ iphone8: &iphone8
77
78
  <<: *iphonese
78
- :iphone7plus:
79
+ iphone7plus:
79
80
  <<: *iphone8plus
80
- :iphone7:
81
+ iphone7:
81
82
  <<: *iphone8
82
- :iphone6splus:
83
+ iphone6splus:
83
84
  <<: *iphone8plus
84
- :iphone6s:
85
+ iphone6s:
85
86
  <<: *iphone8
86
- :iphone6plus:
87
+ iphone6plus:
87
88
  <<: *iphone8plus
88
- :iphone6:
89
+ iphone6:
89
90
  <<: *iphone8
90
- :iphone5s: &iphone5s
91
+ iphone5s: &iphone5s
91
92
  <<: *iphone_default
92
- :portrait:
93
- :width: 320
94
- :height: 454
95
- :landscape:
96
- :width: 568
97
- :height: 320
98
- :iphonese_old:
93
+ portrait:
94
+ width: 320
95
+ height: 454
96
+ landscape:
97
+ width: 568
98
+ height: 320
99
+ iphonese_old:
99
100
  <<: *iphone5s
100
- :iphone5:
101
+ iphone5:
101
102
  <<: *iphone5s
102
- :iphone4s: &iphone4s
103
+ iphone4s: &iphone4s
103
104
  <<: *iphone_default
104
- :portrait:
105
- :width: 320
106
- :height: 356
107
- :landscape:
108
- :width: 480
109
- :height: 196
110
- :iphone4:
105
+ portrait:
106
+ width: 320
107
+ height: 356
108
+ landscape:
109
+ width: 480
110
+ height: 196
111
+ iphone4:
111
112
  <<: *iphone4s
112
- :ipad: &ipad
113
- :user_agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_4) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.1.1 Safari/605.1.15
114
- :portrait:
115
- :width: 810
116
- :height: 1010
117
- :landscape:
118
- :width: 1080
119
- :height: 740
120
- :ipad_default:
113
+ ipad: &ipad
114
+ user_agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_4) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.1.1 Safari/605.1.15
115
+ portrait:
116
+ width: 810
117
+ height: 1010
118
+ landscape:
119
+ width: 1080
120
+ height: 740
121
+ ipad_default:
121
122
  <<: *ipad
122
- :ipad_pro: &ipad_pro
123
+ ipad_pro: &ipad_pro
123
124
  <<: *ipad
124
- :portrait:
125
- :width: 1024
126
- :height: 1292
127
- :landscape:
128
- :width: 1366
129
- :height: 950
130
- :ipad_pro_12:
125
+ portrait:
126
+ width: 1024
127
+ height: 1292
128
+ landscape:
129
+ width: 1366
130
+ height: 950
131
+ ipad_pro_12:
131
132
  <<: *ipad_pro
132
- :ipad_pro_11:
133
+ ipad_pro_11:
133
134
  <<: *ipad
134
- :portrait:
135
- :width: 834
136
- :height: 1120
137
- :landscape:
138
- :width: 1194
139
- :height: 760
140
- :ipad_pro_9:
135
+ portrait:
136
+ width: 834
137
+ height: 1120
138
+ landscape:
139
+ width: 1194
140
+ height: 760
141
+ ipad_pro_9:
141
142
  <<: *ipad
142
- :portrait:
143
- :width: 768
144
- :height: 954
145
- :landscape:
146
- :width: 1024
147
- :height: 698
148
- :ipad_air: &ipad_air
143
+ portrait:
144
+ width: 768
145
+ height: 954
146
+ landscape:
147
+ width: 1024
148
+ height: 698
149
+ ipad_air: &ipad_air
149
150
  <<: *ipad
150
- :portrait:
151
- :width: 834
152
- :height: 1038
153
- :landscape:
154
- :width: 1112
155
- :height: 760
156
- :ipad_pro_10:
151
+ portrait:
152
+ width: 834
153
+ height: 1038
154
+ landscape:
155
+ width: 1112
156
+ height: 760
157
+ ipad_pro_10:
157
158
  <<: *ipad_air
158
- :android_phone:
159
- :user_agent: Mozilla/5.0 (Linux; Android 10; Pixel) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.87 Mobile Safari/537.36
160
- :portrait:
161
- :width: 411
162
- :height: 869
163
- :landscape:
164
- :width: 869
165
- :height: 411
166
- :android_tablet:
167
- :user_agent: Mozilla/5.0 (Linux; Android 9; SAMSUNG SM-T865) AppleWebKit/537.36 (KHTML, like Gecko) SamsungBrowser/10.1 Chrome/71.0.3578.99 Safari/537.36
168
- :portrait:
169
- :width: 800
170
- :height: 1280
171
- :landscape:
172
- :width: 1280
173
- :height: 800
159
+ android_phone:
160
+ user_agent: Mozilla/5.0 (Linux; Android 10; Pixel) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.87 Mobile Safari/537.36
161
+ portrait:
162
+ width: 411
163
+ height: 869
164
+ landscape:
165
+ width: 869
166
+ height: 411
167
+ android_tablet:
168
+ user_agent: Mozilla/5.0 (Linux; Android 9; SAMSUNG SM-T865) AppleWebKit/537.36 (KHTML, like Gecko) SamsungBrowser/10.1 Chrome/71.0.3578.99 Safari/537.36
169
+ portrait:
170
+ width: 800
171
+ height: 1280
172
+ landscape:
173
+ width: 1280
174
+ height: 800
@@ -0,0 +1,32 @@
1
+ class Hash
2
+ DEEP_SYMBOLIZE_KEYS_SYMBOLS = [:deep_symbolize_keys, :deep_symbolize_keys!].freeze
3
+
4
+ def deep_copy
5
+ Marshal.load(Marshal.dump(self))
6
+ end
7
+
8
+ def method_missing(sym, *args)
9
+ super unless DEEP_SYMBOLIZE_KEYS_SYMBOLS.include?(sym)
10
+
11
+ self.send("alias_#{sym}")
12
+ end
13
+
14
+ private
15
+ def alias_deep_symbolize_keys!
16
+ alias_hash_deep_symbolize_keys!(self)
17
+ end
18
+
19
+ def alias_deep_symbolize_keys
20
+ alias_hash_deep_symbolize_keys!(self.deep_copy)
21
+ end
22
+
23
+ def alias_hash_deep_symbolize_keys!(h)
24
+ h.keys.each do |k|
25
+ ks = k.respond_to?(:to_sym) ? k.to_sym : k
26
+ h[ks] = h.delete k
27
+ alias_hash_deep_symbolize_keys! h[ks] if h[ks].kind_of? Hash
28
+ end
29
+
30
+ h
31
+ end # https://stackoverflow.com/a/8379653/1651458
32
+ end
@@ -5,24 +5,29 @@ module Webdriver
5
5
  module Devices
6
6
 
7
7
  def devices
8
- YAML.load_file devices_file
8
+ string_hash = YAML.safe_load_file devices_file, aliases: true
9
+ JSON.parse(JSON[string_hash], symbolize_names: true)
9
10
  end
10
11
 
11
12
  def resolution_for(device_name, orientation, user_width, user_height)
12
13
  return [user_width.to_i, user_height.to_i] if ((user_width.to_i + user_height.to_i) > 1)
13
14
 
14
- device = devices[device_name.downcase][orientation.downcase]
15
+ device = devices[keyify(device_name)][keyify(orientation)]
15
16
  [device[:width],device[:height]]
16
17
  end
17
18
 
18
19
  def agent_string_for(device)
19
- device = (device ? device.downcase : :iphone)
20
+ device = (device ? keyify(device) : :iphone)
20
21
  user_agent_string = (device == :random ? random_user_agent : devices[device][:user_agent])
21
22
  raise "Unsupported user agent: '#{device}'." unless user_agent_string
22
23
  user_agent_string
23
24
  end
24
25
 
25
26
  private
27
+
28
+ def keyify(target)
29
+ target.downcase.to_sym
30
+ end
26
31
 
27
32
  def random_user_agent
28
33
  File.foreach(user_agents_file).each_with_index.reduce(nil) do |picked,pair|
@@ -15,17 +15,6 @@ module Webdriver
15
15
  user_agent_string ||= agent_string_for opts[:agent]
16
16
  options = BrowserOptions.new(opts, user_agent_string)
17
17
  build_driver_using options
18
- ensure
19
- if safari?(opts)
20
- case
21
- when opts[:safari_technology_preview].is_a?(TrueClass)
22
- `defaults delete com.apple.SafariTechnologyPreview CustomUserAgent`
23
- `defaults delete com.apple.SafariTechnologyPreview AppleLanguages`
24
- else
25
- `defaults delete com.apple.Safari CustomUserAgent`
26
- `defaults delete com.apple.Safari AppleLanguages`
27
- end
28
- end
29
18
  end
30
19
 
31
20
  private
@@ -1,4 +1,5 @@
1
1
  require 'webdriver-user-agent/core_ext/symbol'
2
+ require 'webdriver-user-agent/core_ext/hash'
2
3
  require 'webdriver-user-agent/driver'
3
4
 
4
5
  module Webdriver
@@ -7,12 +7,13 @@ require 'selenium-webdriver'
7
7
  require 'watir'
8
8
  require 'webdrivers'
9
9
 
10
- CHROMEBROWSER_UICHROME_HEIGHT = 123
10
+ CHROMEBROWSER_UICHROME_HEIGHT = 124
11
11
  CHROMEBROWSER_UICHROME_HEIGHT_TALL = 50
12
12
  CHROMEBROWSER_UI_MINIMUM_HEIGHT = 289
13
- FIREFOXBROWSER_UICHROME_HEIGHT = 74
13
+ FIREFOXBROWSER_UICHROME_HEIGHT = 85
14
14
  FIREFOXBROWSER_MINIMUM_WIDTH = 450
15
15
  SAFARIBROWSER_UICHROME_HEIGHT = 38
16
+ SIZE_FUDGE_FACTOR = 0.05
16
17
 
17
18
  RSpec.shared_examples "browser driver" do
18
19
  it "creates the browser driver" do
@@ -36,38 +37,44 @@ end
36
37
 
37
38
  RSpec.shared_examples "firefox size" do
38
39
  it "matches the expected width" do
39
- width_expectation = device.dig(orientation, :width)
40
+ width_expectation = device.dig(orientation.downcase.to_sym, :width)
40
41
  width_expectation = FIREFOXBROWSER_MINIMUM_WIDTH if width_expectation < FIREFOXBROWSER_MINIMUM_WIDTH
41
- expect(driver.execute_script(width_script)).to eq(width_expectation)
42
+ width_expectation_fudge = width_expectation.to_f * SIZE_FUDGE_FACTOR
43
+ expect(driver.execute_script(width_script)).to be_within(width_expectation_fudge).of(width_expectation)
42
44
  end
43
45
 
44
46
  it "matches the expected height" do
45
- height_expectation = device.dig(orientation, :height) - FIREFOXBROWSER_UICHROME_HEIGHT
46
- expect(driver.execute_script(height_script)).to eq(height_expectation)
47
+ height_expectation = device.dig(orientation.downcase.to_sym, :height) - FIREFOXBROWSER_UICHROME_HEIGHT
48
+ height_expectation_fudge = height_expectation.to_f * SIZE_FUDGE_FACTOR
49
+ expect(driver.execute_script(height_script)).to be_within(height_expectation_fudge).of(height_expectation)
47
50
  end
48
51
  end
49
52
 
50
53
  RSpec.shared_examples "safari size" do
51
54
  it "matches the expected width" do
52
- width_expectation = device.dig(orientation, :width)
53
- expect(driver.execute_script(width_script)).to eq(width_expectation)
55
+ width_expectation = device.dig(orientation.downcase.to_sym, :width)
56
+ width_expectation_fudge = width_expectation.to_f * SIZE_FUDGE_FACTOR
57
+ expect(driver.execute_script(width_script)).to be_within(width_expectation_fudge).of(width_expectation)
54
58
  end
55
59
 
56
60
  it "matches the expected height" do
57
- height_expectation = device.dig(orientation, :height) - SAFARIBROWSER_UICHROME_HEIGHT
58
- expect(driver.execute_script(height_script)).to eq(height_expectation)
61
+ height_expectation = device.dig(orientation.downcase.to_sym, :height) - SAFARIBROWSER_UICHROME_HEIGHT
62
+ height_expectation_fudge = height_expectation.to_f * SIZE_FUDGE_FACTOR
63
+ expect(driver.execute_script(height_script)).to be_within(height_expectation_fudge).of(height_expectation)
59
64
  end
60
65
  end
61
66
 
62
67
  RSpec.shared_examples "chrome size" do
63
68
  it "matches the expected width" do
64
- width_expectation = device.dig(orientation, :width)
65
- expect(driver.execute_script(width_script)).to eq(width_expectation)
69
+ width_expectation = device.dig(orientation.downcase.to_sym, :width)
70
+ width_expectation_fudge = width_expectation.to_f * SIZE_FUDGE_FACTOR
71
+ expect(driver.execute_script(width_script)).to be_within(width_expectation_fudge).of(width_expectation)
66
72
  end
67
73
 
68
74
  it "matches the expected height" do
69
- height_expectation = device.dig(orientation, :height) - CHROMEBROWSER_UICHROME_HEIGHT
70
- expect(driver.execute_script(height_script)).to eq(height_expectation)
75
+ height_expectation = device.dig(orientation.downcase.to_sym, :height) - CHROMEBROWSER_UICHROME_HEIGHT
76
+ height_expectation_fudge = height_expectation.to_f * SIZE_FUDGE_FACTOR
77
+ expect(driver.execute_script(height_script)).to be_within(height_expectation_fudge).of(height_expectation)
71
78
  end
72
79
  end
73
80
 
@@ -78,8 +85,12 @@ describe "webdriver user agent" do
78
85
  let(:height_script) { 'return Math.max(document.documentElement.clientHeight, window.innerHeight || 0)' }
79
86
 
80
87
  after :each do
81
- driver.quit if defined?(driver)
88
+ driver.quit if defined?(driver) rescue Selenium::WebDriver::Error::SessionNotCreatedError
82
89
  browser.close if defined?(browser) && browser&.is_a?(Watir::Browser)
90
+ `defaults delete com.apple.SafariTechnologyPreview CustomUserAgent >/dev/null 2>/dev/null`
91
+ `defaults delete com.apple.SafariTechnologyPreview AppleLanguages >/dev/null 2>/dev/null`
92
+ `defaults delete com.apple.Safari CustomUserAgent >/dev/null 2>/dev/null`
93
+ `defaults delete com.apple.Safari AppleLanguages >/dev/null 2>/dev/null`
83
94
  sleep(0.5) # Safari needs time to shutdown
84
95
  end
85
96
 
@@ -88,7 +99,7 @@ describe "webdriver user agent" do
88
99
  # browser widths and heights
89
100
  # http://stackoverflow.com/a/8876069/1651458
90
101
 
91
- context "no browser, agent or orientation set" do
102
+ context "standard browser, agent or orientation set" do
92
103
  let(:device) { devices[:iphone] }
93
104
  let(:driver) { Webdriver::UserAgent.driver }
94
105
  let(:browser) { "firefox" }
@@ -98,26 +109,62 @@ describe "webdriver user agent" do
98
109
  it_behaves_like "browser driver"
99
110
  it_behaves_like "firefox size"
100
111
  end
112
+
113
+ context "device, browser, orientation, agent are all symbols" do
114
+ let(:device) { devices[:iphone] }
115
+ let(:device_key) { :iphone }
116
+ let(:browser) { :firefox }
117
+ let(:orientation) { :landscape }
118
+ let(:driver) { Webdriver::UserAgent.driver(
119
+ browser: browser,
120
+ agent: device_key,
121
+ orientation: orientation) }
122
+ let(:agent_match) { 'iPhone' }
123
+
124
+ it_behaves_like "browser driver"
125
+ it_behaves_like "firefox size"
126
+ end
127
+
128
+ context "browser is a symbol; device, orientation, agent are all strings" do
129
+ let(:device) { devices[:iphone] }
130
+ let(:device_key) { "iPhone" }
131
+ let(:browser) { :firefox }
132
+ let(:orientation) { "Portrait" }
133
+ let(:driver) { Webdriver::UserAgent.driver(
134
+ browser: browser,
135
+ agent: device_key,
136
+ orientation: orientation) }
137
+ let(:agent_match) { 'iPhone' }
138
+
139
+ it_behaves_like "browser driver"
140
+ it_behaves_like "firefox size"
141
+ end
101
142
 
102
143
  context "Safari browser, iPhone 11 Pro Max agent, landscape orientation" do
103
144
  let(:device) { devices[:iphone11promax] }
104
145
  let(:orientation) { :landscape }
105
146
  let(:driver) do
106
- # Safari is a mess. safari_technology_preview added because
107
- # Safari just isn't working in my environment as of 13.1 - Sam
147
+ # --- On Safari ---
148
+ # Safari is a mess. We do our best to test it, but
149
+ # it is too unreliable. The gem will still try to provide
150
+ # these features for the time being.
151
+ # If you are a subject matter expert, please
152
+ # get in touch. - Sam
108
153
 
109
154
  Webdriver::UserAgent.driver(
110
155
  browser: :safari,
111
156
  agent: :iphone11promax,
112
- orientation: orientation,
113
- safari_technology_preview: true
157
+ orientation: orientation
114
158
  )
115
159
  end
116
160
  let(:browser) { "safari" }
117
161
  let(:orientation) { :landscape }
118
162
  let(:agent_match) { 'iPhone' }
119
163
 
120
- it_behaves_like "browser driver"
164
+ # pending("a stable, documented way to programmatically change Safari details") { it_behaves_like "browser driver" }
165
+ # But there doesn't seem to be any way for RSpec to handle the above?
166
+ # `it_behaves_like` isn't available inside `pending`, but `pending` isn't available at
167
+ # the `context` level.
121
168
  it_behaves_like "safari size"
122
169
  end
123
170
 
@@ -125,20 +172,19 @@ describe "webdriver user agent" do
125
172
  let(:device) { devices[:iphone6plus] }
126
173
  let(:orientation) { :landscape }
127
174
  let(:driver) do
128
- # Safari is a mess. safari_technology_preview added because
129
- # Safari just isn't working in my environment as of 13.1 - Sam
130
-
131
175
  Webdriver::UserAgent.driver(
132
176
  browser: :safari,
133
177
  agent: :iphone6plus,
134
- orientation: orientation,
135
- safari_technology_preview: true
178
+ orientation: orientation
136
179
  )
137
180
  end
138
181
  let(:browser) { "safari" }
139
182
  let(:agent_match) { 'iPhone' }
140
-
141
- it_behaves_like "browser driver"
183
+
184
+ # pending("a stable, documented way to programmatically change Safari details") { it_behaves_like "browser driver" }
185
+ # But there doesn't seem to be any way for RSpec to handle the above?
186
+ # `it_behaves_like` isn't available inside `pending`, but `pending` isn't available at
187
+ # the `context` level.
142
188
  it_behaves_like "safari size"
143
189
  end
144
190
 
@@ -161,7 +207,7 @@ describe "webdriver user agent" do
161
207
  end
162
208
 
163
209
  context "Chrome browser, iPhone XS agent, landscape orientation" do
164
- let(:device_key) { :ipad }
210
+ let(:device_key) { :iphone6 }
165
211
  let(:device) { devices[device_key] }
166
212
  let(:orientation) { :landscape }
167
213
  let(:driver) do
@@ -204,7 +250,7 @@ describe "webdriver user agent" do
204
250
  end
205
251
 
206
252
  context "Chrome browser, Android tablet agent, landscape orientation" do
207
- let(:device_key) { :android_tablet }
253
+ let(:device_key) { :android_phone }
208
254
  let(:device) { devices[device_key] }
209
255
  let(:orientation) { :landscape }
210
256
  let(:driver) do
@@ -310,14 +356,15 @@ describe "webdriver user agent" do
310
356
  let(:driver) {
311
357
  Webdriver::UserAgent.driver(
312
358
  browser: browser,
313
- accept_language_string: language,
314
- safari_technology_preview: true
359
+ accept_language_string: language
315
360
  )
316
361
  }
317
362
 
318
363
  it "can create a new webdriver driver" do
319
364
  expect("#{driver.browser}").to match(/#{Regexp.quote(browser.to_s)}/i)
320
-
365
+ end
366
+
367
+ pending("a stable, documented way to programmatically change Safari details") do
321
368
  expect(driver.execute_script("return (navigator.language || navigator.userLanguage)")).to include("es-es")
322
369
  end
323
370
  end
@@ -12,7 +12,7 @@ Gem::Specification.new do |gem|
12
12
  gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
13
13
  gem.name = "webdriver-user-agent"
14
14
  gem.require_paths = ["lib"]
15
- gem.version = "7.8"
15
+ gem.version = "7.9"
16
16
  gem.requirements << 'chromedriver, v2.20'
17
17
  # chromedriver v2.19 causes
18
18
  # Selenium::WebDriver::Error::NoSuchDriverError: no such session errors
metadata CHANGED
@@ -1,17 +1,17 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: webdriver-user-agent
3
3
  version: !ruby/object:Gem::Version
4
- version: '7.8'
4
+ version: '7.9'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alister Scott
8
8
  - Jeff Morgan
9
9
  - Sandeep Singh
10
10
  - Sam Nissen
11
- autorequire:
11
+ autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2020-07-10 00:00:00.000000000 Z
14
+ date: 2022-05-25 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: selenium-webdriver
@@ -150,6 +150,7 @@ files:
150
150
  - lib/device-info/user_agents.txt
151
151
  - lib/webdriver-user-agent.rb
152
152
  - lib/webdriver-user-agent/browser_options.rb
153
+ - lib/webdriver-user-agent/core_ext/hash.rb
153
154
  - lib/webdriver-user-agent/core_ext/symbol.rb
154
155
  - lib/webdriver-user-agent/devices.rb
155
156
  - lib/webdriver-user-agent/driver.rb
@@ -158,7 +159,7 @@ files:
158
159
  homepage: https://github.com/alisterscott/webdriver-user-agent
159
160
  licenses: []
160
161
  metadata: {}
161
- post_install_message:
162
+ post_install_message:
162
163
  rdoc_options: []
163
164
  require_paths:
164
165
  - lib
@@ -174,8 +175,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
174
175
  version: '0'
175
176
  requirements:
176
177
  - chromedriver, v2.20
177
- rubygems_version: 3.1.2
178
- signing_key:
178
+ rubygems_version: 3.3.7
179
+ signing_key:
179
180
  specification_version: 4
180
181
  summary: A helper gem to emulate populate device user agents and resolutions when
181
182
  using webdriver