webdrone 1.8.8 → 1.14.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/.rubocop.relaxed.yml +9 -1
- data/.rubocop.yml +12 -2
- data/.ruby-version +1 -1
- data/.tool-versions +1 -0
- data/.travis.yml +3 -2
- data/CHANGELOG.md +72 -0
- data/Gemfile +3 -0
- data/README.md +0 -2
- data/Rakefile +1 -1
- data/bin/console +1 -0
- data/bin/release-version +56 -0
- data/lib/webdrone.rb +4 -3
- data/lib/webdrone/browser.rb +16 -8
- data/lib/webdrone/clic.rb +1 -1
- data/lib/webdrone/conf.rb +3 -2
- data/lib/webdrone/ctxt.rb +34 -0
- data/lib/webdrone/error.rb +2 -1
- data/lib/webdrone/find.rb +7 -7
- data/lib/webdrone/form.rb +7 -7
- data/lib/webdrone/html.rb +1 -1
- data/lib/webdrone/logg.rb +4 -3
- data/lib/webdrone/mark.rb +1 -1
- data/lib/webdrone/text.rb +1 -1
- data/lib/webdrone/version.rb +1 -1
- data/lib/webdrone/vrfy.rb +2 -1
- data/lib/webdrone/xpath.rb +2 -2
- data/webdrone.gemspec +9 -6
- metadata +12 -22
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7e526be196c417ab71f06e9d08c199b86295ca3327b0b73c6aff13f8e7bf12f2
|
4
|
+
data.tar.gz: 4d128b76393382af9908f48ad8967a3dc8d41f4c619ee70673053b1bf1b2dbc2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1306f0537f417e66c279512c5952dd8be5487aee66fa33cf40c42e6e0a69bf36af62a96a41c834ec191fe2b8be0544f5c279f2e24d19f07e0f9b77d1365b351b
|
7
|
+
data.tar.gz: d9366338f341cffbdbc4059a9e2c3676e65af01078cfa838d1e00ca8862cddda2e7274335e5b55ef8c95917f93102aa6018b92d40d96ef9d6dc24f6e3cfb2189
|
data/.rubocop.relaxed.yml
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
# Relaxed.Ruby.Style
|
2
|
-
## Version 2.
|
2
|
+
## Version 2.4
|
3
3
|
|
4
4
|
Style/Alias:
|
5
5
|
Enabled: false
|
@@ -65,6 +65,10 @@ Style/NegatedWhile:
|
|
65
65
|
Enabled: false
|
66
66
|
StyleGuide: https://relaxed.ruby.style/#stylenegatedwhile
|
67
67
|
|
68
|
+
Style/NumericPredicate:
|
69
|
+
Enabled: false
|
70
|
+
StyleGuide: https://relaxed.ruby.style/#stylenumericpredicate
|
71
|
+
|
68
72
|
Style/ParallelAssignment:
|
69
73
|
Enabled: false
|
70
74
|
StyleGuide: https://relaxed.ruby.style/#styleparallelassignment
|
@@ -121,6 +125,10 @@ Style/TrailingCommaInHashLiteral:
|
|
121
125
|
Enabled: false
|
122
126
|
StyleGuide: https://relaxed.ruby.style/#styletrailingcommainhashliteral
|
123
127
|
|
128
|
+
Style/SymbolArray:
|
129
|
+
Enabled: false
|
130
|
+
StyleGuide: http://relaxed.ruby.style/#stylesymbolarray
|
131
|
+
|
124
132
|
Style/WhileUntilModifier:
|
125
133
|
Enabled: false
|
126
134
|
StyleGuide: https://relaxed.ruby.style/#stylewhileuntilmodifier
|
data/.rubocop.yml
CHANGED
@@ -1,8 +1,18 @@
|
|
1
1
|
AllCops:
|
2
|
-
TargetRubyVersion: 2.
|
2
|
+
TargetRubyVersion: 2.6
|
3
3
|
inherit_from:
|
4
4
|
- .rubocop.relaxed.yml
|
5
|
-
Naming/
|
5
|
+
Naming/MethodParameterName:
|
6
6
|
Enabled: false
|
7
7
|
Style/AccessModifierDeclarations:
|
8
8
|
Enabled: false
|
9
|
+
Naming/RescuedExceptionsVariableName:
|
10
|
+
Enabled: false
|
11
|
+
Metrics/BlockLength:
|
12
|
+
Max: 50
|
13
|
+
Style/Attr:
|
14
|
+
Exclude:
|
15
|
+
- lib/webdrone/xpath.rb
|
16
|
+
Lint/DuplicateMethods:
|
17
|
+
Exclude:
|
18
|
+
- lib/webdrone/xpath.rb
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
ruby-2.
|
1
|
+
ruby-2.6.4
|
data/.tool-versions
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
ruby 2.7.2
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -4,6 +4,78 @@ New features are summarized here.
|
|
4
4
|
|
5
5
|
|
6
6
|
|
7
|
+
## v.1.12.2 - 2021-03-19
|
8
|
+
### Changed
|
9
|
+
- New option for logger: :quiet that supress the normal stdout log, but not the log sent to webdrone_output dir.
|
10
|
+
```ruby
|
11
|
+
a0 = Webdrone.create logger: :quiet
|
12
|
+
```
|
13
|
+
|
14
|
+
|
15
|
+
|
16
|
+
## v.1.12.0 - 2019-12-04
|
17
|
+
### Added
|
18
|
+
- Added a new a0.conf.parent option, so instead of setting `parent:` in every method like:
|
19
|
+
```ruby
|
20
|
+
modal = a0.find.css '.modal-dialog'
|
21
|
+
|
22
|
+
a0.form.set 'field', 'value', parent: modal
|
23
|
+
a0.clic.on 'button', parent: modal
|
24
|
+
```
|
25
|
+
you can setup a default parent from now on with `a0.conf.parent=` like:
|
26
|
+
```ruby
|
27
|
+
a0.conf.parent = a0.find.css '.modal-dialog'
|
28
|
+
|
29
|
+
a0.form.set 'field', 'value' # uses a0.conf.parent as default parent
|
30
|
+
a0.clic.on 'button'
|
31
|
+
|
32
|
+
a0.conf.parent = nil # resets default parent
|
33
|
+
```
|
34
|
+
- Added the following methods to `a0.ctxt`:
|
35
|
+
- `a0.ctxt.id`
|
36
|
+
- `a0.ctxt.css`
|
37
|
+
- `a0.ctxt.link`
|
38
|
+
- `a0.ctxt.button`
|
39
|
+
- `a0.ctxt.on`
|
40
|
+
- `a0.ctxt.option`
|
41
|
+
- `a0.ctxt.xpath`
|
42
|
+
|
43
|
+
So instead of code like the above, we can use give a block of code to automatically switch in a stack of parents like:
|
44
|
+
```ruby
|
45
|
+
a0.ctxt.css '.modal-dialog' do
|
46
|
+
# sets a0.conf.parent = the found .modal-dialog
|
47
|
+
a0.form.set 'field', 'value'
|
48
|
+
a0.clic.on 'button'
|
49
|
+
|
50
|
+
a0.ctxt.css '.modal-footer' do
|
51
|
+
# sets a0.conf.parent to the found .modal-footer within the previous .modal-dialog
|
52
|
+
end
|
53
|
+
# sets a0.conf.parent back to the found .modal-dialog
|
54
|
+
end
|
55
|
+
# sets a0.conf.parent back to nil (the default) or whatever it was before calling a0.ctxt.css
|
56
|
+
```
|
57
|
+
|
58
|
+
|
59
|
+
|
60
|
+
## v.1.10.0
|
61
|
+
### Fixed
|
62
|
+
- Warnings for chrome and firefox
|
63
|
+
|
64
|
+
|
65
|
+
|
66
|
+
## v.1.8.12 - 2019-02-22
|
67
|
+
### Fixed
|
68
|
+
- Fixing null terminal column size when used without a terminal, caused by highlight 2.0.1.
|
69
|
+
- Fixing maximizing start for chrome.
|
70
|
+
|
71
|
+
|
72
|
+
|
73
|
+
## v.1.8.10 - 2018-12-28
|
74
|
+
### Fixed
|
75
|
+
- headless can be overriden from environment, for ex: export WEBDRONE_HEADLESS=false
|
76
|
+
|
77
|
+
|
78
|
+
|
7
79
|
## v.1.8.8 - 2018-10-26
|
8
80
|
### Fixed
|
9
81
|
- Fixing `a0.clic` wasn't taking screenshots when passed both `mark: true` and `shot: true`.
|
data/Gemfile
CHANGED
data/README.md
CHANGED
data/Rakefile
CHANGED
data/bin/console
CHANGED
data/bin/release-version
ADDED
@@ -0,0 +1,56 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
path = File.realpath File.join(__dir__, '../lib/webdrone/version.rb')
|
5
|
+
load path
|
6
|
+
|
7
|
+
current = Webdrone::VERSION
|
8
|
+
numbers = current.split('.').map(&:to_i)
|
9
|
+
length = numbers.count
|
10
|
+
|
11
|
+
versions = length.times.map do |index|
|
12
|
+
version = numbers.dup
|
13
|
+
version[index] += index.zero? ? 1 : 2
|
14
|
+
index += 1
|
15
|
+
(index...length).each do |i|
|
16
|
+
version[i] = 0
|
17
|
+
end
|
18
|
+
version.join '.'
|
19
|
+
end.reverse
|
20
|
+
|
21
|
+
text = versions.each_with_index.map do |version, index|
|
22
|
+
"#{index + 1}. #{version}"
|
23
|
+
end.join("\n")
|
24
|
+
|
25
|
+
puts <<~FIN
|
26
|
+
|
27
|
+
Version file: #{path}
|
28
|
+
|
29
|
+
Current version: #{current}. Choose next version:
|
30
|
+
#{text}
|
31
|
+
|
32
|
+
FIN
|
33
|
+
|
34
|
+
print 'Choose? [1]'
|
35
|
+
option = gets.strip
|
36
|
+
|
37
|
+
index = option == '' ? 0 : option.to_i - 1
|
38
|
+
version = versions[index]
|
39
|
+
raise "Invalid option #{option}" unless version
|
40
|
+
|
41
|
+
`ruby -p -i -e 'gsub /#{current}/,"#{version}"' #{path}`
|
42
|
+
puts `bundle; git add #{path} Gemfile.lock; git commit -m "Version #{version}."; git tag v#{version}`
|
43
|
+
|
44
|
+
puts <<~FIN
|
45
|
+
|
46
|
+
Press enter to git push or CTRL+C to cancel
|
47
|
+
|
48
|
+
FIN
|
49
|
+
|
50
|
+
print 'git push origin master --tags'
|
51
|
+
gets
|
52
|
+
puts `git push origin master --tags`
|
53
|
+
|
54
|
+
puts 'rake release'
|
55
|
+
gets
|
56
|
+
puts `rake release`
|
data/lib/webdrone.rb
CHANGED
@@ -53,8 +53,9 @@ module Webdrone
|
|
53
53
|
end
|
54
54
|
|
55
55
|
def self.irb_console(binding = nil)
|
56
|
-
puts
|
56
|
+
puts 'Webdrone: Webdrone.irb_console IS DEPRECATED, please use a0.console instead.'
|
57
57
|
return if IRB.CurrentContext && !binding
|
58
|
+
|
58
59
|
binding ||= Kernel.binding.of_caller(1)
|
59
60
|
IRB.start_session(binding)
|
60
61
|
end
|
@@ -62,7 +63,7 @@ module Webdrone
|
|
62
63
|
Webdrone.running_pry = false
|
63
64
|
def self.pry_console(binding = nil)
|
64
65
|
if Webdrone.running_pry
|
65
|
-
puts
|
66
|
+
puts 'Webdrone: pry console already running.'
|
66
67
|
else
|
67
68
|
Webdrone.running_pry = true
|
68
69
|
binding ||= Kernel.binding.of_caller(1)
|
@@ -91,7 +92,7 @@ module IRB
|
|
91
92
|
@CONF[:IRB_RC]&.call(irb.context)
|
92
93
|
@CONF[:MAIN_CONTEXT] = irb.context
|
93
94
|
|
94
|
-
trap(
|
95
|
+
trap('SIGINT') do
|
95
96
|
irb.signal_handle
|
96
97
|
end
|
97
98
|
|
data/lib/webdrone/browser.rb
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require 'English'
|
4
|
+
|
3
5
|
module Webdrone
|
4
6
|
class Browser
|
5
7
|
attr_reader :driver
|
@@ -14,7 +16,7 @@ module Webdrone
|
|
14
16
|
@firefox_profile['startup.homepage_welcome_url.additional'] = 'about:blank'
|
15
17
|
@firefox_profile['browser.download.folderList'] = 2
|
16
18
|
@firefox_profile['browser.download.manager.showWhenStarting'] = false
|
17
|
-
@firefox_profile['browser.helperApps.neverAsk.saveToDisk'] =
|
19
|
+
@firefox_profile['browser.helperApps.neverAsk.saveToDisk'] = 'images/jpeg, application/pdf, application/octet-stream, application/download'
|
18
20
|
|
19
21
|
@firefox_profile
|
20
22
|
end
|
@@ -42,7 +44,7 @@ module Webdrone
|
|
42
44
|
env_update(Kernel.binding) if use_env
|
43
45
|
|
44
46
|
if create_outdir || outdir
|
45
|
-
outdir ||= File.join(
|
47
|
+
outdir ||= File.join('webdrone_output', Time.new.strftime('%Y%m%d_%H%M%S'))
|
46
48
|
conf.outdir = outdir
|
47
49
|
end
|
48
50
|
outdir = File.join(Dir.pwd, outdir) if !outdir.nil? && !Pathname.new(outdir).absolute?
|
@@ -54,15 +56,20 @@ module Webdrone
|
|
54
56
|
chrome_options.add_preference 'download.default_directory', outdir
|
55
57
|
chrome_options.add_argument '--disable-popup-blocking'
|
56
58
|
chrome_options.add_argument '--headless' if headless
|
57
|
-
|
59
|
+
chrome_options.add_argument '--start-maximized' if maximize
|
60
|
+
maximize = false
|
61
|
+
|
62
|
+
service = Selenium::WebDriver::Service.chrome(args: { log_path: "/tmp/chromedriver.#{$PID}.log", verbose: true })
|
63
|
+
@driver = Selenium::WebDriver.for browser.to_sym, options: chrome_options, service: service
|
58
64
|
elsif !outdir.nil? && browser.to_sym == :firefox
|
59
65
|
firefox_options ||= Browser.firefox_options
|
60
66
|
firefox_profile ||= Browser.firefox_profile
|
61
67
|
|
62
68
|
firefox_options.add_argument '-headless' if headless
|
63
|
-
downdir = OS.windows? ? outdir.tr(
|
69
|
+
downdir = OS.windows? ? outdir.tr('/', '\\') : outdir
|
64
70
|
firefox_profile['browser.download.dir'] = downdir
|
65
|
-
|
71
|
+
firefox_options.profile = firefox_profile
|
72
|
+
@driver = Selenium::WebDriver.for browser.to_sym, options: firefox_options
|
66
73
|
else
|
67
74
|
@driver = Selenium::WebDriver.for browser.to_sym
|
68
75
|
end
|
@@ -121,6 +128,7 @@ module Webdrone
|
|
121
128
|
|
122
129
|
def console(binding = nil)
|
123
130
|
return unless conf.developer
|
131
|
+
|
124
132
|
binding ||= Kernel.binding.of_caller(1)
|
125
133
|
old_error = conf.error
|
126
134
|
old_developer = conf.developer
|
@@ -137,9 +145,9 @@ module Webdrone
|
|
137
145
|
protected
|
138
146
|
|
139
147
|
def env_update_bool(binding, var, val_old, val_new)
|
140
|
-
if val_new ==
|
148
|
+
if val_new == 'true'
|
141
149
|
val_new = true
|
142
|
-
elsif val_new ==
|
150
|
+
elsif val_new == 'false'
|
143
151
|
val_new = false
|
144
152
|
else
|
145
153
|
puts "Webdrone: ignoring value '#{val_new}' for boolean parameter #{var}."
|
@@ -150,7 +158,7 @@ module Webdrone
|
|
150
158
|
end
|
151
159
|
|
152
160
|
def env_update(binding)
|
153
|
-
bool_vars = %i[create_outdir developer quit_at_exit maximize]
|
161
|
+
bool_vars = %i[create_outdir developer quit_at_exit maximize headless]
|
154
162
|
ENV.keys.select { |env| env.start_with? 'WEBDRONE_' }.each do |env|
|
155
163
|
var = env[9..-1].downcase.to_sym
|
156
164
|
if binding.local_variable_defined? var
|
data/lib/webdrone/clic.rb
CHANGED
@@ -14,7 +14,7 @@ module Webdrone
|
|
14
14
|
@a0 = a0
|
15
15
|
end
|
16
16
|
|
17
|
-
def clic(text, n: 1, all: false, visible: true, scroll: false, parent:
|
17
|
+
def clic(text, n: 1, all: false, visible: true, scroll: false, parent: a0.conf.parent, color: '#af1616', times: nil, delay: nil, shot: nil, mark: false)
|
18
18
|
item = @a0.find.send __callee__, text, n: n, all: all, visible: visible, scroll: scroll, parent: parent
|
19
19
|
@a0.mark.mark_item(item, color: color, times: times, delay: delay, shot: shot, text: text) if mark
|
20
20
|
@a0.shot.screen shot.is_a?(String) ? shot : text if shot
|
data/lib/webdrone/conf.rb
CHANGED
@@ -8,7 +8,7 @@ module Webdrone
|
|
8
8
|
end
|
9
9
|
|
10
10
|
class Conf
|
11
|
-
attr_accessor :developer, :logger
|
11
|
+
attr_accessor :developer, :logger, :parent
|
12
12
|
attr_reader :a0, :timeout, :outdir, :error
|
13
13
|
|
14
14
|
def initialize(a0)
|
@@ -32,7 +32,8 @@ module Webdrone
|
|
32
32
|
end
|
33
33
|
|
34
34
|
def error=(val)
|
35
|
-
raise "Invalid value '#{val}' for error"
|
35
|
+
raise "Invalid value '#{val}' for error" unless %i[raise_report raise ignore].include? val
|
36
|
+
|
36
37
|
@error = val
|
37
38
|
rescue StandardError => error
|
38
39
|
Webdrone.report_error(@a0, error)
|
data/lib/webdrone/ctxt.rb
CHANGED
@@ -13,6 +13,7 @@ module Webdrone
|
|
13
13
|
def initialize(a0)
|
14
14
|
@a0 = a0
|
15
15
|
@framestack = []
|
16
|
+
@parent_stack = []
|
16
17
|
end
|
17
18
|
|
18
19
|
def create_tab
|
@@ -83,5 +84,38 @@ module Webdrone
|
|
83
84
|
@a0.conf.send "#{k}=", v
|
84
85
|
end
|
85
86
|
end
|
87
|
+
|
88
|
+
def ctxt(text, n: 1, visible: true, scroll: false, parent: @a0.conf.parent, color: '#3db116', times: nil, delay: nil, shot: nil, mark: true)
|
89
|
+
item = @a0.find.send __callee__, text, n: n, all: false, visible: visible, scroll: scroll, parent: parent
|
90
|
+
@a0.mark.mark_item(item, color: color, times: times, delay: delay, shot: shot, text: text) if mark
|
91
|
+
@a0.shot.screen shot.is_a?(String) ? shot : text if shot
|
92
|
+
|
93
|
+
@parent_stack << @a0.conf.parent
|
94
|
+
@a0.conf.parent = item
|
95
|
+
|
96
|
+
if block_given?
|
97
|
+
begin
|
98
|
+
yield
|
99
|
+
ensure
|
100
|
+
parent_pop
|
101
|
+
end
|
102
|
+
end
|
103
|
+
rescue StandardError => error
|
104
|
+
Webdrone.report_error(@a0, error)
|
105
|
+
end
|
106
|
+
|
107
|
+
def parent_pop
|
108
|
+
@a0.conf.parent = @parent_stack.pop
|
109
|
+
end
|
110
|
+
|
111
|
+
alias_method :id, :ctxt
|
112
|
+
alias_method :css, :ctxt
|
113
|
+
alias_method :link, :ctxt
|
114
|
+
alias_method :button, :ctxt
|
115
|
+
alias_method :on, :ctxt
|
116
|
+
alias_method :option, :ctxt
|
117
|
+
alias_method :xpath, :ctxt
|
118
|
+
|
119
|
+
protected :ctxt
|
86
120
|
end
|
87
121
|
end
|
data/lib/webdrone/error.rb
CHANGED
@@ -65,7 +65,7 @@ module Webdrone
|
|
65
65
|
ini = 0 if ini.negative?
|
66
66
|
|
67
67
|
write_title "LOCATION OF ERROR"
|
68
|
-
write_line "#{@location[:path]} AT LINE #{sprintf '
|
68
|
+
write_line "#{@location[:path]} AT LINE #{sprintf '%<location>3d', location: @location[:lineno]}"
|
69
69
|
File.readlines(@location[:path])[ini..fin].each_with_index do |line, index|
|
70
70
|
lno = index + ini + 1
|
71
71
|
if lno == @location[:lineno]
|
@@ -133,6 +133,7 @@ module Webdrone
|
|
133
133
|
|
134
134
|
def self.report_error(a0, exception)
|
135
135
|
return if a0.conf.error == :ignore
|
136
|
+
|
136
137
|
if exception.class != WebdroneError
|
137
138
|
exception = WebdroneError.new(exception.message, exception, a0, Kernel.binding.callers)
|
138
139
|
if a0.conf.developer && exception.binding
|
data/lib/webdrone/find.rb
CHANGED
@@ -14,7 +14,7 @@ module Webdrone
|
|
14
14
|
@a0 = a0
|
15
15
|
end
|
16
16
|
|
17
|
-
def id(text, n: 1, all: false, visible: true, scroll: false, parent:
|
17
|
+
def id(text, n: 1, all: false, visible: true, scroll: false, parent: a0.conf.parent)
|
18
18
|
@a0.wait.for do
|
19
19
|
items = (parent || @a0.driver).find_elements :id, text
|
20
20
|
choose(items, n, all, visible, scroll)
|
@@ -23,7 +23,7 @@ module Webdrone
|
|
23
23
|
Webdrone.report_error(@a0, error)
|
24
24
|
end
|
25
25
|
|
26
|
-
def css(text, n: 1, all: false, visible: true, scroll: false, parent:
|
26
|
+
def css(text, n: 1, all: false, visible: true, scroll: false, parent: a0.conf.parent)
|
27
27
|
@a0.wait.for do
|
28
28
|
items = (parent || @a0.driver).find_elements :css, text
|
29
29
|
choose(items, n, all, visible, scroll)
|
@@ -32,31 +32,31 @@ module Webdrone
|
|
32
32
|
Webdrone.report_error(@a0, error)
|
33
33
|
end
|
34
34
|
|
35
|
-
def link(text, n: 1, all: false, visible: true, scroll: false, parent:
|
35
|
+
def link(text, n: 1, all: false, visible: true, scroll: false, parent: a0.conf.parent)
|
36
36
|
xpath Webdrone::XPath.link(text).to_s, n: n, all: all, visible: visible, scroll: scroll, parent: parent
|
37
37
|
rescue StandardError => error
|
38
38
|
Webdrone.report_error(@a0, error)
|
39
39
|
end
|
40
40
|
|
41
|
-
def button(text, n: 1, all: false, visible: true, scroll: false, parent:
|
41
|
+
def button(text, n: 1, all: false, visible: true, scroll: false, parent: a0.conf.parent)
|
42
42
|
xpath Webdrone::XPath.button(text).to_s, n: n, all: all, visible: visible, scroll: scroll, parent: parent
|
43
43
|
rescue StandardError => error
|
44
44
|
Webdrone.report_error(@a0, error)
|
45
45
|
end
|
46
46
|
|
47
|
-
def on(text, n: 1, all: false, visible: true, scroll: false, parent:
|
47
|
+
def on(text, n: 1, all: false, visible: true, scroll: false, parent: a0.conf.parent)
|
48
48
|
xpath Webdrone::XPath.link_or_button(text).to_s, n: n, all: all, visible: visible, scroll: scroll, parent: parent
|
49
49
|
rescue StandardError => error
|
50
50
|
Webdrone.report_error(@a0, error)
|
51
51
|
end
|
52
52
|
|
53
|
-
def option(text, n: 1, all: false, visible: true, scroll: false, parent:
|
53
|
+
def option(text, n: 1, all: false, visible: true, scroll: false, parent: a0.conf.parent)
|
54
54
|
xpath Webdrone::XPath.option(text).to_s, n: n, all: all, visible: visible, scroll: scroll, parent: parent
|
55
55
|
rescue StandardError => error
|
56
56
|
Webdrone.report_error(@a0, error)
|
57
57
|
end
|
58
58
|
|
59
|
-
def xpath(text, n: 1, all: false, visible: true, scroll: false, parent:
|
59
|
+
def xpath(text, n: 1, all: false, visible: true, scroll: false, parent: a0.conf.parent)
|
60
60
|
@a0.wait.for do
|
61
61
|
items = (parent || @a0.driver).find_elements :xpath, text
|
62
62
|
choose(items, n, all, visible, scroll)
|
data/lib/webdrone/form.rb
CHANGED
@@ -90,7 +90,7 @@ module Webdrone
|
|
90
90
|
@data = prev
|
91
91
|
end
|
92
92
|
|
93
|
-
def set(key, val, n: 1, visible: true, scroll: false, parent:
|
93
|
+
def set(key, val, n: 1, visible: true, scroll: false, parent: a0.conf.parent, mark: false)
|
94
94
|
item = find_item(key, n: n, visible: visible, scroll: scroll, parent: parent)
|
95
95
|
@a0.mark.mark_item item if mark
|
96
96
|
if item.tag_name == 'select'
|
@@ -114,7 +114,7 @@ module Webdrone
|
|
114
114
|
Webdrone.report_error(@a0, error)
|
115
115
|
end
|
116
116
|
|
117
|
-
def get(key, n: 1, visible: true, scroll: false, parent:
|
117
|
+
def get(key, n: 1, visible: true, scroll: false, parent: a0.conf.parent, mark: false)
|
118
118
|
item = find_item(key, n: n, visible: visible, scroll: scroll, parent: parent)
|
119
119
|
@a0.mark.mark_item item if mark
|
120
120
|
item[:value]
|
@@ -122,7 +122,7 @@ module Webdrone
|
|
122
122
|
Webdrone.report_error(@a0, error)
|
123
123
|
end
|
124
124
|
|
125
|
-
def clic(key, n: 1, visible: true, scroll: false, parent:
|
125
|
+
def clic(key, n: 1, visible: true, scroll: false, parent: a0.conf.parent, mark: false)
|
126
126
|
item = find_item(key, n: n, visible: visible, scroll: scroll, parent: parent)
|
127
127
|
@a0.mark.mark_item item if mark
|
128
128
|
item.click
|
@@ -130,7 +130,7 @@ module Webdrone
|
|
130
130
|
Webdrone.report_error(@a0, error)
|
131
131
|
end
|
132
132
|
|
133
|
-
def selected?(key, n: 1, visible: true, scroll: false, parent:
|
133
|
+
def selected?(key, n: 1, visible: true, scroll: false, parent: a0.conf.parent, mark: false)
|
134
134
|
item = find_item(key, n: n, visible: visible, scroll: scroll, parent: parent)
|
135
135
|
@a0.mark.mark_item item if mark
|
136
136
|
item.selected?
|
@@ -138,13 +138,13 @@ module Webdrone
|
|
138
138
|
Webdrone.report_error(@a0, error)
|
139
139
|
end
|
140
140
|
|
141
|
-
def mark(key, n: 1, visible: true, scroll: false, parent:
|
141
|
+
def mark(key, n: 1, visible: true, scroll: false, parent: a0.conf.parent, color: '#af1616', times: nil, delay: nil, shot: nil)
|
142
142
|
@a0.mark.mark_item find_item(key, n: n, visible: visible, scroll: scroll, parent: parent), color: color, times: times, delay: delay, shot: shot
|
143
143
|
rescue StandardError => error
|
144
144
|
Webdrone.report_error(@a0, error)
|
145
145
|
end
|
146
146
|
|
147
|
-
def submit(key = nil, n: 1, visible: true, scroll: false, parent:
|
147
|
+
def submit(key = nil, n: 1, visible: true, scroll: false, parent: a0.conf.parent, mark: false)
|
148
148
|
item = find_item(key, n: n, visible: visible, scroll: scroll, parent: parent) if key
|
149
149
|
@a0.mark.mark_item item if mark
|
150
150
|
@lastitem.submit
|
@@ -160,7 +160,7 @@ module Webdrone
|
|
160
160
|
Webdrone.report_error(@a0, error)
|
161
161
|
end
|
162
162
|
|
163
|
-
def find_item(key, n: 1, visible: true, scroll: false, parent:
|
163
|
+
def find_item(key, n: 1, visible: true, scroll: false, parent: a0.conf.parent)
|
164
164
|
@lastitem = \
|
165
165
|
if @xpath.respond_to? :call
|
166
166
|
@a0.find.xpath @xpath.call(key).to_s, n: n, visible: visible, scroll: scroll, parent: parent
|
data/lib/webdrone/html.rb
CHANGED
@@ -14,7 +14,7 @@ module Webdrone
|
|
14
14
|
@a0 = a0
|
15
15
|
end
|
16
16
|
|
17
|
-
def find_html(text, n: 1, all: false, visible: true, scroll: false, parent:
|
17
|
+
def find_html(text, n: 1, all: false, visible: true, scroll: false, parent: a0.conf.parent)
|
18
18
|
item = @a0.find.send __callee__, text, n: n, all: all, visible: visible, scroll: scroll, parent: parent
|
19
19
|
if item.is_a? Array
|
20
20
|
item.collect { |x| x.attribute 'innerHTML' }
|
data/lib/webdrone/logg.rb
CHANGED
@@ -60,7 +60,7 @@ module Webdrone
|
|
60
60
|
|
61
61
|
def trace(ini, fin, from, lineno, base, method_name, args, result, exception, screenshot)
|
62
62
|
exception = "#{exception.class}: #{exception}" if exception
|
63
|
-
printf @format, (fin - ini), base, method_name, args, (result || exception)
|
63
|
+
printf @format, (fin - ini), base, method_name, args, (result || exception) unless a0.conf.logger.to_s == 'quiet'
|
64
64
|
CSV.open(@path, "a+") do |csv|
|
65
65
|
csv << [ini.strftime('%Y-%m-%d %H:%M:%S.%L %z'), (fin - ini), from, lineno, base, method_name, args, result, exception, screenshot]
|
66
66
|
end
|
@@ -101,9 +101,10 @@ module Webdrone
|
|
101
101
|
def setup_format
|
102
102
|
begin
|
103
103
|
cols, _line = HighLine.default_instance.terminal.terminal_size
|
104
|
-
rescue StandardError
|
105
|
-
|
104
|
+
rescue StandardError => error
|
105
|
+
puts "ignoring error: #{error}"
|
106
106
|
end
|
107
|
+
cols ||= 120
|
107
108
|
total = 6 + 15 + 11 + 5
|
108
109
|
w = cols - total
|
109
110
|
w /= 2
|
data/lib/webdrone/mark.rb
CHANGED
@@ -18,7 +18,7 @@ module Webdrone
|
|
18
18
|
@clear = ENV['WEBDRONE_MARK_CLEAR'] == 'true' || false
|
19
19
|
end
|
20
20
|
|
21
|
-
def mark(text, n: 1, all: false, visible: true, scroll: false, parent:
|
21
|
+
def mark(text, n: 1, all: false, visible: true, scroll: false, parent: a0.conf.parent, color: '#af1616', times: nil, delay: nil, shot: nil)
|
22
22
|
item = @a0.find.send __callee__, text, n: n, all: all, visible: visible, scroll: scroll, parent: parent
|
23
23
|
mark_item item, color: color, times: times, delay: delay, shot: shot, text: text
|
24
24
|
rescue StandardError => error
|
data/lib/webdrone/text.rb
CHANGED
@@ -14,7 +14,7 @@ module Webdrone
|
|
14
14
|
@a0 = a0
|
15
15
|
end
|
16
16
|
|
17
|
-
def text(text, n: 1, all: false, visible: true, scroll: false, parent:
|
17
|
+
def text(text, n: 1, all: false, visible: true, scroll: false, parent: a0.conf.parent)
|
18
18
|
item = @a0.find.send __callee__, text, n: n, all: all, visible: visible, scroll: scroll, parent: parent
|
19
19
|
if item.is_a? Array
|
20
20
|
item.collect(&:text)
|
data/lib/webdrone/version.rb
CHANGED
data/lib/webdrone/vrfy.rb
CHANGED
@@ -14,7 +14,7 @@ module Webdrone
|
|
14
14
|
@a0 = a0
|
15
15
|
end
|
16
16
|
|
17
|
-
def vrfy(text, n: 1, all: false, visible: true, scroll: false, parent:
|
17
|
+
def vrfy(text, n: 1, all: false, visible: true, scroll: false, parent: a0.conf.parent, attr: nil, eq: nil, contains: nil, mark: false)
|
18
18
|
item = @a0.find.send __callee__, text, n: n, all: all, visible: visible, scroll: scroll, parent: parent
|
19
19
|
@a0.mark.mark_item item if mark
|
20
20
|
if item.is_a? Array
|
@@ -42,6 +42,7 @@ module Webdrone
|
|
42
42
|
targ = "contains: [#{contains}]" if contains
|
43
43
|
|
44
44
|
raise "VRFY: #{callee} [#{text}] text value [#{item.text}] does not comply #{targ}" if attr.nil?
|
45
|
+
|
45
46
|
raise "VRFY: #{callee} [#{text}] attr [#{attr}] value [#{item.attribute(attr)}] does not comply #{targ}"
|
46
47
|
end
|
47
48
|
|
data/lib/webdrone/xpath.rb
CHANGED
@@ -27,7 +27,7 @@ module Webdrone
|
|
27
27
|
locator = locator.to_s
|
28
28
|
button = descendant(:input)[attr(:type).one_of('submit', 'reset', 'image', 'button')][attr(:id).equals(locator) | attr(:value).is(locator) | attr(:title).is(locator)]
|
29
29
|
button += descendant(:button)[attr(:id).equals(locator) | attr(:value).is(locator) | string.n.is(locator) | attr(:title).is(locator)]
|
30
|
-
button
|
30
|
+
button + descendant(:input)[attr(:type).equals('image')][attr(:alt).is(locator)]
|
31
31
|
end
|
32
32
|
|
33
33
|
# Match anything returned by either {#link} or {#button}.
|
@@ -154,7 +154,7 @@ module Webdrone
|
|
154
154
|
# Id of the 'dd' element or text from preciding 'dt' element content
|
155
155
|
def definition_description(locator)
|
156
156
|
locator = locator.to_s
|
157
|
-
descendant(:dd)[attr(:id).equals(locator) | previous_sibling(:dt)[string.n.equals(locator)]
|
157
|
+
descendant(:dd)[attr(:id).equals(locator) | previous_sibling(:dt)[string.n.equals(locator)]]
|
158
158
|
end
|
159
159
|
|
160
160
|
protected
|
data/webdrone.gemspec
CHANGED
@@ -1,6 +1,4 @@
|
|
1
|
-
|
2
|
-
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
-
require 'webdrone/version'
|
1
|
+
require_relative 'lib/webdrone/version'
|
4
2
|
|
5
3
|
Gem::Specification.new do |spec|
|
6
4
|
spec.name = 'webdrone'
|
@@ -12,11 +10,17 @@ Gem::Specification.new do |spec|
|
|
12
10
|
spec.description = 'See webpage for more info.'
|
13
11
|
spec.homepage = 'http://github.com/a0/a0-webdrone-ruby'
|
14
12
|
spec.license = 'MIT'
|
13
|
+
spec.required_ruby_version = Gem::Requirement.new('>= 2.3.0')
|
15
14
|
|
16
15
|
# Prevent pushing this gem to RubyGems.org by setting 'allowed_push_host', or
|
17
16
|
# delete this section to allow pushing this gem to any host.
|
18
|
-
raise
|
19
|
-
|
17
|
+
raise 'RubyGems 2.0 or newer is required to protect against public gem pushes.' unless spec.respond_to?(:metadata)
|
18
|
+
|
19
|
+
spec.metadata['allowed_push_host'] = 'https://rubygems.org'
|
20
|
+
|
21
|
+
spec.metadata['homepage_uri'] = spec.homepage
|
22
|
+
spec.metadata['source_code_uri'] = 'http://github.com/a0/a0-webdrone-ruby'
|
23
|
+
spec.metadata['changelog_uri'] = 'http://github.com/a0/a0-webdrone-ruby/CHANGELOG.md'
|
20
24
|
|
21
25
|
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
22
26
|
spec.bindir = 'exe'
|
@@ -29,7 +33,6 @@ Gem::Specification.new do |spec|
|
|
29
33
|
spec.add_development_dependency 'rake'
|
30
34
|
spec.add_development_dependency 'rspec'
|
31
35
|
spec.add_development_dependency 'rubocop'
|
32
|
-
spec.add_development_dependency 'solargraph'
|
33
36
|
|
34
37
|
spec.add_runtime_dependency 'binding_of_caller'
|
35
38
|
spec.add_runtime_dependency 'highline', '>= 2.0.0'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: webdrone
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.14.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Aldrin Martoq
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-03-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -94,20 +94,6 @@ dependencies:
|
|
94
94
|
- - ">="
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '0'
|
97
|
-
- !ruby/object:Gem::Dependency
|
98
|
-
name: solargraph
|
99
|
-
requirement: !ruby/object:Gem::Requirement
|
100
|
-
requirements:
|
101
|
-
- - ">="
|
102
|
-
- !ruby/object:Gem::Version
|
103
|
-
version: '0'
|
104
|
-
type: :development
|
105
|
-
prerelease: false
|
106
|
-
version_requirements: !ruby/object:Gem::Requirement
|
107
|
-
requirements:
|
108
|
-
- - ">="
|
109
|
-
- !ruby/object:Gem::Version
|
110
|
-
version: '0'
|
111
97
|
- !ruby/object:Gem::Dependency
|
112
98
|
name: binding_of_caller
|
113
99
|
requirement: !ruby/object:Gem::Requirement
|
@@ -219,6 +205,7 @@ files:
|
|
219
205
|
- ".rubocop.yml"
|
220
206
|
- ".ruby-gemset"
|
221
207
|
- ".ruby-version"
|
208
|
+
- ".tool-versions"
|
222
209
|
- ".travis.yml"
|
223
210
|
- CHANGELOG.md
|
224
211
|
- Gemfile
|
@@ -226,6 +213,7 @@ files:
|
|
226
213
|
- README.md
|
227
214
|
- Rakefile
|
228
215
|
- bin/console
|
216
|
+
- bin/release-version
|
229
217
|
- bin/setup
|
230
218
|
- lib/webdrone.rb
|
231
219
|
- lib/webdrone/browser.rb
|
@@ -253,7 +241,10 @@ licenses:
|
|
253
241
|
- MIT
|
254
242
|
metadata:
|
255
243
|
allowed_push_host: https://rubygems.org
|
256
|
-
|
244
|
+
homepage_uri: http://github.com/a0/a0-webdrone-ruby
|
245
|
+
source_code_uri: http://github.com/a0/a0-webdrone-ruby
|
246
|
+
changelog_uri: http://github.com/a0/a0-webdrone-ruby/CHANGELOG.md
|
247
|
+
post_install_message:
|
257
248
|
rdoc_options: []
|
258
249
|
require_paths:
|
259
250
|
- lib
|
@@ -261,16 +252,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
261
252
|
requirements:
|
262
253
|
- - ">="
|
263
254
|
- !ruby/object:Gem::Version
|
264
|
-
version:
|
255
|
+
version: 2.3.0
|
265
256
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
266
257
|
requirements:
|
267
258
|
- - ">="
|
268
259
|
- !ruby/object:Gem::Version
|
269
260
|
version: '0'
|
270
261
|
requirements: []
|
271
|
-
|
272
|
-
|
273
|
-
signing_key:
|
262
|
+
rubygems_version: 3.1.4
|
263
|
+
signing_key:
|
274
264
|
specification_version: 4
|
275
265
|
summary: A simple selenium webdriver wrapper, ruby version.
|
276
266
|
test_files: []
|