webdrone 1.8.10 → 1.16.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: 95fc3004ce907de8f3a99fd537c19a34a82452927ef34c8118c7fd92f2821b37
4
- data.tar.gz: 5f24f79bee0bfa8156e3ee71b3d305f217920ad610c2691b81a2a009b0741e68
3
+ metadata.gz: da42804712c004488731672632dedf04620ad225b5a758cfe8ffed48732d3c89
4
+ data.tar.gz: ee670b6d098ec87a933bac60216ee7fbd73757a7a34ef83e722ff519b16ab9c4
5
5
  SHA512:
6
- metadata.gz: c469a518de176024ea16011482da223e7cda8c6a79865aea74821f9078ba1c107a0828fddaaaee339d2ade6013c9d47057d14a21cc03f67aaadf8d128d522bf3
7
- data.tar.gz: d7f6272527b5ca91c99ee1fa3031509277ae11df5304e62c50f19d284d084f91799f9e456e8cbf9b2e45796984421730fac8a8bc55c3011c39073a0def6b4dc9
6
+ metadata.gz: f949b6c209e48c654c95a4d40d95fe688b3548d6379c54b5fb5d105a3ccec704953bd656656c17067b9ede38bde48fb468867b63d578ab65acc6390fe1984829
7
+ data.tar.gz: ed9dd7147e65d917049c72b583b07ddf13ebcff6edb7ff70f22a4ad7a7b64b637c85978f9992e15246d3af54e6fdfd02772e44133a897a110803feee6ef54490
data/.rubocop.relaxed.yml CHANGED
@@ -1,5 +1,5 @@
1
1
  # Relaxed.Ruby.Style
2
- ## Version 2.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.5
2
+ TargetRubyVersion: 2.6
3
3
  inherit_from:
4
4
  - .rubocop.relaxed.yml
5
- Naming/UncommunicativeMethodParamName:
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.5.3
1
+ ruby-2.6.4
data/.tool-versions ADDED
@@ -0,0 +1 @@
1
+ ruby 2.7.2
data/.travis.yml CHANGED
@@ -1,4 +1,5 @@
1
1
  language: ruby
2
+ cache: bundler
2
3
  rvm:
3
- - 2.2.1
4
- before_install: gem install bundler -v 1.10.6
4
+ - 2.7.2
5
+ before_install: gem install bundler -v 2.1.4
data/CHANGELOG.md CHANGED
@@ -4,6 +4,78 @@ New features are summarized here.
4
4
 
5
5
 
6
6
 
7
+ ## v.1.16.0 - 2021-03-19
8
+ ### Changed
9
+ - Webdrone will not start a developer console when an exception is raised an a0.conf.error is set to :raise, only when it is set to :raise_report
10
+
11
+
12
+
13
+ ## v.1.14.0 - 2021-03-19
14
+ ### Changed
15
+ - New option for logger: :quiet that supress the normal stdout log, but not the log sent to webdrone_output dir.
16
+ ```ruby
17
+ a0 = Webdrone.create logger: :quiet
18
+ ```
19
+
20
+
21
+
22
+ ## v.1.12.0 - 2019-12-04
23
+ ### Added
24
+ - Added a new a0.conf.parent option, so instead of setting `parent:` in every method like:
25
+ ```ruby
26
+ modal = a0.find.css '.modal-dialog'
27
+
28
+ a0.form.set 'field', 'value', parent: modal
29
+ a0.clic.on 'button', parent: modal
30
+ ```
31
+ you can setup a default parent from now on with `a0.conf.parent=` like:
32
+ ```ruby
33
+ a0.conf.parent = a0.find.css '.modal-dialog'
34
+
35
+ a0.form.set 'field', 'value' # uses a0.conf.parent as default parent
36
+ a0.clic.on 'button'
37
+
38
+ a0.conf.parent = nil # resets default parent
39
+ ```
40
+ - Added the following methods to `a0.ctxt`:
41
+ - `a0.ctxt.id`
42
+ - `a0.ctxt.css`
43
+ - `a0.ctxt.link`
44
+ - `a0.ctxt.button`
45
+ - `a0.ctxt.on`
46
+ - `a0.ctxt.option`
47
+ - `a0.ctxt.xpath`
48
+
49
+ So instead of code like the above, we can use give a block of code to automatically switch in a stack of parents like:
50
+ ```ruby
51
+ a0.ctxt.css '.modal-dialog' do
52
+ # sets a0.conf.parent = the found .modal-dialog
53
+ a0.form.set 'field', 'value'
54
+ a0.clic.on 'button'
55
+
56
+ a0.ctxt.css '.modal-footer' do
57
+ # sets a0.conf.parent to the found .modal-footer within the previous .modal-dialog
58
+ end
59
+ # sets a0.conf.parent back to the found .modal-dialog
60
+ end
61
+ # sets a0.conf.parent back to nil (the default) or whatever it was before calling a0.ctxt.css
62
+ ```
63
+
64
+
65
+
66
+ ## v.1.10.0
67
+ ### Fixed
68
+ - Warnings for chrome and firefox
69
+
70
+
71
+
72
+ ## v.1.8.12 - 2019-02-22
73
+ ### Fixed
74
+ - Fixing null terminal column size when used without a terminal, caused by highlight 2.0.1.
75
+ - Fixing maximizing start for chrome.
76
+
77
+
78
+
7
79
  ## v.1.8.10 - 2018-12-28
