true_automation 0.3.18 → 0.5.5
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 +5 -5
- data/lib/true_automation/client.rb +14 -9
- data/lib/true_automation/driver/capybara.rb +109 -19
- data/lib/true_automation/version.rb +1 -1
- metadata +3 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: bfbcc2e493c1522b04336e00792f54959faa29a725c782d0059a32cf278a10ea
|
4
|
+
data.tar.gz: d981ad6cfdf86e844fdf04df0ce1fd4dc9d318f06076d9d1585a46bdf20dbfdd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 587a9f58f8fd6d32e6ae6f703571c340816108df83a57a90a05708328c9f506673fe16a886c58ea8f1cb88b09751dd2e96a3fbea7b7bfb166be26ffdffa91a23
|
7
|
+
data.tar.gz: bb8a4aaf3cc04a103925ca51c82c2676d5d3b8e770ed0dd674c49c1f2e7b7095ae0c5cc5c79691c3944f8708aa5ee7af0aeedd148b1b61601d80b7f2d91cc39d
|
@@ -8,11 +8,13 @@ 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]
|
13
|
+
ta_debug = options[:ta_debug]
|
14
14
|
|
15
|
-
if options[:
|
15
|
+
if options[:ta_service]
|
16
|
+
driver_path = " --driver #{options[:ta_service]}"
|
17
|
+
elsif options[:driver]
|
16
18
|
driver_path = " --driver #{options[:driver]}"
|
17
19
|
driver_path += " --driver-version #{options[:driver_version]}" if options[:driver_version]
|
18
20
|
end
|
@@ -29,19 +31,22 @@ module TrueAutomation
|
|
29
31
|
Dir.mkdir('log') unless File.exist?('log')
|
30
32
|
logfile = "log/trueautomation-#{Time.now.strftime('%Y%m%dT%H%M%S')}.log"
|
31
33
|
|
32
|
-
@pid = spawn("#{@executable} --log-file #{logfile} --port #{@port}#{driver_path}#{remote}")
|
34
|
+
@pid = spawn("#{@executable} --log-file #{logfile} --port #{@port}#{driver_path}#{remote}#{ta_debug}")
|
33
35
|
puts "Started TrueAutomation.IO client with pid #{@pid} listening to port #{@port}"
|
34
36
|
|
35
37
|
@pid
|
36
38
|
end
|
37
39
|
|
38
40
|
def stop
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
41
|
+
begin
|
42
|
+
if @pid
|
43
|
+
puts "Stopping TrueAutomation.IO Client with pid #{@pid}"
|
44
|
+
uri = URI("http://localhost:#{@port}/shutdown")
|
45
|
+
Net::HTTP.get(uri)
|
43
46
|
|
44
|
-
|
47
|
+
@pid = nil
|
48
|
+
end
|
49
|
+
rescue
|
45
50
|
end
|
46
51
|
end
|
47
52
|
|
@@ -1,4 +1,65 @@
|
|
1
1
|
require_relative '../client'
|
2
|
+
module Capybara
|
3
|
+
module Queries
|
4
|
+
class SelectorQuery
|
5
|
+
alias_method :original_description, :description
|
6
|
+
def description(only_applied = false)
|
7
|
+
desc = original_description
|
8
|
+
matched_result = desc.match(/.*__taonly__(.+)__taonly__.*/)
|
9
|
+
if selector = matched_result && matched_result[1]
|
10
|
+
desc = "Element was not found on the page. Element '#{selector}' with such locator is not on this page and could not be detected by TrueAutomation."
|
11
|
+
end
|
12
|
+
matched_result_ta = desc.match(/visible\s(.+)\s\"(.*)__ta__(.+)__ta__.*/)
|
13
|
+
if matched_result_ta && matched_result_ta[3]
|
14
|
+
desc = "Unable to locate element { using: '#{matched_result_ta[1]}', selector: '#{matched_result_ta[2]}' }"
|
15
|
+
end
|
16
|
+
desc
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
module Capybara
|
23
|
+
module Node
|
24
|
+
module Finders
|
25
|
+
private
|
26
|
+
alias_method :original_synced_resolve, :synced_resolve
|
27
|
+
def synced_resolve(query)
|
28
|
+
begin
|
29
|
+
original_synced_resolve(query)
|
30
|
+
rescue Capybara::ElementNotFound => ex
|
31
|
+
raise Capybara::ElementNotFound, query.applied_description if query.locator.match(/.*__ta(only)*__(.+)__ta(only)*__.*/)
|
32
|
+
raise Capybara::ElementNotFound, ex
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
module Capybara
|
40
|
+
module Node
|
41
|
+
class Element < Base
|
42
|
+
def innerHTML=(value)
|
43
|
+
synchronize { base.innerHTML=(value) }
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
class Capybara::Selenium::Node < Capybara::Driver::Node
|
50
|
+
def innerHTML=(value)
|
51
|
+
driver.evaluate_script SET_INNER_HTML_SCRIPT, self, value
|
52
|
+
end
|
53
|
+
|
54
|
+
private
|
55
|
+
|
56
|
+
SET_INNER_HTML_SCRIPT = <<~'JS'
|
57
|
+
(function(el, val){
|
58
|
+
el.innerHTML = val;
|
59
|
+
return;
|
60
|
+
})(arguments[0], arguments[1])
|
61
|
+
JS
|
62
|
+
end
|
2
63
|
|
3
64
|
module TrueAutomation
|
4
65
|
class RecordNotFound < StandardError; end
|
@@ -6,10 +67,20 @@ module TrueAutomation
|
|
6
67
|
module Driver
|
7
68
|
class Capybara < Capybara::Selenium::Driver
|
8
69
|
def initialize(app, **options)
|
9
|
-
|
70
|
+
options = fetch_options(options)
|
71
|
+
@port = options.delete(:port) || find_available_port('localhost')
|
10
72
|
@driver = options.delete(:driver)
|
11
73
|
@driver_version = options.delete(:driver_version)
|
12
74
|
|
75
|
+
if options && options[:ta_debug]
|
76
|
+
@ta_debug = ' --ta-debug'
|
77
|
+
options.delete(:ta_debug)
|
78
|
+
end
|
79
|
+
|
80
|
+
if options[:ta_service]
|
81
|
+
@ta_service = options.delete(:ta_service)
|
82
|
+
end
|
83
|
+
|
13
84
|
super(app, options)
|
14
85
|
|
15
86
|
@ta_client = TrueAutomation::Client.new
|
@@ -18,8 +89,7 @@ module TrueAutomation
|
|
18
89
|
options ||= {}
|
19
90
|
ta_url = options[:ta_url] || "http://localhost:#{@port}/"
|
20
91
|
|
21
|
-
capabilities = options[:desired_capabilities]
|
22
|
-
capabilities ||= {}
|
92
|
+
capabilities = options[:desired_capabilities] || {}
|
23
93
|
|
24
94
|
if options and options[:browser] == :remote
|
25
95
|
raise 'Remote driver URL is not specified' unless options[:url]
|
@@ -36,39 +106,59 @@ module TrueAutomation
|
|
36
106
|
|
37
107
|
def browser
|
38
108
|
unless @browser
|
39
|
-
@ta_client.start(port: @port,
|
109
|
+
@ta_client.start(port: @port,
|
110
|
+
remote: @remote,
|
111
|
+
ta_debug: @ta_debug,
|
112
|
+
driver: @driver,
|
113
|
+
ta_service_path: @ta_service&.executable_path,
|
114
|
+
driver_version: @driver_version)
|
40
115
|
|
41
116
|
@ta_client.wait_until_start
|
42
117
|
|
43
118
|
at_exit do
|
44
119
|
@ta_client.stop
|
45
120
|
end
|
46
|
-
|
47
121
|
super
|
48
122
|
end
|
49
123
|
@browser
|
50
124
|
end
|
51
125
|
|
52
|
-
def
|
53
|
-
|
54
|
-
|
55
|
-
res
|
126
|
+
def quit
|
127
|
+
super
|
128
|
+
@ta_client.stop
|
56
129
|
end
|
57
130
|
|
58
|
-
def
|
59
|
-
|
60
|
-
|
61
|
-
|
131
|
+
def specialize_driver(*args)
|
132
|
+
if ::Capybara::Selenium::Driver.respond_to?(:register_specialization)
|
133
|
+
browser_type = browser.browser
|
134
|
+
# Original method uses self.class, and all classes use Capybara::Selenium::Driver.
|
135
|
+
# Thereby no specializations in the list for TA driver class and error occured.
|
136
|
+
::Capybara::Selenium::Driver.specializations.select { |k, _v| k === browser_type }.each_value do |specialization| # rubocop:disable Style/CaseEquality
|
137
|
+
extend specialization
|
138
|
+
end
|
139
|
+
else
|
140
|
+
super
|
141
|
+
end
|
62
142
|
end
|
63
143
|
|
64
144
|
private
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
145
|
+
def fetch_options(options)
|
146
|
+
if options.key?(:options)
|
147
|
+
browser = options[:options].class.name.split('::')[2]
|
148
|
+
desCaps = Selenium::WebDriver::Remote::Capabilities.send(browser.downcase)
|
149
|
+
opts = options[:options].as_json
|
150
|
+
desCaps[opts.keys.first] = opts[opts.keys.first]
|
151
|
+
options[:desired_capabilities] = desCaps
|
152
|
+
options.delete(:options)
|
71
153
|
end
|
154
|
+
options
|
155
|
+
end
|
156
|
+
|
157
|
+
def find_available_port(host)
|
158
|
+
server = TCPServer.new(host, rand(9515..65515))
|
159
|
+
server.addr[1]
|
160
|
+
ensure
|
161
|
+
server&.close
|
72
162
|
end
|
73
163
|
end
|
74
164
|
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.5.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- TrueAutomation.IO
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-06-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -108,8 +108,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
108
108
|
- !ruby/object:Gem::Version
|
109
109
|
version: '0'
|
110
110
|
requirements: []
|
111
|
-
|
112
|
-
rubygems_version: 2.5.2
|
111
|
+
rubygems_version: 3.0.8
|
113
112
|
signing_key:
|
114
113
|
specification_version: 4
|
115
114
|
summary: TrueAutomation.IO
|