true_automation 0.3.31 → 0.4.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
  SHA256:
3
- metadata.gz: 80ab9c92521f6edf81b4bde9bf529e63e443258483b99de52815372697eb85d9
4
- data.tar.gz: 9ce5f945348159a5d947ee705e2d720470342096c4c3fefcf291cb150e3f39b7
3
+ metadata.gz: 22f6553e2b4a2f3190038a8ad52c2b838bcfb61cae3e86fb963d8492d345b8f2
4
+ data.tar.gz: 64ca3a87d2bdbb8ac1a180e5691051aa11fa9eb72c02fa00a64e94a361971984
5
5
  SHA512:
6
- metadata.gz: a3fcb71c16cab882bb8ec5c0b83f1c230717bb1667cd7d0500ed8d6b039a62c43a5e3dcc8135f45b151be965b2cb7f60e8f9631c669c21284635e8c1ce4dcaa2
7
- data.tar.gz: e633a3c1ab4c3bc8fb58f3d5d70bf0bba51519204e33e3a3211542b464e7c6c28264b2ab68102718a3723d0abb76af9aa7578794acf1471e29baecff0f75a01e
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[:driver]
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
- if @pid
40
- puts "Stopping TrueAutomation.IO Client with pid #{@pid}"
41
- uri = URI("http://localhost:#{@port}/shutdown")
42
- Net::HTTP.get(uri)
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
- @pid = nil
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
- @port = options.delete(:port) || 9515
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
@@ -1,3 +1,3 @@
1
1
  module TrueAutomation
2
- VERSION = '0.3.31'
2
+ VERSION = '0.4.0'
3
3
  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.3.31
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-06-21 00:00:00.000000000 Z
11
+ date: 2019-10-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler