wda_lib 0.2.3 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/wda_lib/custom.rb +8 -10
- data/lib/wda_lib/debug.rb +31 -12
- data/lib/wda_lib/element.rb +44 -13
- data/lib/wda_lib/find_element.rb +1 -1
- data/lib/wda_lib/orientation.rb +4 -4
- data/lib/wda_lib/session.rb +9 -2
- data/lib/wda_lib/touch_id.rb +2 -2
- data/lib/wda_lib/version.rb +1 -1
- data/lib/wda_lib.rb +0 -6
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7517995dcdb3b10660a1f72b2f928aca7ba1ef0f
|
4
|
+
data.tar.gz: 18612a392b4c51a524f4df05163e2fce9f9cd65e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 27167966a5303de42ad65f67b4267a39ecb02298eb98353142a70f025befaa51794019e73228549a54f4fcab754252edc430b2df9b4ca7e3d1181700ba7c63f2
|
7
|
+
data.tar.gz: 40125773e8a05e39eae7e61a42cad5eb5f7842565f1b8e6a5a9d8fb944f8e4ab2e6d86fb0d5521443a06c8af8434c5b4c3159c381bf79da30c3aaa7fd3f7c0ef
|
data/lib/wda_lib/custom.rb
CHANGED
@@ -7,7 +7,7 @@ class WDA
|
|
7
7
|
|
8
8
|
# Go to home screen
|
9
9
|
def homescreen
|
10
|
-
post(@base_url + '/homescreen')
|
10
|
+
post(@base_url + '/wda/homescreen')
|
11
11
|
end
|
12
12
|
|
13
13
|
# Same as homescreen, go to home screen
|
@@ -17,21 +17,19 @@ class WDA
|
|
17
17
|
|
18
18
|
# Deactivate application for given time
|
19
19
|
def pause(duration)
|
20
|
-
post '/deactivateApp', { duration: duration }
|
20
|
+
post '/wda/deactivateApp', { duration: duration }
|
21
21
|
end
|
22
22
|
|
23
|
-
#
|
23
|
+
# Timeouts
|
24
24
|
# @param duration [Float] the timeout in milliseconds
|
25
25
|
# @return [void]
|
26
|
-
def
|
27
|
-
post
|
26
|
+
def timeouts(duration)
|
27
|
+
post '/timeouts', { type: 'xctevent', ms: duration }
|
28
28
|
end
|
29
29
|
|
30
|
-
#
|
31
|
-
|
32
|
-
|
33
|
-
def timeout_in_session(duration)
|
34
|
-
post '/timeout', { type: 'xctevent', ms: duration }
|
30
|
+
# Dismiss keyboard
|
31
|
+
def dismiss_keyboard
|
32
|
+
post '/wda/keyboard/dismiss'
|
35
33
|
end
|
36
34
|
|
37
35
|
def double_tap_homebutton
|
data/lib/wda_lib/debug.rb
CHANGED
@@ -10,14 +10,20 @@ class WDA
|
|
10
10
|
# When accessible is true, ignore all elements except for the main window for accessibility tree
|
11
11
|
# When accessible is false, and visible is true, ignore all invisible elements
|
12
12
|
# @return [Hash]
|
13
|
-
def source(
|
13
|
+
def source(opts = {})
|
14
|
+
response_type = opts.fetch(:response_type, 'xml')
|
15
|
+
response_type = 'json' if opts.empty?
|
16
|
+
session_id = opts.fetch(:session_id, nil)
|
17
|
+
# not_fetch_inaccessible = opts.fetch(:not_fetch_inaccessible, true)
|
18
|
+
# not_fetch_invisible = opts.fetch(:not_fetch_invisible, true)
|
19
|
+
timeout = opts.fetch(:timeout, 60)
|
14
20
|
@timeout = timeout.to_i if !timeout.nil?
|
21
|
+
url = '/source' + '?format=' + response_type
|
22
|
+
url = @base_url + '/source' + '?format=' + response_type if session_id.nil?
|
15
23
|
begin
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
res = post('/source', { accessible: not_fetch_inaccessible, visible: not_fetch_invisible }, @timeout)
|
20
|
-
end
|
24
|
+
res = get(url,
|
25
|
+
# { accessible: not_fetch_inaccessible, visible: not_fetch_invisible },
|
26
|
+
@timeout)
|
21
27
|
rescue
|
22
28
|
raise Error::NoSuchElementError, "Can't fetch current screen elements within #{@timeout}s" if res['status'].nil?
|
23
29
|
end
|
@@ -25,18 +31,31 @@ class WDA
|
|
25
31
|
res
|
26
32
|
end
|
27
33
|
|
28
|
-
|
34
|
+
# Get accessibility tree
|
35
|
+
def accessibility_tree(opts = {})
|
36
|
+
session_id = opts.fetch(:session_id, nil)
|
37
|
+
timeout = opts.fetch(:timeout, 60)
|
38
|
+
@timeout = timeout.to_i if !timeout.nil?
|
39
|
+
url = '/wda/accessibleSource'
|
40
|
+
url = @base_url + '/wda/accessibleSource' if session_id.nil?
|
41
|
+
begin
|
42
|
+
res = get(url, @timeout)
|
43
|
+
rescue
|
44
|
+
raise Error::NoSuchElementError, "Can't fetch current screen accessibility tree within #{@timeout}s" if res['status'].nil?
|
45
|
+
end
|
46
|
+
end
|
29
47
|
|
30
48
|
def get_source
|
31
|
-
|
49
|
+
response = source
|
50
|
+
response['value']['children']
|
32
51
|
end
|
33
52
|
|
34
|
-
def get_window_statusbar
|
35
|
-
|
36
|
-
end
|
53
|
+
# def get_window_statusbar
|
54
|
+
# source['value']['children'][-3]
|
55
|
+
# end
|
37
56
|
|
38
57
|
def get_window(window_number = 0)
|
39
|
-
|
58
|
+
source['value']['children'][window_number]
|
40
59
|
end
|
41
60
|
|
42
61
|
# Had issue when there is app shortcut in SIRI search or Today's extention,
|
data/lib/wda_lib/element.rb
CHANGED
@@ -57,13 +57,13 @@ class WDA
|
|
57
57
|
# Check if element is accessible?
|
58
58
|
# @return is accessible? [Boolean]
|
59
59
|
def accessible?
|
60
|
-
client.get('/element/' + eid + '/accessible')['value']
|
60
|
+
client.get('/wda/element/' + eid + '/accessible')['value']
|
61
61
|
end
|
62
62
|
|
63
63
|
# Check if element is accessibilityContainer?
|
64
64
|
# @return is accessibilityContainer? [Boolean]
|
65
65
|
def accessible_container?
|
66
|
-
client.get('/element/' + eid + '/accessibilityContainer')['value']
|
66
|
+
client.get('/wda/element/' + eid + '/accessibilityContainer')['value']
|
67
67
|
end
|
68
68
|
|
69
69
|
# Get type from an element, ex: type => "Icon"(XCUIElementTypeIcon)
|
@@ -91,38 +91,56 @@ class WDA
|
|
91
91
|
client.post '/element/' + eid + '/clear'
|
92
92
|
end
|
93
93
|
|
94
|
+
# Element swipe
|
95
|
+
# @param direction [String] up, down, left, right
|
96
|
+
# @return element uuid [String]
|
97
|
+
def elswipe(direction)
|
98
|
+
client.post('/wda/element/' + eid + '/swipe', { direction: direction })
|
99
|
+
end
|
100
|
+
|
101
|
+
# Element pinch
|
102
|
+
# @param scale [Double], velocity [Double]
|
103
|
+
# @return element uuid [String]
|
104
|
+
def elswipe(scale, velocity)
|
105
|
+
client.post('/wda/element/' + eid + '/pinch', { scale: scale, velocity: velocity })
|
106
|
+
end
|
107
|
+
|
94
108
|
# Double tap on an element with its id
|
95
109
|
# @return element uuid [String]
|
96
110
|
def double_tap
|
97
|
-
client.post '/
|
111
|
+
client.post '/wda/element/' + eid + '/doubleTap'
|
98
112
|
end
|
99
113
|
|
100
114
|
# Two finger tap on an element with its id
|
101
115
|
# @return element uuid [String]
|
102
116
|
def two_finger_tap
|
103
|
-
client.post '/
|
117
|
+
client.post '/wda/element/' + eid + '/twoFingerTap'
|
104
118
|
end
|
105
119
|
|
106
120
|
# Touch and hold on for a while finger tap on an element with its id
|
107
121
|
# @param duration [Double]
|
108
122
|
# @return element uuid [String]
|
109
123
|
def touch_hold(duration)
|
110
|
-
client.post '/
|
124
|
+
client.post '/wda/element/' + eid + '/touchAndHold', { duration: duration }
|
111
125
|
end
|
112
126
|
|
113
127
|
# Scroll on an element with its id
|
114
128
|
# @param direction [String] up, down, left, right
|
115
129
|
# @return [Hash]
|
116
130
|
def scroll(direction = nil)
|
117
|
-
client.post '/
|
131
|
+
client.post '/wda/element/' + eid + '/scroll', { direction: direction }
|
118
132
|
end
|
119
133
|
|
120
134
|
# Drag on an element with its id and position
|
121
|
-
# @param toX [
|
122
|
-
def
|
123
|
-
fromX
|
124
|
-
|
125
|
-
|
135
|
+
# @param fromX [Double], toX [Double], fromY [Double], toY [Double], duration [Double]
|
136
|
+
def drag_element_from_to(fromX, toX, fromY, toY, duration = 0)
|
137
|
+
client.post '/wda/element/' + eid + '/dragfromtoforduration', { fromX: fromX, toX: toX, fromY: fromY, toY: toY, duration: duration }
|
138
|
+
end
|
139
|
+
|
140
|
+
# Drag from a position to another position
|
141
|
+
# @param fromX [Double], toX [Double], fromY [Double], toY [Double], duration [Double]
|
142
|
+
def drag_from_to(fromX, toX, fromY, toY, duration = 0)
|
143
|
+
client.post '/wda/dragfromtoforduration', { fromX: fromX, toX: toX, fromY: fromY, toY: toY, duration: duration }
|
126
144
|
end
|
127
145
|
|
128
146
|
# Get element size
|
@@ -156,13 +174,26 @@ class WDA
|
|
156
174
|
# Tap on a given positon
|
157
175
|
# @param x [Integer], y [Integer]
|
158
176
|
def tap_on(x, y)
|
159
|
-
post '/tap/0', { x: x, y: y }
|
177
|
+
post '/wda/tap/0', { x: x, y: y }
|
178
|
+
end
|
179
|
+
|
180
|
+
# Double tap on a given positon
|
181
|
+
# @param x [Integer], y [Integer]
|
182
|
+
def double_tap(x, y)
|
183
|
+
post '/wda/doubleTap', { x: x, y: y }
|
184
|
+
end
|
185
|
+
|
186
|
+
# Touch and hold on for a while
|
187
|
+
# @param x [Double], y [Double], duration [Double]
|
188
|
+
# @return element uuid [String]
|
189
|
+
def touch_hold(x, y, duration)
|
190
|
+
client.post '/wda/touchAndHold', { x: x, y: y, duration: duration }
|
160
191
|
end
|
161
192
|
|
162
193
|
# Type text to textfield
|
163
194
|
# @param value [String]
|
164
195
|
def keys(value)
|
165
|
-
post '/keys', { value: value.chars }
|
196
|
+
post '/wda/keys', { value: value.chars }
|
166
197
|
end
|
167
198
|
|
168
199
|
# @return width, height
|
data/lib/wda_lib/find_element.rb
CHANGED
data/lib/wda_lib/orientation.rb
CHANGED
@@ -5,19 +5,19 @@
|
|
5
5
|
class WDA
|
6
6
|
module Orientation
|
7
7
|
def orientation
|
8
|
-
get
|
8
|
+
get '/orientation'
|
9
9
|
end
|
10
10
|
|
11
11
|
def set_orientation
|
12
|
-
post
|
12
|
+
post '/orientation'
|
13
13
|
end
|
14
14
|
|
15
15
|
def get_rotation
|
16
|
-
get
|
16
|
+
get '/rotation'
|
17
17
|
end
|
18
18
|
|
19
19
|
def set_rotation
|
20
|
-
post
|
20
|
+
post '/rotation'
|
21
21
|
end
|
22
22
|
end
|
23
23
|
end
|
data/lib/wda_lib/session.rb
CHANGED
@@ -48,6 +48,13 @@ class WDA
|
|
48
48
|
response
|
49
49
|
end
|
50
50
|
|
51
|
+
# Post url to wda server to open a url in browser and create a session
|
52
|
+
# @return [self]
|
53
|
+
def open_url(url)
|
54
|
+
post('/url', { url: url })
|
55
|
+
status
|
56
|
+
end
|
57
|
+
|
51
58
|
# Post desired_capabilities to wda server to create a session
|
52
59
|
# This is not realy needed since we can find and click app icon to start app
|
53
60
|
# @return [self]
|
@@ -84,7 +91,6 @@ class WDA
|
|
84
91
|
# @return delete session response [Json]
|
85
92
|
def quit(session_id = nil)
|
86
93
|
(session_id.nil?)? sessionId = @session_id : sessionId = session_id
|
87
|
-
@base_url + '/session/' + sessionId
|
88
94
|
delete(@base_url + '/session/' + sessionId)
|
89
95
|
status
|
90
96
|
end
|
@@ -95,8 +101,9 @@ class WDA
|
|
95
101
|
end
|
96
102
|
|
97
103
|
# Healthcheck
|
104
|
+
# This api does also get back to homescreen
|
98
105
|
def healthcheck
|
99
|
-
response = get(@base_url + '/healthcheck')
|
106
|
+
response = get(@base_url + '/wda/healthcheck')
|
100
107
|
update_status(response)
|
101
108
|
end
|
102
109
|
end
|
data/lib/wda_lib/touch_id.rb
CHANGED
@@ -8,12 +8,12 @@ class WDA
|
|
8
8
|
# Touch ID
|
9
9
|
# Match TouchID
|
10
10
|
def match_touchid
|
11
|
-
post(@base_url + '/
|
11
|
+
post(@base_url + '/wda/touch_id', { match: 1 }.to_json)
|
12
12
|
end
|
13
13
|
|
14
14
|
# Do not match TouchID
|
15
15
|
def unmatch_touchid
|
16
|
-
post(@base_url + '/
|
16
|
+
post(@base_url + '/wda/touch_id', { match: 0 }.to_json)
|
17
17
|
end
|
18
18
|
end
|
19
19
|
end
|
data/lib/wda_lib/version.rb
CHANGED
data/lib/wda_lib.rb
CHANGED
@@ -67,12 +67,6 @@ class WDA
|
|
67
67
|
status
|
68
68
|
window_size
|
69
69
|
capabilities(opts)
|
70
|
-
@http_client ||= Selenium::WebDriver::Remote::Http::Default.new(open_timeout: 999_999, read_timeout: 999_999)
|
71
|
-
@driver = Selenium::WebDriver.for(:remote,
|
72
|
-
http_client: @http_client,
|
73
|
-
:url => @base_url,
|
74
|
-
:desired_capabilities => @caps[:desired_capabilities],
|
75
|
-
:listener => @listener)
|
76
70
|
end
|
77
71
|
|
78
72
|
# Build desired_capabilities with options
|
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.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- MIN Yi
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-03-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -131,7 +131,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
131
131
|
version: '0'
|
132
132
|
requirements: []
|
133
133
|
rubyforge_project:
|
134
|
-
rubygems_version: 2.
|
134
|
+
rubygems_version: 2.6.1
|
135
135
|
signing_key:
|
136
136
|
specification_version: 4
|
137
137
|
summary: A simple ruby lib of binding methods for WebDriverAgent
|