8
80
  ### Fixed
9
81
  - headless can be overriden from environment, for ex: export WEBDRONE_HEADLESS=false
data/Gemfile CHANGED
@@ -2,3 +2,6 @@ source 'https://rubygems.org'
2
2
 
3
3
  # Specify your gem's dependencies in webdrone.gemspec
4
4
  gemspec
5
+
6
+ gem 'rake', '~> 12.0'
7
+ gem 'rspec', '~> 3.0'
data/README.md CHANGED
@@ -2,8 +2,6 @@
2
2
 
3
3
  Yet another selenium webdriver wrapper, ruby version.
4
4
 
5
- There is a groovy version available, at https://github.com/a0/a0-webdrone-groovy.
6
-
7
5
  ## Installation
8
6
 
9
7
  Add this line to your application's Gemfile:
data/Rakefile CHANGED
@@ -1,6 +1,6 @@
1
1
  require 'bundler/gem_tasks'
2
2
  require 'rspec/core/rake_task'
3
3
 
4
- RSpec::Core::RakeTask.new(:spec)
4
+ RSpec::Core::RakeTask.new :spec
5
5
 
6
6
  task default: :spec
data/bin/console CHANGED
@@ -1,4 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
2
3
 
3
4
  require 'bundler/setup'
4
5
  require 'webdrone'
@@ -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 "Webdrone: Webdrone.irb_console IS DEPRECATED, please use a0.console instead."
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 "Webdrone: pry console already running."
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("SIGINT") do
95
+ trap('SIGINT') do
95
96
  irb.signal_handle
96
97
  end
97
98
 
@@ -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'] = "images/jpeg, application/pdf, application/octet-stream, application/download"
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("webdrone_output", Time.new.strftime('%Y%m%d_%H%M%S'))
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
- @driver = Selenium::WebDriver.for browser.to_sym, options: chrome_options, driver_opts: { log_path: "/tmp/chromedriver.#{$$}.log", verbose: true }
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("/", "\\") : outdir
69
+ downdir = OS.windows? ? outdir.tr('/', '\\') : outdir
64
70
  firefox_profile['browser.download.dir'] = downdir
65
- @driver = Selenium::WebDriver.for browser.to_sym, profile: firefox_profile, options: firefox_options
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 == "true"
148
+ if val_new == 'true'
141
149
  val_new = true
142
- elsif val_new == "false"
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}."
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: nil, color: '#af1616', times: nil, delay: nil, shot: nil, mark: false)
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" if !%i[raise_report raise ignore].include? val
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
@@ -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 '%3d', @location[:lineno]}"
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,9 +133,10 @@ 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
- if a0.conf.developer && exception.binding
139
+ if a0.conf.developer && exception.binding && %i[raise_report].include?(a0.conf.error)
139
140
  exception.write_title "STARTING DEVELOPER CONSOLE ON ERROR"
140
141
  exception.dump_error_report
141
142
  a0.console 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: nil)
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: nil)
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: nil)
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: nil)
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: nil)
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: nil)
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: nil)
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: nil, mark: false)
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: nil, mark: false)
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: nil, mark: false)
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: nil, mark: false)
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: nil, color: '#af1616', times: nil, delay: nil, shot: nil)
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: nil, mark: false)
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: nil)
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: nil)
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
- cols = 120
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: nil, color: '#af1616', times: nil, delay: nil, shot: nil)
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: nil)
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)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Webdrone
4
- VERSION = "1.8.10"
4
+ VERSION = '1.16.0'
5
5
  end
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: nil, attr: nil, eq: nil, contains: nil, mark: false)
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
 
@@ -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 += descendant(:input)[attr(:type).equals('image')][attr(:alt).is(locator)]
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
- lib = File.expand_path('lib', __dir__)
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 "RubyGems 2.0 or newer is required to protect against public gem pushes." unless spec.respond_to?(:metadata)
19
- spec.metadata['allowed_push_host'] = 'https://rubygems.org'
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,12 +33,12 @@ 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'
36
39
  spec.add_runtime_dependency 'os'
37
40
  spec.add_runtime_dependency 'pry'
41
+ spec.add_runtime_dependency 'rspec'
38
42
  spec.add_runtime_dependency 'rubyXL'
39
43
  spec.add_runtime_dependency 'selenium-webdriver', '>= 3.5.0'
40
44
  spec.add_runtime_dependency 'xpath'
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.8.10
4
+ version: 1.16.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: 2018-12-28 00:00:00.000000000 Z
11
+ date: 2021-03-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -95,13 +95,13 @@ dependencies:
95
95
  - !ruby/object:Gem::Version
96
96
  version: '0'
97
97
  - !ruby/object:Gem::Dependency
98
- name: solargraph
98
+ name: binding_of_caller
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
101
  - - ">="
102
102
  - !ruby/object:Gem::Version
103
103
  version: '0'
104
- type: :development
104
+ type: :runtime
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
@@ -109,35 +109,35 @@ dependencies:
109
109
  - !ruby/object:Gem::Version
110
110
  version: '0'
111
111
  - !ruby/object:Gem::Dependency
112
- name: binding_of_caller
112
+ name: highline
113
113
  requirement: !ruby/object:Gem::Requirement
114
114
  requirements:
115
115
  - - ">="
116
116
  - !ruby/object:Gem::Version
117
- version: '0'
117
+ version: 2.0.0
118
118
  type: :runtime
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  requirements:
122
122
  - - ">="
123
123
  - !ruby/object:Gem::Version
124
- version: '0'
124
+ version: 2.0.0
125
125
  - !ruby/object:Gem::Dependency
126
- name: highline
126
+ name: os
127
127
  requirement: !ruby/object:Gem::Requirement
128
128
  requirements:
129
129
  - - ">="
130
130
  - !ruby/object:Gem::Version
131
- version: 2.0.0
131
+ version: '0'
132
132
  type: :runtime
133
133
  prerelease: false
134
134
  version_requirements: !ruby/object:Gem::Requirement
135
135
  requirements:
136
136
  - - ">="
137
137
  - !ruby/object:Gem::Version
138
- version: 2.0.0
138
+ version: '0'
139
139
  - !ruby/object:Gem::Dependency
140
- name: os
140
+ name: pry
141
141
  requirement: !ruby/object:Gem::Requirement
142
142
  requirements:
143
143
  - - ">="
@@ -151,7 +151,7 @@ dependencies:
151
151
  - !ruby/object:Gem::Version
152
152
  version: '0'
153
153
  - !ruby/object:Gem::Dependency
154
- name: pry
154
+ name: rspec
155
155
  requirement: !ruby/object:Gem::Requirement
156
156
  requirements:
157
157
  - - ">="
@@ -219,6 +219,7 @@ files:
219
219
  - ".rubocop.yml"
220
220
  - ".ruby-gemset"
221
221
  - ".ruby-version"
222
+ - ".tool-versions"
222
223
  - ".travis.yml"
223
224
  - CHANGELOG.md
224
225
  - Gemfile
@@ -226,6 +227,7 @@ files:
226
227
  - README.md
227
228
  - Rakefile
228
229
  - bin/console
230
+ - bin/release-version
229
231
  - bin/setup
230
232
  - lib/webdrone.rb
231
233
  - lib/webdrone/browser.rb
@@ -253,7 +255,10 @@ licenses:
253
255
  - MIT
254
256
  metadata:
255
257
  allowed_push_host: https://rubygems.org
256
- post_install_message:
258
+ homepage_uri: http://github.com/a0/a0-webdrone-ruby
259
+ source_code_uri: http://github.com/a0/a0-webdrone-ruby
260
+ changelog_uri: http://github.com/a0/a0-webdrone-ruby/CHANGELOG.md
261
+ post_install_message:
257
262
  rdoc_options: []
258
263
  require_paths:
259
264
  - lib
@@ -261,16 +266,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
261
266
  requirements:
262
267
  - - ">="
263
268
  - !ruby/object:Gem::Version
264
- version: '0'
269
+ version: 2.3.0
265
270
  required_rubygems_version: !ruby/object:Gem::Requirement
266
271
  requirements:
267
272
  - - ">="
268
273
  - !ruby/object:Gem::Version
269
274
  version: '0'
270
275
  requirements: []
271
- rubyforge_project:
272
- rubygems_version: 2.7.8
273
- signing_key:
276
+ rubygems_version: 3.1.4
277
+ signing_key:
274
278
  specification_version: 4
275
279
  summary: A simple selenium webdriver wrapper, ruby version.
276
280
  test_files: []