true_automation 0.3.31 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/true_automation/client.rb +12 -8
- data/lib/true_automation/driver/capybara.rb +27 -2
- data/lib/true_automation/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: 22f6553e2b4a2f3190038a8ad52c2b838bcfb61cae3e86fb963d8492d345b8f2
|
4
|
+
data.tar.gz: 64ca3a87d2bdbb8ac1a180e5691051aa11fa9eb72c02fa00a64e94a361971984
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e26186f0e510de4185f3a60732fa0040d58a820f2d33a92333231cab9fdedfd1a54afffaf5bf3158c62b73c961a19cf3ed6b42efc252a5fa6fb37576f90720f6
|
7
|
+
data.tar.gz: f399dfc5bcc4fab22517db68ba5eecea5ba911b0b31db65a20d5dbd0acdfa168a16fb13553a46e486909974c4e030f196836d480ce67f12b029f59fdddea7383
|
@@ -8,11 +8,12 @@ module TrueAutomation
|
|
8
8
|
@pid = nil
|
9
9
|
|
10
10
|
def start(options)
|
11
|
-
|
12
|
-
@port = options[:port] || 9515
|
11
|
+
@port = options[:port]
|
13
12
|
remote = options[:remote]
|
14
13
|
|
15
|
-
if options[:
|
14
|
+
if options[:ta_service]
|
15
|
+
driver_path = " --driver #{options[:ta_service]}"
|
16
|
+
elsif options[:driver]
|
16
17
|
driver_path = " --driver #{options[:driver]}"
|
17
18
|
driver_path += " --driver-version #{options[:driver_version]}" if options[:driver_version]
|
18
19
|
end
|
@@ -36,12 +37,15 @@ module TrueAutomation
|
|
36
37
|
end
|
37
38
|
|
38
39
|
def stop
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
40
|
+
begin
|
41
|
+
if @pid
|
42
|
+
puts "Stopping TrueAutomation.IO Client with pid #{@pid}"
|
43
|
+
uri = URI("http://localhost:#{@port}/shutdown")
|
44
|
+
Net::HTTP.get(uri)
|
43
45
|
|
44
|
-
|
46
|
+
@pid = nil
|
47
|
+
end
|
48
|
+
rescue
|
45
49
|
end
|
46
50
|
end
|
47
51
|
|
@@ -25,10 +25,15 @@ module TrueAutomation
|
|
25
25
|
module Driver
|
26
26
|
class Capybara < Capybara::Selenium::Driver
|
27
27
|
def initialize(app, **options)
|
28
|
-
|
28
|
+
options = fetch_options(options)
|
29
|
+
@port = options.delete(:port) || find_available_port('localhost')
|
29
30
|
@driver = options.delete(:driver)
|
30
31
|
@driver_version = options.delete(:driver_version)
|
31
32
|
|
33
|
+
if options[:ta_service]
|
34
|
+
@ta_service = options.delete(:ta_service)
|
35
|
+
end
|
36
|
+
|
32
37
|
super(app, options)
|
33
38
|
|
34
39
|
@ta_client = TrueAutomation::Client.new
|
@@ -57,6 +62,7 @@ module TrueAutomation
|
|
57
62
|
@ta_client.start(port: @port,
|
58
63
|
remote: @remote,
|
59
64
|
driver: @driver,
|
65
|
+
ta_service_path: @ta_service&.executable_path,
|
60
66
|
driver_version: @driver_version)
|
61
67
|
|
62
68
|
@ta_client.wait_until_start
|
@@ -64,7 +70,6 @@ module TrueAutomation
|
|
64
70
|
at_exit do
|
65
71
|
@ta_client.stop
|
66
72
|
end
|
67
|
-
|
68
73
|
super
|
69
74
|
end
|
70
75
|
@browser
|
@@ -87,6 +92,26 @@ module TrueAutomation
|
|
87
92
|
super
|
88
93
|
end
|
89
94
|
end
|
95
|
+
|
96
|
+
private
|
97
|
+
def fetch_options(options)
|
98
|
+
if options.key?(:options)
|
99
|
+
browser = options[:options].class.name.split('::')[2]
|
100
|
+
desCaps = Selenium::WebDriver::Remote::Capabilities.send(browser.downcase)
|
101
|
+
opts = options[:options].as_json
|
102
|
+
desCaps[opts.keys.first] = opts[opts.keys.first]
|
103
|
+
options[:desired_capabilities] = desCaps
|
104
|
+
options.delete(:options)
|
105
|
+
end
|
106
|
+
options
|
107
|
+
end
|
108
|
+
|
109
|
+
def find_available_port(host)
|
110
|
+
server = TCPServer.new(host, rand(9515..65515))
|
111
|
+
server.addr[1]
|
112
|
+
ensure
|
113
|
+
server&.close
|
114
|
+
end
|
90
115
|
end
|
91
116
|
end
|
92
117
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: true_automation
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- TrueAutomation.IO
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-10-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|