superbara 0.7.0 → 0.8.0
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/Gemfile.lock +3 -3
- data/README.md +4 -0
- data/docs/_FontAwesome/css/font-awesome.css +4 -0
- data/docs/_FontAwesome/fonts/FontAwesome.ttf +0 -0
- data/docs/_FontAwesome/fonts/fontawesome-webfont.eot +0 -0
- data/docs/_FontAwesome/fonts/fontawesome-webfont.svg +640 -0
- data/docs/_FontAwesome/fonts/fontawesome-webfont.ttf +0 -0
- data/docs/_FontAwesome/fonts/fontawesome-webfont.woff +0 -0
- data/docs/_FontAwesome/fonts/fontawesome-webfont.woff2 +0 -0
- data/docs/ayu-highlight.css +71 -0
- data/docs/book.css +1454 -0
- data/docs/book.js +590 -0
- data/docs/clipboard.min.js +7 -0
- data/docs/elasticlunr.min.js +10 -0
- data/docs/favicon.png +0 -0
- data/docs/getting_started/index.html +243 -0
- data/docs/getting_started/shell.png +0 -0
- data/docs/highlight.css +69 -0
- data/docs/highlight.js +2 -0
- data/docs/index.html +221 -0
- data/docs/install.html +227 -0
- data/docs/mark.min.js +7 -0
- data/docs/print.html +336 -0
- data/docs/reference/assert.html +258 -0
- data/docs/reference/dialogs/alert.html +225 -0
- data/docs/reference/dialogs/confirm.html +225 -0
- data/docs/reference/dialogs/index.html +230 -0
- data/docs/reference/dialogs/prompt.html +217 -0
- data/docs/reference/find.html +235 -0
- data/docs/reference/tests/has_text.html +241 -0
- data/docs/reference/tests/index.html +225 -0
- data/docs/reference/wait.html +245 -0
- data/docs/reference.html +225 -0
- data/docs/searcher.js +461 -0
- data/docs/searchindex.js +1 -0
- data/docs/superbara.html +222 -0
- data/docs/tomorrow-night.css +96 -0
- data/docs-src/book.toml +11 -0
- data/docs-src/src/SUMMARY.md +18 -0
- data/docs-src/src/getting_started/index.md +38 -0
- data/docs-src/src/getting_started/shell.png +0 -0
- data/docs-src/src/install.md +5 -0
- data/docs-src/src/reference/assert.md +48 -0
- data/docs-src/src/reference/dialogs/alert.md +1 -0
- data/docs-src/src/reference/dialogs/confirm.md +1 -0
- data/docs-src/src/reference/dialogs/index.md +5 -0
- data/docs-src/src/reference/dialogs/prompt.md +1 -0
- data/docs-src/src/reference/find.md +21 -0
- data/docs-src/src/reference/results.md +53 -0
- data/docs-src/src/reference/tests/has_text.md +24 -0
- data/docs-src/src/reference/tests/index.md +1 -0
- data/docs-src/src/reference/wait.md +33 -0
- data/docs-src/src/reference.md +2 -0
- data/docs-src/src/superbara.md +7 -0
- data/lib/capybara_monkey.rb +10 -5
- data/lib/selenium_monkey.rb +2 -17
- data/lib/superbara/cli.rb +16 -8
- data/lib/superbara/context.rb +5 -6
- data/lib/superbara/dsl.rb +25 -8
- data/lib/superbara/helpers.rb +24 -1
- data/lib/superbara/version.rb +1 -1
- data/lib/superbara.rb +12 -2
- data/superbara.gemspec +1 -0
- data/tests/features/screenshot.rb +30 -0
- metadata +55 -2
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
# assert
|
|
2
|
+
|
|
3
|
+
`assert` _asserts_ that the block is truthy at the given time. The first parameter is an optional failure message.
|
|
4
|
+
|
|
5
|
+
```ruby
|
|
6
|
+
assert 'login missing' do
|
|
7
|
+
has_text? 'Login'
|
|
8
|
+
end
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
### Examples
|
|
13
|
+
|
|
14
|
+
Check that example.com still has the same heading.
|
|
15
|
+
|
|
16
|
+
```ruby
|
|
17
|
+
visit 'example.com'
|
|
18
|
+
|
|
19
|
+
assert 'somebody changed the text!'
|
|
20
|
+
h1 = find 'h1'
|
|
21
|
+
h1.text == 'Example Domain'
|
|
22
|
+
end
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
Asserts can also be written without the message.
|
|
26
|
+
|
|
27
|
+
```ruby
|
|
28
|
+
assert do
|
|
29
|
+
has_text? "Something"
|
|
30
|
+
end
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
Negative asserts can also be given.
|
|
34
|
+
|
|
35
|
+
```ruby
|
|
36
|
+
assert do
|
|
37
|
+
has_no_text? "Login"
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
# or
|
|
41
|
+
assert do
|
|
42
|
+
!has_text? "Login"
|
|
43
|
+
end
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
## Related
|
|
47
|
+
|
|
48
|
+
- [find](./reference/find.html)
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# Alert
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# Confirm
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# Prompt
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# find
|
|
2
|
+
|
|
3
|
+
To get a single element use `find`
|
|
4
|
+
|
|
5
|
+
```ruby
|
|
6
|
+
title = find 'h1'
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
For multiple results use `all`
|
|
10
|
+
|
|
11
|
+
```ruby
|
|
12
|
+
links = all 'h1'
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
See (results)[./results.md] for complete list of methods available for the returned element or elements.
|
|
16
|
+
|
|
17
|
+
## Advanced finding
|
|
18
|
+
|
|
19
|
+
```ruby
|
|
20
|
+
title = find 'h1', text: "Example Domain"
|
|
21
|
+
```
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
# Results
|
|
2
|
+
|
|
3
|
+
## Single elements
|
|
4
|
+
|
|
5
|
+
```ruby
|
|
6
|
+
link = find 'a'
|
|
7
|
+
link.text
|
|
8
|
+
```
|
|
9
|
+
|
|
10
|
+
```ruby
|
|
11
|
+
link = find 'a'
|
|
12
|
+
link.show
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
```ruby
|
|
16
|
+
link = find 'a'
|
|
17
|
+
link.click
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
## Multiple elements
|
|
22
|
+
|
|
23
|
+
```ruby
|
|
24
|
+
paragraphs = all 'p'
|
|
25
|
+
paragraphs.show
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
```ruby
|
|
29
|
+
paragraphs = all 'p'
|
|
30
|
+
paragraphs.first.show
|
|
31
|
+
paragraphs.second.show
|
|
32
|
+
# ..
|
|
33
|
+
paragraphs.tenth.show
|
|
34
|
+
|
|
35
|
+
links = all 'a'
|
|
36
|
+
paragraphs.last.click
|
|
37
|
+
paragraphs.middle.click
|
|
38
|
+
paragraphs.random.click
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
# first
|
|
42
|
+
paragraphs[0].show
|
|
43
|
+
paragraphs[1].show
|
|
44
|
+
# ..
|
|
45
|
+
paragraphs[999].show
|
|
46
|
+
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
```ruby
|
|
50
|
+
link = all 'a'
|
|
51
|
+
link.click
|
|
52
|
+
```
|
|
53
|
+
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# has_text?
|
|
2
|
+
|
|
3
|
+
Checks if the text is found on the screen.
|
|
4
|
+
|
|
5
|
+
```ruby
|
|
6
|
+
assert do
|
|
7
|
+
has_text? "Welcome"
|
|
8
|
+
end
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
# Examples
|
|
12
|
+
|
|
13
|
+
```ruby
|
|
14
|
+
if has_text? "Logged in"
|
|
15
|
+
click_link "Log out"
|
|
16
|
+
|
|
17
|
+
wait 3 do
|
|
18
|
+
has_text? "You have logged out"
|
|
19
|
+
end
|
|
20
|
+
else
|
|
21
|
+
click_link "Next"
|
|
22
|
+
end
|
|
23
|
+
```
|
|
24
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# Tests
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# wait
|
|
2
|
+
|
|
3
|
+
`wait` checks every 0.1s for the block to return `true` or "anything but false" until `max_seconds` has elapsed. Quits the script with an error if the wait condition is not satisfied.
|
|
4
|
+
|
|
5
|
+
```ruby
|
|
6
|
+
wait max_seconds do
|
|
7
|
+
# true or anything but false
|
|
8
|
+
end
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
### Examples
|
|
13
|
+
|
|
14
|
+
Wait maximum of 3 seconds for the text 'Example Domain' to appear on the page.
|
|
15
|
+
|
|
16
|
+
```ruby
|
|
17
|
+
visit 'example.com'
|
|
18
|
+
|
|
19
|
+
wait 3 do
|
|
20
|
+
has_text? 'Example Domain'
|
|
21
|
+
end
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
Wait up to 3.3 seconds for a `<div id='login'>` to appear and assign it to a variable for clicking.
|
|
25
|
+
|
|
26
|
+
```ruby
|
|
27
|
+
login = wait 3.3 do
|
|
28
|
+
find 'div#login'
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
login.click
|
|
32
|
+
```
|
|
33
|
+
|
data/lib/capybara_monkey.rb
CHANGED
|
@@ -3,12 +3,8 @@ module Superbara
|
|
|
3
3
|
module Node
|
|
4
4
|
class Element
|
|
5
5
|
module Includes
|
|
6
|
-
def type(*text)
|
|
7
|
-
self.native.type(*text)
|
|
8
|
-
end
|
|
9
|
-
|
|
10
6
|
def show(styles: nil, remove_highlight: 0.1)
|
|
11
|
-
execute_script "scrollTo(#{self.native.location.x}, #{self.native.location.y-200})"
|
|
7
|
+
Capybara.execute_script "scrollTo(#{self.native.location.x}, #{self.native.location.y-200})"
|
|
12
8
|
styles = [
|
|
13
9
|
{
|
|
14
10
|
"border" => "20px dashed Aqua"
|
|
@@ -24,6 +20,11 @@ module Superbara
|
|
|
24
20
|
|
|
25
21
|
self
|
|
26
22
|
end
|
|
23
|
+
|
|
24
|
+
def type(*inputs)
|
|
25
|
+
self.native.type(*inputs)
|
|
26
|
+
end
|
|
27
|
+
|
|
27
28
|
end #Includes
|
|
28
29
|
|
|
29
30
|
module Prepends
|
|
@@ -125,6 +126,10 @@ module Capybara
|
|
|
125
126
|
#warn "including Capybara::DSL in the global scope is not recommended!" if base == Object
|
|
126
127
|
#super
|
|
127
128
|
end
|
|
129
|
+
def self.extended(base)
|
|
130
|
+
#warn "extending the main object with Capybara::DSL is not recommended!" if base == Object
|
|
131
|
+
#super
|
|
132
|
+
end
|
|
128
133
|
end
|
|
129
134
|
|
|
130
135
|
module Node
|
data/lib/selenium_monkey.rb
CHANGED
|
@@ -4,23 +4,8 @@ module Superbara
|
|
|
4
4
|
class Element
|
|
5
5
|
module Includes
|
|
6
6
|
def type(*inputs)
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
end
|
|
10
|
-
|
|
11
|
-
for input in inputs
|
|
12
|
-
case input
|
|
13
|
-
when String
|
|
14
|
-
input.split("").each do |c|
|
|
15
|
-
natural_delay
|
|
16
|
-
self.send_keys c
|
|
17
|
-
end
|
|
18
|
-
when Symbol
|
|
19
|
-
natural_delay
|
|
20
|
-
self.send_keys input
|
|
21
|
-
end
|
|
22
|
-
end
|
|
23
|
-
true
|
|
7
|
+
self.click
|
|
8
|
+
Superbara::Helpers.type *inputs, element: self
|
|
24
9
|
end
|
|
25
10
|
|
|
26
11
|
def show(opts={})
|
data/lib/superbara/cli.rb
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
module Superbara; module CLI
|
|
2
2
|
def self.run!
|
|
3
|
+
require 'superbara/dsl'
|
|
3
4
|
main_command = ARGV[0]
|
|
4
5
|
|
|
5
6
|
case main_command
|
|
@@ -97,12 +98,12 @@ scroll 50
|
|
|
97
98
|
exit 1
|
|
98
99
|
end
|
|
99
100
|
end
|
|
100
|
-
|
|
101
|
+
Pry.start if ENV['SUPERBARA_DEBUG']
|
|
101
102
|
ctx = nil
|
|
102
103
|
webapp_thread = nil
|
|
103
104
|
puts "== superbara #{Superbara::VERSION} =="
|
|
104
105
|
loop do
|
|
105
|
-
Superbara.current_context = Superbara::Context.new
|
|
106
|
+
Superbara.current_context = Superbara::Context.new
|
|
106
107
|
|
|
107
108
|
begin
|
|
108
109
|
case main_command
|
|
@@ -121,9 +122,12 @@ scroll 50
|
|
|
121
122
|
webapp.run!
|
|
122
123
|
end
|
|
123
124
|
end
|
|
124
|
-
|
|
125
|
+
# to make debugger work (TODO)
|
|
126
|
+
extend Capybara::DSL
|
|
127
|
+
extend Superbara::DSL
|
|
125
128
|
Superbara.current_context.__superbara_eval "visit 'localhost:4567'"
|
|
126
|
-
Superbara.current_context.__superbara_debug
|
|
129
|
+
Superbara.current_context.__superbara_debug # <-- ONLY WORKS WITH THIS??? TODO
|
|
130
|
+
exit 0
|
|
127
131
|
when "run", "start"
|
|
128
132
|
puts "project: #{Superbara.project_name}"
|
|
129
133
|
puts ""
|
|
@@ -138,8 +142,7 @@ scroll 50
|
|
|
138
142
|
Superbara.visual_enable!
|
|
139
143
|
end
|
|
140
144
|
|
|
141
|
-
Superbara.current_context.__superbara_load
|
|
142
|
-
|
|
145
|
+
Superbara.current_context.__superbara_load File.join(Superbara.project_path, project_entrypoint)
|
|
143
146
|
puts """
|
|
144
147
|
🏁 🏁 🏁 done."""
|
|
145
148
|
|
|
@@ -147,7 +150,10 @@ scroll 50
|
|
|
147
150
|
when "run"
|
|
148
151
|
exit 0
|
|
149
152
|
when "start"
|
|
150
|
-
Superbara.current_context.
|
|
153
|
+
Superbara.current_context.__superbara_eval """
|
|
154
|
+
debug disable_whereami: true, help: false;
|
|
155
|
+
sleep 0.0001
|
|
156
|
+
"""
|
|
151
157
|
end
|
|
152
158
|
else
|
|
153
159
|
puts "Unknown command: #{main_command}"
|
|
@@ -172,7 +178,9 @@ in #{offending_file_path}:#{offending_line}
|
|
|
172
178
|
|
|
173
179
|
case main_command
|
|
174
180
|
when "start"
|
|
175
|
-
Superbara.current_context.
|
|
181
|
+
Superbara.current_context.instance_eval """debug disable_whereami: true, help: false
|
|
182
|
+
sleep 0.001
|
|
183
|
+
"""
|
|
176
184
|
else
|
|
177
185
|
exit 1
|
|
178
186
|
end
|
data/lib/superbara/context.rb
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
module Superbara; class Context
|
|
2
|
+
require_relative "dsl"
|
|
3
|
+
include Capybara::DSL
|
|
4
|
+
include Superbara::DSL
|
|
2
5
|
|
|
3
|
-
def initialize
|
|
4
|
-
@__superbara_shell = shell
|
|
6
|
+
def initialize
|
|
5
7
|
@__superbara_binding = binding
|
|
6
|
-
@__superbara_binding.eval """
|
|
7
|
-
require 'superbara/dsl'
|
|
8
|
-
"""
|
|
9
8
|
end
|
|
10
9
|
|
|
11
10
|
def __superbara_debug
|
|
@@ -16,7 +15,7 @@ sleep 0.0001
|
|
|
16
15
|
end
|
|
17
16
|
|
|
18
17
|
def __superbara_load(path)
|
|
19
|
-
load path
|
|
18
|
+
load path, true
|
|
20
19
|
end
|
|
21
20
|
|
|
22
21
|
def __superbara_eval(str)
|
data/lib/superbara/dsl.rb
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
module Superbara; module DSL
|
|
2
2
|
def self.included(includer)
|
|
3
|
-
#"Superbara::DSL included in #{includer.inspect}"
|
|
3
|
+
#puts "Superbara::DSL included in #{includer.inspect}"
|
|
4
|
+
end
|
|
5
|
+
|
|
6
|
+
def type(*inputs)
|
|
7
|
+
Superbara::Helpers.type *inputs
|
|
4
8
|
end
|
|
5
9
|
|
|
6
10
|
def assert(message=nil, &block)
|
|
@@ -21,18 +25,31 @@ module Superbara; module DSL
|
|
|
21
25
|
exit 1
|
|
22
26
|
end
|
|
23
27
|
|
|
28
|
+
def screenshot(name=nil)
|
|
29
|
+
name = "#{Time.now.year}-#{Time.now.month}-#{Time.now.day}-#{Time.now.hour}-#{Time.now.min}-#{Time.now.sec}" unless name
|
|
30
|
+
|
|
31
|
+
filename = if name.end_with? ".png"
|
|
32
|
+
name
|
|
33
|
+
else
|
|
34
|
+
"#{name}.png"
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
target_path = File.join(Superbara.project_path, filename)
|
|
38
|
+
save_screenshot(target_path)
|
|
39
|
+
end
|
|
40
|
+
|
|
24
41
|
def back
|
|
25
|
-
Superbara.toast
|
|
42
|
+
Superbara.toast "back", duration: 0.7, delay: 0
|
|
26
43
|
Capybara.go_back
|
|
27
44
|
end
|
|
28
45
|
|
|
29
46
|
def forward
|
|
30
|
-
Superbara.toast
|
|
47
|
+
Superbara.toast "forward", duration: 0.7, delay: 0
|
|
31
48
|
Capybara.go_forward
|
|
32
49
|
end
|
|
33
50
|
|
|
34
51
|
def reload
|
|
35
|
-
Superbara.toast
|
|
52
|
+
Superbara.toast "reload", duration: 0.7, delay: 0
|
|
36
53
|
Capybara.refresh
|
|
37
54
|
end
|
|
38
55
|
|
|
@@ -115,7 +132,7 @@ return Array.from(
|
|
|
115
132
|
end
|
|
116
133
|
|
|
117
134
|
Superbara.output "visit #{url_for_capybara}"
|
|
118
|
-
Superbara.toast
|
|
135
|
+
Superbara.toast "#{url_for_capybara}", delay: 1 if Superbara.visual?
|
|
119
136
|
|
|
120
137
|
Capybara.visit url_for_capybara
|
|
121
138
|
true # capybara returns nil
|
|
@@ -172,6 +189,7 @@ return Array.from(
|
|
|
172
189
|
|
|
173
190
|
Superbara.output " #{word.colorize(color)} (took #{(took_delta)}s)"
|
|
174
191
|
end
|
|
192
|
+
|
|
175
193
|
seconds = seconds.to_f
|
|
176
194
|
source_path, source_line = block.source_location
|
|
177
195
|
|
|
@@ -291,6 +309,5 @@ return Array.from(
|
|
|
291
309
|
end
|
|
292
310
|
end; end
|
|
293
311
|
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
312
|
+
extend Capybara::DSL
|
|
313
|
+
extend Superbara::DSL # override Capybara methods
|
data/lib/superbara/helpers.rb
CHANGED
|
@@ -1,4 +1,27 @@
|
|
|
1
1
|
module Superbara; module Helpers
|
|
2
|
+
def self.type(*inputs, element:nil)
|
|
3
|
+
for input in inputs
|
|
4
|
+
case input
|
|
5
|
+
when String
|
|
6
|
+
if input == "" && element
|
|
7
|
+
element.clear
|
|
8
|
+
else
|
|
9
|
+
input.split("").each do |c|
|
|
10
|
+
Superbara.human_typing_delay
|
|
11
|
+
Capybara.page.driver.browser.action.send_keys(c).perform
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
when Symbol
|
|
15
|
+
Superbara.human_typing_delay
|
|
16
|
+
Capybara.page.driver.browser.action.send_keys(input).perform
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
sleep 0.5 # without this events might not get sent properly
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
true
|
|
23
|
+
end
|
|
24
|
+
|
|
2
25
|
def self.highlight_element(elem, styles={}, remove_highlight=0.1)
|
|
3
26
|
remove_highlight_millis = (1000 * remove_highlight).round
|
|
4
27
|
|
|
@@ -49,7 +72,7 @@ window.setTimeout(function() {
|
|
|
49
72
|
js_builder
|
|
50
73
|
end
|
|
51
74
|
|
|
52
|
-
execute_script js
|
|
75
|
+
Capybara.execute_script js
|
|
53
76
|
sleep remove_highlight
|
|
54
77
|
end
|
|
55
78
|
end; end
|
data/lib/superbara/version.rb
CHANGED
data/lib/superbara.rb
CHANGED
|
@@ -19,6 +19,7 @@ module Superbara
|
|
|
19
19
|
@@current_context = nil
|
|
20
20
|
@@visual = false
|
|
21
21
|
@@started_at = Time.now
|
|
22
|
+
@@project_path = Dir.pwd
|
|
22
23
|
|
|
23
24
|
def self.start!
|
|
24
25
|
@@started_at = Time.now
|
|
@@ -105,6 +106,11 @@ module Superbara
|
|
|
105
106
|
File.join(File.dirname(__FILE__), "..")
|
|
106
107
|
end
|
|
107
108
|
|
|
109
|
+
def self.human_typing_delay
|
|
110
|
+
return unless ENV["SUPERBARA_HUMANIZE"]
|
|
111
|
+
sleep (rand(32) * 0.01).round(2)
|
|
112
|
+
end
|
|
113
|
+
|
|
108
114
|
def self.platform
|
|
109
115
|
require 'rbconfig'
|
|
110
116
|
cfg = RbConfig::CONFIG
|
|
@@ -126,7 +132,7 @@ module Superbara
|
|
|
126
132
|
end
|
|
127
133
|
end
|
|
128
134
|
|
|
129
|
-
def self.toast(text, duration: 1, delay:
|
|
135
|
+
def self.toast(text, duration: 1, delay: nil)
|
|
130
136
|
return unless Superbara.visual?
|
|
131
137
|
|
|
132
138
|
duration_millis = (duration * 1000).floor
|
|
@@ -177,7 +183,11 @@ setTimeout(function() {
|
|
|
177
183
|
}, #{duration_millis});
|
|
178
184
|
"""
|
|
179
185
|
Capybara.current_session.current_window.session.execute_script js
|
|
180
|
-
|
|
186
|
+
if delay
|
|
187
|
+
sleep delay
|
|
188
|
+
else
|
|
189
|
+
sleep duration
|
|
190
|
+
end
|
|
181
191
|
end
|
|
182
192
|
end
|
|
183
193
|
|
data/superbara.gemspec
CHANGED
|
@@ -30,6 +30,7 @@ Gem::Specification.new do |spec|
|
|
|
30
30
|
spec.add_dependency 'selenium-webdriver', '~> 3.12', '>= 3.12.0'
|
|
31
31
|
spec.add_dependency 'faker', '~> 1.8', '>= 1.8.7'
|
|
32
32
|
spec.add_dependency 'sinatra', '~> 2.0', '>= 2.0.1'
|
|
33
|
+
|
|
33
34
|
spec.add_development_dependency 'bundler', '~> 1.15', '>= 1.15.0'
|
|
34
35
|
spec.add_development_dependency 'rake', '~> 10.0', '>= 10.0.0'
|
|
35
36
|
spec.add_development_dependency 'rspec', '~> 3.7', '>= 3.7.0'
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
run "../common"
|
|
2
|
+
|
|
3
|
+
def test_file_path(name="test")
|
|
4
|
+
File.join(Superbara.project_path, "#{name}.png")
|
|
5
|
+
end
|
|
6
|
+
|
|
7
|
+
def cleanup(files)
|
|
8
|
+
for path in files
|
|
9
|
+
File.unlink path if File.exist? path
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
cleanup [test_file_path]
|
|
14
|
+
screenshot "test"
|
|
15
|
+
|
|
16
|
+
assert "#{test_file_path} not found" do
|
|
17
|
+
File.exist? test_file_path
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
png_files = Dir.glob(File.join(File.dirname(__FILE__), "*.png"))
|
|
22
|
+
cleanup png_files
|
|
23
|
+
|
|
24
|
+
screenshot
|
|
25
|
+
|
|
26
|
+
png_files = Dir.glob(File.join(File.dirname(__FILE__), "*.png"))
|
|
27
|
+
assert "did not find screenshot" do
|
|
28
|
+
png_files.any?
|
|
29
|
+
end
|
|
30
|
+
cleanup png_files
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: superbara
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.8.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Matti Paksula
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2018-05-
|
|
11
|
+
date: 2018-05-30 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: colorize
|
|
@@ -257,6 +257,58 @@ files:
|
|
|
257
257
|
- docker-compose.build.yml
|
|
258
258
|
- docker-compose.test.yml
|
|
259
259
|
- docker-compose.yml
|
|
260
|
+
- docs-src/book.toml
|
|
261
|
+
- docs-src/src/SUMMARY.md
|
|
262
|
+
- docs-src/src/getting_started/index.md
|
|
263
|
+
- docs-src/src/getting_started/shell.png
|
|
264
|
+
- docs-src/src/install.md
|
|
265
|
+
- docs-src/src/reference.md
|
|
266
|
+
- docs-src/src/reference/assert.md
|
|
267
|
+
- docs-src/src/reference/dialogs/alert.md
|
|
268
|
+
- docs-src/src/reference/dialogs/confirm.md
|
|
269
|
+
- docs-src/src/reference/dialogs/index.md
|
|
270
|
+
- docs-src/src/reference/dialogs/prompt.md
|
|
271
|
+
- docs-src/src/reference/find.md
|
|
272
|
+
- docs-src/src/reference/results.md
|
|
273
|
+
- docs-src/src/reference/tests/has_text.md
|
|
274
|
+
- docs-src/src/reference/tests/index.md
|
|
275
|
+
- docs-src/src/reference/wait.md
|
|
276
|
+
- docs-src/src/superbara.md
|
|
277
|
+
- docs/_FontAwesome/css/font-awesome.css
|
|
278
|
+
- docs/_FontAwesome/fonts/FontAwesome.ttf
|
|
279
|
+
- docs/_FontAwesome/fonts/fontawesome-webfont.eot
|
|
280
|
+
- docs/_FontAwesome/fonts/fontawesome-webfont.svg
|
|
281
|
+
- docs/_FontAwesome/fonts/fontawesome-webfont.ttf
|
|
282
|
+
- docs/_FontAwesome/fonts/fontawesome-webfont.woff
|
|
283
|
+
- docs/_FontAwesome/fonts/fontawesome-webfont.woff2
|
|
284
|
+
- docs/ayu-highlight.css
|
|
285
|
+
- docs/book.css
|
|
286
|
+
- docs/book.js
|
|
287
|
+
- docs/clipboard.min.js
|
|
288
|
+
- docs/elasticlunr.min.js
|
|
289
|
+
- docs/favicon.png
|
|
290
|
+
- docs/getting_started/index.html
|
|
291
|
+
- docs/getting_started/shell.png
|
|
292
|
+
- docs/highlight.css
|
|
293
|
+
- docs/highlight.js
|
|
294
|
+
- docs/index.html
|
|
295
|
+
- docs/install.html
|
|
296
|
+
- docs/mark.min.js
|
|
297
|
+
- docs/print.html
|
|
298
|
+
- docs/reference.html
|
|
299
|
+
- docs/reference/assert.html
|
|
300
|
+
- docs/reference/dialogs/alert.html
|
|
301
|
+
- docs/reference/dialogs/confirm.html
|
|
302
|
+
- docs/reference/dialogs/index.html
|
|
303
|
+
- docs/reference/dialogs/prompt.html
|
|
304
|
+
- docs/reference/find.html
|
|
305
|
+
- docs/reference/tests/has_text.html
|
|
306
|
+
- docs/reference/tests/index.html
|
|
307
|
+
- docs/reference/wait.html
|
|
308
|
+
- docs/searcher.js
|
|
309
|
+
- docs/searchindex.js
|
|
310
|
+
- docs/superbara.html
|
|
311
|
+
- docs/tomorrow-night.css
|
|
260
312
|
- exe/superbara
|
|
261
313
|
- lib/capybara_monkey.rb
|
|
262
314
|
- lib/pry_monkey.rb
|
|
@@ -280,6 +332,7 @@ files:
|
|
|
280
332
|
- tests/features/find.rb
|
|
281
333
|
- tests/features/navigate.rb
|
|
282
334
|
- tests/features/prompt.rb
|
|
335
|
+
- tests/features/screenshot.rb
|
|
283
336
|
- tests/features/type.rb
|
|
284
337
|
- tests/features/wait.rb
|
|
285
338
|
- tests/minimal/main.rb
|