testa_appium_driver 0.1.11 → 0.1.12

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.
Files changed (48) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +15 -15
  3. data/.idea/deployment.xml +21 -21
  4. data/.idea/inspectionProfiles/Project_Default.xml +8 -8
  5. data/.idea/misc.xml +5 -5
  6. data/.idea/modules.xml +7 -7
  7. data/.idea/runConfigurations/Android_Test.xml +41 -41
  8. data/.idea/runConfigurations.xml +9 -9
  9. data/.idea/sshConfigs.xml +12 -12
  10. data/.idea/vcs.xml +5 -5
  11. data/.idea/webServers.xml +20 -20
  12. data/.rspec +3 -3
  13. data/.rubocop.yml +13 -13
  14. data/CHANGELOG.md +5 -5
  15. data/CODE_OF_CONDUCT.md +102 -102
  16. data/Gemfile +12 -12
  17. data/LICENSE.txt +21 -21
  18. data/README.md +378 -378
  19. data/Rakefile +12 -12
  20. data/bin/console +17 -17
  21. data/bin/setup +8 -8
  22. data/lib/testa_appium_driver/android/class_selectors.rb +437 -437
  23. data/lib/testa_appium_driver/android/driver.rb +69 -69
  24. data/lib/testa_appium_driver/android/locator/attributes.rb +113 -113
  25. data/lib/testa_appium_driver/android/locator.rb +141 -141
  26. data/lib/testa_appium_driver/android/scroll_actions/uiautomator_scroll_actions.rb +61 -61
  27. data/lib/testa_appium_driver/android/selenium_element.rb +7 -7
  28. data/lib/testa_appium_driver/common/bounds.rb +149 -149
  29. data/lib/testa_appium_driver/common/constants.rb +36 -36
  30. data/lib/testa_appium_driver/common/exceptions/strategy_mix_exception.rb +11 -11
  31. data/lib/testa_appium_driver/common/helpers.rb +270 -270
  32. data/lib/testa_appium_driver/common/locator/scroll_actions.rb +397 -397
  33. data/lib/testa_appium_driver/common/locator.rb +610 -610
  34. data/lib/testa_appium_driver/common/scroll_actions/json_wire_scroll_actions.rb +3 -3
  35. data/lib/testa_appium_driver/common/scroll_actions/w3c_scroll_actions.rb +237 -237
  36. data/lib/testa_appium_driver/common/scroll_actions.rb +246 -246
  37. data/lib/testa_appium_driver/common/selenium_element.rb +19 -19
  38. data/lib/testa_appium_driver/driver.rb +312 -312
  39. data/lib/testa_appium_driver/ios/driver.rb +48 -48
  40. data/lib/testa_appium_driver/ios/locator/attributes.rb +80 -80
  41. data/lib/testa_appium_driver/ios/locator.rb +70 -70
  42. data/lib/testa_appium_driver/ios/selenium_element.rb +6 -6
  43. data/lib/testa_appium_driver/ios/type_selectors.rb +187 -187
  44. data/lib/testa_appium_driver/version.rb +5 -5
  45. data/lib/testa_appium_driver.rb +6 -6
  46. data/testa_appium_driver.gemspec +41 -41
  47. data/testa_appium_driver.iml +27 -78
  48. metadata +3 -3
