wda_lib 0.0.3 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e65ae5ada8b0e5e3a5dae6137c2490b1da31d582
4
- data.tar.gz: f163d6e1070406d562c4209006dc9ac4bea69ed2
3
+ metadata.gz: 0b70066b286241a28e6880b8f7c67de48cfebbe7
4
+ data.tar.gz: 31fe50980434ba902e28bf7b507494eb0c2c80f6
5
5
  SHA512:
6
- metadata.gz: acd58efc072a5f1b9f91f0ba758e03dbc5b4c2cab1d6901da950f6dfb4d06f8644b48cc92354a3c202dce1f58bb1c93556c0bf9717f24e080bd60fe7f98f6511
7
- data.tar.gz: ec0e79215ab2c9dfbc42644b2640ed85919281dc573217e461a8c29dcf0db463b7a87beff45164bd5c0bb4c94736e0a2f0e3d5fa0238a357be843eec00a536fe
6
+ metadata.gz: d9c3c3ece0bd6f0af1d98d1ca1ef40399fc22e5d620f71d39d5ba7ac9506816971b98e80691fe69142e3a9ee92b5d6174ae3600cf24634b5caa6b35042639cd7
7
+ data.tar.gz: bd91aba742025e6a976eaffdb36a0e3e82759e464c9aa1ac65a36ff6867516b53f1ed0d8ba96d4eb9117fae90753afcbbeefbea7c13a56b0a0a0acd8df0f409b
data/.gitignore CHANGED
@@ -6,4 +6,4 @@
6
6
  /doc/
7
7
  /pkg/
