webdrone 1.7.0 → 1.7.2
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/CHANGELOG.md +10 -1
- data/lib/webdrone/clic.rb +2 -2
- data/lib/webdrone/find.rb +20 -15
- data/lib/webdrone/form.rb +19 -14
- data/lib/webdrone/html.rb +2 -2
- data/lib/webdrone/mark.rb +13 -5
- data/lib/webdrone/text.rb +2 -2
- data/lib/webdrone/version.rb +1 -1
- data/lib/webdrone/vrfy.rb +5 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 141718e84c9548a1dc99d014b84c7a0cb93daa4f
|
4
|
+
data.tar.gz: e84dc032f5d2c518ff41a0a3c0418e4ab4701a81
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0e0e96ce97f449aa4b9f63b1e2e07e667e0e5afab367da12ec984c1c07823363737f6d8e2751ab0280e319eaf2796db5cc1954b5b32072a14097252bfd5a50c5
|
7
|
+
data.tar.gz: 3e53743cb6cca9afaf4abe34252d92f9206cdabee284c4d696025b9ee54bfc84cc0b721d7ef648e00f24bc04470bec92000f8859204643e88de76ed1dc2c84ea
|
data/CHANGELOG.md
CHANGED
@@ -4,7 +4,14 @@ New features are summarized here.
|
|
4
4
|
|
5
5
|
|
6
6
|
|
7
|
-
## v.1.7.
|
7
|
+
## v.1.7.2 - 2017-08-13
|
8
|
+
### Added
|
9
|
+
- New option to clear the mark outline. Enable with `a0.mark.clear = true` or setting the environment variable `WEBDRONE_MARK_CLEAR` to `true`
|
10
|
+
- Initial support to scroll element with `scroll: true`. Scrolling is supported in the following verbs: `a0.clic.*`, `a0.find.*`, `a0.form.*`, `a0.html.*`, `a0.mark.*`, `a0.text.*` and `a0.vrfy.*` (Closes: #5)
|
11
|
+
|
12
|
+
|
13
|
+
|
14
|
+
## v.1.7.0 - 2017-08-13
|
8
15
|
### Added
|
9
16
|
- Find children elements of a parent element. For ex, given the following HTML:
|
10
17
|
```HTML
|
@@ -26,6 +33,8 @@ a0.clic.on 'Create', parent: objs
|
|
26
33
|
```
|
27
34
|
- parent is supported in the following verbs: `a0.clic.*`, `a0.find.*`, `a0.form.*`, `a0.html.*`, `a0.mark.*`, `a0.text.*` and `a0.vrfy.*`
|
28
35
|
|
36
|
+
|
37
|
+
|
29
38
|
## v.1.6.2 - 2017-04-11
|
30
39
|
### Changed
|
31
40
|
- Changed default preferences for chrome, disabling the password save dialog.
|
data/lib/webdrone/clic.rb
CHANGED
@@ -12,8 +12,8 @@ module Webdrone
|
|
12
12
|
@a0 = a0
|
13
13
|
end
|
14
14
|
|
15
|
-
def clic(text, n: 1, all: false, visible: true, color: '#af1616', times: nil, delay: nil, shot: nil, mark: false
|
16
|
-
item = @a0.find.send __callee__, text, n: n, all: all, visible: visible, parent: parent
|
15
|
+
def clic(text, n: 1, all: false, visible: true, scroll: false, parent: nil, color: '#af1616', times: nil, delay: nil, shot: nil, mark: false)
|
16
|
+
item = @a0.find.send __callee__, text, n: n, all: all, visible: visible, scroll: scroll, parent: parent
|
17
17
|
if mark
|
18
18
|
@a0.mark.mark_item(item, color: color, times: times, delay: delay, shot: shot, text: text)
|
19
19
|
elsif shot
|
data/lib/webdrone/find.rb
CHANGED
@@ -12,59 +12,59 @@ module Webdrone
|
|
12
12
|
@a0 = a0
|
13
13
|
end
|
14
14
|
|
15
|
-
def id(text, n: 1, all: false, visible: true, parent: nil)
|
15
|
+
def id(text, n: 1, all: false, visible: true, scroll: false, parent: nil)
|
16
16
|
@a0.wait.for do
|
17
17
|
items = (parent || @a0.driver).find_elements :id, text
|
18
|
-
choose(items, n, all, visible)
|
18
|
+
choose(items, n, all, visible, scroll)
|
19
19
|
end
|
20
20
|
rescue => exception
|
21
21
|
Webdrone.report_error(@a0, exception)
|
22
22
|
end
|
23
23
|
|
24
|
-
def css(text, n: 1, all: false, visible: true, parent: nil)
|
24
|
+
def css(text, n: 1, all: false, visible: true, scroll: false, parent: nil)
|
25
25
|
@a0.wait.for do
|
26
26
|
items = (parent || @a0.driver).find_elements :css, text
|
27
|
-
choose(items, n, all, visible)
|
27
|
+
choose(items, n, all, visible, scroll)
|
28
28
|
end
|
29
29
|
rescue => exception
|
30
30
|
Webdrone.report_error(@a0, exception)
|
31
31
|
end
|
32
32
|
|
33
|
-
def link(text, n: 1, all: false, visible: true, parent: nil)
|
34
|
-
self.xpath XPath::HTML.link(text).to_s, n: n, all: all, visible: visible, parent: parent
|
33
|
+
def link(text, n: 1, all: false, visible: true, scroll: false, parent: nil)
|
34
|
+
self.xpath XPath::HTML.link(text).to_s, n: n, all: all, visible: visible, scroll: scroll, parent: parent
|
35
35
|
rescue => exception
|
36
36
|
Webdrone.report_error(@a0, exception)
|
37
37
|
end
|
38
38
|
|
39
|
-
def button(text, n: 1, all: false, visible: true, parent: nil)
|
40
|
-
self.xpath XPath::HTML.button(text).to_s, n: n, all: all, visible: visible, parent: parent
|
39
|
+
def button(text, n: 1, all: false, visible: true, scroll: false, parent: nil)
|
40
|
+
self.xpath XPath::HTML.button(text).to_s, n: n, all: all, visible: visible, scroll: scroll, parent: parent
|
41
41
|
rescue => exception
|
42
42
|
Webdrone.report_error(@a0, exception)
|
43
43
|
end
|
44
44
|
|
45
|
-
def on(text, n: 1, all: false, visible: true, parent: nil)
|
46
|
-
self.xpath XPath::HTML.link_or_button(text).to_s, n: n, all: all, visible: visible, parent: parent
|
45
|
+
def on(text, n: 1, all: false, visible: true, scroll: false, parent: nil)
|
46
|
+
self.xpath XPath::HTML.link_or_button(text).to_s, n: n, all: all, visible: visible, scroll: scroll, parent: parent
|
47
47
|
rescue => exception
|
48
48
|
Webdrone.report_error(@a0, exception)
|
49
49
|
end
|
50
50
|
|
51
|
-
def option(text, n: 1, all: false, visible: true, parent: nil)
|
52
|
-
self.xpath XPath::HTML.option(text).to_s, n: n, all: all, visible: visible, parent: parent
|
51
|
+
def option(text, n: 1, all: false, visible: true, scroll: false, parent: nil)
|
52
|
+
self.xpath XPath::HTML.option(text).to_s, n: n, all: all, visible: visible, scroll: scroll, parent: parent
|
53
53
|
rescue => exception
|
54
54
|
Webdrone.report_error(@a0, exception)
|
55
55
|
end
|
56
56
|
|
57
|
-
def xpath(text, n: 1, all: false, visible: true, parent: nil)
|
57
|
+
def xpath(text, n: 1, all: false, visible: true, scroll: false, parent: nil)
|
58
58
|
@a0.wait.for do
|
59
59
|
items = (parent || @a0.driver).find_elements :xpath, text
|
60
|
-
choose(items, n, all, visible)
|
60
|
+
choose(items, n, all, visible, scroll)
|
61
61
|
end
|
62
62
|
rescue => exception
|
63
63
|
Webdrone.report_error(@a0, exception)
|
64
64
|
end
|
65
65
|
|
66
66
|
protected
|
67
|
-
def choose(list, n, all, visible)
|
67
|
+
def choose(list, n, all, visible, scroll)
|
68
68
|
list = list.select do |x|
|
69
69
|
if visible == true
|
70
70
|
x.displayed?
|
@@ -74,6 +74,11 @@ module Webdrone
|
|
74
74
|
true
|
75
75
|
end
|
76
76
|
end
|
77
|
+
|
78
|
+
if scroll and list.length > 0
|
79
|
+
@a0.exec.script 'arguments[0].scrollIntoView()', list.first
|
80
|
+
end
|
81
|
+
|
77
82
|
if all
|
78
83
|
list
|
79
84
|
else
|
data/lib/webdrone/form.rb
CHANGED
@@ -87,8 +87,9 @@ module Webdrone
|
|
87
87
|
@data = prev
|
88
88
|
end
|
89
89
|
|
90
|
-
def set(key, val, n: 1, visible: true, parent: nil)
|
91
|
-
item = self.find_item(key, n: n, visible: visible, parent: parent)
|
90
|
+
def set(key, val, n: 1, visible: true, scroll: false, parent: nil, mark: false)
|
91
|
+
item = self.find_item(key, n: n, visible: visible, scroll: scroll, parent: parent)
|
92
|
+
@a0.mark.mark_item item if mark
|
92
93
|
if item.tag_name == 'select'
|
93
94
|
option = item.find_element :xpath, XPath::HTML.option(val).to_s
|
94
95
|
option.click
|
@@ -102,26 +103,30 @@ module Webdrone
|
|
102
103
|
Webdrone.report_error(@a0, exception)
|
103
104
|
end
|
104
105
|
|
105
|
-
def get(key, n: 1, visible: true, parent: nil)
|
106
|
-
self.find_item(key, n: n, visible: visible, parent: parent)
|
106
|
+
def get(key, n: 1, visible: true, scroll: false, parent: nil, mark: false)
|
107
|
+
item = self.find_item(key, n: n, visible: visible, scroll: scroll, parent: parent)
|
108
|
+
@a0.mark.mark_item item if mark
|
109
|
+
item[:value]
|
107
110
|
rescue => exception
|
108
111
|
Webdrone.report_error(@a0, exception)
|
109
112
|
end
|
110
113
|
|
111
|
-
def clic(key, n: 1, visible: true, parent: nil)
|
112
|
-
self.find_item(key, n: n, visible: visible, parent: parent)
|
114
|
+
def clic(key, n: 1, visible: true, scroll: false, parent: nil, mark: false)
|
115
|
+
item = self.find_item(key, n: n, visible: visible, scroll: scroll, parent: parent)
|
116
|
+
@a0.mark.mark_item item if mark
|
117
|
+
item.click
|
113
118
|
rescue => exception
|
114
119
|
Webdrone.report_error(@a0, exception)
|
115
120
|
end
|
116
121
|
|
117
|
-
def mark(key, n: 1, visible: true, parent: nil, color: '#af1616', times: nil, delay: nil, shot: nil)
|
118
|
-
@a0.mark.mark_item self.find_item(key, n: n, visible: visible, parent: parent), color: color, times: times, delay: delay, shot: shot
|
122
|
+
def mark(key, n: 1, visible: true, scroll: false, parent: nil, color: '#af1616', times: nil, delay: nil, shot: nil)
|
123
|
+
@a0.mark.mark_item self.find_item(key, n: n, visible: visible, scroll: scroll, parent: parent), color: color, times: times, delay: delay, shot: shot
|
119
124
|
rescue => exception
|
120
125
|
Webdrone.report_error(@a0, exception)
|
121
126
|
end
|
122
127
|
|
123
|
-
def submit(key = nil, n: 1, visible: true, parent: nil)
|
124
|
-
self.find_item(key, n: n, visible: visible, parent: parent) if key
|
128
|
+
def submit(key = nil, n: 1, visible: true, scroll: false, parent: nil, mark: false)
|
129
|
+
self.find_item(key, n: n, visible: visible, scroll: scroll, parent: parent) if key
|
125
130
|
@lastitem.submit
|
126
131
|
rescue => exception
|
127
132
|
Webdrone.report_error(@a0, exception)
|
@@ -136,13 +141,13 @@ module Webdrone
|
|
136
141
|
end
|
137
142
|
|
138
143
|
protected
|
139
|
-
def find_item(key, n: 1, visible: true, parent: nil)
|
144
|
+
def find_item(key, n: 1, visible: true, scroll: false, parent: nil)
|
140
145
|
if @xpath.respond_to? :call
|
141
|
-
@lastitem = @a0.find.xpath @xpath.call(key).to_s, n: n, visible: visible, parent: parent
|
146
|
+
@lastitem = @a0.find.xpath @xpath.call(key).to_s, n: n, visible: visible, scroll: scroll, parent: parent
|
142
147
|
elsif @xpath.is_a? String and @xpath.include? '%s'
|
143
|
-
@lastitem = @a0.find.xpath sprintf(@xpath, key), n: n, visible: visible, parent: parent
|
148
|
+
@lastitem = @a0.find.xpath sprintf(@xpath, key), n: n, visible: visible, scroll: scroll, parent: parent
|
144
149
|
else
|
145
|
-
@lastitem = @a0.find.xpath XPath::HTML.field(key).to_s, n: n, visible: visible, parent: parent
|
150
|
+
@lastitem = @a0.find.xpath XPath::HTML.field(key).to_s, n: n, visible: visible, scroll: scroll, parent: parent
|
146
151
|
end
|
147
152
|
end
|
148
153
|
end
|
data/lib/webdrone/html.rb
CHANGED
@@ -12,8 +12,8 @@ module Webdrone
|
|
12
12
|
@a0 = a0
|
13
13
|
end
|
14
14
|
|
15
|
-
def find_html(text, n: 1, all: false, visible: true, parent: nil)
|
16
|
-
item = @a0.find.send __callee__, text, n: n, all: all, visible: visible, parent: parent
|
15
|
+
def find_html(text, n: 1, all: false, visible: true, scroll: scroll, parent: nil)
|
16
|
+
item = @a0.find.send __callee__, text, n: n, all: all, visible: visible, scroll: scroll, parent: parent
|
17
17
|
if item.is_a? Array
|
18
18
|
item.collect { |x| x.attribute 'innerHTML'}
|
19
19
|
else
|
data/lib/webdrone/mark.rb
CHANGED
@@ -6,16 +6,17 @@ module Webdrone
|
|
6
6
|
end
|
7
7
|
|
8
8
|
class Mark
|
9
|
-
attr_accessor :a0, :default_times, :default_delay
|
9
|
+
attr_accessor :a0, :default_times, :default_delay, :clear
|
10
10
|
|
11
11
|
def initialize(a0)
|
12
12
|
@a0 = a0
|
13
13
|
@default_times = ENV['WEBDRONE_MARK_TIMES'] || 3
|
14
14
|
@default_delay = ENV['WEBDRONE_MARK_DELAY'] || 0.05
|
15
|
+
@clear = ENV['WEBDRONE_MARK_CLEAR'] == 'true' || false
|
15
16
|
end
|
16
17
|
|
17
|
-
def mark(text, n: 1, all: false, visible: true, parent: nil, color: '#af1616', times: nil, delay: nil, shot: nil)
|
18
|
-
item = @a0.find.send __callee__, text, n: n, all: all, visible: visible, parent: parent
|
18
|
+
def mark(text, n: 1, all: false, visible: true, scroll: false, parent: nil, color: '#af1616', times: nil, delay: nil, shot: nil)
|
19
|
+
item = @a0.find.send __callee__, text, n: n, all: all, visible: visible, scroll: scroll, parent: parent
|
19
20
|
mark_item item, color: color, times: times, delay: delay, shot: shot, text: text
|
20
21
|
rescue => exception
|
21
22
|
Webdrone.report_error(@a0, exception)
|
@@ -41,16 +42,23 @@ module Webdrone
|
|
41
42
|
sleep delay
|
42
43
|
end
|
43
44
|
@a0.shot.screen shot.is_a?(String) ? shot : text if shot
|
45
|
+
mark_clear item if @clear
|
44
46
|
item
|
45
47
|
end
|
46
48
|
|
49
|
+
def mark_clear(item)
|
50
|
+
mark_item_border item, nil
|
51
|
+
end
|
52
|
+
|
47
53
|
def mark_item_border(item, color)
|
54
|
+
style = color ? "'2px solid #{color}'" : "null"
|
55
|
+
set_outline = "arguments[0].style.outline = #{style}"
|
48
56
|
if item.is_a? Array
|
49
57
|
item.each do |item|
|
50
|
-
@a0.exec.script(
|
58
|
+
@a0.exec.script(set_outline, item)
|
51
59
|
end
|
52
60
|
else
|
53
|
-
@a0.exec.script(
|
61
|
+
@a0.exec.script(set_outline, item)
|
54
62
|
end
|
55
63
|
end
|
56
64
|
|
data/lib/webdrone/text.rb
CHANGED
@@ -12,8 +12,8 @@ module Webdrone
|
|
12
12
|
@a0 = a0
|
13
13
|
end
|
14
14
|
|
15
|
-
def text(text, n: 1, all: false, visible: true, parent: nil)
|
16
|
-
item = @a0.find.send __callee__, text, n: n, all: all, visible: visible, parent: parent
|
15
|
+
def text(text, n: 1, all: false, visible: true, scroll: false, parent: nil)
|
16
|
+
item = @a0.find.send __callee__, text, n: n, all: all, visible: visible, scroll: scroll, parent: parent
|
17
17
|
if item.is_a? Array
|
18
18
|
item.collect(&:text)
|
19
19
|
else
|
data/lib/webdrone/version.rb
CHANGED
data/lib/webdrone/vrfy.rb
CHANGED
@@ -12,11 +12,13 @@ module Webdrone
|
|
12
12
|
@a0 = a0
|
13
13
|
end
|
14
14
|
|
15
|
-
def vrfy(text, n: 1, all: false, visible: true, parent: nil, attr: nil, eq: nil, contains: nil)
|
16
|
-
item = @a0.find.send __callee__, text, n: n, all: all, visible: visible, parent: parent
|
15
|
+
def vrfy(text, n: 1, all: false, visible: true, scroll: false, parent: nil, attr: nil, eq: nil, contains: nil, mark: false)
|
16
|
+
item = @a0.find.send __callee__, text, n: n, all: all, visible: visible, scroll: scroll, parent: parent
|
17
17
|
if item.is_a? Array
|
18
|
-
|
18
|
+
@a0.mark.mark_item item if mark
|
19
|
+
item.each { |x| vrfy_item x, text: text, callee: __callee__, attr: attr, eq: eq, contains: contains, mark: mark }
|
19
20
|
else
|
21
|
+
@a0.mark.mark_item item if mark
|
20
22
|
vrfy_item item, text: text, callee: __callee__, attr: attr, eq: eq, contains: contains
|
21
23
|
end
|
22
24
|
rescue => exception
|
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.7.
|
4
|
+
version: 1.7.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Aldrin Martoq
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-08-
|
11
|
+
date: 2017-08-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|