taf 0.4.6 → 0.4.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/lib/taf/browser.rb +29 -46
  3. data/lib/taf/version.rb +1 -1
  4. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 98afd007e9cf30821d8543994680b8fd8a8540ace5252a5aa4863900caf1034d
4
- data.tar.gz: e2ecb265527f100c74606dec7cb6878d65ef8853df46b4837a7b7f15cf1acfc3
3
+ metadata.gz: 04bfd83f1b4afcb338b6afd15e91d841000000c7786e928ece58df06cef52002
4
+ data.tar.gz: 24363e1820e50bcf7063ec2b42f3623ce61b51099d60568046d458731f6330f7
5
5
  SHA512:
6
- metadata.gz: dc8af10f6757f6f4a39835278a8f679e35d5c9022b02fa2b8f26b36441fc41244d05e3d1c3788383f578ca646fc818c87869c9ea07e192aa8a716d9d37fea841
7
- data.tar.gz: f6246f7f9e7b2a2bbe145501b804fc50b20b7e1dddc35f4a2c4b3e023d4177f12b4939510c013c971b5859537a34522cc9dbecee13ac1fa7956b4b92dd4d3838
6
+ metadata.gz: bb53d9c56e944568293b70c6097181fcf0805c4bf3c5ed559779a7db4cb8f9f1d4034ba8a882b93525f58613b5b017409efb3a89b78ee61e3e3be831fc37d13d
7
+ data.tar.gz: 650d779bc0f420b517b7e2f54f6bc09faff4a8ea0885892663920d742834abeb12e6c0f7ef05d261c1aa73b510c985bb85d44e524ce878da3891fda0c34a3f3b
@@ -9,7 +9,7 @@
9
9
  module Taf
10
10
  # browser_setup.rb - a browser functions
11
11
  module Browser
12
- # Suppoerted Browser names
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
- browser = Taf::CMDLine.browser_type.downcase
21
- case browser
22
- when @chrome_name then chrome
23
- when @chrome_headless_name then chrome_headless
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: #{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
- @browser = Watir::Browser.new :chrome, switches: %w[
35
- --acceptInsecureCerts-true --start-maximized --window-size=1920,1080
36
- ]
37
- end
38
-
39
- # chrome headless browser details
40
- def self.chrome_headless
41
- @browser = Watir::Browser.new :chrome, switches: %w[
42
- --start-maximized --disable-gpu --headless --acceptInsecureCerts-true
43
- --no-sandbox --window-size=1920,1080
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
- driver = Selenium::WebDriver.for(:firefox, desired_capabilities: caps)
52
- @browser = Watir::Browser.new(driver)
53
- browser_full_screen
54
- end
55
-
56
- # firefox headless browser details
57
- def self.firefox_headless
58
- caps = Selenium::WebDriver::Remote::Capabilities.firefox
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
- # makes the browser full screen.
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 = Taf::CMDLine.browser_type.downcase
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 = Taf::CMDLine.browser_type.downcase
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]
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Taf
4
- VERSION = '0.4.6'
4
+ VERSION = '0.4.7'
5
5
  end
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.6
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-23 00:00:00.000000000 Z
11
+ date: 2019-08-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler