automation_object 0.5.0 → 0.5.1
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.rb +22 -11
- data/lib/automation_object/blue_print.rb +13 -12
- data/lib/automation_object/blue_print/composite/automatic_onload_modal.rb +9 -8
- data/lib/automation_object/blue_print/composite/base.rb +5 -4
- data/lib/automation_object/blue_print/composite/custom_method.rb +8 -7
- data/lib/automation_object/blue_print/composite/element.rb +6 -5
- data/lib/automation_object/blue_print/composite/element_array.rb +6 -5
- data/lib/automation_object/blue_print/composite/element_hash.rb +7 -6
- data/lib/automation_object/blue_print/composite/helpers/element_helper.rb +7 -7
- data/lib/automation_object/blue_print/composite/helpers/multiple_elements_helper.rb +5 -4
- data/lib/automation_object/blue_print/composite/hook.rb +9 -11
- data/lib/automation_object/blue_print/composite/hook_action.rb +25 -24
- data/lib/automation_object/blue_print/composite/hook_element_requirements.rb +14 -13
- data/lib/automation_object/blue_print/composite/modal.rb +11 -21
- data/lib/automation_object/blue_print/composite/screen.rb +22 -16
- data/lib/automation_object/blue_print/composite/top.rb +13 -12
- data/lib/automation_object/blue_print/composite/view.rb +27 -16
- data/lib/automation_object/blue_print/hash_adapter.rb +15 -11
- data/lib/automation_object/blue_print/hash_adapter/automatic_onload_modal.rb +12 -11
- data/lib/automation_object/blue_print/hash_adapter/composite.rb +28 -25
- data/lib/automation_object/blue_print/hash_adapter/custom_method.rb +11 -10
- data/lib/automation_object/blue_print/hash_adapter/element.rb +10 -9
- data/lib/automation_object/blue_print/hash_adapter/element_array.rb +10 -9
- data/lib/automation_object/blue_print/hash_adapter/element_hash.rb +11 -10
- data/lib/automation_object/blue_print/hash_adapter/helpers/element_helper.rb +20 -25
- data/lib/automation_object/blue_print/hash_adapter/helpers/multiple_elements_helper.rb +15 -14
- data/lib/automation_object/blue_print/hash_adapter/helpers/validation_error.rb +9 -8
- data/lib/automation_object/blue_print/hash_adapter/helpers/validation_helper.rb +19 -24
- data/lib/automation_object/blue_print/hash_adapter/helpers/validators/validate.rb +8 -5
- data/lib/automation_object/blue_print/hash_adapter/helpers/validators/validate_allowed_keys.rb +7 -8
- data/lib/automation_object/blue_print/hash_adapter/helpers/validators/validate_element_presence_of.rb +28 -23
- data/lib/automation_object/blue_print/hash_adapter/helpers/validators/validate_instance_of.rb +12 -13
- data/lib/automation_object/blue_print/hash_adapter/helpers/validators/validate_modal_presence_of.rb +27 -23
- data/lib/automation_object/blue_print/hash_adapter/helpers/validators/validate_presence_of.rb +9 -8
- data/lib/automation_object/blue_print/hash_adapter/helpers/validators/validate_screen_presence_of.rb +27 -23
- data/lib/automation_object/blue_print/hash_adapter/helpers/validators/validate_view_presence_of.rb +25 -21
- data/lib/automation_object/blue_print/hash_adapter/hook.rb +14 -11
- data/lib/automation_object/blue_print/hash_adapter/hook_action.rb +45 -47
- data/lib/automation_object/blue_print/hash_adapter/hook_element_requirements.rb +24 -28
- data/lib/automation_object/blue_print/hash_adapter/modal.rb +14 -13
- data/lib/automation_object/blue_print/hash_adapter/screen.rb +23 -22
- data/lib/automation_object/blue_print/hash_adapter/top.rb +16 -15
- data/lib/automation_object/blue_print/hash_adapter/view.rb +58 -4
- data/lib/automation_object/blue_print/yaml_adapter.rb +33 -34
- data/lib/automation_object/driver.rb +15 -13
- data/lib/automation_object/driver/appium_adapter/driver.rb +47 -46
- data/lib/automation_object/driver/appium_adapter/element.rb +29 -96
- data/lib/automation_object/driver/base.rb +4 -2
- data/lib/automation_object/driver/common_selenium/driver.rb +60 -0
- data/lib/automation_object/driver/common_selenium/element.rb +107 -0
- data/lib/automation_object/driver/common_selenium/element_geometry.rb +86 -0
- data/lib/automation_object/driver/driver.rb +60 -30
- data/lib/automation_object/driver/element.rb +70 -15
- data/lib/automation_object/driver/nokogiri_adapter/driver.rb +88 -34
- data/lib/automation_object/driver/nokogiri_adapter/element.rb +94 -16
- data/lib/automation_object/driver/nokogiri_adapter/error.rb +29 -8
- data/lib/automation_object/driver/nokogiri_adapter/{backup/form.rb → form.rb} +19 -6
- data/lib/automation_object/driver/nokogiri_adapter/request.rb +17 -0
- data/lib/automation_object/driver/nokogiri_adapter/session.rb +94 -0
- data/lib/automation_object/driver/nokogiri_adapter/window.rb +86 -0
- data/lib/automation_object/driver/selenium_adapter/driver.rb +36 -45
- data/lib/automation_object/driver/selenium_adapter/element.rb +15 -85
- data/lib/automation_object/dsl.rb +11 -28
- data/lib/automation_object/dsl/_base.rb +70 -0
- data/lib/automation_object/dsl/_proxy.rb +24 -0
- data/lib/automation_object/dsl/element.rb +34 -0
- data/lib/automation_object/dsl/element_array.rb +34 -0
- data/lib/automation_object/dsl/element_hash.rb +34 -0
- data/lib/automation_object/dsl/modal.rb +43 -0
- data/lib/automation_object/dsl/screen.rb +45 -0
- data/lib/automation_object/dsl/top.rb +25 -0
- data/lib/automation_object/framework.rb +28 -38
- data/lib/automation_object/helpers/composite.rb +30 -27
- data/lib/automation_object/helpers/composite_hook.rb +16 -15
- data/lib/automation_object/{blue_print/helpers/file_helper.rb → helpers/file.rb} +12 -12
- data/lib/automation_object/helpers/hash.rb +6 -5
- data/lib/automation_object/helpers/kernel.rb +11 -0
- data/lib/automation_object/helpers/{reflection_helper.rb → reflection.rb} +9 -8
- data/lib/automation_object/helpers/string.rb +25 -15
- data/lib/automation_object/{proxies → proxy}/mutex_proxy.rb +18 -21
- data/lib/automation_object/proxy/proxy.rb +23 -0
- data/lib/automation_object/proxy/throttle_proxy.rb +52 -0
- data/lib/automation_object/state.rb +11 -29
- data/lib/automation_object/state/{blue_print_adapter/composite.rb → composite/_base.rb} +35 -25
- data/lib/automation_object/state/{blue_print_adapter/helpers/element_helper.rb → composite/_common_element.rb} +11 -11
- data/lib/automation_object/state/composite/element.rb +22 -0
- data/lib/automation_object/state/composite/element_array.rb +27 -0
- data/lib/automation_object/state/composite/element_hash.rb +33 -0
- data/lib/automation_object/state/composite/element_proxy.rb +33 -0
- data/lib/automation_object/state/composite/helpers/window.rb +61 -0
- data/lib/automation_object/state/composite/helpers/window_manager.rb +60 -0
- data/lib/automation_object/state/composite/hook.rb +56 -0
- data/lib/automation_object/state/{blue_print_adapter → composite}/hook_action.rb +10 -8
- data/lib/automation_object/state/composite/hook_actions/action_loop.rb +36 -0
- data/lib/automation_object/state/{blue_print_adapter → composite}/hook_actions/change_screen.rb +7 -5
- data/lib/automation_object/state/{blue_print_adapter → composite}/hook_actions/change_to_previous_screen.rb +7 -5
- data/lib/automation_object/state/composite/hook_actions/close_modal.rb +29 -0
- data/lib/automation_object/state/composite/hook_actions/close_screen.rb +19 -0
- data/lib/automation_object/state/composite/hook_actions/element_requirement.rb +32 -0
- data/lib/automation_object/state/composite/hook_actions/new_screen.rb +35 -0
- data/lib/automation_object/state/{blue_print_adapter → composite}/hook_actions/possible_screen_changes.rb +8 -7
- data/lib/automation_object/state/composite/hook_actions/reset_screen.rb +14 -0
- data/lib/automation_object/state/{blue_print_adapter → composite}/hook_actions/show_modal.rb +7 -5
- data/lib/automation_object/state/{blue_print_adapter → composite}/hook_actions/sleep.rb +4 -2
- data/lib/automation_object/state/{blue_print_adapter → composite}/hook_actions/wait_for_elements.rb +7 -5
- data/lib/automation_object/state/composite/modal.rb +45 -0
- data/lib/automation_object/state/composite/screen.rb +58 -0
- data/lib/automation_object/state/composite/top.rb +51 -0
- data/lib/automation_object/state/error.rb +45 -6
- data/lib/automation_object/state/session.rb +25 -23
- data/lib/automation_object/step_definitions.rb +5 -3
- data/lib/automation_object/step_definitions/element.rb +77 -0
- data/lib/automation_object/step_definitions/element_array.rb +135 -0
- data/lib/automation_object/step_definitions/element_hash.rb +126 -0
- data/lib/automation_object/step_definitions/screen.rb +62 -0
- data/lib/automation_object/step_definitions/{cache.rb → support/cache.rb} +8 -6
- data/lib/automation_object/step_definitions/support/element_array.rb +40 -0
- data/lib/automation_object/step_definitions/support/element_hash.rb +41 -0
- data/lib/automation_object/step_definitions/{parse.rb → support/parse.rb} +8 -6
- data/lib/automation_object/version.rb +2 -1
- metadata +203 -103
- data/lib/automation_object/driver/helpers/selenium_driver_helper.rb +0 -41
- data/lib/automation_object/driver/helpers/selenium_element_helper.rb +0 -138
- data/lib/automation_object/driver/nokogiri_adapter/backup/driver.rb +0 -83
- data/lib/automation_object/driver/nokogiri_adapter/backup/element.rb +0 -66
- data/lib/automation_object/driver/nokogiri_adapter/backup/helpers/driver_element_helper.rb +0 -52
- data/lib/automation_object/driver/nokogiri_adapter/backup/session.rb +0 -115
- data/lib/automation_object/dsl/blue_print_adapter.rb +0 -16
- data/lib/automation_object/dsl/blue_print_adapter/composite.rb +0 -54
- data/lib/automation_object/dsl/blue_print_adapter/element.rb +0 -14
- data/lib/automation_object/dsl/blue_print_adapter/element_array.rb +0 -14
- data/lib/automation_object/dsl/blue_print_adapter/element_hash.rb +0 -14
- data/lib/automation_object/dsl/blue_print_adapter/modal.rb +0 -23
- data/lib/automation_object/dsl/blue_print_adapter/screen.rb +0 -26
- data/lib/automation_object/dsl/blue_print_adapter/top.rb +0 -19
- data/lib/automation_object/dsl/models.rb +0 -18
- data/lib/automation_object/dsl/proxies/element.rb +0 -16
- data/lib/automation_object/dsl/proxies/element_array.rb +0 -16
- data/lib/automation_object/dsl/proxies/element_hash.rb +0 -16
- data/lib/automation_object/dsl/proxies/helpers/composite_helper.rb +0 -74
- data/lib/automation_object/dsl/proxies/modal.rb +0 -17
- data/lib/automation_object/dsl/proxies/screen.rb +0 -17
- data/lib/automation_object/dsl/proxies/top.rb +0 -17
- data/lib/automation_object/proxies/proxy.rb +0 -20
- data/lib/automation_object/proxies/throttle_proxy.rb +0 -57
- data/lib/automation_object/state/blue_print_adapter.rb +0 -16
- data/lib/automation_object/state/blue_print_adapter/element.rb +0 -20
- data/lib/automation_object/state/blue_print_adapter/element_array.rb +0 -25
- data/lib/automation_object/state/blue_print_adapter/element_hash.rb +0 -31
- data/lib/automation_object/state/blue_print_adapter/element_proxy.rb +0 -28
- data/lib/automation_object/state/blue_print_adapter/helpers/screen_manager.rb +0 -137
- data/lib/automation_object/state/blue_print_adapter/helpers/window.rb +0 -39
- data/lib/automation_object/state/blue_print_adapter/hook.rb +0 -56
- data/lib/automation_object/state/blue_print_adapter/hook_actions/action_loop.rb +0 -35
- data/lib/automation_object/state/blue_print_adapter/hook_actions/close_modal.rb +0 -31
- data/lib/automation_object/state/blue_print_adapter/hook_actions/close_screen.rb +0 -19
- data/lib/automation_object/state/blue_print_adapter/hook_actions/element_requirement.rb +0 -34
- data/lib/automation_object/state/blue_print_adapter/hook_actions/new_screen.rb +0 -37
- data/lib/automation_object/state/blue_print_adapter/hook_actions/reset_screen.rb +0 -18
- data/lib/automation_object/state/blue_print_adapter/modal.rb +0 -26
- data/lib/automation_object/state/blue_print_adapter/screen.rb +0 -32
- data/lib/automation_object/state/blue_print_adapter/top.rb +0 -45
- data/lib/automation_object/step_definitions/action.rb +0 -21
- data/lib/automation_object/step_definitions/element/actions.rb +0 -87
- data/lib/automation_object/step_definitions/element/regex.rb +0 -24
- data/lib/automation_object/step_definitions/element/steps.rb +0 -67
@@ -1,34 +0,0 @@
|
|
1
|
-
require_relative 'action_loop'
|
2
|
-
|
3
|
-
module AutomationObject
|
4
|
-
module State
|
5
|
-
module BluePrintAdapter
|
6
|
-
class ElementRequirement < ActionLoop
|
7
|
-
def element
|
8
|
-
@element ||= self.driver.find_element(*self.blue_prints.element_blueprints.selector_params)
|
9
|
-
end
|
10
|
-
|
11
|
-
def single_run
|
12
|
-
self.blue_prints.hook_order.each { |requirement_name|
|
13
|
-
next if self.blue_prints.requirement(requirement_name) == nil
|
14
|
-
|
15
|
-
requirement_value = self.blue_prints.requirement(requirement_name)
|
16
|
-
|
17
|
-
case requirement_name
|
18
|
-
when :exists?
|
19
|
-
if requirement_value != self.driver.exists?(*self.blue_prints.element_blueprints.selector_params)
|
20
|
-
return false
|
21
|
-
end
|
22
|
-
else
|
23
|
-
if requirement_value != self.element.send(requirement_name)
|
24
|
-
return false
|
25
|
-
end
|
26
|
-
end
|
27
|
-
}
|
28
|
-
|
29
|
-
return true
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
@@ -1,37 +0,0 @@
|
|
1
|
-
require_relative 'action_loop'
|
2
|
-
require_relative '../../error'
|
3
|
-
|
4
|
-
module AutomationObject
|
5
|
-
module State
|
6
|
-
module BluePrintAdapter
|
7
|
-
class NewScreen < ActionLoop
|
8
|
-
def initialize(args = {})
|
9
|
-
super
|
10
|
-
end
|
11
|
-
|
12
|
-
def single_run
|
13
|
-
new_screen_name = self.blue_prints
|
14
|
-
new_screen = self.composite.top.screens[new_screen_name]
|
15
|
-
|
16
|
-
stored_window_handles = self.composite.top.window_handles
|
17
|
-
driver_handles = self.driver.window_handles
|
18
|
-
|
19
|
-
if driver_handles.length <= stored_window_handles.length
|
20
|
-
return false
|
21
|
-
end
|
22
|
-
|
23
|
-
if (driver_handles.length - stored_window_handles.length) > 1
|
24
|
-
raise MoreThenOneScreenCreated.new
|
25
|
-
end
|
26
|
-
|
27
|
-
self.composite.top.create_screen(new_screen_name)
|
28
|
-
self.composite.top.use_screen(new_screen_name)
|
29
|
-
|
30
|
-
self.driver.document_complete_wait
|
31
|
-
|
32
|
-
return new_screen.load.live?
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
@@ -1,18 +0,0 @@
|
|
1
|
-
require_relative 'action_loop'
|
2
|
-
|
3
|
-
module AutomationObject
|
4
|
-
module State
|
5
|
-
module BluePrintAdapter
|
6
|
-
class ResetScreen < ActionLoop
|
7
|
-
def single_run
|
8
|
-
unless self.composite.screen
|
9
|
-
raise ScreenParentExpected.new
|
10
|
-
end
|
11
|
-
|
12
|
-
screen_name = self.composite.screen.name
|
13
|
-
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
@@ -1,26 +0,0 @@
|
|
1
|
-
require_relative 'composite'
|
2
|
-
|
3
|
-
require_relative 'element'
|
4
|
-
require_relative 'element_array'
|
5
|
-
require_relative 'element_hash'
|
6
|
-
|
7
|
-
module AutomationObject
|
8
|
-
module State
|
9
|
-
module BluePrintAdapter
|
10
|
-
#TODO: refactor to container
|
11
|
-
class Modal < AutomationObject::State::BluePrintAdapter::Composite
|
12
|
-
has_one :load, interface: Hook
|
13
|
-
|
14
|
-
has_many :elements, interface: Element
|
15
|
-
has_many :element_arrays, interface: ElementArray
|
16
|
-
has_many :element_hashes, interface: ElementHash
|
17
|
-
|
18
|
-
attr_accessor :active
|
19
|
-
# @return [Boolean] screen is active or not
|
20
|
-
def active
|
21
|
-
return @active ||= false
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
@@ -1,32 +0,0 @@
|
|
1
|
-
require_relative 'composite'
|
2
|
-
|
3
|
-
require_relative 'modal'
|
4
|
-
require_relative 'hook'
|
5
|
-
require_relative 'element'
|
6
|
-
require_relative 'element_array'
|
7
|
-
require_relative 'element_hash'
|
8
|
-
|
9
|
-
module AutomationObject
|
10
|
-
module State
|
11
|
-
module BluePrintAdapter
|
12
|
-
class Screen < AutomationObject::State::BluePrintAdapter::Composite
|
13
|
-
attr_accessor :modal, :current_modal
|
14
|
-
|
15
|
-
has_one :load, interface: Hook
|
16
|
-
|
17
|
-
#Children for this composite
|
18
|
-
has_many :modals, interface: Modal
|
19
|
-
|
20
|
-
has_many :elements, interface: Element
|
21
|
-
has_many :element_arrays, interface: ElementArray
|
22
|
-
has_many :element_hashes, interface: ElementHash
|
23
|
-
|
24
|
-
attr_accessor :active
|
25
|
-
# @return [Boolean] screen is active or not
|
26
|
-
def active
|
27
|
-
return @active ||= false
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
@@ -1,45 +0,0 @@
|
|
1
|
-
require_relative 'composite'
|
2
|
-
require_relative 'screen'
|
3
|
-
|
4
|
-
require_relative 'helpers/screen_manager'
|
5
|
-
|
6
|
-
require_relative '../error'
|
7
|
-
|
8
|
-
module AutomationObject
|
9
|
-
module State
|
10
|
-
module BluePrintAdapter
|
11
|
-
class Top < AutomationObject::State::BluePrintAdapter::Composite
|
12
|
-
include ScreenManager
|
13
|
-
|
14
|
-
#Children for this composite
|
15
|
-
has_many :screens, interface: Screen
|
16
|
-
|
17
|
-
# @return [Symbol] symbol of the initial screen found
|
18
|
-
def create
|
19
|
-
self.driver.get(self.blue_prints.base_url) if self.blue_prints.base_url
|
20
|
-
self.set_screen(self.initial_screen)
|
21
|
-
end
|
22
|
-
|
23
|
-
def initial_screen
|
24
|
-
#If default screen then check if its live and set it
|
25
|
-
if self.blue_prints.default_screen
|
26
|
-
screen_name = self.blue_prints.default_screen
|
27
|
-
default_screen_live = self.screens[screen_name].load.live?
|
28
|
-
|
29
|
-
if default_screen_live == nil or default_screen_live == true
|
30
|
-
return screen_name
|
31
|
-
else
|
32
|
-
raise AutomationObject::State::NoInitialScreenError.new
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
self.screens.each { |screen_name, screen|
|
37
|
-
return screen_name if screen.load.live?
|
38
|
-
}
|
39
|
-
|
40
|
-
raise AutomationObject::State::NoInitialScreenError.new
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|
@@ -1,21 +0,0 @@
|
|
1
|
-
require_relative 'parse'
|
2
|
-
|
3
|
-
module AutomationObject
|
4
|
-
module StepDefinitions
|
5
|
-
class Action
|
6
|
-
attr_accessor :args, :automation_object
|
7
|
-
|
8
|
-
def initialize(*args)
|
9
|
-
#Parse arguments
|
10
|
-
self.args = AutomationObject::StepDefinitions::Parse.new(args).get
|
11
|
-
end
|
12
|
-
|
13
|
-
def automation_object
|
14
|
-
return @automation_object if @automation_object
|
15
|
-
|
16
|
-
@automation_object = AutomationObject::Framework.get
|
17
|
-
return @automation_object
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
@@ -1,87 +0,0 @@
|
|
1
|
-
require_relative '../action'
|
2
|
-
|
3
|
-
module AutomationObject
|
4
|
-
module StepDefinitions
|
5
|
-
module Element
|
6
|
-
class CallAction < AutomationObject::StepDefinitions::Action
|
7
|
-
def initialize(*args)
|
8
|
-
super
|
9
|
-
@method, @screen, @element = self.args
|
10
|
-
end
|
11
|
-
|
12
|
-
def run
|
13
|
-
automation_object.send(@screen).send(@element).send(@method)
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
class TypeAction < AutomationObject::StepDefinitions::Action
|
18
|
-
def initialize(*args)
|
19
|
-
super
|
20
|
-
@text, @screen, @element = self.args
|
21
|
-
end
|
22
|
-
|
23
|
-
def run
|
24
|
-
automation_object.send(@screen).send(@element).send_keys(@text)
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
class ScrollAction < AutomationObject::StepDefinitions::Action
|
29
|
-
def initialize(*args)
|
30
|
-
super
|
31
|
-
@screen, @element = self.args
|
32
|
-
end
|
33
|
-
|
34
|
-
def run
|
35
|
-
automation_object.send(@screen).send(@element).scroll_into_view
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
class SaveAction < AutomationObject::StepDefinitions::Action
|
40
|
-
def initialize(*args)
|
41
|
-
super
|
42
|
-
@method, @key, @screen, @element = self.args
|
43
|
-
end
|
44
|
-
|
45
|
-
def run
|
46
|
-
#Save value from called method/property
|
47
|
-
value = automation_object.send(@screen).send(@element).send(@method)
|
48
|
-
AutomationObject::StepDefinitions::Cache.set(@key, value)
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
class ExistAction < AutomationObject::StepDefinitions::Action
|
53
|
-
def initialize(*args)
|
54
|
-
super
|
55
|
-
@screen, @element, @negative = self.args
|
56
|
-
end
|
57
|
-
|
58
|
-
def run
|
59
|
-
exists = AutomationObject::Framework.get.send(@screen).send(@element).exists?
|
60
|
-
|
61
|
-
if @negative
|
62
|
-
assert_equal false, exists
|
63
|
-
else
|
64
|
-
assert_equal true, exists
|
65
|
-
end
|
66
|
-
end
|
67
|
-
end
|
68
|
-
|
69
|
-
class EqualAction < AutomationObject::StepDefinitions::Action
|
70
|
-
def initialize(*args)
|
71
|
-
super
|
72
|
-
@screen, @element, @method, @negative, @expected_value = self.args
|
73
|
-
end
|
74
|
-
|
75
|
-
def run
|
76
|
-
actual_value = AutomationObject::Framework.get.send(@screen).send(@element).send(@method)
|
77
|
-
|
78
|
-
if @negative
|
79
|
-
refute_equal @expected_value, actual_value
|
80
|
-
else
|
81
|
-
assert_equal @expected_value, actual_value
|
82
|
-
end
|
83
|
-
end
|
84
|
-
end
|
85
|
-
end
|
86
|
-
end
|
87
|
-
end
|
@@ -1,24 +0,0 @@
|
|
1
|
-
module AutomationObject
|
2
|
-
module StepDefinitions
|
3
|
-
#Storing regular expressions in a module
|
4
|
-
#So I can unit test the matches and any changes that can occur to them
|
5
|
-
#To make sure we don't break existing implementations by accident
|
6
|
-
module Element
|
7
|
-
#Action
|
8
|
-
|
9
|
-
CALL_REGEX = /^I (\w+|%\{[\w\d]+\}) ?(?: on| over)? (?:the )?"(\w+|%\{[\w\d]+\})" "(\w+|%\{[\w\d]+\})" element$/
|
10
|
-
|
11
|
-
TYPE_REGEX = /^I type "([\w\s]+|%\{[\w\d]+\})" in(?:to)? (?:the )?"(\w+|%\{[\w\d]+\})" "(\w+|%\{[\w\d]+\})" element$/
|
12
|
-
|
13
|
-
SCROLL_REGEX = /^I scroll to (?:the )?"(\w+|%\{[\w\d]+\})" "(\w+|%\{[\w\d]+\})" element$/
|
14
|
-
|
15
|
-
SAVE_REGEX = /^I save "(\w+|%\{[\w\d]+\})" as "([\w\d]+)" from (?:the )?"(\w+|%\{[\w\d]+\})" "(\w+|%\{[\w\d]+\})" element$/
|
16
|
-
|
17
|
-
#Should
|
18
|
-
|
19
|
-
EXIST_REGEX = /^(?:the )?"(\w+|%\{[\w\d]+\})" "(\w+|%\{[\w\d]+\})" element should ?(n't |not )?exist$/
|
20
|
-
|
21
|
-
EQUAL_REGEX = /^(?:the )?"(\w+|%\{[\w\d]+\})" "(\w+|%\{[\w\d]+\})" element "(\w+|%\{[\w\d]+\})" should ?(n't |not )?equal "(.+)"$/
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
@@ -1,67 +0,0 @@
|
|
1
|
-
require_relative 'regex'
|
2
|
-
require_relative 'actions'
|
3
|
-
|
4
|
-
# Element related step definitions
|
5
|
-
|
6
|
-
# Step to call a method on an element
|
7
|
-
#
|
8
|
-
# Examples:
|
9
|
-
# I click on the "home_screen" "about_button" element
|
10
|
-
# I hover over the "home_screen" "test_link" element
|
11
|
-
# I tap on "home_screen" "logo_button" element
|
12
|
-
|
13
|
-
When(AutomationObject::StepDefinitions::Element::CALL_REGEX) do |*args|
|
14
|
-
AutomationObject::StepDefinitions::Element::CallAction.new(args).run
|
15
|
-
end
|
16
|
-
|
17
|
-
# Step to type into a field element
|
18
|
-
#
|
19
|
-
# Examples:
|
20
|
-
# I type "blah" into the "home_screen" "text_field" element
|
21
|
-
# I hover over the "home_screen" "test_link" element
|
22
|
-
# I tap on "home_screen" "logo_button" element
|
23
|
-
|
24
|
-
When(AutomationObject::StepDefinitions::Element::TYPE_REGEX) do |*args|
|
25
|
-
AutomationObject::StepDefinitions::Element::TypeAction.new(args).run
|
26
|
-
end
|
27
|
-
|
28
|
-
# Step to scroll to an element
|
29
|
-
#
|
30
|
-
# Examples:
|
31
|
-
# I scroll to the "home_screen" "logo_button" element
|
32
|
-
|
33
|
-
When(AutomationObject::StepDefinitions::Element::SCROLL_REGEX) do |*args|
|
34
|
-
AutomationObject::StepDefinitions::Element::ScrollAction.new(args).run
|
35
|
-
end
|
36
|
-
|
37
|
-
# Step to save something from an element
|
38
|
-
#
|
39
|
-
# Examples:
|
40
|
-
# I save "text" as "unique_value" from the "home_screen" "logo_button" element
|
41
|
-
|
42
|
-
When(AutomationObject::StepDefinitions::Element::SAVE_REGEX) do |*args|
|
43
|
-
AutomationObject::StepDefinitions::Element::SaveAction.new(args).run
|
44
|
-
end
|
45
|
-
|
46
|
-
# Step to test element exists
|
47
|
-
#
|
48
|
-
# Examples:
|
49
|
-
# Then the "home_screen" "title" element should exist
|
50
|
-
# Then the "home_screen" "title" element shouldn't exist
|
51
|
-
# Then "home_screen" "title" element should not exist
|
52
|
-
|
53
|
-
Then(AutomationObject::StepDefinitions::Element::EXIST_REGEX) do |*args|
|
54
|
-
AutomationObject::StepDefinitions::Element::ExistAction.new(args).run
|
55
|
-
end
|
56
|
-
|
57
|
-
# Step to test element value to a given value
|
58
|
-
# If trying to carry over from any other object, use cache mechanism
|
59
|
-
#
|
60
|
-
# Examples:
|
61
|
-
# the "home_screen" "title" element "text" should equal "Home"
|
62
|
-
# "home_screen" "title" element "text" should not equal "About"
|
63
|
-
# the "home_screen" "title" element "text" shouldn't equal "%{saved_value}"
|
64
|
-
|
65
|
-
Then(AutomationObject::StepDefinitions::Element::EQUAL_REGEX) do |*args|
|
66
|
-
AutomationObject::StepDefinitions::Element::EqualAction.new(args).run
|
67
|
-
end
|