automation_object 0.8.1 → 0.8.2
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/automation_object/blue_print.rb +9 -2
- data/lib/automation_object/blue_print/composite/helpers/container_helper.rb +2 -7
- data/lib/automation_object/blue_print/composite/modal.rb +0 -25
- data/lib/automation_object/blue_print/composite/screen.rb +0 -20
- data/lib/automation_object/blue_print/hash_adapter.rb +1 -1
- data/lib/automation_object/blue_print/hash_adapter/element.rb +0 -1
- data/lib/automation_object/blue_print/page_object_adapter.rb +55 -0
- data/lib/automation_object/blue_print/page_object_adapter/automatic_modal_change.rb +34 -0
- data/lib/automation_object/blue_print/page_object_adapter/composite.rb +93 -0
- data/lib/automation_object/blue_print/page_object_adapter/custom_method.rb +27 -0
- data/lib/automation_object/blue_print/page_object_adapter/element.rb +16 -0
- data/lib/automation_object/blue_print/page_object_adapter/element_array.rb +18 -0
- data/lib/automation_object/blue_print/page_object_adapter/element_hash.rb +25 -0
- data/lib/automation_object/blue_print/page_object_adapter/helpers/element_helper.rb +62 -0
- data/lib/automation_object/blue_print/page_object_adapter/helpers/multiple_elements_helper.rb +37 -0
- data/lib/automation_object/blue_print/page_object_adapter/hook.rb +27 -0
- data/lib/automation_object/blue_print/page_object_adapter/hook_action.rb +112 -0
- data/lib/automation_object/blue_print/page_object_adapter/hook_element_requirements.rb +56 -0
- data/lib/automation_object/blue_print/page_object_adapter/modal.rb +27 -0
- data/lib/automation_object/blue_print/page_object_adapter/screen.rb +34 -0
- data/lib/automation_object/blue_print/page_object_adapter/top.rb +52 -0
- data/lib/automation_object/dsl/_error.rb +0 -27
- data/lib/automation_object/dsl/modal.rb +2 -2
- data/lib/automation_object/dsl/screen.rb +7 -6
- data/lib/automation_object/framework.rb +1 -8
- data/lib/automation_object/helpers/composite.rb +4 -4
- data/lib/automation_object/page_object.rb +15 -0
- data/lib/automation_object/page_object/base.rb +22 -0
- data/lib/automation_object/page_object/configuration.rb +35 -0
- data/lib/automation_object/page_object/element.rb +10 -0
- data/lib/automation_object/page_object/element_array.rb +10 -0
- data/lib/automation_object/page_object/element_hash.rb +10 -0
- data/lib/automation_object/page_object/modal.rb +10 -0
- data/lib/automation_object/page_object/screen.rb +10 -0
- data/lib/automation_object/step_definitions/element.rb +24 -18
- data/lib/automation_object/step_definitions/element_array.rb +28 -21
- data/lib/automation_object/step_definitions/element_hash.rb +28 -21
- data/lib/automation_object/step_definitions/support/element_array.rb +2 -2
- data/lib/automation_object/step_definitions/support/element_hash.rb +2 -2
- data/lib/automation_object/version.rb +1 -1
- metadata +30 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 948c2e3cbdbda291e87ce5d000bad8871ffd9e03
|
4
|
+
data.tar.gz: f2bb2fed5cce0206a3380adf874f96ee07091241
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9ef1f75d16980edba5bccd0324a633b4d55961f3d2a30727dec03c241ce399686f7f61db23448fd61bfd45ebf6b78415b05452c1aa1f1822fae4870909fec191
|
7
|
+
data.tar.gz: 06a21cd5eac5ccc6855c055ab78affb5315d0e3aa721d076c347e68c13ca6bfdcc16e9b000a3131ee45e85448efc6260ac29d7325e27b3b8c92b36ea3937e3a2
|
@@ -2,6 +2,7 @@
|
|
2
2
|
|
3
3
|
require_relative 'blue_print/hash_adapter'
|
4
4
|
require_relative 'blue_print/yaml_adapter'
|
5
|
+
require_relative 'blue_print/page_object_adapter'
|
5
6
|
|
6
7
|
module AutomationObject
|
7
8
|
# BluePrint Port, encapsulation of code required to parse and build composite data structure representing UI
|
@@ -12,7 +13,7 @@ module AutomationObject
|
|
12
13
|
|
13
14
|
# Get method for BluePrint adapter const for composite BluePrint build
|
14
15
|
# Each adapter will implement common BluePrint interface
|
15
|
-
# @return [AutomationObject::BluePrint::YamlAdapter, AutomationObject::BluePrint::HashAdapter]
|
16
|
+
# @return [AutomationObject::BluePrint::YamlAdapter, AutomationObject::BluePrint::HashAdapter, AutomationObject::BluePrint::PageObjectAdapter]
|
16
17
|
def adapter
|
17
18
|
return @adapter if @adapter
|
18
19
|
self.adapter = :hash
|
@@ -34,7 +35,13 @@ module AutomationObject
|
|
34
35
|
def create(blueprint_arg)
|
35
36
|
case blueprint_arg
|
36
37
|
when String
|
37
|
-
|
38
|
+
path = File.expand_path(blueprint_arg)
|
39
|
+
|
40
|
+
self.adapter = if !Dir[File.join(path, '/**/*.rb')].empty?
|
41
|
+
:page_object
|
42
|
+
else
|
43
|
+
:yaml
|
44
|
+
end
|
38
45
|
when Hash
|
39
46
|
self.adapter = :hash
|
40
47
|
end
|
@@ -6,14 +6,9 @@ module AutomationObject
|
|
6
6
|
module Composite
|
7
7
|
# Screen composite class
|
8
8
|
module ContainerHelper
|
9
|
-
# @return [Array<AutomationObject::BluePrint::Composite::AutomaticModalChange>]
|
10
|
-
def automatic_modal_changes
|
11
|
-
adapter.automatic_modal_changes
|
12
|
-
end
|
13
|
-
|
14
9
|
# @return [Array<Symbol>]
|
15
|
-
def
|
16
|
-
adapter.
|
10
|
+
def included_views
|
11
|
+
adapter.included_views
|
17
12
|
end
|
18
13
|
|
19
14
|
# @return [AutomationObject::BluePrint::Composite::Hook]
|
@@ -18,31 +18,6 @@ module AutomationObject
|
|
18
18
|
# Modal composite class
|
19
19
|
class Modal < Base
|
20
20
|
include ContainerHelper
|
21
|
-
|
22
|
-
# @return [Array<Symbol>]
|
23
|
-
def included_views
|
24
|
-
adapter.included_views
|
25
|
-
end
|
26
|
-
|
27
|
-
# @return [AutomationObject::BluePrint::Composite::Hook]
|
28
|
-
def load
|
29
|
-
adapter.load
|
30
|
-
end
|
31
|
-
|
32
|
-
# @return [Hash<AutomationObject::BluePrint::Composite::Element>]
|
33
|
-
def elements
|
34
|
-
adapter.elements
|
35
|
-
end
|
36
|
-
|
37
|
-
# @return [Hash<AutomationObject::BluePrint::Composite::ElementArray>]
|
38
|
-
def element_arrays
|
39
|
-
adapter.element_arrays
|
40
|
-
end
|
41
|
-
|
42
|
-
# @return [Hash<AutomationObject::BluePrint::Composite::ElementHash>]
|
43
|
-
def element_hashes
|
44
|
-
adapter.element_hashes
|
45
|
-
end
|
46
21
|
end
|
47
22
|
end
|
48
23
|
end
|
@@ -40,30 +40,10 @@ module AutomationObject
|
|
40
40
|
adapter.dismiss
|
41
41
|
end
|
42
42
|
|
43
|
-
# @return [AutomationObject::BluePrint::Composite::Hook]
|
44
|
-
def load
|
45
|
-
adapter.load
|
46
|
-
end
|
47
|
-
|
48
43
|
# @return [Hash<AutomationObject::BluePrint::Composite::Modal>]
|
49
44
|
def modals
|
50
45
|
adapter.modals
|
51
46
|
end
|
52
|
-
|
53
|
-
# @return [Hash<AutomationObject::BluePrint::Composite::Element>]
|
54
|
-
def elements
|
55
|
-
adapter.elements
|
56
|
-
end
|
57
|
-
|
58
|
-
# @return [Hash<AutomationObject::BluePrint::Composite::ElementArray>]
|
59
|
-
def element_arrays
|
60
|
-
adapter.element_arrays
|
61
|
-
end
|
62
|
-
|
63
|
-
# @return [Hash<AutomationObject::BluePrint::Composite::ElementHash>]
|
64
|
-
def element_hashes
|
65
|
-
adapter.element_hashes
|
66
|
-
end
|
67
47
|
end
|
68
48
|
end
|
69
49
|
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require 'securerandom'
|
3
|
+
|
4
|
+
require_relative 'composite/top'
|
5
|
+
require_relative 'page_object_adapter/top'
|
6
|
+
|
7
|
+
require_relative '../page_object'
|
8
|
+
|
9
|
+
# PageObject adapter
|
10
|
+
module AutomationObject
|
11
|
+
module BluePrint
|
12
|
+
# BluePrint PageObject Adapter
|
13
|
+
# Using classes to define page objects
|
14
|
+
module PageObjectAdapter
|
15
|
+
module_function
|
16
|
+
|
17
|
+
# @param path [String] path to PageObject classes
|
18
|
+
# @return [AutomationObject::BluePrint::Composite::Top] Composite BluePrint Object
|
19
|
+
def build(path = '')
|
20
|
+
# Require ruby files in that path into a module namespace
|
21
|
+
path = File.expand_path(path)
|
22
|
+
|
23
|
+
defined_module = define_random_module()
|
24
|
+
|
25
|
+
# Remove any defined classes in UserDefined namespace
|
26
|
+
defined_module.constants.select do |constant|
|
27
|
+
defined_module.const_get(constant).is_a? Class
|
28
|
+
defined_module.remove_const(constant)
|
29
|
+
end
|
30
|
+
|
31
|
+
# Add classes defined into UserDefined module
|
32
|
+
Dir[File.join(path, '**/*.rb')].each do |file|
|
33
|
+
defined_module.module_eval(File.read(file))
|
34
|
+
end
|
35
|
+
|
36
|
+
# Will look for classes defined
|
37
|
+
adapter_top = self::Top.new(defined_module)
|
38
|
+
AutomationObject::BluePrint::Composite::Top.new(adapter_top)
|
39
|
+
end
|
40
|
+
|
41
|
+
def define_random_module
|
42
|
+
random_module_name = [*('A'..'Z')].sample(20).join
|
43
|
+
random_module_symbol = random_module_name.to_sym
|
44
|
+
|
45
|
+
AutomationObject::BluePrint::PageObjectAdapter.module_eval %Q?
|
46
|
+
module #{random_module_name}
|
47
|
+
|
48
|
+
end
|
49
|
+
?
|
50
|
+
|
51
|
+
const_get(random_module_symbol)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'composite'
|
4
|
+
|
5
|
+
module AutomationObject
|
6
|
+
module BluePrint
|
7
|
+
module PageObjectAdapter
|
8
|
+
# Modal composite
|
9
|
+
class AutomaticModalChange < Composite
|
10
|
+
# @return [Symbol, nil]
|
11
|
+
def modal_name
|
12
|
+
modal_name = get_property(:modal_name)
|
13
|
+
|
14
|
+
case modal_name
|
15
|
+
when Symbol, String
|
16
|
+
return modal_name.to_sym
|
17
|
+
else
|
18
|
+
return nil
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
# @return [Integer]
|
23
|
+
def number_of_checks
|
24
|
+
get_property(:number_of_checks) || 1
|
25
|
+
end
|
26
|
+
|
27
|
+
# @return [Boolean]
|
28
|
+
def close
|
29
|
+
get_property(:close) || false
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,93 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative '../../helpers/composite'
|
4
|
+
require_relative '../../helpers/string'
|
5
|
+
|
6
|
+
require_relative '../../page_object'
|
7
|
+
|
8
|
+
module AutomationObject
|
9
|
+
module BluePrint
|
10
|
+
module PageObjectAdapter
|
11
|
+
# Base composite for PageObject adapter
|
12
|
+
class Composite < AutomationObject::Composite
|
13
|
+
# @return [Module]
|
14
|
+
attr_accessor :user_defined_module
|
15
|
+
|
16
|
+
# @return [AutomationObject::PageObject::Base]
|
17
|
+
attr_accessor :constant
|
18
|
+
|
19
|
+
# @param user_defined_module [Module] runtime defined module for loaded page objects
|
20
|
+
# @param constant [Class] class to build composite off of
|
21
|
+
# @param name [Symbol] name of composite element
|
22
|
+
# @param parent [Object, nil] parent composite object
|
23
|
+
# @param location [String] string location for error/debugging purposes
|
24
|
+
def initialize(user_defined_module, constant = nil, name = :top, parent = nil, location = 'top')
|
25
|
+
self.user_defined_module = user_defined_module
|
26
|
+
self.constant = constant.is_a?(Class) ? constant : nil
|
27
|
+
|
28
|
+
super(name, parent, location)
|
29
|
+
end
|
30
|
+
|
31
|
+
# Get child of composite
|
32
|
+
# @param name [Symbol] name of child
|
33
|
+
# @param options [Hash] options for child
|
34
|
+
# @return child [Object, nil] return child composite object
|
35
|
+
def get_child(name, options)
|
36
|
+
self.constant.constants.each { |constant_symbol|
|
37
|
+
constant = self.constant.const_get(constant_symbol)
|
38
|
+
|
39
|
+
# Check to see if constant is a child class of the public PageObject interface
|
40
|
+
next unless constant < get_page_object(options[:interface])
|
41
|
+
|
42
|
+
name = constant.name.split('::').last.to_underscore.to_sym
|
43
|
+
return create_composite(constant, options[:interface], name)
|
44
|
+
}
|
45
|
+
|
46
|
+
nil
|
47
|
+
end
|
48
|
+
|
49
|
+
# Get children of composite
|
50
|
+
# @param name [Symbol] name of child
|
51
|
+
# @param options [Hash] options for child
|
52
|
+
# @return [Hash] return children and names
|
53
|
+
def get_children(name, options)
|
54
|
+
new_children = {}
|
55
|
+
|
56
|
+
self.constant.constants.each { |constant_symbol|
|
57
|
+
constant = self.constant.const_get(constant_symbol)
|
58
|
+
|
59
|
+
# Check to see if constant is a child class of the public PageObject interface
|
60
|
+
next unless constant < get_page_object(options[:interface])
|
61
|
+
|
62
|
+
name = constant.name.split('::').last.to_underscore.to_sym
|
63
|
+
new_children[name] = create_composite(constant, options[:interface], name)
|
64
|
+
}
|
65
|
+
|
66
|
+
new_children
|
67
|
+
end
|
68
|
+
|
69
|
+
def create_composite(constant, interface, name)
|
70
|
+
# Get the Composite Class that corresponds with the PageObjectAdapter Class
|
71
|
+
class_name = interface.name.split('::').last
|
72
|
+
child_location = location + "[#{name}]"
|
73
|
+
|
74
|
+
require_relative "../composite/#{class_name.to_underscore}"
|
75
|
+
composite_class = AutomationObject::BluePrint::Composite.const_get(class_name)
|
76
|
+
|
77
|
+
composite_class.new(interface.new(user_defined_module, constant, name, self, child_location))
|
78
|
+
end
|
79
|
+
|
80
|
+
def get_page_object(adapter_interface)
|
81
|
+
name = adapter_interface.name.split('::').last.to_sym
|
82
|
+
AutomationObject::PageObject.const_get(name)
|
83
|
+
end
|
84
|
+
|
85
|
+
# @param name [Symbol]
|
86
|
+
# @return [Object]
|
87
|
+
def get_property(name)
|
88
|
+
self.constant.get_property(name)
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'composite'
|
4
|
+
|
5
|
+
module AutomationObject
|
6
|
+
module BluePrint
|
7
|
+
module PageObjectAdapter
|
8
|
+
# CustomMethod composite
|
9
|
+
class CustomMethod < Composite
|
10
|
+
def element_method
|
11
|
+
element_method = get_property(:element_method)
|
12
|
+
|
13
|
+
case element_method
|
14
|
+
when Symbol, String
|
15
|
+
return element_method.to_sym
|
16
|
+
else
|
17
|
+
return nil
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def evaluate
|
22
|
+
get_property(:evaluate) || nil
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'composite'
|
4
|
+
|
5
|
+
require_relative 'helpers/element_helper'
|
6
|
+
|
7
|
+
module AutomationObject
|
8
|
+
module BluePrint
|
9
|
+
module PageObjectAdapter
|
10
|
+
# Element composite
|
11
|
+
class Element < Composite
|
12
|
+
include ElementHelper
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'composite'
|
4
|
+
|
5
|
+
require_relative 'helpers/element_helper'
|
6
|
+
require_relative 'helpers/multiple_elements_helper'
|
7
|
+
|
8
|
+
module AutomationObject
|
9
|
+
module BluePrint
|
10
|
+
module PageObjectAdapter
|
11
|
+
# ElementArray composite
|
12
|
+
class ElementArray < Composite
|
13
|
+
include ElementHelper
|
14
|
+
include MultipleElementsHelper
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'composite'
|
4
|
+
|
5
|
+
require_relative 'helpers/element_helper'
|
6
|
+
require_relative 'helpers/multiple_elements_helper'
|
7
|
+
|
8
|
+
module AutomationObject
|
9
|
+
module BluePrint
|
10
|
+
module PageObjectAdapter
|
11
|
+
# ElementHash composite
|
12
|
+
class ElementHash < Composite
|
13
|
+
include ElementHelper
|
14
|
+
include MultipleElementsHelper
|
15
|
+
|
16
|
+
# @return [Symbol, nil] element method to define element keys by
|
17
|
+
def define_elements_by
|
18
|
+
return nil unless get_property(:define_elements_by)
|
19
|
+
|
20
|
+
get_property(:define_elements_by).to_sym
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative '../hook'
|
4
|
+
|
5
|
+
module AutomationObject
|
6
|
+
module BluePrint
|
7
|
+
module PageObjectAdapter
|
8
|
+
# Helper module for Element composite classes
|
9
|
+
module ElementHelper
|
10
|
+
# @return [String, nil] text input for automatic screen/modal change if needed
|
11
|
+
def default_input
|
12
|
+
get_property(:default_input)
|
13
|
+
end
|
14
|
+
|
15
|
+
# @return [Array<Symbol, String>, nil] params as an array for driver find_element args
|
16
|
+
def selector_params
|
17
|
+
if hash[:xpath].is_a?(String)
|
18
|
+
[:xpath, hash[:xpath]]
|
19
|
+
elsif hash[:css].is_a?(String)
|
20
|
+
[:css, hash[:css]]
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
# @return [Symbol, nil] element name of iframe element is in or nil if not
|
25
|
+
def in_iframe
|
26
|
+
case hash[:in_iframe]
|
27
|
+
when Symbol, String
|
28
|
+
hash[:in_iframe].to_sym
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
# @return [Boolean] whether or not element is in iframe
|
33
|
+
def in_iframe?
|
34
|
+
in_iframe ? true : false
|
35
|
+
end
|
36
|
+
|
37
|
+
def method_hook?(name)
|
38
|
+
method_hooks.key?(name)
|
39
|
+
end
|
40
|
+
|
41
|
+
# @return [Hash<Hook>] hash of Hook that are defined under the element
|
42
|
+
def method_hooks
|
43
|
+
return @method_hooks if defined? @method_hooks
|
44
|
+
|
45
|
+
children = {}
|
46
|
+
hash.each do |key, value|
|
47
|
+
# Skip possible keys that elements can have
|
48
|
+
# Otherwise should be a method hook
|
49
|
+
next if %i[load custom_methods in_iframe css xpath define_elements_by custom_range].include?(key)
|
50
|
+
children[key] = value
|
51
|
+
end
|
52
|
+
|
53
|
+
@method_hooks = create_hash_children(children,
|
54
|
+
interface: Hook,
|
55
|
+
location: location + '[hook]')
|
56
|
+
|
57
|
+
@method_hooks
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|