testa_appium_driver 0.1.0

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 (46) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +15 -0
  3. data/.idea/deployment.xml +21 -0
  4. data/.idea/inspectionProfiles/Project_Default.xml +9 -0
  5. data/.idea/misc.xml +6 -0
  6. data/.idea/modules.xml +8 -0
  7. data/.idea/runConfigurations/Android_Test.xml +42 -0
  8. data/.idea/sshConfigs.xml +10 -0
  9. data/.idea/vcs.xml +6 -0
  10. data/.idea/webServers.xml +14 -0
  11. data/.rspec +3 -0
  12. data/.rubocop.yml +13 -0
  13. data/CHANGELOG.md +5 -0
  14. data/CODE_OF_CONDUCT.md +102 -0
  15. data/Gemfile +12 -0
  16. data/LICENSE.txt +21 -0
  17. data/README.md +52 -0
  18. data/Rakefile +12 -0
  19. data/bin/console +17 -0
  20. data/bin/setup +8 -0
  21. data/lib/testa_appium_driver.rb +6 -0
  22. data/lib/testa_appium_driver/android/class_selectors.rb +353 -0
  23. data/lib/testa_appium_driver/android/driver.rb +52 -0
  24. data/lib/testa_appium_driver/android/locator.rb +115 -0
  25. data/lib/testa_appium_driver/android/locator/attributes.rb +116 -0
  26. data/lib/testa_appium_driver/android/scroll_actions/uiautomator_scroll_actions.rb +77 -0
  27. data/lib/testa_appium_driver/android/selenium_element.rb +8 -0
  28. data/lib/testa_appium_driver/common/bounds.rb +150 -0
  29. data/lib/testa_appium_driver/common/constants.rb +33 -0
  30. data/lib/testa_appium_driver/common/exceptions/strategy_mix_exception.rb +12 -0
  31. data/lib/testa_appium_driver/common/helpers.rb +242 -0
  32. data/lib/testa_appium_driver/common/locator.rb +371 -0
  33. data/lib/testa_appium_driver/common/locator/scroll_actions.rb +287 -0
  34. data/lib/testa_appium_driver/common/scroll_actions.rb +253 -0
  35. data/lib/testa_appium_driver/common/scroll_actions/json_wire_scroll_actions.rb +4 -0
  36. data/lib/testa_appium_driver/common/scroll_actions/w3c_scroll_actions.rb +261 -0
  37. data/lib/testa_appium_driver/driver.rb +226 -0
  38. data/lib/testa_appium_driver/ios/driver.rb +35 -0
  39. data/lib/testa_appium_driver/ios/locator.rb +40 -0
  40. data/lib/testa_appium_driver/ios/locator/attributes.rb +79 -0
  41. data/lib/testa_appium_driver/ios/selenium_element.rb +7 -0
  42. data/lib/testa_appium_driver/ios/type_selectors.rb +167 -0
  43. data/lib/testa_appium_driver/version.rb +5 -0
  44. data/testa_appium_driver.gemspec +40 -0
  45. data/testa_appium_driver.iml +79 -0
  46. metadata +147 -0
