true_automation 0.5.9 → 0.6.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5899752657a55d787cd0d34e450485baa81ccd00fcb04b39299646dd016404de
4
- data.tar.gz: 961a54b9115cc568ec44cfafbc9cb5c530a0d9126a3c3cfcfb0efd6efca81eda
3
+ metadata.gz: f0bf53dc1f2d8755f2b13e7c63a2b62172225fcc26c8fddfc461963a77ecc595
4
+ data.tar.gz: 1ca188644cd2411f68f4153b7352fc31a9bf821c5d6613718d6202ef939f641d
5
5
  SHA512:
6
- metadata.gz: '0966514008a28ac8a073065c605b63c41d248159279560042da26459ade761fbed733fe31710a174d9e9450cd335e8ea934cfa8d20776b03a2084cb7984aab58'
7
- data.tar.gz: 81eb2f5120ec29af5bc8be0ca2794fd1a947d0a138a192dbe5a16626db5fe3489e6c03a57923ac8037a3a85b2d26c75e6d7a43331e9224350cf99c086dfcb75a
6
+ metadata.gz: 7945c55acaa37f7bf931aed7760648d0abc941ed4b8607ff7166a92290c1a7556eebff9b3627e2bad3d926d0df4fec06a9e9ba969b686052d19567b40ac10baa
7
+ data.tar.gz: baba5d0a9b3d6ee227cc3c7d89ca759db46d5f9b25c8c57ff0f57ebf870e45cf55ad45df2800b977f0fd49f8f5e53f8b77c98c4bf44c6a32db868874c170b8f4
@@ -10,6 +10,7 @@ module TrueAutomation
10
10
  def start(options)
11
11
  @port = options[:port]
12
12
  remote = options[:remote]
13
+ recorder = options[:ta_recorder]
13
14
  ta_debug = options[:ta_debug]
14
15
 
15
16
  if options[:ta_service]
@@ -31,7 +32,7 @@ module TrueAutomation
31
32
  Dir.mkdir('log') unless File.exist?('log')
32
33
  logfile = "log/trueautomation-#{Time.now.strftime('%Y%m%dT%H%M%S')}.log"
33
34
 
34
- @pid = spawn("#{@executable} --log-file #{logfile} --port #{@port}#{driver_path}#{remote}#{ta_debug}")
35
+ @pid = spawn("#{@executable} --log-file #{logfile} --port #{@port}#{driver_path}#{remote}#{ta_debug}#{recorder}")
35
36
  puts "Started TrueAutomation.IO client with pid #{@pid} listening to port #{@port}"
36
37
 
37
38
  @pid
@@ -3,13 +3,13 @@ require_relative '../client'
3
3
  module TrueAutomation
4
4
  module Driver
5
5
  class AppiumLib < Appium::Core::Driver
6
- def initialize(*args)
6
+ def initialize(**opts)
7
7
  @ta_client = TrueAutomation::Client.new
8
8
  @remote = ''
9
- super
9
+ super(**opts)
10
10
  end
11
11
 
12
- def start_driver(*args)
12
+ def start_driver(**opts)
13
13
  @ta_client.start(port: @port,
14
14
  remote: @remote,
15
15
  ta_debug: @ta_debug,
@@ -20,7 +20,7 @@ module TrueAutomation
20
20
  at_exit do
21
21
  @ta_client.stop
22
22
  end
23
- super
23
+ super(**opts)
24
24
  end
25
25
  end
26
26
  end
@@ -68,6 +68,10 @@ module TrueAutomation
68
68
  class Capybara < Capybara::Selenium::Driver
69
69
  def initialize(app, **options)
70
70
  options = fetch_options(options)
71
+ if options[:browser].to_s != 'remote'
72
+ default_options = Selenium::WebDriver::Options.send(options[:browser] || :chrome)
73
+ end
74
+ options[:capabilities] ||= default_options
71
75
  @port = options.delete(:port) || find_available_port('localhost')
72
76
  @driver = options.delete(:driver)
73
77
  @driver_version = options.delete(:driver_version)
@@ -91,17 +95,11 @@ module TrueAutomation
91
95
 
92
96
  capabilities = options[:capabilities] || {}
93
97
 
94
- if options and options[:browser] == :remote
98
+ if options && options[:browser] == :remote
95
99
  raise 'Remote driver URL is not specified' unless options[:url]
96
- input_caps = options[:capabilities]&.as_json || {}
97
- input_caps = options[:capabilities]&.as_json || {}
98
- browser = opts_browser(options[:capabilities] || Selenium::WebDriver::Chrome::Capabilities.new)
99
- browser_class_name = browser.to_s.slice(0,1).capitalize + browser.to_s.slice(1..-1)
100
- capabilities = browser.to_s == 'remote' ?
101
- Selenium::WebDriver::Remote::Options.new :
102
- self.class.class_eval("Selenium::WebDriver::#{browser_class_name}::Options").send(browser)
103
- copy_options(capabilities, input_caps)
104
-
100
+ input_caps = opts_to_json(options[:capabilities]) || {}
101
+ browser = opts_browser(options[:capabilities] || Selenium::WebDriver::Options.chrome)
102
+ capabilities = options_class(browser).new(**input_caps)
105
103
  capabilities.add_preference(:taRemoteUrl, options[:url])
106
104
  @remote = ' --remote'
107
105
  end
@@ -118,7 +116,8 @@ module TrueAutomation
118
116
  ta_debug: @ta_debug,
119
117
  driver: @driver,
120
118
  ta_service_path: @ta_service&.executable_path,
121
- driver_version: @driver_version)
119
+ driver_version: @driver_version,
120
+ ta_recorder: @ta_recorder)
122
121
 