8
8
  /*.gem
9
-
9
+ test.rb
data/README.md CHANGED
@@ -11,11 +11,11 @@ gem install wda_lib
11
11
  ## Usage example
12
12
 
13
13
  A simple test to show all actions on WDA IntegrationApp
14
- [Single devices](../blob/master/example/single_device.rb)
14
+ [Single devices](../master/example/single_device.rb)
15
15
 
16
16
  ## Example of multiple devices
17
17
 
18
- [Multiple devices](../blob/master/example/multiple_devices.rb)
18
+ [Multiple devices](../master/example/multiple_devices.rb)
19
19
 
20
20
 
21
21
  ## Options
@@ -7,7 +7,8 @@ thread_iphone = Thread.new{
7
7
  start_time = Time.now
8
8
  app = WDA.new(device_url: 'http://192.168.1.2:8100/')
9
9
  app.x
10
- app.homescreen
10
+ app.status
11
+ sleep 0.5
11
12
  app.launch_app('com.facebook.IntegrationApp')
12
13
  app.find(:xpath, "//XCUIElementTypeButton[@name='Scrolling']").click
13
14
  app.text('ScrollView').click
@@ -27,7 +28,8 @@ thread_simulator = Thread.new{
27
28
  start_time = Time.now
28
29
  sim = WDA.new
29
30
  sim.x
30
- sim.homescreen
31
+ sim.status
32
+ sleep 0.5
31
33
  sim.launch_app('com.facebook.IntegrationApp')
32
34
  sim.find(:xpath, "//XCUIElementTypeButton[@name='Scrolling']").click
33
35
  sim.text('ScrollView').click
@@ -4,13 +4,11 @@ app = WDA.new # Default devive url: http://localhost:8100
4
4
 
5
5
  app.x
6
6
 
7
- app.homescreen
8
-
9
- app.launch_app('com.facebook.IntegrationApp')
10
-
11
7
  app.status
12
8
 
13
- app.session
9
+ sleep 0.5
10
+
11
+ app.launch_app('com.facebook.IntegrationApp')
14
12
 
15
13
  app.button('Alerts')
16
14
 
data/lib/wda_lib/debug.rb CHANGED
@@ -22,14 +22,30 @@ class WDA
22
22
  get(@base_url + '/source')['value']['tree']['children'][window_number]
23
23
  end
24
24
 
25
+ # Had issue when there is app shortcut in SIRI search or Today's extention,
26
+ # having duplication app text, have to find the visibile one
25
27
  def find_app(app_name)
26
28
  max = 1
27
- homescreen if !text(app_name).displayed? && max <= 5
28
- while !text(app_name).displayed? do
29
- swipe(@win_x-50, 10, @win_y/2, @win_y/2)
29
+ app_found = false
30
+ app = nil
31
+ homescreen
32
+ while !app_found do
33
+ swipe(@win_x*4/5, 10, @win_y/2, @win_y/2)
30
34
  max += 1
35
+ texts(app_name).each do |e|
36
+ app = e
37
+ if e.displayed?
38
+ app_found = true
39
+ break
40
+ end
41
+ end
42
+ end
43
+
44
+ if app.nil?
45
+ fail "Can't find app :#{app_name}"
46
+ else
47
+ app
31
48
  end
32
- text(app_name)
33
49
  end
34
50
 
35
51
  end
@@ -68,11 +68,11 @@ class WDA
68
68
  client.get('/element/' + eid + '/accessibilityContainer')['value']
69
69
  end
70
70
 
71
- # Get type from an element
71
+ # Get type from an element, ex: type => "Icon"(XCUIElementTypeIcon)
72
72
  # @param id [String] Element uuid
73
73
  # @return type [String]
74
- def name
75
- client.get '/element/' + eid + '/name'
74
+ def type
75
+ client.get('/element/' + eid + '/name')['value']
76
76
  end
77
77
 
78
78
  # Set value to an element
@@ -35,6 +35,48 @@ class WDA
35
35
  elements.map { |element| Element.new self, element['ELEMENT'] }
36
36
  end
37
37
 
38
+ # Search with given name
39
+ # @param value [String]
40
+ # @retrun [Hash]
41
+ def name(value)
42
+ find :name, value
43
+ end
44
+
45
+ # Search all element with given name
46
+ # @param value [String]
47
+ # @retrun [Array]
48
+ def names(value)
49
+ finds :name, value
50
+ end
51
+
52
+ # Search with given id
53
+ # @param value [String]
54
+ # @retrun [Hash]
55
+ def id(value)
56
+ find :id, value
57
+ end
58
+
59
+ # Search all element with given id
60
+ # @param value [String]
61
+ # @retrun [Array]
62
+ def ids(value)
63
+ finds :id, value
64
+ end
65
+
66
+ # Search with given accessibility_id
67
+ # @param value [String]
68
+ # @retrun [Hash]
69
+ def accessibility_id(value)
70
+ find :accessibility_id, value
71
+ end
72
+
73
+ # Search all element with given accessibility_id
74
+ # @param value [String]
75
+ # @retrun [Array]
76
+ def accessibility_ids(value)
77
+ finds :accessibility_id, value
78
+ end
79
+
38
80
  # Search with given value (Complete value)
39
81
  # @param value [String]
40
82
  # @retrun [Hash]
@@ -64,10 +106,17 @@ class WDA
64
106
  end
65
107
 
66
108
  # Search with class name
67
- # @param class_name [String] XCUIElementType*, class name in XCUITest, ex: names('Button') to search XCUIElementTypeButton
109
+ # @param value [String] XCUIElementType*, class name in XCUITest, ex: class_names('Button') to search XCUIElementTypeButton
110
+ # @return [Hash] found XCUIElementType* elements
111
+ def class_name(value)
112
+ find :class_name, match(value)
113
+ end
114
+
115
+ # Search with class name
116
+ # @param value [String] XCUIElementType*, class name in XCUITest, ex: class_names('Button') to search XCUIElementTypeButton
68
117
  # @return [Array] contains all XCUIElementType* elements
69
- def names(class_name)
70
- finds :class_name, match(class_name)
118
+ def class_names(value)
119
+ finds :class_name, match(value)
71
120
  end
72
121
 
73
122
  # Search with xpath
@@ -105,29 +154,35 @@ class WDA
105
154
  finds :predicate_string, predicate_value
106
155
  end
107
156
 
108
-
109
157
  # @return element's visible cells [Array]
110
158
  def visible_cell(id)
111
159
  get '/uiaElement/' + id + '/getVisibleCells'
112
160
  end
113
161
 
114
-
115
162
  # Find button by given index or value
116
163
  # @param value [String, Integer]
117
164
  # If value is integer then return the button at that index
118
165
  # If value is string then return the first button which contains given value
119
- # @return [Button]
166
+ # @return [Hash, Element]
120
167
  def button(value = 0)
121
168
  if value.is_a? Numeric
122
169
  finds(:xpath, "//XCUIElementTypeButton")[value]
123
170
  else
124
171
  find(:xpath, "//XCUIElementTypeButton[@name='#{value}']")
125
172
  end
126
- end
173
+ end
127
174
 
128
- # @return [Hash] All buttons
129
- def buttons
130
- finds(:xpath, "//XCUIElementTypeButton")
175
+ # Find buttons by given index or value
176
+ # @param value [String, Integer]
177
+ # If value is integer then return the button at that index
178
+ # If value is string then return the all button which contains given value
179
+ # @return [Array] All found buttons
180
+ def buttons(value = nil)
181
+ if value.nil?
182
+ finds(:xpath, "//XCUIElementTypeButton")
183
+ else
184
+ finds(:xpath, "//XCUIElementTypeButton[@name='#{value}']")
185
+ end
131
186
  end
132
187
 
133
188
  # Find the first Button
@@ -211,6 +266,32 @@ class WDA
211
266
  finds(:xpath, "//XCUIElementTypeStaticText")
212
267
  end
213
268
 
269
+ # Find icon by given index or value
270
+ # @param value [String, Integer]
271
+ # If value is integer then return the icon at that index
272
+ # If value is string then return the first icon which contains given value
273
+ # @return [Hash, Element]
274
+ def icon(value = 0)
275
+ if value.is_a? Numeric
276
+ finds(:xpath, "//XCUIElementTypeIcon")[value]
277
+ else
278
+ find :xpath, "//XCUIElementTypeIcon[@name='#{value}']"
279
+ end
280
+ end
281
+
282
+ # Find icons by given index or value
283
+ # @param value [String, Integer]
284
+ # If value is integer then return the icon at that index
285
+ # If value is string then return the all icons which contains given value
286
+ # @return [Array] All found icons
287
+ def icons(value = nil)
288
+ if value.nil?
289
+ finds(:xpath, "//XCUIElementTypeIcon")
290
+ else
291
+ finds :xpath, "//XCUIElementTypeIcon[@name='#{value}']"
292
+ end
293
+ end
294
+
214
295
  ########### This is calling selenium find_element* methods##########
215
296
  # Find element with given type and value, return first found element
216
297
  # @param args [*args]
@@ -5,6 +5,8 @@ class WDA
5
5
  # @return [Obj]
6
6
  def status
7
7
  @status = get(@base_url + '/status')
8
+ @platform_name = @status['value']['os']['name']
9
+ @platform_version = @status['value']['os']['version']
8
10
  update_status(@status)
9
11
  end
10
12
 
@@ -1,3 +1,3 @@
1
1
  class WDA
2
- VERSION = '0.0.3'
2
+ VERSION = '0.0.6'
3
3
  end
data/lib/wda_lib.rb CHANGED
@@ -51,6 +51,7 @@ class WDA
51
51
  @url = @base_url
52
52
  @server_host = parsed_url.host
53
53
  @server_port = parsed_url.port
54
+ healthcheck
54
55
  status
55
56
  window_size
56
57
  capabilities(opts)
@@ -77,11 +78,8 @@ class WDA
77
78
  # @param session_response [object] : http GET session response body
78
79
  # @return session_reponse [object]
79
80
  def update_status(status_response)
80
- @session_id = status_response['sessionId']
81
81
  @session_valid = true
82
82
  @session_id = status_response['sessionId']
83
- @platform_name = status_response['value']['os']['name']
84
- @platform_version = status_response['value']['os']['version']
85
83
  @url = @base_url + "/session/#{@session_id}"
86
84
  capabilities
87
85
  status_response
data/wda_lib.gemspec CHANGED
@@ -7,7 +7,7 @@ Gem::Specification.new do |s|
7
7
  s.name = 'wda_lib'
8
8
  s.version = WDA::VERSION
9
9
  s.authors = ["MIN Yi"]
10
- s.email = 'minsparky@gmail.com'
10
+ s.email = 'yi@zen.ly'
11
11
 
12
12
  s.summary = "A simple ruby lib of binding methods for WebDriverAgent"
13
13
  s.description = "A simple ruby lib of binding methods for WebDriverAgent"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wda_lib
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - MIN Yi
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-10-10 00:00:00.000000000 Z
11
+ date: 2016-11-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -81,7 +81,7 @@ dependencies:
81
81
  - !ruby/object:Gem::Version
82
82
  version: 3.0.0.beta3.1
83
83
  description: A simple ruby lib of binding methods for WebDriverAgent
84
- email: minsparky@gmail.com
84
+ email: yi@zen.ly
85
85
  executables: []
86
86
  extensions: []
87
87
  extra_rdoc_files: []
@@ -127,7 +127,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
127
127
  version: '0'
128
128
  requirements: []
129
129
  rubyforge_project:
130
- rubygems_version: 2.4.8
130
+ rubygems_version: 2.5.1
131
131
  signing_key:
132
132
  specification_version: 4
133
133
  summary: A simple ruby lib of binding methods for WebDriverAgent