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