taf 0.4.6 → 0.4.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/taf/browser.rb +29 -46
- data/lib/taf/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 04bfd83f1b4afcb338b6afd15e91d841000000c7786e928ece58df06cef52002
|
4
|
+
data.tar.gz: 24363e1820e50bcf7063ec2b42f3623ce61b51099d60568046d458731f6330f7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bb53d9c56e944568293b70c6097181fcf0805c4bf3c5ed559779a7db4cb8f9f1d4034ba8a882b93525f58613b5b017409efb3a89b78ee61e3e3be831fc37d13d
|
7
|
+
data.tar.gz: 650d779bc0f420b517b7e2f54f6bc09faff4a8ea0885892663920d742834abeb12e6c0f7ef05d261c1aa73b510c985bb85d44e524ce878da3891fda0c34a3f3b
|
data/lib/taf/browser.rb
CHANGED
@@ -9,7 +9,7 @@
|
|
9
9
|
module Taf
|
10
10
|
# browser_setup.rb - a browser functions
|
11
11
|
module Browser
|
12
|
-
#
|
12
|
+
# Supported Browser names
|
13
13
|
@chrome_name = 'chrome'
|
14
14
|
@chrome_headless_name = 'chrome-headless'
|
15
15
|
@firefox_name = 'firefox'
|
@@ -17,61 +17,46 @@ module Taf
|
|
17
17
|
|
18
18
|
# open_browser function
|
19
19
|
def self.open_browser
|
20
|
-
|
21
|
-
case
|
22
|
-
when @chrome_name then chrome
|
23
|
-
when @
|
24
|
-
when @firefox_name then firefox
|
25
|
-
when @firefox_headless_name then firefox_headless
|
20
|
+
@browser_name = Taf::CMDLine.browser_type.downcase
|
21
|
+
case @browser_name
|
22
|
+
when @chrome_name, @chrome_headless_name then chrome
|
23
|
+
when @firefox_name, @firefox_headless_name then firefox
|
26
24
|
else
|
27
25
|
raise Taf::BrowserFailedOpen,
|
28
|
-
"unable to open selected browser: #{
|
26
|
+
"unable to open selected browser: #{@browser_name}"
|
29
27
|
end
|
30
28
|
end
|
31
29
|
|
32
30
|
# chrome browser details
|
33
31
|
def self.chrome
|
34
|
-
@
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
32
|
+
case @browser_name
|
33
|
+
when @chrome_name
|
34
|
+
chrome_values = %w[
|
35
|
+
--acceptInsecureCerts-true --start-maximized --window-size=1920,1080
|
36
|
+
]
|
37
|
+
when @chrome_headless_name
|
38
|
+
chrome_values = %w[
|
39
|
+
--start-maximized --disable-gpu --headless --acceptInsecureCerts-true
|
40
|
+
--no-sandbox --window-size=1920,1080
|
41
|
+
]
|
42
|
+
end
|
43
|
+
@browser = Watir::Browser.new :chrome, switches: chrome_values
|
45
44
|
end
|
46
45
|
|
47
46
|
# firefox browser details
|
48
47
|
def self.firefox
|
49
48
|
caps = Selenium::WebDriver::Remote::Capabilities.firefox
|
50
49
|
caps['acceptInsecureCerts'] = true
|
51
|
-
|
52
|
-
@
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
options = Selenium::WebDriver::Firefox::Options.new(args: ['-headless'])
|
60
|
-
caps['acceptInsecureCerts'] = true
|
61
|
-
driver = Selenium::WebDriver.for(:firefox, options: options,
|
62
|
-
desired_capabilities: caps)
|
50
|
+
case @browser_name
|
51
|
+
when @firefox_name
|
52
|
+
driver = Selenium::WebDriver.for(:firefox, desired_capabilities: caps)
|
53
|
+
when @firefox_headless_name
|
54
|
+
options = Selenium::WebDriver::Firefox::Options.new(args: ['-headless'])
|
55
|
+
driver = Selenium::WebDriver.for(:firefox, options: options,
|
56
|
+
desired_capabilities: caps)
|
57
|
+
end
|
63
58
|
@browser = Watir::Browser.new(driver)
|
64
|
-
|
65
|
-
@browser.driver.manage.window.resize_to(1920, 1200)
|
66
|
-
@browser.driver.manage.window.move_to(0, 0)
|
67
|
-
end
|
68
|
-
|
69
|
-
# makes the browser full screen.
|
70
|
-
def self.browser_full_screen
|
71
|
-
screen_width = @browser.execute_script('return screen.width;')
|
72
|
-
screen_height = @browser.execute_script('return screen.height;')
|
73
|
-
@browser.driver.manage.window.resize_to(screen_width, screen_height)
|
74
|
-
@browser.driver.manage.window.move_to(0, 0)
|
59
|
+
@browser.driver.manage.window.maximize
|
75
60
|
end
|
76
61
|
|
77
62
|
# define browser value
|
@@ -81,8 +66,7 @@ module Taf
|
|
81
66
|
|
82
67
|
# Check browser version
|
83
68
|
def self.browser_version
|
84
|
-
browser_name
|
85
|
-
case browser_name
|
69
|
+
case @browser_name
|
86
70
|
when @chrome_name, @chrome_headless_name
|
87
71
|
@browser.driver.capabilities[:version]
|
88
72
|
when @firefox_name, @firefox_headless_name
|
@@ -94,8 +78,7 @@ module Taf
|
|
94
78
|
|
95
79
|
# Check platform
|
96
80
|
def self.browser_platform
|
97
|
-
browser_name
|
98
|
-
case browser_name
|
81
|
+
case @browser_name
|
99
82
|
when @chrome_name, @chrome_headless_name
|
100
83
|
@browser.execute_script('return navigator.userAgent;')
|
101
84
|
.split(';')[1].split(')')[0]
|
data/lib/taf/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: taf
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andy Perrett
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-08-
|
11
|
+
date: 2019-08-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|