wda_lib 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +15 -124
- data/example/multiple_devices.rb +48 -0
- data/example/single_device.rb +72 -0
- data/lib/wda_lib/debug.rb +10 -0
- data/lib/wda_lib/element.rb +8 -7
- data/lib/wda_lib/find_element.rb +3 -3
- data/lib/wda_lib/session.rb +1 -1
- data/lib/wda_lib/version.rb +1 -1
- data/lib/wda_lib.rb +2 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e65ae5ada8b0e5e3a5dae6137c2490b1da31d582
|
4
|
+
data.tar.gz: f163d6e1070406d562c4209006dc9ac4bea69ed2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: acd58efc072a5f1b9f91f0ba758e03dbc5b4c2cab1d6901da950f6dfb4d06f8644b48cc92354a3c202dce1f58bb1c93556c0bf9717f24e080bd60fe7f98f6511
|
7
|
+
data.tar.gz: ec0e79215ab2c9dfbc42644b2640ed85919281dc573217e461a8c29dcf0db463b7a87beff45164bd5c0bb4c94736e0a2f0e3d5fa0238a357be843eec00a536fe
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
### wda_lib
|
2
2
|
|
3
|
-
A simple ruby lib of binding methods for WebDriverAgent
|
3
|
+
A simple ruby lib of binding methods for [WebDriverAgent](https://github.com/facebook/WebDriverAgent)
|
4
4
|
|
5
5
|
## Install
|
6
6
|
|
@@ -9,134 +9,14 @@ gem install wda_lib
|
|
9
9
|
```
|
10
10
|
|
11
11
|
## Usage example
|
12
|
-
A simple test to show all actions on WDA IntegrationApp
|
13
|
-
|
14
|
-
```ruby
|
15
|
-
require 'wda_lib'
|
16
|
-
|
17
|
-
app = WDA.new
|
18
|
-
|
19
|
-
app.x
|
20
|
-
|
21
|
-
app.homescreen
|
22
|
-
|
23
|
-
app.launch_app('com.facebook.IntegrationApp')
|
24
|
-
|
25
|
-
app.status
|
26
|
-
|
27
|
-
app.session
|
28
|
-
|
29
|
-
app.button('Alerts')
|
30
|
-
|
31
|
-
app.button('Alerts').ref
|
32
|
-
|
33
|
-
app.button('Alerts').name
|
34
|
-
|
35
|
-
app.button('Alerts').click
|
36
|
-
|
37
|
-
app.partial_texts('Create')[1].click
|
38
|
-
|
39
|
-
app.alert_text
|
40
|
-
|
41
|
-
app.accept_alert
|
42
|
-
|
43
|
-
app.button('Back').click
|
44
|
-
|
45
|
-
app.partial_text('Attri').click
|
46
|
-
|
47
|
-
app.xpath_search('StaticText', 'label', 'Label')
|
48
|
-
|
49
|
-
app.xpath_search('Button', 'name', 'Second')[0].click
|
50
|
-
|
51
|
-
app.textfield('Value').click
|
52
|
-
|
53
|
-
app.textfield('Value').send_keys('test')
|
54
|
-
|
55
|
-
app.textfield('Valuetest').clear
|
56
|
-
|
57
|
-
location = app.textfield('Value2').location
|
58
12
|
|
59
|
-
|
60
|
-
|
61
|
-
app.keys('Type more keys')
|
62
|
-
|
63
|
-
app.button('Back').click
|
64
|
-
|
65
|
-
sleep 1
|
66
|
-
|
67
|
-
app.find(:xpath, "//XCUIElementTypeButton[@name='Scrolling']").click
|
68
|
-
|
69
|
-
app.text('ScrollView').click
|
70
|
-
|
71
|
-
app.text('7').scroll('down')
|
72
|
-
|
73
|
-
app.text('7').scroll('down')
|
74
|
-
|
75
|
-
app.text('7').scroll('up')
|
76
|
-
|
77
|
-
app.swipe(180, 180, 330, 100)
|
78
|
-
|
79
|
-
app.swipe(180, 180, 100, 330)
|
80
|
-
|
81
|
-
app.button('Back').click
|
82
|
-
|
83
|
-
app.button('Back').click
|
84
|
-
|
85
|
-
app.x
|
86
|
-
|
87
|
-
```
|
13
|
+
A simple test to show all actions on WDA IntegrationApp
|
14
|
+
[Single devices](../blob/master/example/single_device.rb)
|
88
15
|
|
89
16
|
## Example of multiple devices
|
90
17
|
|
91
|
-
|
92
|
-
iphone_testing = true
|
93
|
-
simulator_testing = true
|
94
|
-
|
95
|
-
thread_iphone = Thread.new{
|
96
|
-
start_time = Time.now
|
97
|
-
app = WDA.new(device_url: 'http://192.168.1.56:8100/')
|
98
|
-
app.x
|
99
|
-
app.homescreen
|
100
|
-
app.launch_app('com.facebook.IntegrationApp')
|
101
|
-
app.find(:xpath, "//XCUIElementTypeButton[@name='Scrolling']").click
|
102
|
-
app.text('ScrollView').click
|
103
|
-
app.text('7').scroll('down')
|
104
|
-
app.text('7').scroll('down')
|
105
|
-
app.text('7').scroll('up')
|
106
|
-
app.swipe(180, 180, 330, 100)
|
107
|
-
app.swipe(180, 180, 100, 330)
|
108
|
-
app.button('Back').click
|
109
|
-
app.x
|
110
|
-
end_time = Time.now
|
111
|
-
p "Testing time: #{end_time-start_time}"
|
112
|
-
iphone_testing = false
|
113
|
-
}
|
114
|
-
|
115
|
-
thread_simulator = Thread.new{
|
116
|
-
start_time = Time.now
|
117
|
-
sim = WDA.new
|
118
|
-
sim.x
|
119
|
-
sim.homescreen
|
120
|
-
sim.launch_app('com.facebook.IntegrationApp')
|
121
|
-
sim.find(:xpath, "//XCUIElementTypeButton[@name='Scrolling']").click
|
122
|
-
sim.text('ScrollView').click
|
123
|
-
sim.text('7').scroll('down')
|
124
|
-
sim.text('7').scroll('down')
|
125
|
-
sim.text('7').scroll('up')
|
126
|
-
sim.swipe(180, 180, 330, 100)
|
127
|
-
sim.swipe(180, 180, 100, 330)
|
128
|
-
sim.button('Back').click
|
129
|
-
sim.x
|
130
|
-
end_time = Time.now
|
131
|
-
p "Testing time: #{end_time-start_time}"
|
132
|
-
simulator_testing = false
|
133
|
-
}
|
134
|
-
|
135
|
-
while iphone_testing || simulator_testing do
|
136
|
-
sleep 5
|
137
|
-
end
|
18
|
+
[Multiple devices](../blob/master/example/multiple_devices.rb)
|
138
19
|
|
139
|
-
```
|
140
20
|
|
141
21
|
## Options
|
142
22
|
|
@@ -156,6 +36,17 @@ element.rect
|
|
156
36
|
element.location
|
157
37
|
```
|
158
38
|
|
39
|
+
## Doc
|
40
|
+
|
41
|
+
Use yard to generate locale documentations.
|
42
|
+
```ruby
|
43
|
+
yard doc
|
44
|
+
|
45
|
+
yard server
|
46
|
+
```
|
47
|
+
|
48
|
+
Open [wda doc](http://localhost:8808) in your browser.
|
49
|
+
|
159
50
|
## TODO
|
160
51
|
|
161
52
|
Add more tests...
|
@@ -0,0 +1,48 @@
|
|
1
|
+
require 'wda_lib'
|
2
|
+
|
3
|
+
iphone_testing = true
|
4
|
+
simulator_testing = true
|
5
|
+
|
6
|
+
thread_iphone = Thread.new{
|
7
|
+
start_time = Time.now
|
8
|
+
app = WDA.new(device_url: 'http://192.168.1.2:8100/')
|
9
|
+
app.x
|
10
|
+
app.homescreen
|
11
|
+
app.launch_app('com.facebook.IntegrationApp')
|
12
|
+
app.find(:xpath, "//XCUIElementTypeButton[@name='Scrolling']").click
|
13
|
+
app.text('ScrollView').click
|
14
|
+
app.text('7').scroll('down')
|
15
|
+
app.text('7').scroll('down')
|
16
|
+
app.text('7').scroll('up')
|
17
|
+
app.swipe(180, 180, 330, 100)
|
18
|
+
app.swipe(180, 180, 100, 330)
|
19
|
+
app.button('Back').click
|
20
|
+
app.x
|
21
|
+
end_time = Time.now
|
22
|
+
p "Testing time: #{end_time-start_time}"
|
23
|
+
iphone_testing = false
|
24
|
+
}
|
25
|
+
|
26
|
+
thread_simulator = Thread.new{
|
27
|
+
start_time = Time.now
|
28
|
+
sim = WDA.new
|
29
|
+
sim.x
|
30
|
+
sim.homescreen
|
31
|
+
sim.launch_app('com.facebook.IntegrationApp')
|
32
|
+
sim.find(:xpath, "//XCUIElementTypeButton[@name='Scrolling']").click
|
33
|
+
sim.text('ScrollView').click
|
34
|
+
sim.text('7').scroll('down')
|
35
|
+
sim.text('7').scroll('down')
|
36
|
+
sim.text('7').scroll('up')
|
37
|
+
sim.swipe(180, 180, 330, 100)
|
38
|
+
sim.swipe(180, 180, 100, 330)
|
39
|
+
sim.button('Back').click
|
40
|
+
sim.x
|
41
|
+
end_time = Time.now
|
42
|
+
p "Testing time: #{end_time-start_time}"
|
43
|
+
simulator_testing = false
|
44
|
+
}
|
45
|
+
|
46
|
+
while iphone_testing || simulator_testing do
|
47
|
+
sleep 5
|
48
|
+
end
|
@@ -0,0 +1,72 @@
|
|
1
|
+
require 'wda_lib'
|
2
|
+
|
3
|
+
app = WDA.new # Default devive url: http://localhost:8100
|
4
|
+
|
5
|
+
app.x
|
6
|
+
|
7
|
+
app.homescreen
|
8
|
+
|
9
|
+
app.launch_app('com.facebook.IntegrationApp')
|
10
|
+
|
11
|
+
app.status
|
12
|
+
|
13
|
+
app.session
|
14
|
+
|
15
|
+
app.button('Alerts')
|
16
|
+
|
17
|
+
app.button('Alerts').ref
|
18
|
+
|
19
|
+
app.button('Alerts').name
|
20
|
+
|
21
|
+
app.button('Alerts').click
|
22
|
+
|
23
|
+
app.partial_texts('Create')[1].click
|
24
|
+
|
25
|
+
app.alert_text
|
26
|
+
|
27
|
+
app.accept_alert
|
28
|
+
|
29
|
+
app.button('Back').click
|
30
|
+
|
31
|
+
app.partial_text('Attri').click
|
32
|
+
|
33
|
+
app.xpath_search('StaticText', 'label', 'Label')
|
34
|
+
|
35
|
+
app.xpath_search('Button', 'name', 'Second')[0].click
|
36
|
+
|
37
|
+
app.textfield('Value').click
|
38
|
+
|
39
|
+
app.textfield('Value').send_keys('test')
|
40
|
+
|
41
|
+
app.textfield('Valuetest').clear
|
42
|
+
|
43
|
+
location = app.textfield('Value2').location
|
44
|
+
|
45
|
+
app.tap_on(location[:x], location[:y])
|
46
|
+
|
47
|
+
app.keys('Type more keys')
|
48
|
+
|
49
|
+
app.button('Back').click
|
50
|
+
|
51
|
+
sleep 1
|
52
|
+
|
53
|
+
app.find(:xpath, "//XCUIElementTypeButton[@name='Scrolling']").click
|
54
|
+
|
55
|
+
app.text('ScrollView').click
|
56
|
+
|
57
|
+
app.text('7').scroll('down')
|
58
|
+
|
59
|
+
app.text('7').scroll('down')
|
60
|
+
|
61
|
+
app.text('7').scroll('up')
|
62
|
+
|
63
|
+
app.swipe(180, 180, 330, 100)
|
64
|
+
|
65
|
+
app.swipe(180, 180, 100, 330)
|
66
|
+
|
67
|
+
app.button('Back').click
|
68
|
+
|
69
|
+
app.button('Back').click
|
70
|
+
|
71
|
+
app.x
|
72
|
+
|
data/lib/wda_lib/debug.rb
CHANGED
@@ -22,5 +22,15 @@ class WDA
|
|
22
22
|
get(@base_url + '/source')['value']['tree']['children'][window_number]
|
23
23
|
end
|
24
24
|
|
25
|
+
def find_app(app_name)
|
26
|
+
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)
|
30
|
+
max += 1
|
31
|
+
end
|
32
|
+
text(app_name)
|
33
|
+
end
|
34
|
+
|
25
35
|
end
|
26
36
|
end
|
data/lib/wda_lib/element.rb
CHANGED
@@ -23,7 +23,7 @@ class WDA
|
|
23
23
|
# @param id [String] Element uuid
|
24
24
|
# @return isEnabled? [Boolean]
|
25
25
|
def enabled?
|
26
|
-
client.get
|
26
|
+
client.get('/element/' + eid + '/enabled')['value']
|
27
27
|
end
|
28
28
|
|
29
29
|
# Get wdRect by id
|
@@ -51,24 +51,23 @@ class WDA
|
|
51
51
|
# @param id [String] Element uuid
|
52
52
|
# @return isVisible? [Boolean]
|
53
53
|
def displayed?
|
54
|
-
client.get
|
54
|
+
client.get('/element/' + eid + '/displayed')['value']
|
55
55
|
end
|
56
56
|
|
57
57
|
# Check if element is accessible?
|
58
58
|
# @param id [String] Element uuid
|
59
|
-
# @return is accessible? [
|
59
|
+
# @return is accessible? [Boolean]
|
60
60
|
def accessible?
|
61
|
-
client.get
|
61
|
+
client.get('/element/' + eid + '/accessible')['value']
|
62
62
|
end
|
63
63
|
|
64
64
|
# Check if element is accessibilityContainer?
|
65
65
|
# @param id [String] Element uuid
|
66
|
-
# @return is accessibilityContainer? [
|
66
|
+
# @return is accessibilityContainer? [Boolean]
|
67
67
|
def accessible_container?
|
68
|
-
client.get
|
68
|
+
client.get('/element/' + eid + '/accessibilityContainer')['value']
|
69
69
|
end
|
70
70
|
|
71
|
-
|
72
71
|
# Get type from an element
|
73
72
|
# @param id [String] Element uuid
|
74
73
|
# @return type [String]
|
@@ -176,6 +175,8 @@ class WDA
|
|
176
175
|
# @return width, height
|
177
176
|
def window_size
|
178
177
|
win_size = get('/window/size')['value']
|
178
|
+
@win_x = win_size['width']
|
179
|
+
@win_y = win_size['height']
|
179
180
|
Dimension.new(win_size['width'], win_size['height'])
|
180
181
|
end
|
181
182
|
|
data/lib/wda_lib/find_element.rb
CHANGED
@@ -64,10 +64,10 @@ class WDA
|
|
64
64
|
end
|
65
65
|
|
66
66
|
# Search with class name
|
67
|
-
# @param class_name [String] XCUIElementType*, class name in XCUITest, ex: XCUIElementTypeButton
|
67
|
+
# @param class_name [String] XCUIElementType*, class name in XCUITest, ex: names('Button') to search XCUIElementTypeButton
|
68
68
|
# @return [Array] contains all XCUIElementType* elements
|
69
|
-
def
|
70
|
-
finds :class_name, class_name
|
69
|
+
def names(class_name)
|
70
|
+
finds :class_name, match(class_name)
|
71
71
|
end
|
72
72
|
|
73
73
|
# Search with xpath
|
data/lib/wda_lib/session.rb
CHANGED
data/lib/wda_lib/version.rb
CHANGED
data/lib/wda_lib.rb
CHANGED
@@ -27,7 +27,7 @@ class WDA
|
|
27
27
|
Dimension = Struct.new(:width, :height)
|
28
28
|
|
29
29
|
attr_accessor :session_id, :http, :bundle_id, :caps, :device, :driver
|
30
|
-
attr_reader :base_url, :server_host, :server_port, :url, :window_w, :window_h
|
30
|
+
attr_reader :base_url, :server_host, :server_port, :url, :window_w, :window_h, :win_x, :win_y
|
31
31
|
|
32
32
|
# Get base_url from XCTRunner logs: ServerURLHere->http://x.x.x.x:8100<-ServerURLHere
|
33
33
|
# Default base_url 'http://localhost:8100' for running XCTRunner on simulator
|
@@ -52,6 +52,7 @@ class WDA
|
|
52
52
|
@server_host = parsed_url.host
|
53
53
|
@server_port = parsed_url.port
|
54
54
|
status
|
55
|
+
window_size
|
55
56
|
capabilities(opts)
|
56
57
|
@driver = Selenium::WebDriver::Driver.for(:remote, :url => @base_url, :desired_capabilities => @caps[:desiredCapabilities])
|
57
58
|
end
|
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.
|
4
|
+
version: 0.0.3
|
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-
|
11
|
+
date: 2016-10-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -89,6 +89,8 @@ files:
|
|
89
89
|
- ".gitignore"
|
90
90
|
- ".rspec"
|
91
91
|
- README.md
|
92
|
+
- example/multiple_devices.rb
|
93
|
+
- example/single_device.rb
|
92
94
|
- lib/selenium_patch/commands.rb
|
93
95
|
- lib/selenium_patch/element_patch.rb
|
94
96
|
- lib/selenium_patch/w3c_bridge_patch.rb
|