@@ -1,49 +1,49 @@
1
- require_relative 'type_selectors'
2
- require_relative 'locator'
3
- require_relative 'selenium_element'
4
-
5
- module TestaAppiumDriver
6
- class Driver
7
- include TypeSelectors
8
-
9
-
10
-
11
- # @param params [Hash]
12
- # @return [TestaAppiumDriver::Locator] first scrollable element
13
- def scrollable(params = {})
14
- scroll_view(params)
15
- end
16
-
17
- # @param params [Hash]
18
- # @return [TestaAppiumDriver::Locator] first scrollable element
19
- def scrollables(params = {})
20
- scroll_views(params)
21
- end
22
-
23
- private
24
- def handle_testa_opts
25
- if @testa_opts[:default_find_strategy].nil?
26
- @default_find_strategy = DEFAULT_IOS_FIND_STRATEGY
27
- else
28
- case @testa_opts[:default_find_strategy].to_sym
29
- when FIND_STRATEGY_XPATH
30
- @default_find_strategy = @testa_opts[:default_find_strategy].to_sym
31
- else
32
- raise "Default find strategy #{@testa_opts[:default_find_strategy]} not supported for iOS"
33
- end
34
- end
35
-
36
-
37
- if @testa_opts[:default_scroll_strategy].nil?
38
- @default_scroll_strategy = DEFAULT_IOS_SCROLL_STRATEGY
39
- else
40
- case @testa_opts[:default_scroll_strategy].to_sym
41
- when SCROLL_STRATEGY_W3C
42
- @default_scroll_strategy = @testa_opts[:default_scroll_strategy].to_sym
43
- else
44
- raise "Default scroll strategy #{@testa_opts[:default_scroll_strategy]} not supported for iOS"
45
- end
46
- end
47
- end
48
- end
1
+ require_relative 'type_selectors'
2
+ require_relative 'locator'
3
+ require_relative 'selenium_element'
4
+
5
+ module TestaAppiumDriver
6
+ class Driver
7
+ include TypeSelectors
8
+
9
+
10
+
11
+ # @param params [Hash]
12
+ # @return [TestaAppiumDriver::Locator] first scrollable element
13
+ def scrollable(params = {})
14
+ scroll_view(params)
15
+ end
16
+
17
+ # @param params [Hash]
18
+ # @return [TestaAppiumDriver::Locator] first scrollable element
19
+ def scrollables(params = {})
20
+ scroll_views(params)
21
+ end
22
+
23
+ private
24
+ def handle_testa_opts
25
+ if @testa_opts[:default_find_strategy].nil?
26
+ @default_find_strategy = DEFAULT_IOS_FIND_STRATEGY
27
+ else
28
+ case @testa_opts[:default_find_strategy].to_sym
29
+ when FIND_STRATEGY_XPATH
30
+ @default_find_strategy = @testa_opts[:default_find_strategy].to_sym
31
+ else
32
+ raise "Default find strategy #{@testa_opts[:default_find_strategy]} not supported for iOS"
33
+ end
34
+ end
35
+
36
+
37
+ if @testa_opts[:default_scroll_strategy].nil?
38
+ @default_scroll_strategy = DEFAULT_IOS_SCROLL_STRATEGY
39
+ else
40
+ case @testa_opts[:default_scroll_strategy].to_sym
41
+ when SCROLL_STRATEGY_W3C
42
+ @default_scroll_strategy = @testa_opts[:default_scroll_strategy].to_sym
43
+ else
44
+ raise "Default scroll strategy #{@testa_opts[:default_scroll_strategy]} not supported for iOS"
45
+ end
46
+ end
47
+ end
48
+ end
49
49
  end
