testcentricity_web 0.7.8 → 0.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
  SHA1:
3
- metadata.gz: 98298b1269fe2d4737edcca42ee62cd492821cb1
4
- data.tar.gz: d67323c361b7131e2989a7f3cd7ea6672edc1ca5
3
+ metadata.gz: e3eb35217003e7c6f2828883021e9b5088ee3006
4
+ data.tar.gz: 8b8e132ac3ee73442cef16731c2145fba046f63d
5
5
  SHA512:
6
- metadata.gz: 5156b3d332280bd77036acb1a671a4ef981d5eaaea60371b8e091d3a5bd0b5df524082141e1e6873b165d983e45ee97a15b6ff4af8a48c4a3baeddea5568631c
7
- data.tar.gz: de20a06d2d0f82da95a66ef10bcb4a808a8f40daaa5a1daeb387d9d49d1926d66d89485f2444cf9d0bbd1dcdf84a0a9ec829b213898efc8e755e796d08d4d0a8
6
+ metadata.gz: b7367b9001be3c10a766187863b8239b36a93eb98319bc156660616785ff03d740c347fdfe2359e88f79b53308a2a386b3c619baff28c53978412dd1bc26e2fa
7
+ data.tar.gz: 994539843137d2964a35a30d10d8f6b9bc3bf805583ad57886d16e02525b7ecf8cd1ed4b087c86ca78c9e108439d4bcc5769a83413f3cf5c32808cbb702fdefc
data/README.md CHANGED
@@ -6,7 +6,7 @@
6
6
  The TestCentricity™ core generic framework for desktop and mobile web site testing implements a Page Object and Data Object Model DSL for
7
7
  use with Cucumber, Capybara, and Selenium-Webdriver.
8
8
 
9
- The TestCentricity™ web gem supports running testing against the following web test targets:
9
+ The TestCentricity™ Web gem supports running testing against the following web test targets:
10
10
 
11
11
  * locally hosted desktop browsers (Firefox, Chrome, Safari, IE, or Edge)
12
12
  * locally hosted emulated iOS, Android, and Windows Phone mobile browsers (using Firefox)
@@ -337,7 +337,7 @@ the connection.
337
337
 
338
338
  For locally hosted desktop web browsers, the `WEB_BROWSER` Environment Variable must be set to one of the values from the table below:
339
339
 
340
- `WEB_BROWSER` | Desktop Platform
340
+ `WEB_BROWSER` | **Desktop Platform**
341
341
  --------------- | ----------------
342
342
  `firefox` | OS X or Windows
343
343
  `chrome` | OS X or Windows
@@ -72,6 +72,14 @@ module TestCentricity
72
72
  end
73
73
  end
74
74
 
75
+ def self.set_device_orientation(orientation)
76
+ if Environ.is_mobile? && !Environ.is_device?
77
+ Browsers.set_browser_window_size(Browsers.browser_size(Environ.browser.to_s, orientation))
78
+ else
79
+ puts '***** Cannot change device orientation of desktop web browsers or remote devices *****'
80
+ end
81
+ end
82
+
75
83
  def self.mobile_device_agent(device)
76
84
  key = device.gsub(/\s+/, "").downcase.to_sym
77
85
  devices = device_agents
@@ -1,4 +1,6 @@
1
1
  require 'yaml'
2
+ require 'json'
3
+
2
4
 
3
5
  module TestCentricity
4
6
 
@@ -32,6 +34,12 @@ module TestCentricity
32
34
  data = YAML.load_file("#{XL_PRIMARY_DATA_PATH}#{file_name}")
33
35
  data[node_name]
34
36
  end
37
+
38
+ def read_json_node_data(file_name, node_name)
39
+ raw_data = File.read("#{XL_PRIMARY_DATA_PATH}#{file_name}")
40
+ data = JSON.parse(raw_data)
41
+ data[node_name]
42
+ end
35
43
  end
36
44
 
37
45
 
@@ -10,6 +10,8 @@ module TestCentricity
10
10
  data = ExcelData.read_row_data(XL_PRIMARY_DATA_FILE, WKS_ENVIRONS, environ_name)
11
11
  when :yaml
12
12
  data = read_yaml_node_data('environments.yml', environ_name)
13
+ when :json
14
+ data = read_json_node_data('environments.json', environ_name)
13
15
  end
14
16
  @current = Environ.new(data)
15
17
  Environ.set_current(@current)
@@ -6,20 +6,20 @@ module TestCentricity
6
6
 
7
7
  def self.enqueue_assert_equal(expected, actual, error_message)
8
8
  unless expected == actual
9
- @error_queue = "#{@error_queue}#{error_message} to be\n #{expected}\nbut found\n #{actual}\n\n"
9
+ enqueue("#{error_message} to be\n #{expected}\nbut found\n #{actual}")
10
10
  enqueue_screenshot
