webdrone 0.9.9 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -5
- data/lib/webdrone.rb +11 -4
- data/lib/webdrone/browser.rb +2 -1
- data/lib/webdrone/conf.rb +1 -1
- data/lib/webdrone/error.rb +22 -4
- data/lib/webdrone/form.rb +14 -14
- data/lib/webdrone/version.rb +1 -1
- 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: 18327a95145f6320c3ebebd258f7b3a3f1546276
|
4
|
+
data.tar.gz: 5c806d95e56819bdcc228330ffe649e9b64ff59e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 31ddf69bc8c078320a66c07cbf16d0c52890fd3d088431b6cfcc1fde914d6fcc9d7ecd68d5b419865889d413cbc72aaba871a02531bc140e6f4307d6cc5ebb01
|
7
|
+
data.tar.gz: 474e733306f50f3a39a027e53365261098d6534158800bd68e23fa68bf13861f50e9be94e83cb86d017b2fdc9cf0a5a9251ef03605c456cbe4d7d15002e51707
|
data/README.md
CHANGED
@@ -16,17 +16,14 @@ And then execute:
|
|
16
16
|
|
17
17
|
$ bundle
|
18
18
|
|
19
|
-
Or install
|
19
|
+
Or install and check for updates:
|
20
20
|
|
21
21
|
$ gem install webdrone
|
22
|
-
|
23
|
-
Check for updates:
|
24
|
-
|
25
22
|
$ gem update webdrone
|
26
23
|
|
27
24
|
## Documentation
|
28
25
|
|
29
|
-
* [Documentation Wiki](https://github.com/a0/a0-webdrone-ruby/wiki)
|
26
|
+
* [Documentation Wiki](https://github.com/a0/a0-webdrone-ruby/wiki) (Basic installation, usage and more).
|
30
27
|
* Docs can be found [here](http://www.rubydoc.info/gems/webdrone).
|
31
28
|
|
32
29
|
## Development
|
data/lib/webdrone.rb
CHANGED
@@ -41,7 +41,7 @@ module Webdrone
|
|
41
41
|
end
|
42
42
|
|
43
43
|
def self.irb_console(binding = nil)
|
44
|
-
return if IRB.CurrentContext
|
44
|
+
return if IRB.CurrentContext and not binding
|
45
45
|
binding = Kernel.binding.of_caller(1) if binding == nil
|
46
46
|
IRB.start_session(binding)
|
47
47
|
end
|
@@ -49,7 +49,10 @@ end
|
|
49
49
|
|
50
50
|
module IRB
|
51
51
|
def self.start_session(binding)
|
52
|
-
|
52
|
+
unless $a0_irb_setup_done
|
53
|
+
IRB.setup(nil)
|
54
|
+
$a0_irb_setup_done = true
|
55
|
+
end
|
53
56
|
|
54
57
|
workspace = WorkSpace.new(binding)
|
55
58
|
|
@@ -66,8 +69,12 @@ module IRB
|
|
66
69
|
irb.signal_handle
|
67
70
|
end
|
68
71
|
|
69
|
-
|
70
|
-
|
72
|
+
begin
|
73
|
+
catch(:IRB_EXIT) do
|
74
|
+
irb.eval_input
|
75
|
+
end
|
76
|
+
ensure
|
77
|
+
IRB.irb_at_exit
|
71
78
|
end
|
72
79
|
end
|
73
80
|
end
|
data/lib/webdrone/browser.rb
CHANGED
@@ -25,7 +25,7 @@ module Webdrone
|
|
25
25
|
@@chrome_prefs
|
26
26
|
end
|
27
27
|
|
28
|
-
def initialize(browser: 'firefox', create_outdir: true, outdir: nil, timeout:, maximize: true, error: :raise_report, chrome_prefs: nil, firefox_profile: nil)
|
28
|
+
def initialize(browser: 'firefox', create_outdir: true, outdir: nil, timeout:, developer: false, maximize: true, error: :raise_report, chrome_prefs: nil, firefox_profile: nil)
|
29
29
|
if create_outdir or outdir
|
30
30
|
outdir ||= File.join("webdrone_output", Time.new.strftime('%Y%m%d_%H%M%S'))
|
31
31
|
self.conf.outdir = outdir
|
@@ -44,6 +44,7 @@ module Webdrone
|
|
44
44
|
@driver = Selenium::WebDriver.for browser.to_sym
|
45
45
|
end
|
46
46
|
self.conf.error = error
|
47
|
+
self.conf.developer = developer
|
47
48
|
self.conf.timeout = timeout if timeout
|
48
49
|
self.maximize if maximize
|
49
50
|
end
|
data/lib/webdrone/conf.rb
CHANGED
data/lib/webdrone/error.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
module Webdrone
|
2
2
|
class WebdroneError < StandardError
|
3
|
-
attr_reader :original, :a0, :caller_locations
|
3
|
+
attr_reader :original, :a0, :caller_locations, :consoled
|
4
4
|
def initialize(msg, original = $!, a0, caller_locations)
|
5
5
|
super(msg)
|
6
6
|
@original = original
|
@@ -97,11 +97,12 @@ module Webdrone
|
|
97
97
|
write_title "EXCEPTION DUMP"
|
98
98
|
|
99
99
|
write_line "#{@original.class}: #{@original.message}"
|
100
|
-
@original.backtrace_locations.
|
100
|
+
@original.backtrace_locations.each_with_index do |location, index|
|
101
101
|
if location.path == @location.path and location.lineno == @location.lineno
|
102
|
-
write_line sprintf " ==> from %s", location
|
102
|
+
write_line sprintf "%02d: ==> from %s", index, location
|
103
|
+
@caller_index = index
|
103
104
|
else
|
104
|
-
write_line sprintf " from %s", location
|
105
|
+
write_line sprintf "%02d: from %s", index, location
|
105
106
|
end
|
106
107
|
end
|
107
108
|
|
@@ -124,12 +125,29 @@ module Webdrone
|
|
124
125
|
|
125
126
|
dump_error_report
|
126
127
|
end
|
128
|
+
|
129
|
+
def start_console
|
130
|
+
return if @consoled
|
131
|
+
@consoled = true
|
132
|
+
while true do
|
133
|
+
write_title "DEVELOPER CONSOLE"
|
134
|
+
print "Enter stack index [#{@caller_index}] or 'exit': "
|
135
|
+
input = gets.chomp
|
136
|
+
break if input.include? 'exit'
|
137
|
+
@caller_index = input.to_i unless input.empty?
|
138
|
+
location = @original.backtrace_locations[@caller_index]
|
139
|
+
index = Kernel.caller_locations.index { |item| item.path == location.path and item.lineno == location.lineno }
|
140
|
+
Webdrone.irb_console Kernel.binding.of_caller(index + 1)
|
141
|
+
report_exception
|
142
|
+
end
|
143
|
+
end
|
127
144
|
end
|
128
145
|
|
129
146
|
def self.report_error(a0, exception, caller_locations)
|
130
147
|
return if a0.conf.error == :ignore
|
131
148
|
exception = WebdroneError.new(exception.message, exception, a0, caller_locations) if exception.class != WebdroneError
|
132
149
|
|
150
|
+
exception.start_console if a0.conf.developer
|
133
151
|
raise exception if a0.conf.error == :raise or a0.conf.error == :raise_report
|
134
152
|
end
|
135
153
|
end
|
data/lib/webdrone/form.rb
CHANGED
@@ -19,8 +19,8 @@ module Webdrone
|
|
19
19
|
Webdrone.report_error(@a0, exception, Kernel.caller_locations)
|
20
20
|
end
|
21
21
|
|
22
|
-
def set(key, val)
|
23
|
-
item = self.find_item(key)
|
22
|
+
def set(key, val, n: 1, visible: true)
|
23
|
+
item = self.find_item(key, n: n, visible: visible)
|
24
24
|
if item.tag_name == 'select'
|
25
25
|
option = item.find_element :xpath, XPath::HTML.option(val).to_s
|
26
26
|
option.click
|
@@ -32,26 +32,26 @@ module Webdrone
|
|
32
32
|
Webdrone.report_error(@a0, exception, Kernel.caller_locations)
|
33
33
|
end
|
34
34
|
|
35
|
-
def get(key)
|
36
|
-
self.find_item(key)[:value]
|
35
|
+
def get(key, n: 1, visible: true)
|
36
|
+
self.find_item(key, n: n, visible: visible)[:value]
|
37
37
|
rescue => exception
|
38
38
|
Webdrone.report_error(@a0, exception, Kernel.caller_locations)
|
39
39
|
end
|
40
40
|
|
41
|
-
def clic(key)
|
42
|
-
self.find_item(key).click
|
41
|
+
def clic(key, n: 1, visible: true)
|
42
|
+
self.find_item(key, n: n, visible: visible).click
|
43
43
|
rescue => exception
|
44
44
|
Webdrone.report_error(@a0, exception, Kernel.caller_locations)
|
45
45
|
end
|
46
46
|
|
47
|
-
def mark(key, color: '#af1616', times: 3, sleep: 0.05)
|
48
|
-
@a0.mark.mark_item self.find_item(key), color: color, times: times, sleep: sleep
|
47
|
+
def mark(key, n: 1, visible: true, color: '#af1616', times: 3, sleep: 0.05)
|
48
|
+
@a0.mark.mark_item self.find_item(key, n: n, visible: visible), color: color, times: times, sleep: sleep
|
49
49
|
rescue => exception
|
50
50
|
Webdrone.report_error(@a0, exception, Kernel.caller_locations)
|
51
51
|
end
|
52
52
|
|
53
|
-
def submit(key = nil)
|
54
|
-
self.find_item(key) if key
|
53
|
+
def submit(key = nil, n: 1, visible: true)
|
54
|
+
self.find_item(key, n: n, visible: visible) if key
|
55
55
|
@lastitem.submit
|
56
56
|
rescue => exception
|
57
57
|
Webdrone.report_error(@a0, exception, Kernel.caller_locations)
|
@@ -66,13 +66,13 @@ module Webdrone
|
|
66
66
|
end
|
67
67
|
|
68
68
|
protected
|
69
|
-
def find_item(key)
|
69
|
+
def find_item(key, n: 1, visible: true)
|
70
70
|
if @xpath.respond_to? :call
|
71
|
-
@lastitem = @a0.find.xpath @xpath.call(key).to_s
|
71
|
+
@lastitem = @a0.find.xpath @xpath.call(key).to_s, n: n, visible: visible
|
72
72
|
elsif @xpath.is_a? String and @xpath.include? '%s'
|
73
|
-
@lastitem = @a0.find.xpath sprintf(@xpath, key)
|
73
|
+
@lastitem = @a0.find.xpath sprintf(@xpath, key), n: n, visible: visible
|
74
74
|
else
|
75
|
-
@lastitem = @a0.find.xpath XPath::HTML.field(key).to_s
|
75
|
+
@lastitem = @a0.find.xpath XPath::HTML.field(key).to_s, n: n, visible: visible
|
76
76
|
end
|
77
77
|
end
|
78
78
|
end
|
data/lib/webdrone/version.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.
|
4
|
+
version: 1.0.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: 2016-04
|
11
|
+
date: 2016-05-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|