@@ -1,81 +1,81 @@
1
- module TestaAppiumDriver
2
- module Attributes
3
-
4
- #noinspection RubyNilAnalysis
5
- def attribute(name, *args)
6
- elements = execute(*args)
7
-
8
- if elements.instance_of?(Selenium::WebDriver::Element)
9
- r = elements.send(:attribute, name.to_s)
10
- r = TestaAppiumDriver::Bounds.from_ios(r, @driver) if name.to_s == "rect"
11
- else
12
- r = elements.map { |e| e.send(:attribute, name.to_s) }
13
- r.map! { |b| TestaAppiumDriver::Bounds.from_ios(b, @driver) } if name.to_s == "rect"
14
- end
15
- r
16
- end
17
-
18
-
19
- def accessibility_container(*args)
20
- attribute("accessibilityContainer", *args)
21
- end
22
-
23
- def accessible?(*args)
24
- attribute("accessible", *args).to_s == "true"
25
- end
26
-
27
-
28
- def class_name(*args)
29
- attribute("class", *args)
30
- end
31
-
32
- def enabled?(*args)
33
- attribute("enabled", *args).to_s == "true"
34
- end
35
-
36
- def frame(*args)
37
- attribute("frame", *args)
38
- end
39
-
40
- def index(*args)
41
- attribute("index", *args)
42
- end
43
-
44
- def label(*args)
45
- attribute("label", *args)
46
- end
47
-
48
- def name(*args)
49
- attribute("name", *args)
50
- end
51
-
52
-
53
- def rect(*args)
54
- attribute("rect", *args)
55
- end
56
-
57
- def selected?(*args)
58
- attribute("selected", *args).to_s == "true"
59
- end
60
-
61
- def type(*args)
62
- attribute("type", *args)
63
- end
64
-
65
- def value(*args)
66
- attribute("value", *args)
67
- end
68
-
69
- def visible?(*args)
70
- attribute("visible", *args).to_s == "true"
71
- end
72
-
73
-
74
- alias_method :bounds, :rect
75
- alias_method :text, :label
76
- end
77
- #noinspection RubyYardReturnMatch
78
- class Locator
79
- include TestaAppiumDriver::Attributes
80
- end
1
+ module TestaAppiumDriver
2
+ module Attributes
3
+
4
+ #noinspection RubyNilAnalysis
5
+ def attribute(name, *args)
6
+ elements = execute(*args)
7
+
8
+ if elements.instance_of?(Selenium::WebDriver::Element)
9
+ r = elements.send(:attribute, name.to_s)
10
+ r = TestaAppiumDriver::Bounds.from_ios(r, @driver) if name.to_s == "rect"
11
+ else
12
+ r = elements.map { |e| e.send(:attribute, name.to_s) }
13
+ r.map! { |b| TestaAppiumDriver::Bounds.from_ios(b, @driver) } if name.to_s == "rect"
14
+ end
15
+ r
16
+ end
17
+
18
+
19
+ def accessibility_container(*args)
20
+ attribute("accessibilityContainer", *args)
21
+ end
22
+
23
+ def accessible?(*args)
24
+ attribute("accessible", *args).to_s == "true"
25
+ end
26
+
27
+
28
+ def class_name(*args)
29
+ attribute("class", *args)
30
+ end
31
+
32
+ def enabled?(*args)
33
+ attribute("enabled", *args).to_s == "true"
34
+ end
35
+
36
+ def frame(*args)
37
+ attribute("frame", *args)
38
+ end
39
+
40
+ def index(*args)
41
+ attribute("index", *args)
42
+ end
43
+
44
+ def label(*args)
45
+ attribute("label", *args)
46
+ end
47
+
48
+ def name(*args)
49
+ attribute("name", *args)
50
+ end
51
+
52
+
53
+ def rect(*args)
54
+ attribute("rect", *args)
55
+ end
56
+
57
+ def selected?(*args)
58
+ attribute("selected", *args).to_s == "true"
59
+ end
60
+
61
+ def type(*args)
62
+ attribute("type", *args)
63
+ end
64
+
65
+ def value(*args)
66
+ attribute("value", *args)
67
+ end
68
+
69
+ def visible?(*args)
70
+ attribute("visible", *args).to_s == "true"
71
+ end
72
+
73
+
74
+ alias_method :bounds, :rect
75
+ alias_method :text, :label
76
+ end
77
+ #noinspection RubyYardReturnMatch
78
+ class Locator
79
+ include TestaAppiumDriver::Attributes
80
+ end
81
81
  end