11
11
  end
12
12
  end
13
13
 
14
14
  def self.enqueue_assert_not_equal(expected, actual, error_message)
15
15
  unless expected != actual
16
- @error_queue = "#{@error_queue}#{error_message} to not be equal to #{expected}\n\n"
16
+ enqueue("#{error_message} to not be equal to #{expected}")
17
17
  enqueue_screenshot
18
18
  end
19
19
  end
20
20
 
21
21
  def self.enqueue_exception(error_message)
22
- @error_queue = "#{@error_queue}#{error_message}\n\n"
22
+ enqueue(error_message)
23
23
  end
24
24
 
25
25
  def self.post_exceptions
@@ -30,6 +30,10 @@ module TestCentricity
30
30
 
31
31
  private
32
32
 
33
+ def self.enqueue(message)
34
+ @error_queue = "#{@error_queue}#{message}\n\n"
35
+ end
36
+
33
37
  def self.enqueue_screenshot
34
38
  timestamp = Time.now.strftime('%Y%m%d%H%M%S')
35
39
  filename = "Screenshot-#{timestamp}"
@@ -11,7 +11,7 @@ end
11
11
 
12
12
  class String
13
13
  def to_bool
14
- return true if self == true || self =~ (/(true|t|yes|y|x|1)$/i)
14
+ return true if self == true || self =~ (/(true|t|yes|y|x|1)$/i)
15
15
  return false if self == false || self.blank? || self =~ (/(false|f|no|n|0)$/i)
16
16
  raise ArgumentError.new("invalid value for Boolean: \"#{self}\"")
17
17
  end
@@ -1,3 +1,3 @@
1
1
  module TestCentricityWeb
2
- VERSION = '0.7.8'
2
+ VERSION = '0.7.9'
3
3
  end
@@ -15,18 +15,18 @@ module TestCentricity
15
15
  Environ.set_device_type('browser')
16
16
 
17
17
  case browser.downcase.to_sym
18
- when :browserstack
19
- initialize_browserstack
20
- when :crossbrowser
21
- initialize_crossbrowser
22
- when :poltergeist
23
- initialize_poltergeist
24
- when :saucelabs
25
- initialize_saucelabs
26
- when :testingbot
27
- initialize_testingbot
28
- else
29
- initialize_local_browser(browser)
18
+ when :browserstack
19
+ initialize_browserstack
20
+ when :crossbrowser
21
+ initialize_crossbrowser
22
+ when :poltergeist
23
+ initialize_poltergeist
24
+ when :saucelabs
25
+ initialize_saucelabs
26
+ when :testingbot
27
+ initialize_testingbot
28
+ else
29
+ initialize_local_browser(browser)
30
30
  end
31
31
 
32
32
  Capybara.app_host = app_host unless app_host.nil?
@@ -34,13 +34,15 @@ module TestCentricity
34
34
  # set browser window size only if testing with a desktop web browser
35
35
  unless Capybara.current_driver == :poltergeist
36
36
  if Environ.is_desktop?
37
- if (ENV['BROWSER_SIZE'] == 'max') then
37
+ if ENV['BROWSER_SIZE'] == 'max'
38
38
  Browsers.maximize_browser
39
39
  elsif ENV['BROWSER_SIZE']
40
40
  Browsers.set_browser_window_size(ENV['BROWSER_SIZE'])
41
41
  else
42
42
  Browsers.set_browser_window_size(Browsers.browser_size(browser, ENV['ORIENTATION']))
43
43
  end
44
+ elsif Environ.is_mobile? && !Environ.is_device?
45
+ Browsers.set_browser_window_size(Browsers.browser_size(browser, ENV['ORIENTATION']))
44
46
  end
45
47
  end
46
48
 
@@ -53,16 +55,16 @@ module TestCentricity
53
55
  Capybara.default_driver = :selenium
54
56
  Capybara.register_driver :selenium do |app|
55
57
  case browser.downcase.to_sym
56
- when :firefox, :chrome, :ie, :safari, :edge
57
- Capybara::Selenium::Driver.new(app, :browser => browser.to_sym)
58
- when :iphone, :iphone5, :iphone6, :iphone6_plus, :ipad, :ipad_pro, :android_phone, :android_tablet, :windows_phone7, :windows_phone8
59
- Environ.set_platform(:mobile)
60
- profile = Selenium::WebDriver::Firefox::Profile.new
61
- profile['general.useragent.override'] = Browsers.mobile_device_agent(browser)
62
- Capybara::Selenium::Driver.new(app, :profile => profile)
63
- else
64
- Capybara::Selenium::Driver.new(app, :browser => :firefox)
65
- Environ.set_browser('firefox')
58
+ when :firefox, :chrome, :ie, :safari, :edge
59
+ Capybara::Selenium::Driver.new(app, :browser => browser.to_sym)
60
+ when :iphone, :iphone5, :iphone6, :iphone6_plus, :ipad, :ipad_pro, :android_phone, :android_tablet, :windows_phone7, :windows_phone8
61
+ Environ.set_platform(:mobile)
62
+ profile = Selenium::WebDriver::Firefox::Profile.new
63
+ profile['general.useragent.override'] = Browsers.mobile_device_agent(browser)
64
+ Capybara::Selenium::Driver.new(app, :profile => profile)
65
+ else
66
+ Capybara::Selenium::Driver.new(app, :browser => :firefox)
67
+ Environ.set_browser('firefox')
66
68
  end
