webdrone 0.9.2 → 0.9.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +7 -1
- data/lib/webdrone/clic.rb +2 -2
- data/lib/webdrone/error.rb +10 -3
- data/lib/webdrone/find.rb +3 -4
- data/lib/webdrone/html.rb +36 -0
- data/lib/webdrone/mark.rb +6 -6
- data/lib/webdrone/text.rb +16 -37
- data/lib/webdrone/version.rb +1 -1
- data/lib/webdrone/vrfy.rb +2 -2
- data/lib/webdrone.rb +1 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e3a26ea163cdfb711c8037ff6e8550bb9ba27787
|
4
|
+
data.tar.gz: 02e5a85d31ddde91b0448c24a7ee48d5ba759db4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f55b9f99a04f3b36013c2371f7ff5ff567889dad77cb0d3d68b3f51556ca2386a0e7d66ff1b33c5c797618725ba4444670197d04a6a81413d8897828063ffbf3
|
7
|
+
data.tar.gz: 38be7081da5b436cefaf46c3fa80663e98a0ae0343e0f3a8f3c2fc17c33a8efaec0c1dd4d5720dcd933c55a6e323b6fa27fa57bff04564d1074defe95f98e9cf
|
data/README.md
CHANGED
@@ -16,10 +16,14 @@ And then execute:
|
|
16
16
|
|
17
17
|
$ bundle
|
18
18
|
|
19
|
-
|
19
|
+
Or install it yourself as:
|
20
20
|
|
21
21
|
$ gem install webdrone
|
22
22
|
|
23
|
+
Check for updates:
|
24
|
+
|
25
|
+
$ gem update webdrone
|
26
|
+
|
23
27
|
## Usage
|
24
28
|
|
25
29
|
Create a browser:
|
@@ -120,7 +124,9 @@ a0.vrfy.link 'link', attr: 'disabled', eq: 'true'
|
|
120
124
|
a0.vrfy.link 'link', attr: 'sample', contains: 'something'
|
121
125
|
```
|
122
126
|
|
127
|
+
## Documentation
|
123
128
|
|
129
|
+
Docs can be found [here](http://www.rubydoc.info/gems/webdrone).
|
124
130
|
|
125
131
|
## Development
|
126
132
|
|
data/lib/webdrone/clic.rb
CHANGED
@@ -12,8 +12,8 @@ module Webdrone
|
|
12
12
|
@a0 = a0
|
13
13
|
end
|
14
14
|
|
15
|
-
def id(text)
|
16
|
-
@a0.find.id(text).click
|
15
|
+
def id(text, n: 1, all: false, visible: true)
|
16
|
+
@a0.find.id(text, n: n, all: all, visible: visible).click
|
17
17
|
rescue => exception
|
18
18
|
Webdrone.report_error(@a0, exception, Kernel.caller_locations)
|
19
19
|
end
|
data/lib/webdrone/error.rb
CHANGED
@@ -74,8 +74,14 @@ module Webdrone
|
|
74
74
|
def report_screenshot
|
75
75
|
begin
|
76
76
|
write_title "AUTOMATIC SCREENSHOT"
|
77
|
-
|
78
|
-
|
77
|
+
begin
|
78
|
+
@a0.ctxt.with_conf error: :raise do
|
79
|
+
file = @a0.shot.screen 'a0_webdrone_error_report'
|
80
|
+
write_line "Screenshot Saved filename: #{file.path}"
|
81
|
+
end
|
82
|
+
rescue => exception
|
83
|
+
write_line "Error Saving screenhot: #{exception}"
|
84
|
+
end
|
79
85
|
|
80
86
|
dump_error_report
|
81
87
|
rescue
|
@@ -108,8 +114,9 @@ module Webdrone
|
|
108
114
|
end
|
109
115
|
|
110
116
|
def self.report_error(a0, exception, caller_locations)
|
117
|
+
return if a0.conf.error == :ignore
|
111
118
|
exception = WebdroneError.new(exception.message, exception, a0, caller_locations) if exception.class != WebdroneError
|
112
|
-
|
119
|
+
|
113
120
|
raise exception if a0.conf.error == :raise or a0.conf.error == :raise_report
|
114
121
|
end
|
115
122
|
end
|
data/lib/webdrone/find.rb
CHANGED
@@ -12,9 +12,10 @@ module Webdrone
|
|
12
12
|
@a0 = a0
|
13
13
|
end
|
14
14
|
|
15
|
-
def id(text)
|
15
|
+
def id(text, n: 1, all: false, visible: true)
|
16
16
|
@a0.wait.for do
|
17
|
-
@a0.driver.
|
17
|
+
items = @a0.driver.find_elements :id, text
|
18
|
+
choose(items, n, all, visible)
|
18
19
|
end
|
19
20
|
rescue => exception
|
20
21
|
Webdrone.report_error(@a0, exception, Kernel.caller_locations)
|
@@ -75,8 +76,6 @@ module Webdrone
|
|
75
76
|
end
|
76
77
|
if all
|
77
78
|
list
|
78
|
-
elsif n == 1
|
79
|
-
list.first
|
80
79
|
else
|
81
80
|
list[n - 1]
|
82
81
|
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
module Webdrone
|
2
|
+
class Browser
|
3
|
+
def html
|
4
|
+
@html ||= Html.new self
|
5
|
+
end
|
6
|
+
end
|
7
|
+
|
8
|
+
class Html
|
9
|
+
attr_accessor :a0
|
10
|
+
|
11
|
+
def initialize(a0)
|
12
|
+
@a0 = a0
|
13
|
+
end
|
14
|
+
|
15
|
+
def find_html(text, n: 1, all: false, visible: true)
|
16
|
+
item = @a0.find.send __callee__, text, n: n, all: all, visible: visible
|
17
|
+
if item.is_a? Array
|
18
|
+
item.collect { |x| x.attribute 'innerHTML'}
|
19
|
+
else
|
20
|
+
item.attribute 'innerHTML'
|
21
|
+
end
|
22
|
+
rescue => exception
|
23
|
+
Webdrone.report_error(@a0, exception, Kernel.caller_locations)
|
24
|
+
end
|
25
|
+
|
26
|
+
alias_method :id, :find_html
|
27
|
+
alias_method :css, :find_html
|
28
|
+
alias_method :link, :find_html
|
29
|
+
alias_method :button, :find_html
|
30
|
+
alias_method :on, :find_html
|
31
|
+
alias_method :option, :find_html
|
32
|
+
alias_method :xpath, :find_html
|
33
|
+
|
34
|
+
protected :find_html
|
35
|
+
end
|
36
|
+
end
|
data/lib/webdrone/mark.rb
CHANGED
@@ -12,8 +12,8 @@ module Webdrone
|
|
12
12
|
@a0 = a0
|
13
13
|
end
|
14
14
|
|
15
|
-
def id(text, color: 'red')
|
16
|
-
flash @a0.find.id(text), color: color
|
15
|
+
def id(text, color: 'red', n: 1, all: false, visible: true)
|
16
|
+
flash @a0.find.id(text, n: n, all: all, visible: visible), color: color
|
17
17
|
rescue => exception
|
18
18
|
Webdrone.report_error(@a0, exception, Kernel.caller_locations)
|
19
19
|
end
|
@@ -57,11 +57,11 @@ module Webdrone
|
|
57
57
|
def flash(item, color: 'red')
|
58
58
|
3.times do
|
59
59
|
border item, 'white'
|
60
|
-
sleep 0.
|
61
|
-
border item, '
|
62
|
-
sleep 0.
|
60
|
+
sleep 0.05
|
61
|
+
border item, 'black'
|
62
|
+
sleep 0.05
|
63
63
|
border item, color
|
64
|
-
sleep 0.
|
64
|
+
sleep 0.05
|
65
65
|
end
|
66
66
|
item
|
67
67
|
end
|
data/lib/webdrone/text.rb
CHANGED
@@ -12,52 +12,31 @@ module Webdrone
|
|
12
12
|
@a0 = a0
|
13
13
|
end
|
14
14
|
|
15
|
-
def
|
16
|
-
@a0.find.
|
15
|
+
def find_text(text, n: 1, all: false, visible: true)
|
16
|
+
item = @a0.find.send __callee__, text, n: n, all: all, visible: visible
|
17
|
+
if item.is_a? Array
|
18
|
+
item.collect(&:text)
|
19
|
+
else
|
20
|
+
item.text
|
21
|
+
end
|
17
22
|
rescue => exception
|
18
23
|
Webdrone.report_error(@a0, exception, Kernel.caller_locations)
|
19
24
|
end
|
20
25
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
@a0.find.link(text, n: n, all: all, visible: visible).text
|
29
|
-
rescue => exception
|
30
|
-
Webdrone.report_error(@a0, exception, Kernel.caller_locations)
|
31
|
-
end
|
32
|
-
|
33
|
-
def button(text, n: 1, all: false, visible: true)
|
34
|
-
@a0.find.button(text, n: n, all: all, visible: visible).text
|
35
|
-
rescue => exception
|
36
|
-
Webdrone.report_error(@a0, exception, Kernel.caller_locations)
|
37
|
-
end
|
38
|
-
|
39
|
-
def on(text, n: 1, all: false, visible: true)
|
40
|
-
@a0.find.on(text, n: n, all: all, visible: visible).text
|
41
|
-
rescue => exception
|
42
|
-
Webdrone.report_error(@a0, exception, Kernel.caller_locations)
|
43
|
-
end
|
44
|
-
|
45
|
-
def option(text, n: 1, all: false, visible: true)
|
46
|
-
@a0.find.option(text, n: n, all: all, visible: visible).text
|
47
|
-
rescue => exception
|
48
|
-
Webdrone.report_error(@a0, exception, Kernel.caller_locations)
|
49
|
-
end
|
50
|
-
|
51
|
-
def xpath(text, n: 1, all: false, visible: true)
|
52
|
-
@a0.find.xpath(text, n: n, all: all, visible: visible).text
|
53
|
-
rescue => exception
|
54
|
-
Webdrone.report_error(@a0, exception, Kernel.caller_locations)
|
55
|
-
end
|
26
|
+
alias_method :id, :find_text
|
27
|
+
alias_method :css, :find_text
|
28
|
+
alias_method :link, :find_text
|
29
|
+
alias_method :button, :find_text
|
30
|
+
alias_method :on, :find_text
|
31
|
+
alias_method :option, :find_text
|
32
|
+
alias_method :xpath, :find_text
|
56
33
|
|
57
34
|
def page_title
|
58
35
|
@a0.driver.title
|
59
36
|
rescue => exception
|
60
37
|
Webdrone.report_error(@a0, exception, Kernel.caller_locations)
|
61
38
|
end
|
39
|
+
|
40
|
+
protected :find_text
|
62
41
|
end
|
63
42
|
end
|
data/lib/webdrone/version.rb
CHANGED
data/lib/webdrone/vrfy.rb
CHANGED
@@ -12,13 +12,13 @@ module Webdrone
|
|
12
12
|
@a0 = a0
|
13
13
|
end
|
14
14
|
|
15
|
-
def id(text, attr: nil, eq: nil, contains: nil)
|
15
|
+
def id(text, n: 1, visible: true, attr: nil, eq: nil, contains: nil)
|
16
16
|
vrfy @a0.find.id(text), attr: attr, eq: eq, contains: contains
|
17
17
|
rescue => exception
|
18
18
|
Webdrone.report_error(@a0, exception, Kernel.caller_locations)
|
19
19
|
end
|
20
20
|
|
21
|
-
def css(text, attr: nil, eq: nil, contains: nil)
|
21
|
+
def css(text, n: 1, visible: true, attr: nil, eq: nil, contains: nil)
|
22
22
|
vrfy @a0.find.css(text), attr: attr, eq: eq, contains: contains
|
23
23
|
rescue => exception
|
24
24
|
Webdrone.report_error(@a0, exception, Kernel.caller_locations)
|
data/lib/webdrone.rb
CHANGED
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: 0.9.
|
4
|
+
version: 0.9.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Aldrin Martoq
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-03-
|
11
|
+
date: 2016-03-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -163,6 +163,7 @@ files:
|
|
163
163
|
- lib/webdrone/exec.rb
|
164
164
|
- lib/webdrone/find.rb
|
165
165
|
- lib/webdrone/form.rb
|
166
|
+
- lib/webdrone/html.rb
|
166
167
|
- lib/webdrone/mark.rb
|
167
168
|
- lib/webdrone/open.rb
|
168
169
|
- lib/webdrone/shot.rb
|