@@ -1,71 +1,71 @@
1
- require_relative 'locator/attributes'
2
-
3
- module TestaAppiumDriver
4
- class Locator
5
- include TypeSelectors
6
- attr_accessor :class_chain_selector
7
-
8
- def init(params, selectors, single)
9
- if is_scrollable_selector?(selectors, single)
10
- @scroll_orientation = :vertical
11
-
12
- if !params[:top].nil? || !params[:bottom].nil? || !params[:right].nil? || !params[:left].nil?
13
- @scroll_deadzone = {}
14
- @scroll_deadzone[:top] = params[:top].to_f unless params[:top].nil?
15
- @scroll_deadzone[:bottom] = params[:bottom].to_f unless params[:bottom].nil?
16
- @scroll_deadzone[:right] = params[:right].to_f unless params[:right].nil?
17
- @scroll_deadzone[:left] = params[:left].to_f unless params[:left].nil?
18
- end
19
-
20
- params[:scrollable_locator] = self.dup
21
- end
22
-
23
- @class_chain_selector = hash_to_class_chain(selectors, single)
24
-
25
-
26
- @scrollable_locator = params[:scrollable_locator] if params[:scrollable_locator]
27
- end
28
-
29
-
30
- # @return [Array] returns 2 elements. The first is the resolved find element strategy and the second is the resolved selector
31
- def strategies_and_selectors
32
- ss = []
33
- if @can_use_id_strategy
34
- ss.push({"#{FIND_STRATEGY_NAME}": @can_use_id_strategy})
35
- end
36
- ss.push({"#{FIND_STRATEGY_CLASS_CHAIN}": @class_chain_selector}) if @strategy.nil? || @strategy == FIND_STRATEGY_CLASS_CHAIN
37
- ss.push({"#{FIND_STRATEGY_XPATH}": @xpath_selector}) if @strategy.nil? || @strategy == FIND_STRATEGY_XPATH
38
- ss.push({"#{FIND_STRATEGY_IMAGE}": @image_selector}) if @strategy == FIND_STRATEGY_IMAGE
39
- ss
40
- end
41
-
42
-
43
-
44
- # @return [Locator] new child locator element
45
- def add_child_selector(params)
46
- params, selectors = extract_selectors_from_params(params)
47
- single = params[:single]
48
- raise "Cannot add child selector to Array" if single && !@single
49
-
50
- locator = self.dup
51
- add_xpath_child_selectors(locator, selectors, single)
52
- if @strategy.nil? || @strategy == FIND_STRATEGY_CLASS_CHAIN
53
- add_class_chain_child_selectors(locator, selectors, single)
54
- end
55
-
56
- if is_scrollable_selector?(selectors, single)
57
- locator.scrollable_locator.scroll_orientation = :vertical
58
- locator.scrollable_locator = locator
59
- end
60
-
61
- locator.last_selector_adjacent = false
62
- locator
63
- end
64
-
65
-
66
- def add_class_chain_child_selectors(locator, selectors, single)
67
- locator.single = false unless single # switching from single result to multiple
68
- locator.class_chain_selector += "/" + hash_to_class_chain(selectors, single)
69
- end
70
- end
1
+ require_relative 'locator/attributes'
2
+
3
+ module TestaAppiumDriver
4
+ class Locator
5
+ include TypeSelectors
6
+ attr_accessor :class_chain_selector
7
+
8
+ def init(params, selectors, single)
9
+ if is_scrollable_selector?(selectors, single)
10
+ @scroll_orientation = :vertical
11
+
12
+ if !params[:top].nil? || !params[:bottom].nil? || !params[:right].nil? || !params[:left].nil?
13
+ @scroll_deadzone = {}
14
+ @scroll_deadzone[:top] = params[:top].to_f unless params[:top].nil?
15
+ @scroll_deadzone[:bottom] = params[:bottom].to_f unless params[:bottom].nil?
16
+ @scroll_deadzone[:right] = params[:right].to_f unless params[:right].nil?
17
+ @scroll_deadzone[:left] = params[:left].to_f unless params[:left].nil?
18
+ end
19
+
20
+ params[:scrollable_locator] = self.dup
21
+ end
22
+
23
+ @class_chain_selector = hash_to_class_chain(selectors, single)
24
+
25
+
26
+ @scrollable_locator = params[:scrollable_locator] if params[:scrollable_locator]
27
+ end
28
+
29
+
30
+ # @return [Array] returns 2 elements. The first is the resolved find element strategy and the second is the resolved selector
31
+ def strategies_and_selectors
32
+ ss = []
33
+ if @can_use_id_strategy
34
+ ss.push({"#{FIND_STRATEGY_NAME}": @can_use_id_strategy})
35
+ end
36
+ ss.push({"#{FIND_STRATEGY_CLASS_CHAIN}": @class_chain_selector}) if @strategy.nil? || @strategy == FIND_STRATEGY_CLASS_CHAIN
37
+ ss.push({"#{FIND_STRATEGY_XPATH}": @xpath_selector}) if @strategy.nil? || @strategy == FIND_STRATEGY_XPATH
38
+ ss.push({"#{FIND_STRATEGY_IMAGE}": @image_selector}) if @strategy == FIND_STRATEGY_IMAGE
39
+ ss
40
+ end
41
+
42
+
43
+
44
+ # @return [Locator] new child locator element
45
+ def add_child_selector(params)
46
+ params, selectors = extract_selectors_from_params(params)
47
+ single = params[:single]
48
+ raise "Cannot add child selector to Array" if single && !@single
49
+
50
+ locator = self.dup
51
+ add_xpath_child_selectors(locator, selectors, single)
52
+ if @strategy.nil? || @strategy == FIND_STRATEGY_CLASS_CHAIN
53
+ add_class_chain_child_selectors(locator, selectors, single)
54
+ end
55
+
56
+ if is_scrollable_selector?(selectors, single)
57
+ locator.scrollable_locator.scroll_orientation = :vertical
58
+ locator.scrollable_locator = locator
59
+ end
60
+
61
+ locator.last_selector_adjacent = false
62
+ locator
63
+ end
64
+
65
+
66
+ def add_class_chain_child_selectors(locator, selectors, single)
67
+ locator.single = false unless single # switching from single result to multiple
68
+ locator.class_chain_selector += "/" + hash_to_class_chain(selectors, single)
69
+ end
70
+ end
71
71
  end
@@ -1,7 +1,7 @@
1
- module Selenium
2
- module WebDriver
3
- class Element
4
- include TestaAppiumDriver::TypeSelectors
5
- end
6
- end
1
+ module Selenium
2
+ module WebDriver
3
+ class Element
4
+ include TestaAppiumDriver::TypeSelectors
5
+ end
6
+ end
7
7
  end