wda_client 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +14 -0
- data/README.md +10 -3
- data/lib/wda_client.rb +7 -8
- data/lib/wda_client/homescreen.rb +2 -3
- data/lib/wda_client/screenshot.rb +2 -3
- data/lib/wda_client/sessions.rb +41 -5
- data/lib/wda_client/source.rb +2 -3
- data/lib/wda_client/status.rb +6 -4
- data/lib/wda_client/version.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1bb55bd2a43a1c14108e3d9ef93118456d7c2963
|
4
|
+
data.tar.gz: 690b308c23c327077f2c95ddcf30eb2118567b0b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5c04b017723c7fb5d5f3a9e0487fff5ee0b1b7a395902233da268a94f5fa58b4a3cb1f9944b3f0ef6c61eeb3ddac1a29894cb9b15b6b4738b0b93b8cb529e5b8
|
7
|
+
data.tar.gz: 418597e40bdaa173d692a6aaff3fcb014a9672223164d6cdd5fb7c2171017d061c645d107a81292fab144fd22524df1071b8d1a396bf3a6d23796229d5e19833
|
data/CHANGELOG.md
ADDED
data/README.md
CHANGED
@@ -33,9 +33,10 @@ Or install it yourself as:
|
|
33
33
|
$ pry
|
34
34
|
> require 'wda_client'
|
35
35
|
> client = WdaClient.new desired_capabilities: "{\"desiredCapabilities\":{\"bundleId\": \"com.my.app\"}}"
|
36
|
-
> client.get_status
|
36
|
+
> client.get_status # https://github.com/facebook/WebDriverAgent/wiki/Queries#checking-service-status
|
37
37
|
> client.take_screenshot # https://github.com/facebook/WebDriverAgent/wiki/Queries#get-a-screenshot
|
38
|
-
> client.get_source
|
38
|
+
> client.get_source # https://github.com/facebook/WebDriverAgent/wiki/Queries#source-aka-tree
|
39
|
+
> client.close # close session
|
39
40
|
```
|
40
41
|
|
41
42
|
## Advanced
|
@@ -55,7 +56,13 @@ client = WdaClient.new desired_capabilities: "{\"desiredCapabilities\":{\"bundle
|
|
55
56
|
|
56
57
|
## Current Status
|
57
58
|
|
58
|
-
- Get Status
|
59
|
+
- Get Status
|
60
|
+
- Get source
|
61
|
+
- go to homescreen
|
62
|
+
- Take Screenshot
|
63
|
+
- install app and get session id
|
64
|
+
- get current session id
|
65
|
+
- close current session
|
59
66
|
|
60
67
|
## Contributing
|
61
68
|
|
data/lib/wda_client.rb
CHANGED
@@ -15,28 +15,27 @@ class WdaClient
|
|
15
15
|
include ::WdaClient::Source
|
16
16
|
include ::WdaClient::Homescreen
|
17
17
|
|
18
|
-
attr_accessor :session_id, :capabilities, :desired_capabilities
|
18
|
+
attr_accessor :session_id, :capabilities, :desired_capabilities, :status
|
19
19
|
attr_reader :base_url
|
20
20
|
|
21
21
|
BASE_URL = 'http://localhost:8100'
|
22
22
|
|
23
23
|
def initialize(desired_capabilities:, base_url: BASE_URL)
|
24
24
|
@desired_capabilities = parse(desired_capabilities)
|
25
|
-
@base_url = base_url
|
25
|
+
@base_url = URI.parse(base_url)
|
26
26
|
@capabilities = nil
|
27
27
|
@session_id = nil
|
28
|
-
|
29
|
-
|
30
|
-
def generate_uri(url_path:)
|
31
|
-
URI.parse(@base_url + url_path)
|
28
|
+
@status = 0
|
32
29
|
end
|
33
30
|
|
34
31
|
def generate_base_req(method:, url_path:)
|
35
32
|
req = case method
|
36
|
-
when
|
33
|
+
when :get
|
37
34
|
Net::HTTP::Get.new(url_path)
|
38
|
-
when
|
35
|
+
when :post
|
39
36
|
Net::HTTP::Post.new(url_path)
|
37
|
+
when :delete
|
38
|
+
Net::HTTP::Delete.new(url_path)
|
40
39
|
else
|
41
40
|
# no method
|
42
41
|
end
|
@@ -3,11 +3,10 @@ require 'json'
|
|
3
3
|
class WdaClient
|
4
4
|
module Homescreen
|
5
5
|
def homescreen
|
6
|
-
|
7
|
-
req = generate_base_req(method: 'post', url_path: '/homescreen')
|
6
|
+
req = generate_base_req(method: :post, url_path: '/homescreen')
|
8
7
|
req.body = ""
|
9
8
|
|
10
|
-
res = Net::HTTP.start(
|
9
|
+
res = Net::HTTP.start(@base_url.host, @base_url.port) { |http| http.request(req) }
|
11
10
|
|
12
11
|
JSON.parse(res.body)
|
13
12
|
end
|
@@ -4,10 +4,9 @@ require 'base64'
|
|
4
4
|
class WdaClient
|
5
5
|
module Screenshot
|
6
6
|
def take_screenshot(to_file: './snapshot.png')
|
7
|
-
|
8
|
-
req = generate_base_req(method: 'get', url_path: '/screenshot')
|
7
|
+
req = generate_base_req(method: :get, url_path: '/screenshot')
|
9
8
|
|
10
|
-
res = Net::HTTP.start(
|
9
|
+
res = Net::HTTP.start(@base_url.host, @base_url.port) { |http| http.request(req) }
|
11
10
|
|
12
11
|
parsed_result = JSON.parse res.body
|
13
12
|
|
data/lib/wda_client/sessions.rb
CHANGED
@@ -3,17 +3,53 @@ require 'json'
|
|
3
3
|
class WdaClient
|
4
4
|
module Sessions
|
5
5
|
def install
|
6
|
-
|
7
|
-
req =
|
8
|
-
req.body = @desired_capabilities
|
6
|
+
req = generate_base_req(method: :post, url_path: '/session')
|
7
|
+
req.body = @desired_capabilities.to_json
|
9
8
|
|
10
|
-
res = Net::HTTP.start(
|
9
|
+
res = Net::HTTP.start(@base_url.host, @base_url.port) { |http| http.request(req) }
|
11
10
|
|
12
11
|
result = JSON.parse(res.body)
|
13
|
-
@session_id = result['sessionId']
|
12
|
+
@session_id = result['sessionId']
|
14
13
|
@capabilities = result['value']['capabilities']
|
14
|
+
@status = result['status']
|
15
15
|
|
16
16
|
result
|
17
17
|
end
|
18
|
+
|
19
|
+
def close
|
20
|
+
session_id = parse_session_id @session_id
|
21
|
+
req = generate_base_req(method: :delete, url_path: "/session/#{session_id}")
|
22
|
+
|
23
|
+
res = Net::HTTP.start(@base_url.host, @base_url.port) { |http| http.request(req) }
|
24
|
+
|
25
|
+
result = JSON.parse(res.body)
|
26
|
+
@session_id = result['sessionId']
|
27
|
+
@status = result['status']
|
28
|
+
|
29
|
+
result
|
30
|
+
end
|
31
|
+
|
32
|
+
def get_current_session
|
33
|
+
session_id = parse_session_id @session_id
|
34
|
+
req = generate_base_req(method: :get, url_path: "/session/#{session_id}")
|
35
|
+
|
36
|
+
res = Net::HTTP.start(@base_url.host, @base_url.port) { |http| http.request(req) }
|
37
|
+
|
38
|
+
result = JSON.parse(res.body)
|
39
|
+
@session_id = result['sessionId']
|
40
|
+
@status = result['status']
|
41
|
+
|
42
|
+
result
|
43
|
+
end
|
44
|
+
|
45
|
+
private
|
46
|
+
|
47
|
+
def parse_session_id(session_id)
|
48
|
+
if @session_id.nil?
|
49
|
+
""
|
50
|
+
else
|
51
|
+
@session_id
|
52
|
+
end
|
53
|
+
end
|
18
54
|
end
|
19
55
|
end
|
data/lib/wda_client/source.rb
CHANGED
@@ -3,10 +3,9 @@ require 'json'
|
|
3
3
|
class WdaClient
|
4
4
|
module Source
|
5
5
|
def get_source
|
6
|
-
|
7
|
-
req = generate_base_req(method: 'get', url_path: '/source')
|
6
|
+
req = generate_base_req(method: :get, url_path: '/source')
|
8
7
|
|
9
|
-
res = Net::HTTP.start(
|
8
|
+
res = Net::HTTP.start(@base_url.host, @base_url.port) { |http| http.request(req) }
|
10
9
|
|
11
10
|
JSON.parse res.body
|
12
11
|
end
|
data/lib/wda_client/status.rb
CHANGED
@@ -3,12 +3,14 @@ require 'json'
|
|
3
3
|
class WdaClient
|
4
4
|
module Status
|
5
5
|
def get_status
|
6
|
-
|
7
|
-
req = generate_base_req(method: 'get', url_path: '/status')
|
6
|
+
req = generate_base_req(method: :get, url_path: '/status')
|
8
7
|
|
9
|
-
res = Net::HTTP.start(
|
8
|
+
res = Net::HTTP.start(@base_url.host, @base_url.port) { |http| http.request(req) }
|
10
9
|
|
11
|
-
JSON.parse res.body
|
10
|
+
result = JSON.parse res.body
|
11
|
+
@status = result['status']
|
12
|
+
|
13
|
+
result
|
12
14
|
end
|
13
15
|
end
|
14
16
|
end
|
data/lib/wda_client/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: wda_client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kazuaki MATSUO
|
@@ -75,6 +75,7 @@ extra_rdoc_files: []
|
|
75
75
|
files:
|
76
76
|
- ".gitignore"
|
77
77
|
- ".travis.yml"
|
78
|
+
- CHANGELOG.md
|
78
79
|
- CODE_OF_CONDUCT.md
|
79
80
|
- Gemfile
|
80
81
|
- LICENSE.txt
|