testcentricity_web 2.0.12 → 2.0.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/testcentricity_web.rb +4 -0
- data/lib/testcentricity_web/browser_helper.rb +4 -0
- data/lib/testcentricity_web/elements/cell_element.rb +15 -2
- data/lib/testcentricity_web/elements/list.rb +4 -0
- data/lib/testcentricity_web/elements/list_button.rb +8 -0
- data/lib/testcentricity_web/elements/list_checkbox.rb +38 -0
- data/lib/testcentricity_web/elements/list_element.rb +51 -0
- data/lib/testcentricity_web/elements/list_radio.rb +31 -0
- data/lib/testcentricity_web/page_objects_helper.rb +37 -0
- data/lib/testcentricity_web/page_sections_helper.rb +47 -2
- data/lib/testcentricity_web/version.rb +1 -1
- metadata +6 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: aec7592d71cdbcdfb4219ebbf143794875764611
|
4
|
+
data.tar.gz: 502ded4e78118e682c8f3c7f51e72be52651fbae
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f909d3bd1a0850d88c73eecf5519f85736465e3afa990b4a4bd5f1ac8392a29402cc6f512ae7fae441a100f801e111634cf7e2a943801cc844f90ddd2bde384d
|
7
|
+
data.tar.gz: c69b601e32fc446c6dd8ea96c3385eb21bad42fc63042785c63f72d5feae89f4f869c5eb9ab6882c325f58cc132796dfc4e518f9f8bcc041b8de5cb5c1091d22
|
data/lib/testcentricity_web.rb
CHANGED
@@ -32,6 +32,10 @@ require 'testcentricity_web/elements/cell_element'
|
|
32
32
|
require 'testcentricity_web/elements/cell_button'
|
33
33
|
require 'testcentricity_web/elements/cell_checkbox'
|
34
34
|
require 'testcentricity_web/elements/cell_radio'
|
35
|
+
require 'testcentricity_web/elements/list_element'
|
36
|
+
require 'testcentricity_web/elements/list_button'
|
37
|
+
require 'testcentricity_web/elements/list_checkbox'
|
38
|
+
require 'testcentricity_web/elements/list_radio'
|
35
39
|
|
36
40
|
module TestCentricity
|
37
41
|
class PageManager
|
@@ -65,6 +65,10 @@ module TestCentricity
|
|
65
65
|
end
|
66
66
|
end
|
67
67
|
|
68
|
+
def self.num_browser_instances
|
69
|
+
Capybara.page.driver.browser.window_handles.count
|
70
|
+
end
|
71
|
+
|
68
72
|
def self.close_current_browser_instance
|
69
73
|
Capybara.page.driver.browser.close
|
70
74
|
Capybara.page.driver.browser.switch_to.window(Capybara.page.driver.browser.window_handles.last)
|
@@ -31,9 +31,22 @@ module TestCentricity
|
|
31
31
|
obj.click
|
32
32
|
end
|
33
33
|
|
34
|
-
def
|
34
|
+
def get_value(row, visible = true)
|
35
|
+
obj, = find_cell_element(row, visible)
|
36
|
+
cell_object_not_found_exception(obj, @type, row)
|
37
|
+
case obj.tag_name.downcase
|
38
|
+
when 'input', 'select', 'textarea'
|
39
|
+
obj.value
|
40
|
+
else
|
41
|
+
obj.text
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
alias get_caption get_value
|
46
|
+
|
47
|
+
def find_cell_element(row, visible = true)
|
35
48
|
set_alt_locator("#{@locator.gsub('ROW_SPEC', row.to_s)}")
|
36
|
-
find_element
|
49
|
+
find_element(visible)
|
37
50
|
end
|
38
51
|
|
39
52
|
def cell_object_not_found_exception(obj, obj_type, row)
|
@@ -41,5 +41,9 @@ module TestCentricity
|
|
41
41
|
ExceptionQueue.enqueue_assert_equal(expected, actual, "Expected list #{object_ref_message}") :
|
42
42
|
assert_equal(expected, actual, "Expected list #{object_ref_message} to be #{expected} but found #{actual}")
|
43
43
|
end
|
44
|
+
|
45
|
+
def get_list_row_locator(row)
|
46
|
+
"#{@locator}/#{@list_item}[#{row}]"
|
47
|
+
end
|
44
48
|
end
|
45
49
|
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
module TestCentricity
|
2
|
+
class ListCheckBox < ListElement
|
3
|
+
attr_accessor :proxy
|
4
|
+
|
5
|
+
def initialize(name, parent, locator, context, list, proxy)
|
6
|
+
super
|
7
|
+
@type = :list_checkbox
|
8
|
+
@proxy = proxy
|
9
|
+
end
|
10
|
+
|
11
|
+
def checked?(row)
|
12
|
+
obj, = find_list_element(row)
|
13
|
+
list_object_not_found_exception(obj, 'List CheckBox', row)
|
14
|
+
obj.checked?
|
15
|
+
end
|
16
|
+
|
17
|
+
def set_checkbox_state(row, state)
|
18
|
+
obj, = find_list_element(row)
|
19
|
+
list_object_not_found_exception(obj, 'List CheckBox', row)
|
20
|
+
obj.set(state)
|
21
|
+
end
|
22
|
+
|
23
|
+
def check(row)
|
24
|
+
set_checkbox_state(row, true)
|
25
|
+
end
|
26
|
+
|
27
|
+
def uncheck(row)
|
28
|
+
set_checkbox_state(row, false)
|
29
|
+
end
|
30
|
+
|
31
|
+
def verify_check_state(row, state, enqueue = false)
|
32
|
+
actual = checked?(row)
|
33
|
+
enqueue ?
|
34
|
+
ExceptionQueue.enqueue_assert_equal(state, actual, "Expected Row #{row} List Checkbox #{object_ref_message}") :
|
35
|
+
assert_equal(state, actual, "Expected Row #{row} List Checkbox #{object_ref_message} to be #{state} but found #{actual} instead")
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
module TestCentricity
|
2
|
+
class ListElement < UIElement
|
3
|
+
attr_accessor :list
|
4
|
+
attr_accessor :element_locator
|
5
|
+
|
6
|
+
def initialize(name, parent, locator, context, list)
|
7
|
+
@name = name
|
8
|
+
@parent = parent
|
9
|
+
@context = context
|
10
|
+
@alt_locator = nil
|
11
|
+
@list = list
|
12
|
+
@element_locator = locator
|
13
|
+
locator.nil? ?
|
14
|
+
@locator = list.get_list_row_locator('ROW_SPEC') :
|
15
|
+
@locator = "#{list.get_list_row_locator('ROW_SPEC')}/#{@element_locator}"
|
16
|
+
end
|
17
|
+
|
18
|
+
def exists?(row)
|
19
|
+
obj, = find_list_element(row)
|
20
|
+
obj != nil
|
21
|
+
end
|
22
|
+
|
23
|
+
def click(row)
|
24
|
+
obj, = find_list_element(row)
|
25
|
+
list_object_not_found_exception(obj, @type, row)
|
26
|
+
obj.click
|
27
|
+
end
|
28
|
+
|
29
|
+
def get_value(row, visible = true)
|
30
|
+
obj, = find_list_element(row, visible)
|
31
|
+
list_object_not_found_exception(obj, @type, row)
|
32
|
+
case obj.tag_name.downcase
|
33
|
+
when 'input', 'select', 'textarea'
|
34
|
+
obj.value
|
35
|
+
else
|
36
|
+
obj.text
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
alias get_caption get_value
|
41
|
+
|
42
|
+
def find_list_element(row, visible = true)
|
43
|
+
set_alt_locator("#{@locator.gsub('ROW_SPEC', row.to_s)}")
|
44
|
+
find_element(visible)
|
45
|
+
end
|
46
|
+
|
47
|
+
def list_object_not_found_exception(obj, obj_type, row)
|
48
|
+
object_not_found_exception(obj, "Row #{row} #{obj_type}")
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module TestCentricity
|
2
|
+
class ListRadio < ListElement
|
3
|
+
attr_accessor :proxy
|
4
|
+
|
5
|
+
def initialize(name, parent, locator, context, list, proxy)
|
6
|
+
super
|
7
|
+
@type = :list_radio
|
8
|
+
@proxy = proxy
|
9
|
+
end
|
10
|
+
|
11
|
+
def selected?(row)
|
12
|
+
obj, = find_list_element(row)
|
13
|
+
list_object_not_found_exception(obj, 'List Radio', row)
|
14
|
+
obj.checked?
|
15
|
+
end
|
16
|
+
|
17
|
+
def set_selected_state(row, state)
|
18
|
+
obj, = find_list_element(row)
|
19
|
+
list_object_not_found_exception(obj, 'List Radio', row)
|
20
|
+
obj.set(state)
|
21
|
+
end
|
22
|
+
|
23
|
+
def select(row)
|
24
|
+
set_selected_state(row, true)
|
25
|
+
end
|
26
|
+
|
27
|
+
def unselect(row)
|
28
|
+
set_selected_state(row, false)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -318,6 +318,43 @@ module TestCentricity
|
|
318
318
|
class_eval(%(def #{element_name};@#{element_name} ||= TestCentricity::CellRadio.new("#{element_name}", self, "#{locator}", :page, #{table}, #{column});end))
|
319
319
|
end
|
320
320
|
|
321
|
+
# Declare and instantiate a list button in a row of a list object on this page object.
|
322
|
+
#
|
323
|
+
# @param element_name [Symbol] name of list button object (as a symbol)
|
324
|
+
# @param locator [String] XPath expression that uniquely identifies list button within row of parent list object
|
325
|
+
# @param list [Symbol] Name (as a symbol) of parent list object
|
326
|
+
# @example
|
327
|
+
# list_button :delete_button, "a[@class='delete']", :icon_list
|
328
|
+
# list_button :edit_button, "a[@class='edit']", :icon_list
|
329
|
+
#
|
330
|
+
def self.list_button(element_name, locator, list)
|
331
|
+
class_eval(%(def #{element_name};@#{element_name} ||= TestCentricity::ListButton.new("#{element_name}", self, "#{locator}", :page, #{list});end))
|
332
|
+
end
|
333
|
+
|
334
|
+
# Declare and instantiate a list checkbox in a row of a list object on this page object.
|
335
|
+
#
|
336
|
+
# @param element_name [Symbol] name of list checkbox object (as a symbol)
|
337
|
+
# @param locator [String] XPath expression that uniquely identifies list checkbox within row of parent list object
|
338
|
+
# @param list [Symbol] Name (as a symbol) of parent list object
|
339
|
+
# @example
|
340
|
+
# list_checkbox :is_registered_check, "a[@class='registered']", :data_list
|
341
|
+
#
|
342
|
+
def self.list_checkbox(element_name, locator, list)
|
343
|
+
class_eval(%(def #{element_name};@#{element_name} ||= TestCentricity::ListCheckBox.new("#{element_name}", self, "#{locator}", :page, #{list});end))
|
344
|
+
end
|
345
|
+
|
346
|
+
# Declare and instantiate a list radio in a row of a list object on this page object.
|
347
|
+
#
|
348
|
+
# @param element_name [Symbol] name of list radio object (as a symbol)
|
349
|
+
# @param locator [String] XPath expression that uniquely identifies list radio within row of parent list object
|
350
|
+
# @param list [Symbol] Name (as a symbol) of parent list object
|
351
|
+
# @example
|
352
|
+
# list_radio :sharing_radio, "a[@class='sharing']", :data_list
|
353
|
+
#
|
354
|
+
def self.list_radio(element_name, locator, list)
|
355
|
+
class_eval(%(def #{element_name};@#{element_name} ||= TestCentricity::ListRadio.new("#{element_name}", self, "#{locator}", :page, #{list});end))
|
356
|
+
end
|
357
|
+
|
321
358
|
# Instantiate a single PageSection object for this page object.
|
322
359
|
#
|
323
360
|
# @param section_name [Symbol] name of PageSection object (as a symbol)
|
@@ -331,6 +331,43 @@ module TestCentricity
|
|
331
331
|
class_eval(%(def #{element_name};@#{element_name} ||= TestCentricity::CellRadio.new("#{element_name}", self, "#{locator}", :section, #{table}, #{column});end))
|
332
332
|
end
|
333
333
|
|
334
|
+
# Declare and instantiate a list button in a row of a list object on this section object.
|
335
|
+
#
|
336
|
+
# @param element_name [Symbol] name of list button object (as a symbol)
|
337
|
+
# @param locator [String] XPath expression that uniquely identifies list button within row of parent list object
|
338
|
+
# @param list [Symbol] Name (as a symbol) of parent list object
|
339
|
+
# @example
|
340
|
+
# list_button :delete_button, "a[@class='delete']", :icon_list
|
341
|
+
# list_button :edit_button, "a[@class='edit']", :icon_list
|
342
|
+
#
|
343
|
+
def self.list_button(element_name, locator, list)
|
344
|
+
class_eval(%(def #{element_name};@#{element_name} ||= TestCentricity::ListButton.new("#{element_name}", self, "#{locator}", :section, #{list});end))
|
345
|
+
end
|
346
|
+
|
347
|
+
# Declare and instantiate a list checkbox in a row of a list object on this section object.
|
348
|
+
#
|
349
|
+
# @param element_name [Symbol] name of list checkbox object (as a symbol)
|
350
|
+
# @param locator [String] XPath expression that uniquely identifies list checkbox within row of parent list object
|
351
|
+
# @param list [Symbol] Name (as a symbol) of parent list object
|
352
|
+
# @example
|
353
|
+
# list_checkbox :is_registered_check, "a[@class='registered']", :data_list
|
354
|
+
#
|
355
|
+
def self.list_checkbox(element_name, locator, list)
|
356
|
+
class_eval(%(def #{element_name};@#{element_name} ||= TestCentricity::ListCheckBox.new("#{element_name}", self, "#{locator}", :section, #{list});end))
|
357
|
+
end
|
358
|
+
|
359
|
+
# Declare and instantiate a list radio in a row of a list object on this section object.
|
360
|
+
#
|
361
|
+
# @param element_name [Symbol] name of list radio object (as a symbol)
|
362
|
+
# @param locator [String] XPath expression that uniquely identifies list radio within row of parent list object
|
363
|
+
# @param list [Symbol] Name (as a symbol) of parent list object
|
364
|
+
# @example
|
365
|
+
# list_radio :sharing_radio, "a[@class='sharing']", :data_list
|
366
|
+
#
|
367
|
+
def self.list_radio(element_name, locator, list)
|
368
|
+
class_eval(%(def #{element_name};@#{element_name} ||= TestCentricity::CellRadio.new("#{element_name}", self, "#{locator}", :section, #{list});end))
|
369
|
+
end
|
370
|
+
|
334
371
|
# Instantiate a single PageSection object within this PageSection object.
|
335
372
|
#
|
336
373
|
# @param section_name [Symbol] name of PageSection object (as a symbol)
|
@@ -349,8 +386,16 @@ module TestCentricity
|
|
349
386
|
end
|
350
387
|
|
351
388
|
def get_locator
|
352
|
-
@locator.empty? && defined?(section_locator)
|
353
|
-
|
389
|
+
if @locator.empty? && defined?(section_locator)
|
390
|
+
locator = section_locator
|
391
|
+
else
|
392
|
+
locator = @locator
|
393
|
+
end
|
394
|
+
if @context == :section && !@parent.nil? && !@parent.get_locator.nil?
|
395
|
+
"#{@parent.get_locator}|#{locator}"
|
396
|
+
else
|
397
|
+
locator
|
398
|
+
end
|
354
399
|
end
|
355
400
|
|
356
401
|
def get_name
|
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: 2.0.
|
4
|
+
version: 2.0.13
|
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: 2017-04-
|
11
|
+
date: 2017-04-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -218,6 +218,10 @@ files:
|
|
218
218
|
- lib/testcentricity_web/elements/label.rb
|
219
219
|
- lib/testcentricity_web/elements/link.rb
|
220
220
|
- lib/testcentricity_web/elements/list.rb
|
221
|
+
- lib/testcentricity_web/elements/list_button.rb
|
222
|
+
- lib/testcentricity_web/elements/list_checkbox.rb
|
223
|
+
- lib/testcentricity_web/elements/list_element.rb
|
224
|
+
- lib/testcentricity_web/elements/list_radio.rb
|
221
225
|
- lib/testcentricity_web/elements/radio.rb
|
222
226
|
- lib/testcentricity_web/elements/select_list.rb
|
223
227
|
- lib/testcentricity_web/elements/table.rb
|