@@ -0,0 +1,35 @@
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
+ def handle_testa_opts
11
+ if @testa_opts[:default_find_strategy].nil?
12
+ @default_find_strategy = DEFAULT_IOS_FIND_STRATEGY
13
+ else
14
+ case @testa_opts[:default_find_strategy].to_sym
15
+ when FIND_STRATEGY_XPATH
16
+ @default_find_strategy = @testa_opts[:default_find_strategy].to_sym
17
+ else
18
+ raise "Default find strategy #{@testa_opts[:default_find_strategy]} not supported for iOS"
19
+ end
20
+ end
21
+
22
+
23
+ if @testa_opts[:default_scroll_strategy].nil?
24
+ @default_scroll_strategy = DEFAULT_IOS_SCROLL_STRATEGY
25
+ else
26
+ case @testa_opts[:default_scroll_strategy].to_sym
27
+ when SCROLL_STRATEGY_W3C
28
+ @default_scroll_strategy = @testa_opts[:default_scroll_strategy].to_sym
29
+ else
30
+ raise "Default scroll strategy #{@testa_opts[:default_scroll_strategy]} not supported for iOS"
31
+ end
32
+ end
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,40 @@
1
+ require_relative 'locator/attributes'
2
+
3
+ module TestaAppiumDriver
4
+ #noinspection RubyTooManyInstanceVariablesInspection
5
+ class Locator
6
+ include TypeSelectors
7
+
8
+ def init(params, selectors, single)
9
+ if is_scrollable_selector?(selectors, single)
10
+ @scroll_orientation = :vertical
11
+ params[:scrollable_locator] = self.dup
12
+ end
13
+
14
+ @scrollable_locator = params[:scrollable_locator] if params[:scrollable_locator]
15
+ end
16
+
17
+
18
+ def selector
19
+ @xpath_selector
20
+ end
21
+
22
+
23
+ # @return [Locator] existing locator element
24
+ def add_child_selector(params)
25
+ params, selectors = extract_selectors_from_params(params)
26
+ single = params[:single]
27
+ raise "Cannot add child selector to Array" if single && !@single
28
+
29
+ locator = self.dup
30
+ add_xpath_child_selectors(locator, selectors, single)
31
+ if is_scrollable_selector?(selectors, single)
32
+ locator.scrollable_locator.scroll_orientation = :vertical
33
+ locator.scrollable_locator = self.dup
34
+ end
35
+
36
+ locator.last_selector_adjacent = false
37
+ locator
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,79 @@
1
+ module TestaAppiumDriver
2
+ #noinspection RubyYardReturnMatch
3
+ class Locator
4
+
5
+
6
+ #noinspection RubyNilAnalysis
7
+ def attribute(name, *args)
8
+ elements = execute(*args)
9
+
10
+ if elements.instance_of?(Selenium::WebDriver::Element)
11
+ r = elements.send(:attribute, name.to_s)
12
+ r = TestaAppiumDriver::Bounds.from_ios(r, @driver) if name.to_s == "rect"
13
+ else
14
+ r = elements.map { |e| e.send(:attribute, name.to_s) }
15
+ r.map! { |b| TestaAppiumDriver::Bounds.from_ios(b, @driver) } if name.to_s == "rect"
16
+ end
17
+ r
18
+ end
19
+
20
+
21
+ def accessibility_container(*args)
22
+ attribute("accessibilityContainer", *args)
23
+ end
24
+
25
+ def accessible?(*args)
26
+ attribute("accessible", *args).to_s == "true"
27
+ end
28
+
29
+
30
+ def class_name(*args)
31
+ attribute("class", *args)
32
+ end
33
+
34
+ def enabled?(*args)
35
+ attribute("enabled", *args).to_s == "true"
36
+ end
37
+
38
+ def frame(*args)
39
+ attribute("frame", *args)
40
+ end
41
+
42
+ def index(*args)
43
+ attribute("index", *args)
44
+ end
45
+
46
+ def label(*args)
47
+ attribute("label", *args)
48
+ end
49
+
50
+ def name(*args)
51
+ attribute("name", *args)
52
+ end
53
+
54
+
55
+ def rect(*args)
56
+ attribute("rect", *args)
57
+ end
58
+
59
+ def selected?(*args)
60
+ attribute("selected", *args).to_s == "true"
61
+ end
62
+
63
+ def type(*args)
64
+ attribute("type", *args)
65
+ end
66
+
67
+ def value(*args)
68
+ attribute("value", *args)
69
+ end
70
+
71
+ def visible?(*args)
72
+ attribute("visible", *args).to_s == "true"
73
+ end
74
+
75
+
76
+ alias_method :bounds, :rect
77
+ alias_method :text, :label
78
+ end
79
+ end
@@ -0,0 +1,7 @@
1
+ module Selenium
2
+ module WebDriver
3
+ class Element
4
+ include TestaAppiumDriver::TypeSelectors
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,167 @@
1
+ module TestaAppiumDriver
2
+ #noinspection ALL
3
+ module TypeSelectors
4
+
5
+ # @return [TestaAppiumDriver::Locator]
6
+ def add_selector(*args, &block)
7
+ # if class selector is executed from driver, create new locator instance
8
+ if self.kind_of?(TestaAppiumDriver::Driver) || self.kind_of(Selenium::WebDriver::Element)
9
+ args.last[:default_find_strategy] = @default_find_strategy
10
+ args.last[:default_scroll_strategy] = @default_scroll_strategy
11
+ Locator.new(self, self, *args)
12
+ else
13
+ # class selector is executed from locator, just add child selector criteria
14
+ self.add_child_selector(*args)
15
+ end
16
+ end
17
+
18
+ # @param selectors [Hash]
19
+ # @return [TestaAppiumDriver::Locator] first element
20
+ def element(selectors = {})
21
+ add_selector(selectors)
22
+ end
23
+
24
+ # @param params [Hash]
25
+ # @return [TestaAppiumDriver::Locator] all elements that match given selectors
26
+ def elements(params = {})
27
+ params[:single] = false
28
+ add_selector(params)
29
+ end
30
+
31
+
32
+ # @return [TestaAppiumDriver::Locator]
33
+ def window(params = {})
34
+ params[:type] = "XCUIElementTypeWindow"
35
+ add_selector(params)
36
+ end
37
+
38
+ # @return [TestaAppiumDriver::Locator]
39
+ def windows(params = {})
40
+ params[:type] = "XCUIElementTypeWindow"
41
+ params[:single] = false
42
+ add_selector(params)
43
+ end
44
+
45
+ # @return [TestaAppiumDriver::Locator]
46
+ def other(params = {})
47
+ params[:type] = "XCUIElementTypeOther"
48
+ add_selector(params)
49
+ end
50
+
51
+ # @return [TestaAppiumDriver::Locator]
52
+ def others(params = {})
53
+ params[:type] = "XCUIElementTypeOther"
54
+ params[:single] = false
55
+ add_selector(params)
56
+ end
57
+
58
+
59
+ # @return [TestaAppiumDriver::Locator]
60
+ def navigation_bar(params = {})
61
+ params[:type] = "XCUIElementTypeNavigationBar"
62
+ add_selector(params)
63
+ end
64
+
65
+ # @return [TestaAppiumDriver::Locator]
66
+ def navigation_bars(params = {})
67
+ params[:type] = "XCUIElementTypeNavigationBar"
68
+ params[:single] = false
69
+ add_selector(params)
70
+ end
71
+
72
+
73
+ # @return [TestaAppiumDriver::Locator]
74
+ def button(params = {})
75
+ params[:type] = "XCUIElementTypeButton"
76
+ add_selector(params)
77
+ end
78
+
79
+ # @return [TestaAppiumDriver::Locator]
80
+ def buttons(params = {})
81
+ params[:type] = "XCUIElementTypeButton"
82
+ params[:single] = false
83
+ add_selector(params)
84
+ end
85
+
86
+
87
+ # @return [TestaAppiumDriver::Locator]
88
+ def image(params = {})
89
+ params[:type] = "XCUIElementTypeImage"
90
+ add_selector(params)
91
+ end
92
+
93
+ # @return [TestaAppiumDriver::Locator]
94
+ def images(params = {})
95
+ params[:type] = "XCUIElementTypeImage"
96
+ params[:single] = false
97
+ add_selector(params)
98
+ end
99
+
100
+ # @return [TestaAppiumDriver::Locator]
101
+ def static_text(params = {})
102
+ params[:type] = "XCUIElementTypeStaticText"
103
+ add_selector(params)
104
+ end
105
+
106
+ # @return [TestaAppiumDriver::Locator]
107
+ def static_texts(params = {})
108
+ params[:type] = "XCUIElementTypeStaticText"
109
+ params[:single] = false
110
+ add_selector(params)
111
+ end
112
+
113
+
114
+ # @param params [Hash]
115
+ # @return [TestaAppiumDriver::Locator] first scrollable element
116
+ def scrollable(params = {})
117
+ scroll_view(params)
118
+ end
119
+
120
+ # @param params [Hash]
121
+ # @return [TestaAppiumDriver::Locator] first scrollable element
122
+ def scrollables(params = {})
123
+ scroll_views(params)
124
+ end
125
+
126
+
127
+ # @return [TestaAppiumDriver::Locator]
128
+ def scroll_view(params = {})
129
+ params[:type] = "XCUIElementTypeScrollView"
130
+ add_selector(params)
131
+ end
132
+
133
+ # @return [TestaAppiumDriver::Locator]
134
+ def scroll_views(params = {})
135
+ params[:type] = "XCUIElementTypeScrollView"
136
+ params[:single] = false
137
+ add_selector(params)
138
+ end
139
+
140
+
141
+ # @return [TestaAppiumDriver::Locator]
142
+ def table(params = {})
143
+ params[:type] = "XCUIElementTypeTable"
144
+ add_selector(params)
145
+ end
146
+
147
+ # @return [TestaAppiumDriver::Locator]
148
+ def tables(params = {})
149
+ params[:type] = "XCUIElementTypeTable"
150
+ params[:single] = false
151
+ add_selector(params)
152
+ end
153
+
154
+ # @return [TestaAppiumDriver::Locator]
155
+ def cell(params = {})
156
+ params[:type] = "XCUIElementTypeCell"
157
+ add_selector(params)
158
+ end
159
+
160
+ # @return [TestaAppiumDriver::Locator]
161
+ def cells(params = {})
162
+ params[:type] = "XCUIElementTypeCell"
163
+ params[:single] = false
164
+ add_selector(params)
165
+ end
166
+ end
167
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module TestaAppiumDriver
4
+ VERSION = "0.1.0"
5
+ end
@@ -0,0 +1,40 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "lib/testa_appium_driver/version"
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "testa_appium_driver"
7
+ spec.version = TestaAppiumDriver::VERSION
8
+ spec.authors = ["karlo.razumovic"]
9
+ spec.email = ["karlo.razumovic@gmail.com"]
10
+
11
+ spec.summary = "Appium made easy"
12
+ spec.description = "Testa appium driver is a wrapper around ruby_lib_core. It significantly reduces the amount of code need to achieve your goals."
13
+ spec.homepage = "https://github.com/Karazum/testa_appium_driver"
14
+ spec.license = "MIT"
15
+ spec.required_ruby_version = ">= 2.4.0"
16
+
17
+ #spec.metadata["allowed_push_host"] = "Set to 'https://mygemserver.com'"
18
+
19
+ spec.metadata["homepage_uri"] = spec.homepage
20
+ spec.metadata["source_code_uri"] = "https://github.com/Karazum/testa_appium_driver"
21
+ spec.metadata["changelog_uri"] = "https://github.com/Karazum/testa_appium_driver"
22
+
23
+ # Specify which files should be added to the gem when it is released.
24
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
25
+ spec.files = Dir.chdir(File.expand_path(__dir__)) do
26
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{\A(?:test|spec|features)/}) }
27
+ end
28
+ spec.bindir = "exe"
29
+ spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
30
+ spec.require_paths = ["lib"]
31
+
32
+ spec.add_runtime_dependency "appium_lib_core", ["= 4.7.0"]
33
+ spec.add_runtime_dependency "json", ["= 2.1.0"]
34
+
35
+ spec.add_development_dependency "rubocop", ["= 1.19.0"]
36
+ spec.add_development_dependency "rake", ["~> 13.0"]
37
+
38
+ # For more information and examples about making a new gem, checkout our
39
+ # guide at: https://bundler.io/guides/creating_gem.html
40
+ end
@@ -0,0 +1,79 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <module type="RUBY_MODULE" version="4">
3
+ <component name="NewModuleRootManager" inherit-compiler-output="true">
4
+ <exclude-output />
5
+ <content url="file://$MODULE_DIR$">
6
+ <sourceFolder url="file://$MODULE_DIR$/features" isTestSource="true" />
7
+ <sourceFolder url="file://$MODULE_DIR$/spec" isTestSource="true" />
8
+ <sourceFolder url="file://$MODULE_DIR$/test" isTestSource="true" />
9
+ </content>
10
+ <orderEntry type="jdk" jdkName="ruby-2.6.5-p114" jdkType="RUBY_SDK" />
11
+ <orderEntry type="sourceFolder" forTests="false" />
12
+ <orderEntry type="library" scope="PROVIDED" name="appium_lib_core (v4.7.0, ruby-2.6.5-p114) [gem]" level="application" />
13
+ <orderEntry type="library" scope="PROVIDED" name="ast (v2.4.2, ruby-2.6.5-p114) [gem]" level="application" />
14
+ <orderEntry type="library" scope="PROVIDED" name="bundler (v2.2.25, ruby-2.6.5-p114) [gem]" level="application" />
15
+ <orderEntry type="library" scope="PROVIDED" name="childprocess (v3.0.0, ruby-2.6.5-p114) [gem]" level="application" />
16
+ <orderEntry type="library" scope="PROVIDED" name="diff-lcs (v1.4.4, ruby-2.6.5-p114) [gem]" level="application" />
17
+ <orderEntry type="library" scope="PROVIDED" name="eventmachine (v1.2.7, ruby-2.6.5-p114) [gem]" level="application" />
18
+ <orderEntry type="library" scope="PROVIDED" name="faye-websocket (v0.11.1, ruby-2.6.5-p114) [gem]" level="application" />
19
+ <orderEntry type="library" scope="PROVIDED" name="json (v2.1.0, ruby-2.6.5-p114) [gem]" level="application" />
20
+ <orderEntry type="library" scope="PROVIDED" name="parallel (v1.20.1, ruby-2.6.5-p114) [gem]" level="application" />
21
+ <orderEntry type="library" scope="PROVIDED" name="parser (v3.0.2.0, ruby-2.6.5-p114) [gem]" level="application" />
22
+ <orderEntry type="library" scope="PROVIDED" name="rainbow (v3.0.0, ruby-2.6.5-p114) [gem]" level="application" />
23
+ <orderEntry type="library" scope="PROVIDED" name="rake (v13.0.6, ruby-2.6.5-p114) [gem]" level="application" />
24
+ <orderEntry type="library" scope="PROVIDED" name="regexp_parser (v2.1.1, ruby-2.6.5-p114) [gem]" level="application" />
25
+ <orderEntry type="library" scope="PROVIDED" name="rexml (v3.2.5, ruby-2.6.5-p114) [gem]" level="application" />
26
+ <orderEntry type="library" scope="PROVIDED" name="rspec (v3.10.0, ruby-2.6.5-p114) [gem]" level="application" />
27
+ <orderEntry type="library" scope="PROVIDED" name="rspec-core (v3.10.1, ruby-2.6.5-p114) [gem]" level="application" />
28
+ <orderEntry type="library" scope="PROVIDED" name="rspec-expectations (v3.10.1, ruby-2.6.5-p114) [gem]" level="application" />
29
+ <orderEntry type="library" scope="PROVIDED" name="rspec-mocks (v3.10.2, ruby-2.6.5-p114) [gem]" level="application" />
30
+ <orderEntry type="library" scope="PROVIDED" name="rspec-support (v3.10.2, ruby-2.6.5-p114) [gem]" level="application" />
31
+ <orderEntry type="library" scope="PROVIDED" name="rubocop (v1.19.0, ruby-2.6.5-p114) [gem]" level="application" />
32
+ <orderEntry type="library" scope="PROVIDED" name="rubocop-ast (v1.10.0, ruby-2.6.5-p114) [gem]" level="application" />
33
+ <orderEntry type="library" scope="PROVIDED" name="ruby-progressbar (v1.11.0, ruby-2.6.5-p114) [gem]" level="application" />
34
+ <orderEntry type="library" scope="PROVIDED" name="rubyzip (v2.3.2, ruby-2.6.5-p114) [gem]" level="application" />
35
+ <orderEntry type="library" scope="PROVIDED" name="selenium-webdriver (v3.142.7, ruby-2.6.5-p114) [gem]" level="application" />
36
+ <orderEntry type="library" scope="PROVIDED" name="unicode-display_width (v2.0.0, ruby-2.6.5-p114) [gem]" level="application" />
37
+ <orderEntry type="library" scope="PROVIDED" name="websocket-driver (v0.7.5, ruby-2.6.5-p114) [gem]" level="application" />
38
+ <orderEntry type="library" scope="PROVIDED" name="websocket-extensions (v0.1.5, ruby-2.6.5-p114) [gem]" level="application" />
39
+ </component>
40
+ <component name="RakeTasksCache">
41
+ <option name="myRootTask">
42
+ <RakeTaskImpl id="rake">
43
+ <subtasks>
44
+ <RakeTaskImpl description="Build testa_appium_driver-0.1.0.gem into the pkg directory" fullCommand="build" id="build" />
45
+ <RakeTaskImpl id="build">
46
+ <subtasks>
47
+ <RakeTaskImpl description="Generate SHA512 checksum if testa_appium_driver-0.1.0.gem into the checksums directory" fullCommand="build:checksum" id="checksum" />
48
+ </subtasks>
49
+ </RakeTaskImpl>
50
+ <RakeTaskImpl description="Remove any temporary products" fullCommand="clean" id="clean" />
51
+ <RakeTaskImpl description="Remove any generated files" fullCommand="clobber" id="clobber" />
52
+ <RakeTaskImpl description="Build and install testa_appium_driver-0.1.0.gem into system gems" fullCommand="install" id="install" />
53
+ <RakeTaskImpl id="install">
54
+ <subtasks>
55
+ <RakeTaskImpl description="Build and install testa_appium_driver-0.1.0.gem into system gems without network access" fullCommand="install:local" id="local" />
56
+ </subtasks>
57
+ </RakeTaskImpl>
58
+ <RakeTaskImpl description="Create tag v0.1.0 and build and push testa_appium_driver-0.1.0.gem to rubygems.org" fullCommand="release[remote]" id="release[remote]" />
59
+ <RakeTaskImpl description="Run RuboCop" fullCommand="rubocop" id="rubocop" />
60
+ <RakeTaskImpl id="rubocop">
61
+ <subtasks>
62
+ <RakeTaskImpl description="Auto-correct RuboCop offenses" fullCommand="rubocop:auto_correct" id="auto_correct" />
63
+ </subtasks>
64
+ </RakeTaskImpl>
65
+ <RakeTaskImpl description="Run RSpec code examples" fullCommand="spec" id="spec" />
66
+ <RakeTaskImpl description="" fullCommand="default" id="default" />
67
+ <RakeTaskImpl description="" fullCommand="release" id="release" />
68
+ <RakeTaskImpl id="release">
69
+ <subtasks>
70
+ <RakeTaskImpl description="" fullCommand="release:guard_clean" id="guard_clean" />
71
+ <RakeTaskImpl description="" fullCommand="release:rubygem_push" id="rubygem_push" />
72
+ <RakeTaskImpl description="" fullCommand="release:source_control_push" id="source_control_push" />
73
+ </subtasks>
74
+ </RakeTaskImpl>
75
+ </subtasks>
76
+ </RakeTaskImpl>
77
+ </option>
78
+ </component>
79
+ </module>