123
122
  @ta_client.wait_until_start
124
123
 
@@ -150,16 +149,34 @@ module TrueAutomation
150
149
 
151
150
  private
152
151
 
152
+ def options_class(browser)
153
+ browser.to_s == 'remote' ?
154
+ Selenium::WebDriver::Remote::Options :
155
+ eval("Selenium::WebDriver::#{browser_class_name(browser)}::Options")
156
+ end
157
+
158
+ def browser_class_name(browser)
159
+ browser.to_s.slice(0,1).capitalize + browser.to_s.slice(1..-1)
160
+ end
161
+
153
162
  def opts_browser(opts)
154
163
  opts.class.name.split('::')[2].downcase.to_sym
155
164
  end
156
165
 
166
+ def opts_to_json(opts)
167
+ opts.is_a?(Selenium::WebDriver::Options) ?
168
+ opts&.options :
169
+ opts&.as_json
170
+ end
171
+
157
172
  def fetch_options(options)
173
+ if options.delete(:ta_recorder)
174
+ @ta_recorder = ' --ta-recorder'
175
+ end
158
176
  if options.key?(:options)
159
177
  browser = opts_browser(options[:options])
160
- desCaps = Selenium::WebDriver::Remote::Capabilities.send(browser.downcase)
161
- opts = options[:options].as_json
162
- copy_options(desCaps, opts)
178
+ opts = opts_to_json(options[:options])
179
+ desCaps = options_class(browser).new(**opts)
163
180
  options[:capabilities] = desCaps
164
181
  options.delete(:options)
165
182
  end
@@ -169,7 +186,7 @@ module TrueAutomation
169
186
  def copy_options(caps, opts)
170
187
  # Add options to capabilities mapping if required
171
188
  opts.keys.each do |key|
172
- caps.add_preference(key, opts[key])
189
+ caps.add_option(key, opts[key])
173
190
  end
174
191
  end
175
192
 
@@ -1,3 +1,3 @@
1
1
  module TrueAutomation
2
- VERSION = '0.5.9'
2
+ VERSION = '0.6.0'
3
3
  end
@@ -29,6 +29,6 @@ Gem::Specification.new do |spec|
29
29
  spec.add_development_dependency 'minitest', '~> 5.0'
30
30
  spec.add_development_dependency 'rake', '~> 10.0'
31
31
  spec.add_development_dependency 'rspec', '~> 3.4'
32
- spec.add_development_dependency 'appium_lib', '~> 11.2'
33
- spec.add_development_dependency 'appium_lib_core', '~> 4.2'
32
+ spec.add_development_dependency 'appium_lib', '~> 12.2.2'
33
+ spec.add_development_dependency 'appium_lib_core', '~> 6.4.1'
34
34
  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.5.9
4
+ version: 0.6.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: 2023-05-17 00:00:00.000000000 Z
11
+ date: 2023-06-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -72,28 +72,28 @@ dependencies:
72
72
  requirements:
73
73
  - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: '11.2'
75
+ version: 12.2.2
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: '11.2'
82
+ version: 12.2.2
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: appium_lib_core
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
87
  - - "~>"
88
88
  - !ruby/object:Gem::Version
89
- version: '4.2'
89
+ version: 6.4.1
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
94
  - - "~>"
95
95
  - !ruby/object:Gem::Version
96
- version: '4.2'
96
+ version: 6.4.1
97
97
  description: " true_automation gem enables awesome TrueAutomation.IO features for
98
98
  Capybara and Watir projects.\n"
99
99
  email:
@@ -137,7 +137,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
137
137
  - !ruby/object:Gem::Version
138
138
  version: '0'
139
139
  requirements: []
140
- rubygems_version: 3.4.10
140
+ rubygems_version: 3.4.13
141
141
  signing_key:
142
142
  specification_version: 4
143
143
  summary: TrueAutomation.IO