webdriver-user-agent 7.1 → 7.2
Sign up to get free protection for your applications and to get access to all the features.
- data/ChangeLog +5 -0
- data/README.md +5 -5
- data/lib/device-info/devices.yaml +36 -12
- data/lib/webdriver-user-agent/browser_options.rb +1 -1
- data/lib/webdriver-user-agent/driver.rb +2 -1
- data/spec/webdriver-user-agent_spec.rb +47 -30
- data/webdriver-user-agent.gemspec +1 -1
- metadata +29 -17
- checksums.yaml +0 -7
data/ChangeLog
CHANGED
@@ -1,3 +1,8 @@
|
|
1
|
+
=== Version 7.2 / 2014-12-12
|
2
|
+
* Enhancements
|
3
|
+
* Added iphone 5 and 6 variants (Thanks samnissen)
|
4
|
+
* Added ability to pass options user agent (Thanks samnissen)
|
5
|
+
|
1
6
|
=== Version 7.1 / 2014-3-2
|
2
7
|
* Enhancements
|
3
8
|
* Added ipad 7 device support (Thanks Matthwe Fleeger)
|
data/README.md
CHANGED
@@ -39,15 +39,15 @@ provides a UserAgent.driver method to return a new web-driver with user agent an
|
|
39
39
|
|
40
40
|
require 'selenium-webdriver'
|
41
41
|
require 'webdriver-user-agent'
|
42
|
-
driver = UserAgent.driver(:browser => :chrome, :agent => :iphone, :orientation => :landscape)
|
42
|
+
driver = Webdriver::UserAgent.driver(:browser => :chrome, :agent => :iphone, :orientation => :landscape)
|
43
43
|
driver.get 'http://tiffany.com'
|
44
44
|
driver.current_url.should == 'http://m.tiffany.com/International.aspx'
|
45
45
|
|
46
46
|
### Example using random user agent
|
47
47
|
|
48
|
-
require 'selenium-
|
48
|
+
require 'selenium-webdriver'
|
49
49
|
require 'webdriver-user-agent'
|
50
|
-
driver = UserAgent.driver(:agent => :random)
|
50
|
+
driver = Webdriver::UserAgent.driver(:agent => :random)
|
51
51
|
driver.execute_script('return navigator.userAgent')
|
52
52
|
# random agent like "Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:0.9.2) Gecko/20010726 Netscape6/6.1"
|
53
53
|
|
@@ -55,8 +55,8 @@ provides a UserAgent.driver method to return a new web-driver with user agent an
|
|
55
55
|
|
56
56
|
require 'watir-webdriver'
|
57
57
|
require 'webdriver-user-agent'
|
58
|
-
driver = UserAgent.driver(:browser => :chrome, :agent => :iphone, :orientation => :landscape)
|
59
|
-
browser = Watir::Browser.new
|
58
|
+
driver = Webdriver::UserAgent.driver(:browser => :chrome, :agent => :iphone, :orientation => :landscape)
|
59
|
+
browser = Watir::Browser.new(driver)
|
60
60
|
browser.goto 'tiffany.com'
|
61
61
|
browser.url.should == 'http://m.tiffany.com/International.aspx'
|
62
62
|
|
@@ -1,27 +1,51 @@
|
|
1
1
|
:iphone:
|
2
|
-
|
2
|
+
:user_agent: "Mozilla/5.0 (iPhone; CPU iPhone OS 8_1_1 like Mac OS X) AppleWebKit/600.1.4 (KHTML, like Gecko) Version/8.0 Mobile/12B435 Safari/600.1.4"
|
3
|
+
:portrait:
|
4
|
+
:width: 375
|
5
|
+
:height: 559
|
6
|
+
:landscape:
|
7
|
+
:width: 667
|
8
|
+
:height: 375
|
9
|
+
:iphone6plus:
|
10
|
+
:user_agent: "Mozilla/5.0 (iPhone; CPU iPhone OS 8_1_1 like Mac OS X) AppleWebKit/600.1.4 (KHTML, like Gecko) Version/8.0 Mobile/12B435 Safari/600.1.4"
|
11
|
+
:portrait:
|
12
|
+
:width: 414
|
13
|
+
:height: 628
|
14
|
+
:landscape:
|
15
|
+
:width: 736
|
16
|
+
:height: 414
|
17
|
+
:iphone6:
|
18
|
+
:user_agent: "Mozilla/5.0 (iPhone; CPU iPhone OS 8_1_1 like Mac OS X) AppleWebKit/600.1.4 (KHTML, like Gecko) Version/8.0 Mobile/12B435 Safari/600.1.4"
|
19
|
+
:portrait:
|
20
|
+
:width: 375
|
21
|
+
:height: 559
|
22
|
+
:landscape:
|
23
|
+
:width: 667
|
24
|
+
:height: 375
|
25
|
+
:iphone5s:
|
26
|
+
:user_agent: "Mozilla/5.0 (iPhone; CPU iPhone OS 8_1_1 like Mac OS X) AppleWebKit/600.1.4 (KHTML, like Gecko) Version/8.0 Mobile/12B435 Safari/600.1.4"
|
27
|
+
:portrait:
|
28
|
+
:width: 320
|
29
|
+
:height: 460
|
30
|
+
:landscape:
|
31
|
+
:width: 568
|
32
|
+
:height: 212
|
33
|
+
:iphone4s:
|
34
|
+
:user_agent: "Mozilla/5.0 (iPhone; CPU iPhone OS 8_1_1 like Mac OS X) AppleWebKit/600.1.4 (KHTML, like Gecko) Version/8.0 Mobile/12B435 Safari/600.1.4"
|
3
35
|
:portrait:
|
4
36
|
:width: 320
|
5
37
|
:height: 356
|
6
38
|
:landscape:
|
7
39
|
:width: 480
|
8
40
|
:height: 196
|
9
|
-
:ipad_seven:
|
10
|
-
:user_agent: "Mozilla/5.0 (iPad; CPU OS 6_1_3 like Mac OS X) AppleWebKit/536.26 (KHTML, like Gecko) Version/6.0 Mobile/10B329 Safari/8536.25"
|
11
|
-
:portrait:
|
12
|
-
:width: 768
|
13
|
-
:height: 946
|
14
|
-
:landscape:
|
15
|
-
:width: 1024
|
16
|
-
:height: 690
|
17
41
|
:ipad:
|
18
|
-
:user_agent: "Mozilla/5.0(iPad; U; CPU OS
|
42
|
+
:user_agent: "Mozilla/5.0(iPad; U; CPU OS 8_1_1 like Mac OS X) AppleWebKit/600.14 (KHTML, like Gecko) Version/8.0 Mobile/12B435 Safari/9537.53"
|
19
43
|
:portrait:
|
20
44
|
:width: 768
|
21
|
-
:height:
|
45
|
+
:height: 960
|
22
46
|
:landscape:
|
23
47
|
:width: 1024
|
24
|
-
:height:
|
48
|
+
:height: 704
|
25
49
|
:android_phone:
|
26
50
|
:user_agent: "Mozilla/5.0 (Linux; U; Android 4.0.1; en-us; sdk Build/ICS_MR0) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30"
|
27
51
|
:portrait:
|
@@ -10,7 +10,8 @@ module Webdriver
|
|
10
10
|
include Devices
|
11
11
|
|
12
12
|
def for(opts)
|
13
|
-
user_agent_string
|
13
|
+
user_agent_string = opts[:user_agent_string]
|
14
|
+
user_agent_string ||= agent_string_for opts[:agent]
|
14
15
|
options = BrowserOptions.new(opts, user_agent_string)
|
15
16
|
build_driver_using options
|
16
17
|
end
|
@@ -13,67 +13,84 @@ describe "webdriver user agent" do
|
|
13
13
|
|
14
14
|
it "can create a new webdriver driver using firefox and iphone (portrait) by default" do
|
15
15
|
@driver = Webdriver::UserAgent.driver
|
16
|
-
@driver.browser.
|
17
|
-
@driver.execute_script('return navigator.userAgent').
|
18
|
-
@driver.execute_script('return window.innerWidth').
|
19
|
-
@driver.execute_script('return window.innerHeight').
|
16
|
+
expect(@driver.browser).to eq(:firefox)
|
17
|
+
expect(@driver.execute_script('return navigator.userAgent')).to include 'iPhone'
|
18
|
+
expect(@driver.execute_script('return window.innerWidth')).to eq(375)
|
19
|
+
expect(@driver.execute_script('return window.innerHeight')).to eq(559)
|
20
|
+
end
|
21
|
+
|
22
|
+
it "can create a new webdriver driver using chrome and iphone 6 plus (landscape)" do
|
23
|
+
@driver = Webdriver::UserAgent.driver(:browser => :chrome, :agent => :iphone6plus, :orientation => :landscape)
|
24
|
+
expect(@driver.browser).to eq(:chrome)
|
25
|
+
expect(@driver.execute_script('return navigator.userAgent')).to include 'iPhone'
|
26
|
+
expect(@driver.execute_script('return window.innerWidth')).to eq(736)
|
27
|
+
expect(@driver.execute_script('return window.innerHeight')).to eq(414)
|
20
28
|
end
|
21
29
|
|
22
30
|
it "can create a new webdriver driver using chrome and iPad (landscape)" do
|
23
31
|
@driver = Webdriver::UserAgent.driver(:browser => :chrome, :agent => :iPad, :orientation => :landscape)
|
24
|
-
@driver.browser.
|
25
|
-
@driver.execute_script('return navigator.userAgent').
|
26
|
-
@driver.execute_script('return window.innerWidth').
|
27
|
-
@driver.execute_script('return window.innerHeight').
|
32
|
+
expect(@driver.browser).to eq(:chrome)
|
33
|
+
expect(@driver.execute_script('return navigator.userAgent')).to include 'iPad'
|
34
|
+
expect(@driver.execute_script('return window.innerWidth')).to eq(1024)
|
35
|
+
expect(@driver.execute_script('return window.innerHeight')).to eq(704)
|
28
36
|
end
|
29
37
|
|
30
38
|
it "can create a new webdriver driver using firefox and android phone (landscape)" do
|
31
39
|
@driver = Webdriver::UserAgent.driver(:browser => :chrome, :agent => :android_phone, :orientation => :landscape)
|
32
|
-
@driver.browser.
|
33
|
-
@driver.execute_script('return navigator.userAgent').
|
34
|
-
@driver.execute_script('return window.innerWidth').
|
35
|
-
@driver.execute_script('return window.innerHeight').
|
40
|
+
expect(@driver.browser).to eq(:chrome)
|
41
|
+
expect(@driver.execute_script('return navigator.userAgent')).to include 'Android'
|
42
|
+
expect(@driver.execute_script('return window.innerWidth')).to eq(480)
|
43
|
+
expect(@driver.execute_script('return window.innerHeight')).to eq(196)
|
36
44
|
end
|
37
45
|
|
38
46
|
it "can create a new webdriver driver using firefox and android tablet (portrait)" do
|
39
47
|
@driver = Webdriver::UserAgent.driver(:browser => :chrome, :agent => :android_tablet, :orientation => :portrait)
|
40
|
-
@driver.browser.
|
41
|
-
@driver.execute_script('return navigator.userAgent').
|
42
|
-
@driver.execute_script('return window.innerWidth').
|
43
|
-
@driver.execute_script('return window.innerHeight').
|
48
|
+
expect(@driver.browser).to eq(:chrome)
|
49
|
+
expect(@driver.execute_script('return navigator.userAgent')).to include 'Android'
|
50
|
+
expect(@driver.execute_script('return window.innerWidth')).to eq(768)
|
51
|
+
expect(@driver.execute_script('return window.innerHeight')).to eq(946)
|
44
52
|
end
|
45
53
|
|
46
54
|
it "can create a new webdriver driver using firefox and random user agent" do
|
47
55
|
@driver = Webdriver::UserAgent.driver(:agent => :random)
|
48
|
-
@driver.browser.
|
49
|
-
@driver.execute_script('return navigator.userAgent').
|
50
|
-
@driver.execute_script('return window.innerWidth').
|
51
|
-
@driver.execute_script('return window.innerHeight').
|
56
|
+
expect(@driver.browser).to eq(:firefox)
|
57
|
+
expect(@driver.execute_script('return navigator.userAgent')).not_to be_nil
|
58
|
+
expect(@driver.execute_script('return window.innerWidth')).not_to eq(320)
|
59
|
+
expect(@driver.execute_script('return window.innerHeight')).not_to eq(356)
|
52
60
|
end
|
53
61
|
|
54
62
|
it "can create a new webdriver driver using chrome and random user agent" do
|
55
63
|
@driver = Webdriver::UserAgent.driver(:browser => :chrome, :agent => :random)
|
56
|
-
@driver.browser.
|
57
|
-
@driver.execute_script('return navigator.userAgent').
|
58
|
-
@driver.execute_script('return window.innerWidth').
|
59
|
-
@driver.execute_script('return window.innerHeight').
|
64
|
+
expect(@driver.browser).to eq(:chrome)
|
65
|
+
expect(@driver.execute_script('return navigator.userAgent')).not_to be_nil
|
66
|
+
expect(@driver.execute_script('return window.innerWidth')).not_to eq(320)
|
67
|
+
expect(@driver.execute_script('return window.innerHeight')).not_to eq(356)
|
60
68
|
end
|
61
69
|
|
62
70
|
it "can create a new webdriver driver using an existing firefox profile" do
|
63
71
|
profile = Selenium::WebDriver::Firefox::Profile.new
|
64
72
|
profile['browser.startup.homepage'] = "data:text/html,<title>hello</title>"
|
65
73
|
@driver = Webdriver::UserAgent.driver(:browser => :firefox, :profile => profile)
|
66
|
-
@driver.browser.
|
67
|
-
@driver.execute_script('return navigator.userAgent').
|
68
|
-
@driver.execute_script('return window.innerWidth').
|
69
|
-
@driver.execute_script('return window.innerHeight').
|
70
|
-
@driver.title.
|
74
|
+
expect(@driver.browser).to eq(:firefox)
|
75
|
+
expect(@driver.execute_script('return navigator.userAgent')).to include 'iPhone'
|
76
|
+
expect(@driver.execute_script('return window.innerWidth')).to eq(375)
|
77
|
+
expect(@driver.execute_script('return window.innerHeight')).to eq(559)
|
78
|
+
expect(@driver.title).to eq('hello')
|
71
79
|
end
|
80
|
+
|
81
|
+
it "can create a new webdriver driver using firefox and user-specified user agent" do
|
82
|
+
@driver = Webdriver::UserAgent.driver(:user_agent_string => "Mozilla/4.0 (compatible; MSIE 5.5b1; Mac_PowerPC)")
|
83
|
+
expect(@driver.browser).to eq(:firefox)
|
84
|
+
expect(@driver.execute_script('return navigator.userAgent')).not_to be_nil
|
85
|
+
|
86
|
+
@browser = Watir::Browser.new @driver
|
87
|
+
expect(@browser.url).to eq("about:blank")
|
88
|
+
end
|
72
89
|
|
73
90
|
it "can allow using selenium driver for watir browser" do
|
74
91
|
@driver = Webdriver::UserAgent.driver(:browser => :firefox, :agent => :iphone, :orientation => :portrait)
|
75
92
|
@browser = Watir::Browser.new @driver
|
76
|
-
@browser.url.
|
93
|
+
expect(@browser.url).to eq("about:blank")
|
77
94
|
end
|
78
95
|
|
79
96
|
|
@@ -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.
|
15
|
+
gem.version = "7.2"
|
16
16
|
gem.add_dependency 'selenium-webdriver'
|
17
17
|
gem.add_dependency 'facets'
|
18
18
|
gem.add_dependency 'json'
|
metadata
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: webdriver-user-agent
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '7.
|
4
|
+
version: '7.2'
|
5
|
+
prerelease:
|
5
6
|
platform: ruby
|
6
7
|
authors:
|
7
8
|
- Alister Scott
|
@@ -9,76 +10,86 @@ authors:
|
|
9
10
|
autorequire:
|
10
11
|
bindir: bin
|
11
12
|
cert_chain: []
|
12
|
-
date: 2014-
|
13
|
+
date: 2014-12-12 00:00:00.000000000 Z
|
13
14
|
dependencies:
|
14
15
|
- !ruby/object:Gem::Dependency
|
15
16
|
name: selenium-webdriver
|
16
17
|
requirement: !ruby/object:Gem::Requirement
|
18
|
+
none: false
|
17
19
|
requirements:
|
18
|
-
- - '>='
|
20
|
+
- - ! '>='
|
19
21
|
- !ruby/object:Gem::Version
|
20
22
|
version: '0'
|
21
23
|
type: :runtime
|
22
24
|
prerelease: false
|
23
25
|
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
none: false
|
24
27
|
requirements:
|
25
|
-
- - '>='
|
28
|
+
- - ! '>='
|
26
29
|
- !ruby/object:Gem::Version
|
27
30
|
version: '0'
|
28
31
|
- !ruby/object:Gem::Dependency
|
29
32
|
name: facets
|
30
33
|
requirement: !ruby/object:Gem::Requirement
|
34
|
+
none: false
|
31
35
|
requirements:
|
32
|
-
- - '>='
|
36
|
+
- - ! '>='
|
33
37
|
- !ruby/object:Gem::Version
|
34
38
|
version: '0'
|
35
39
|
type: :runtime
|
36
40
|
prerelease: false
|
37
41
|
version_requirements: !ruby/object:Gem::Requirement
|
42
|
+
none: false
|
38
43
|
requirements:
|
39
|
-
- - '>='
|
44
|
+
- - ! '>='
|
40
45
|
- !ruby/object:Gem::Version
|
41
46
|
version: '0'
|
42
47
|
- !ruby/object:Gem::Dependency
|
43
48
|
name: json
|
44
49
|
requirement: !ruby/object:Gem::Requirement
|
50
|
+
none: false
|
45
51
|
requirements:
|
46
|
-
- - '>='
|
52
|
+
- - ! '>='
|
47
53
|
- !ruby/object:Gem::Version
|
48
54
|
version: '0'
|
49
55
|
type: :runtime
|
50
56
|
prerelease: false
|
51
57
|
version_requirements: !ruby/object:Gem::Requirement
|
58
|
+
none: false
|
52
59
|
requirements:
|
53
|
-
- - '>='
|
60
|
+
- - ! '>='
|
54
61
|
- !ruby/object:Gem::Version
|
55
62
|
version: '0'
|
56
63
|
- !ruby/object:Gem::Dependency
|
57
64
|
name: rspec
|
58
65
|
requirement: !ruby/object:Gem::Requirement
|
66
|
+
none: false
|
59
67
|
requirements:
|
60
|
-
- - '>='
|
68
|
+
- - ! '>='
|
61
69
|
- !ruby/object:Gem::Version
|
62
70
|
version: '0'
|
63
71
|
type: :development
|
64
72
|
prerelease: false
|
65
73
|
version_requirements: !ruby/object:Gem::Requirement
|
74
|
+
none: false
|
66
75
|
requirements:
|
67
|
-
- - '>='
|
76
|
+
- - ! '>='
|
68
77
|
- !ruby/object:Gem::Version
|
69
78
|
version: '0'
|
70
79
|
- !ruby/object:Gem::Dependency
|
71
80
|
name: watir-webdriver
|
72
81
|
requirement: !ruby/object:Gem::Requirement
|
82
|
+
none: false
|
73
83
|
requirements:
|
74
|
-
- - '>='
|
84
|
+
- - ! '>='
|
75
85
|
- !ruby/object:Gem::Version
|
76
86
|
version: '0'
|
77
87
|
type: :development
|
78
88
|
prerelease: false
|
79
89
|
version_requirements: !ruby/object:Gem::Requirement
|
90
|
+
none: false
|
80
91
|
requirements:
|
81
|
-
- - '>='
|
92
|
+
- - ! '>='
|
82
93
|
- !ruby/object:Gem::Version
|
83
94
|
version: '0'
|
84
95
|
description: A helper gem to emulate populate device user agents and resolutions when
|
@@ -111,26 +122,27 @@ files:
|
|
111
122
|
- webdriver-user-agent.gemspec
|
112
123
|
homepage: https://github.com/alisterscott/webdriver-user-agent
|
113
124
|
licenses: []
|
114
|
-
metadata: {}
|
115
125
|
post_install_message:
|
116
126
|
rdoc_options: []
|
117
127
|
require_paths:
|
118
128
|
- lib
|
119
129
|
required_ruby_version: !ruby/object:Gem::Requirement
|
130
|
+
none: false
|
120
131
|
requirements:
|
121
|
-
- - '>='
|
132
|
+
- - ! '>='
|
122
133
|
- !ruby/object:Gem::Version
|
123
134
|
version: '0'
|
124
135
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
136
|
+
none: false
|
125
137
|
requirements:
|
126
|
-
- - '>='
|
138
|
+
- - ! '>='
|
127
139
|
- !ruby/object:Gem::Version
|
128
140
|
version: '0'
|
129
141
|
requirements: []
|
130
142
|
rubyforge_project:
|
131
|
-
rubygems_version:
|
143
|
+
rubygems_version: 1.8.25
|
132
144
|
signing_key:
|
133
|
-
specification_version:
|
145
|
+
specification_version: 3
|
134
146
|
summary: A helper gem to emulate populate device user agents and resolutions when
|
135
147
|
using webdriver
|
136
148
|
test_files:
|
checksums.yaml
DELETED
@@ -1,7 +0,0 @@
|
|
1
|
-
---
|
2
|
-
SHA1:
|
3
|
-
metadata.gz: 246376dd09fe9eac558fb372804af885dd6003c7
|
4
|
-
data.tar.gz: 55dbadaf04794351c98dd424ac3d070beed31bfb
|
5
|
-
SHA512:
|
6
|
-
metadata.gz: 6028660e13b8adbadcc1d4aafab55ead2b6293ed694381981ec8f6d48d39ecc29a380e21f60fe036a6d09b547183cf592b9af65741515e47af56a2b288b0a319
|
7
|
-
data.tar.gz: e3b2392dcfa301994b381d46cc26e26491e5170fae94d772ce85614d39d273d923ec7c2e5eedb750cb25d7963f59d1ee18f14b2ab220e1e298464f0c429d4968
|