67
69
  end
68
70
  end
@@ -103,15 +105,15 @@ module TestCentricity
103
105
  capabilities['browserstack.localIdentifier'] = ENV['BS_LOCAL_ID'] if ENV['BS_LOCAL_ID']
104
106
 
105
107
  case browser.downcase.to_sym
106
- when :ie
107
- capabilities['ie.ensureCleanSession'] = 'true'
108
- capabilities['ie.browserCommandLineSwitches'] = 'true'
109
- capabilities['nativeEvents'] ='true'
110
- when :safari
111
- capabilities['cleanSession'] = 'true'
112
- when :iphone, :ipad
113
- capabilities['javascriptEnabled'] = 'true'
114
- capabilities['cleanSession'] = 'true'
108
+ when :ie
109
+ capabilities['ie.ensureCleanSession'] = 'true'
110
+ capabilities['ie.browserCommandLineSwitches'] = 'true'
111
+ capabilities['nativeEvents'] ='true'
112
+ when :safari
113
+ capabilities['cleanSession'] = 'true'
114
+ when :iphone, :ipad
115
+ capabilities['javascriptEnabled'] = 'true'
116
+ capabilities['cleanSession'] = 'true'
115
117
  end
116
118
  Capybara::Selenium::Driver.new(app, :browser => :remote, :url => endpoint, :desired_capabilities => capabilities)
117
119
  end
@@ -137,6 +139,7 @@ module TestCentricity
137
139
  Environ.set_platform(:desktop)
138
140
  elsif ENV['CB_PLATFORM']
139
141
  capabilities['os_api_name'] = ENV['CB_PLATFORM']
142
+ Environ.set_device_type(ENV['CB_PLATFORM'])
140
143
  Environ.set_platform(:mobile)
141
144
  end
142
145
  Capybara::Selenium::Driver.new(app, :browser => :remote, :url => endpoint, :desired_capabilities => capabilities)
@@ -181,6 +184,7 @@ module TestCentricity
181
184
  capabilities['deviceName'] = ENV['SL_DEVICE']
182
185
  capabilities['deviceType'] = ENV['SL_DEVICE_TYPE'] if ENV['SL_DEVICE_TYPE']
183
186
  capabilities['deviceOrientation'] = ENV['ORIENTATION'] if ENV['ORIENTATION']
187
+ Environ.set_device_type(ENV['SL_DEVICE'])
184
188
  Environ.set_platform(:mobile)
185
189
  end
186
190
 
@@ -3,11 +3,15 @@ module WorldData
3
3
  @environs ||= TestCentricity::EnvironData.new
4
4
  end
5
5
 
6
+ # instantiate and register all data objects specified in data_objects method
6
7
  def instantiate_data_objects
8
+ # return if data objects have already been instantiated and registered
7
9
  return if TestCentricity::DataManager.loaded?
8
10
 
9
11
  data_objects.each do | data_type, data_class |
12
+ # instantiate next data object
10
13
  eval("def #{data_type.to_s};@#{data_type.to_s} ||= #{data_class}.new;end")
14
+ # register the data object
11
15
  TestCentricity::DataManager.register_data_object(data_type, data_class.new)
12
16
  end
13
17
  end
@@ -15,11 +19,15 @@ end
15
19
 
16
20
 
17
21
  module WorldPages
22
+ # instantiate and register all page objects specified in page_objects method
18
23
  def instantiate_page_objects
24
+ # return if page objects have already been instantiated and registered
19
25
  return if TestCentricity::PageManager.loaded?
20
26
 
21
27
  page_objects.each do | page_object, page_class |
28
+ # instantiate next page object
22
29
  eval("def #{page_object.to_s};@#{page_object.to_s} ||= #{page_class}.new;end")
30
+ # register the page object
23
31
  TestCentricity::PageManager.register_page_object(page_object, page_class.new)
24
32
  end
25
33
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: testcentricity_web
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.8
4
+ version: 0.7.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - A.J. Mrozinski
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-04-19 00:00:00.000000000 Z
11
+ date: 2016-04-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler