async-webdriver 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +2 -2
- data/lib/async/webdriver/client.rb +3 -2
- data/lib/async/webdriver/connection.rb +36 -26
- data/lib/async/webdriver/session_creator.rb +7 -4
- data/lib/async/webdriver/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 10af3bfaf7f567c54aaa67fc66865b60e8797756762fb13b3e7f32701d234de5
|
4
|
+
data.tar.gz: 91a457bdbc9343cd41eb4c3ba9d63a9f81b571c1f91ffc5c315b81130c0c1d76
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 226ca38936a96df93d97b55ed583316a7651b528f70ac9a246e3af784959d6df1137e077903b92e94b0613a792a58ed80800f31c9cd7f4dbd518c211ff099adb
|
7
|
+
data.tar.gz: b1db3afdbaaaef09eb54c495a4d31bcb80a80dfe88bd25d12f6dfae68b4c3dffadc1d24f934f76dc5c643cb3b4d2e225962a91e34a2bfbd8a7eaef46fe3325fb
|
data/Gemfile.lock
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
async-webdriver (0.1.
|
4
|
+
async-webdriver (0.1.1)
|
5
5
|
async-http
|
6
6
|
selenium-webdriver
|
7
7
|
|
8
8
|
GEM
|
9
9
|
remote: https://rubygems.org/
|
10
10
|
specs:
|
11
|
-
async (1.
|
11
|
+
async (1.13.1)
|
12
12
|
nio4r (~> 2.3)
|
13
13
|
timers (~> 4.1)
|
14
14
|
async-http (0.37.7)
|
@@ -3,12 +3,13 @@ require "async/queue"
|
|
3
3
|
module Async
|
4
4
|
module Webdriver
|
5
5
|
class Client
|
6
|
-
def initialize(endpoint:)
|
6
|
+
def initialize(endpoint:, desired_capabilities: {})
|
7
7
|
@connection = Connection.new endpoint: endpoint
|
8
|
+
@desired_capabilities = desired_capabilities
|
8
9
|
end
|
9
10
|
|
10
11
|
def session
|
11
|
-
SessionCreator.new connection: @connection
|
12
|
+
SessionCreator.new connection: @connection, desired_capabilities: @desired_capabilities
|
12
13
|
end
|
13
14
|
|
14
15
|
def status
|
@@ -12,6 +12,20 @@ module Async
|
|
12
12
|
end
|
13
13
|
|
14
14
|
def call(method:, path:nil, headers:[], body:nil)
|
15
|
+
task = begin
|
16
|
+
Async::Task.current.async { async_call(method: method, path: path, headers: headers, body: body) }
|
17
|
+
rescue RuntimeError => e
|
18
|
+
raise unless e.message == "No async task available!"
|
19
|
+
|
20
|
+
Async.run { async_call(method: method, path: path, headers: headers, body: body) }
|
21
|
+
end
|
22
|
+
|
23
|
+
task.wait
|
24
|
+
end
|
25
|
+
|
26
|
+
private
|
27
|
+
|
28
|
+
def async_call(method:, path:, headers:, body:nil)
|
15
29
|
body_array = case body
|
16
30
|
when Hash
|
17
31
|
[body.to_json]
|
@@ -23,36 +37,32 @@ module Async
|
|
23
37
|
@url
|
24
38
|
end
|
25
39
|
|
26
|
-
|
27
|
-
r = @internet.call method, path_or_url, headers, body_array
|
40
|
+
r = @internet.call method.upcase, path_or_url, headers, body_array
|
28
41
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
42
|
+
body = begin
|
43
|
+
JSON.parse r.read
|
44
|
+
rescue JSON::ParserError => ex
|
45
|
+
p ex
|
46
|
+
exit 1
|
47
|
+
end
|
48
|
+
|
49
|
+
@internet.close
|
35
50
|
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
if
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
else # everything else works like this
|
47
|
-
body.dig "value"
|
48
|
-
end
|
49
|
-
else
|
50
|
-
p body
|
51
|
-
raise "Error: #{status} - #{body.dig("value", "message")}"
|
51
|
+
status = body.dig "status"
|
52
|
+
if status == 0
|
53
|
+
# POST /session has different response structure than other calls
|
54
|
+
if method == "post" && path == "session"
|
55
|
+
{
|
56
|
+
"id" => body.dig("sessionId"),
|
57
|
+
"capabilities" => body.dig("value")
|
58
|
+
}
|
59
|
+
else # everything else works like this
|
60
|
+
body.dig "value"
|
52
61
|
end
|
62
|
+
else
|
63
|
+
p body
|
64
|
+
raise "Error: #{status} - #{body.dig("value", "message")}"
|
53
65
|
end
|
54
|
-
|
55
|
-
task.wait
|
56
66
|
end
|
57
67
|
end
|
58
68
|
end
|
@@ -3,14 +3,17 @@ require "async/queue"
|
|
3
3
|
module Async
|
4
4
|
module Webdriver
|
5
5
|
class SessionCreator
|
6
|
-
def initialize(connection:)
|
6
|
+
def initialize(connection:, desired_capabilities: {})
|
7
7
|
@connection = connection
|
8
|
+
@desired_capabilities = desired_capabilities
|
8
9
|
end
|
9
10
|
|
10
11
|
def create!
|
11
|
-
value = @connection.call
|
12
|
-
|
13
|
-
|
12
|
+
value = @connection.call(
|
13
|
+
method: "post",
|
14
|
+
path: "session",
|
15
|
+
body: { desiredCapabilities: @desired_capabilities }
|
16
|
+
)
|
14
17
|
|
15
18
|
Session.new json: value, connection: @connection
|
16
19
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: async-webdriver
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matti Paksula
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-01-
|
11
|
+
date: 2019-01-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: async-http
|