wda_lib 0.0.20 → 0.1.0

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: 19883542a4fe2fc7642ded024233e0b232f07d56
4
- data.tar.gz: 2af914564729ff76ff75974d1a21907c269b27a7
3
+ metadata.gz: 221802f6fc6baa68274145fde265c911c7ca03c4
4
+ data.tar.gz: cb2140ff5d9055afc139c88702b6ec395367d9a7
5
5
  SHA512:
6
- metadata.gz: aae9e4320f23268979f7cc2aba7af70fd6a7c846da858ebeca93fca8302f4a8e33759b0044d0f94b758b210755b8799a0c30654b120d413d25758e06a60bea28
7
- data.tar.gz: d9e6af8060a6d7f0451b6aeea05f2d14189ea04652b795b4b9562fb6cf68f893e261f90b4985858ade51479361869d157295b8da75a97136b18befd1f369acb6
6
+ metadata.gz: ff14d99fdefaf1f88bb8eddc97e261eb05fb8c7dcb0b51768ff117a51f11f48bba77c8cfe299982567797671112732428bab68b655566b5137c678530d96cea6
7
+ data.tar.gz: 91195e8815e41f1eabeaa0c0b8ab2aa3a0d54d46a10f55181451316045aebac3cc1bb7a2c406aa6217a0ff3bf5b2aaa155cfe9c96ed466616ee9b26a4616996f
data/lib/wda_lib/debug.rb CHANGED
@@ -6,18 +6,27 @@ class WDA
6
6
  module Debug
7
7
 
8
8
  # Get all elements on current screen
9
- # @param session_id [String], accessible [Boolean], visible [Boolean]
9
+ # @param session_id [String], not_fetch_inaccessible [Boolean], not_fetch_invisible [Boolean], timeout [Integer]
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(session_id = nil, accessible = true, visible = true)
14
- if session_id.nil?
15
- post(@base_url + '/source', { accessible: accessible, visible: visible })
16
- else
17
- post '/source', { accessible: accessible, visible: visible }
18
- end
13
+ def source(session_id = nil, not_fetch_inaccessible = true, not_fetch_invisible = true, timeout = 60)
14
+ @timeout = timeout.to_i if !timeout.nil?
15
+ begin
16
+ if session_id.nil?
17
+ res = post(@base_url + '/source', { accessible: not_fetch_inaccessible, visible: not_fetch_invisible }, @timeout)
18
+ else
19
+ res = post('/source', { accessible: not_fetch_inaccessible, visible: not_fetch_invisible }, @timeout)
20
+ end
21
+ rescue
22
+ raise Error::NoSuchElementError, "Can't fetch current screen elements within #{@timeout}s" if res['status'].nil?
23
+ end
24
+ @timeout = @default_timeout
25
+ res
19
26
  end
20
27
 
28
+
29
+
21
30
  def get_source
22
31
  get(@base_url + '/source')['value']['tree']['children']
23
32
  end
@@ -8,7 +8,7 @@ class WDA
8
8
  # Get current status
9
9
  # @return [Obj]
10
10
  def status
11
- @status = get(@base_url + '/status')
11
+ @status = get(@base_url + '/status', 5)
12
12
  @platform_name = @status['value']['os']['name']
13
13
  @platform_version = @status['value']['os']['version']
14
14
  update_status(@status)
@@ -12,7 +12,7 @@ class WDA
12
12
  end
13
13
 
14
14
  # Do not match TouchID
15
- def match_touchid
15
+ def unmatch_touchid
16
16
  post(@base_url + '/Simulator/touch_id', { match: 0 }.to_json)
17
17
  end
18
18
  end
@@ -3,5 +3,5 @@
3
3
  # Copyright © 2016 Zenly. All rights reserved.
4
4
  #
5
5
  class WDA
6
- VERSION = '0.0.20'
6
+ VERSION = '0.1.0'
7
7
  end
data/lib/wda_lib.rb CHANGED
@@ -96,19 +96,19 @@ class WDA
96
96
  # HTTP methods for dealing with all supported motheds in FB WDA
97
97
  # I don't like to write such pieces of code, it removes all query params and headers,
98
98
  # But as FB WDA is doing like this, this can simplify codes
99
- def get(path)
99
+ def get(path, timeout = 60)
100
100
  if URI.parse(path).absolute?
101
- WDA.get(path)
101
+ WDA.get(path, timeout: timeout)
102
102
  else
103
- WDA.get(@url + path)
103
+ WDA.get(@url + path, timeout: timeout)
104
104
  end
105
105
  end
106
106
 
107
- def post(path, body = nil)
107
+ def post(path, body = nil, timeout = 60)
108
108
  if URI.parse(path).absolute?
109
- WDA.post(path, body: body.to_json)
109
+ WDA.post(path, body: body.to_json, timeout: timeout)
110
110
  else
111
- WDA.post(@url + path, body: body.to_json)
111
+ WDA.post(@url + path, body: body.to_json, timeout: timeout)
112
112
  end
113
113
  end
114
114
 
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.20
4
+ version: 0.1.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-01-05 00:00:00.000000000 Z
11
+ date: 2017-01-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake