webdrone 1.10.0 → 1.12.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: 54033552a41d39468377a85f94dab87190f0e390488835a37b13647503950189
4
- data.tar.gz: 874c198bc2ae7167600be37ad096c744b82b5cd3fc88ad53a854020e1c8062d7
3
+ metadata.gz: 59b21203e4a9a61a584a1e062e7f26efe225a2212ac34bfef5ace8c4fe01d460
4
+ data.tar.gz: d12bbf98c32ab410d784c5c6a1af2d59ec2a8b7cad1fc12ac609d5d3b579252f
5
5
  SHA512:
6
- metadata.gz: 529391d94128a9d0e7bd0ab5ff68de96e8991e8d4400e9e5446e74572fe651505ae57caa9e48ca880bea72ac0b020d212b39bfe368309476a9ed79526b1c5062
7
- data.tar.gz: 40f4855afbfe706c0821936cd302364edd0d16fd24b65c227eea1a7f139614d08678b69ce7b8915af5a642259b1a476ff37cc5145b4f2a2ba4d73d017fa4a53b
6
+ metadata.gz: 3b3a88c1b42159fb7887ea3ff18e02a5637c17b3aab50d3121bfaa7a4a7602490c6fdf334d368531815b08cc5fef1d852c738e2edf9c6989b9ff3f07f95ebb8e
7
+ data.tar.gz: 10654e5945c31e7c31f45a74784147be0dcdbbfebbf169421fa9cc6755ccc973c01a3a4dae8a3a3fecfaad76f2f71cc927e519d6febfec68fd4ffdf2cf6595c9
@@ -1,8 +1,8 @@
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
@@ -4,6 +4,56 @@ New features are summarized here.
4
4
 
5
5
 
6
6
 
7
+ ## v.1.12.0 - 2019-12-04
8
+ ### Added
9
+ - Added a new a0.conf.parent option, so instead of setting `parent:` in every method like:
10
+ ```ruby
11
+ modal = a0.find.css '.modal-dialog'
12
+
13
+ a0.form.set 'field', 'value', parent: modal
14
+ a0.clic.on 'button', parent: modal
15
+ ```
16
+ you can setup a default parent from now on with `a0.conf.parent=` like:
17
+ ```ruby
18
+ a0.conf.parent = a0.find.css '.modal-dialog'
19
+
20
+ a0.form.set 'field', 'value' # uses a0.conf.parent as default parent
21
+ a0.clic.on 'button'
22
+
23
+ a0.conf.parent = nil # resets default parent
24
+ ```
25
+ - Added the following methods to `a0.ctxt`:
26
+ - `a0.ctxt.id`
27
+ - `a0.ctxt.css`
28
+ - `a0.ctxt.link`
29
+ - `a0.ctxt.button`
30
+ - `a0.ctxt.on`
31
+ - `a0.ctxt.option`
32
+ - `a0.ctxt.xpath`
33
+
34
+ So instead of code like the above, we can use give a block of code to automatically switch in a stack of parents like:
35
+ ```ruby
36
+ a0.ctxt.css '.modal-dialog' do
37
+ # sets a0.conf.parent = the found .modal-dialog
38
+ a0.form.set 'field', 'value'
39
+ a0.clic.on 'button'
40
+
41
+ a0.ctxt.css '.modal-footer' do
42
+ # sets a0.conf.parent to the found .modal-footer within the previous .modal-dialog
43
+ end
44
+ # sets a0.conf.parent back to the found .modal-dialog
45
+ end
46
+ # sets a0.conf.parent back to nil (the default) or whatever it was before calling a0.ctxt.css
47
+ ```
48
+
49
+
50
+
51
+ ## v.1.10.0
52
+ ### Fixed
53
+ - Warnings for chrome and firefox
54
+
55
+
56
+
7
57
  ## v.1.8.12 - 2019-02-22
8
58
  ### Fixed
9
59
  - Fixing null terminal column size when used without a terminal, caused by highlight 2.0.1.
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:
@@ -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
@@ -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)
@@ -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]
@@ -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)
@@ -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
@@ -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' }
@@ -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
@@ -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.10.0'
4
+ VERSION = '1.12.0'
5
5
  end
@@ -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
@@ -32,7 +32,6 @@ Gem::Specification.new do |spec|
32
32
  spec.add_development_dependency 'rake'
33
33
  spec.add_development_dependency 'rspec'
34
34
  spec.add_development_dependency 'rubocop'
35
- spec.add_development_dependency 'solargraph'
36
35
 
37
36
  spec.add_runtime_dependency 'binding_of_caller'
38
37
  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.10.0
4
+ version: 1.12.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aldrin Martoq
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-09-30 00:00:00.000000000 Z
11
+ date: 2019-12-04 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