superbara 0.8.1 → 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +4 -4
- data/Rakefile +17 -4
- data/examples/login-and-logout/common.rb +6 -0
- data/examples/login-and-logout/helpers/login.rb +19 -0
- data/examples/login-and-logout/helpers/logout.rb +5 -0
- data/examples/login-and-logout/main.rb +14 -0
- data/examples/sites/pharos.sh/main.rb +14 -0
- data/examples/sites/vr.fi/helsinki-tampere/main.rb +21 -0
- data/lib/selenium_monkey.rb +1 -1
- data/lib/superbara/dsl.rb +4 -3
- data/lib/superbara/helpers.rb +4 -0
- data/lib/superbara/version.rb +1 -1
- data/lib/superbara.rb +12 -9
- metadata +8 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b471220fa7a1ad1859a0c2b42685210eb6785ad3b2b00409af719c6bb2c8a228
|
4
|
+
data.tar.gz: 9d5fcfd54166dfb7293dd52d0d13808c486634111d0d76b2f90094ed2deb42ec
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 53a1072e41dded5d705a6703030c73ee9ca8ae546cb1f92469f08c1f6f9e7deebc9bb1f05f29d5c1abd402bdbfd63cf6a543d731ff6a744456c3dcfa4e1f8da4
|
7
|
+
data.tar.gz: b13287fe45fe64ba3773bda6818059a6128a0da738c76379302913984f4e35cd150de0e0ce0ad0ba31a6eb72712a50d4242affca3b92a3ec512abd50aa718f0d
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
superbara (0.
|
4
|
+
superbara (0.9.0)
|
5
5
|
binding_of_caller (~> 0.8, >= 0.8.0)
|
6
6
|
capybara (~> 3.1, >= 3.1.0)
|
7
7
|
colorize (~> 0.8, >= 0.8.1)
|
@@ -18,13 +18,13 @@ GEM
|
|
18
18
|
binding_of_caller (0.8.0)
|
19
19
|
debug_inspector (>= 0.0.1)
|
20
20
|
byebug (10.0.2)
|
21
|
-
capybara (3.
|
21
|
+
capybara (3.2.0)
|
22
22
|
addressable
|
23
23
|
mini_mime (>= 0.1.3)
|
24
24
|
nokogiri (~> 1.8)
|
25
25
|
rack (>= 1.6.0)
|
26
26
|
rack-test (>= 0.6.3)
|
27
|
-
xpath (~> 3.
|
27
|
+
xpath (~> 3.1)
|
28
28
|
childprocess (0.9.0)
|
29
29
|
ffi (~> 1.0, >= 1.0.11)
|
30
30
|
coderay (1.1.2)
|
@@ -34,7 +34,7 @@ GEM
|
|
34
34
|
diff-lcs (1.3)
|
35
35
|
faker (1.8.7)
|
36
36
|
i18n (>= 0.7)
|
37
|
-
ffi (1.9.
|
37
|
+
ffi (1.9.25)
|
38
38
|
i18n (1.0.1)
|
39
39
|
concurrent-ruby (~> 1.0)
|
40
40
|
kommando (0.1.2)
|
data/Rakefile
CHANGED
@@ -1,13 +1,12 @@
|
|
1
1
|
require "bundler/gem_tasks"
|
2
2
|
require "rspec/core/rake_task"
|
3
|
+
require 'kommando'
|
3
4
|
|
4
5
|
RSpec::Core::RakeTask.new(:spec)
|
5
6
|
|
6
|
-
task :default => [:spec, :
|
7
|
-
|
8
|
-
task :superbara do
|
9
|
-
require 'kommando'
|
7
|
+
task :default => [:spec, :cli, :examples]
|
10
8
|
|
9
|
+
task :cli do
|
11
10
|
k = Kommando.new "bin/tests", {
|
12
11
|
output: true
|
13
12
|
}
|
@@ -16,3 +15,17 @@ task :superbara do
|
|
16
15
|
|
17
16
|
raise "not clean" unless k.code == 0
|
18
17
|
end
|
18
|
+
|
19
|
+
task :examples do
|
20
|
+
mains = Dir.glob("examples/**/main.rb")
|
21
|
+
|
22
|
+
for main in mains do
|
23
|
+
k = Kommando.new "exe/superbara run #{main}", {
|
24
|
+
output: true
|
25
|
+
}
|
26
|
+
|
27
|
+
k.run
|
28
|
+
|
29
|
+
raise "not clean" unless k.code == 0
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
click_link 'Form Authentication'
|
2
|
+
|
3
|
+
# wait 3 seconds for field 'username' to appear
|
4
|
+
username = wait 3 do
|
5
|
+
find_field 'username'
|
6
|
+
end
|
7
|
+
|
8
|
+
# $username is set in vars.rb
|
9
|
+
username.type $username
|
10
|
+
|
11
|
+
# we assume that because username was found, then password will be found without waiting
|
12
|
+
# also we use parenthesis around to be able to call .type on the returned element
|
13
|
+
find_field('password').type $password
|
14
|
+
|
15
|
+
click_button 'Login'
|
16
|
+
|
17
|
+
wait 3 do
|
18
|
+
has_text? 'Welcome to the Secure Area'
|
19
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
visit 'vr.fi'
|
2
|
+
|
3
|
+
languages = wait 3 do
|
4
|
+
find("div.langbox")
|
5
|
+
end
|
6
|
+
|
7
|
+
english = languages.find("a", text: "EN")
|
8
|
+
english.click
|
9
|
+
|
10
|
+
wait 3 do
|
11
|
+
has_text? "Search timetables"
|
12
|
+
end
|
13
|
+
|
14
|
+
type :tab, "hels", :down, :tab, :tab
|
15
|
+
type "tamp", :down, :enter
|
16
|
+
|
17
|
+
type :enter
|
18
|
+
|
19
|
+
wait 5 do
|
20
|
+
has_text? "Outbound journey: Helsinki → Tampere"
|
21
|
+
end
|
data/lib/selenium_monkey.rb
CHANGED
data/lib/superbara/dsl.rb
CHANGED
@@ -71,7 +71,7 @@ return Array.from(
|
|
71
71
|
return e.textContent.toLowerCase().match('#{text}') ? true : false
|
72
72
|
}).pop()
|
73
73
|
"""
|
74
|
-
element =
|
74
|
+
element = Capybara.execute_script js
|
75
75
|
element&.show if Superbara.visual?
|
76
76
|
element
|
77
77
|
end
|
@@ -137,6 +137,7 @@ return Array.from(
|
|
137
137
|
Superbara.toast "#{url_for_capybara}", delay: 1 if Superbara.visual?
|
138
138
|
|
139
139
|
Capybara.visit url_for_capybara
|
140
|
+
|
140
141
|
true # capybara returns nil
|
141
142
|
end
|
142
143
|
|
@@ -187,7 +188,7 @@ return Array.from(
|
|
187
188
|
true
|
188
189
|
end
|
189
190
|
|
190
|
-
def wait(seconds, &block)
|
191
|
+
def wait(seconds=5, &block)
|
191
192
|
def wait_formatted_output(status, took_delta)
|
192
193
|
word, color = if status
|
193
194
|
["ok", :green]
|
@@ -225,7 +226,7 @@ return Array.from(
|
|
225
226
|
loop do
|
226
227
|
block_value = block.call
|
227
228
|
case block_value
|
228
|
-
when false, nil
|
229
|
+
when false, nil, []
|
229
230
|
sleep 0.1
|
230
231
|
else
|
231
232
|
break
|
data/lib/superbara/helpers.rb
CHANGED
@@ -49,6 +49,10 @@ __superbara.getElementByXpath = function(path) {
|
|
49
49
|
return document.evaluate(path, document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
|
50
50
|
};
|
51
51
|
window.__superbara.highlightElem = window.__superbara.getElementByXpath('#{elem.path}');
|
52
|
+
if (!window.__superbara.highlightElem) {
|
53
|
+
return;
|
54
|
+
}
|
55
|
+
|
52
56
|
window.__superbara.highlightElem.oldStyle = {};
|
53
57
|
"""
|
54
58
|
styles.each_pair do |k,v|
|
data/lib/superbara/version.rb
CHANGED
data/lib/superbara.rb
CHANGED
@@ -178,15 +178,18 @@ __superbaraToastTextElem.style.color = 'white';
|
|
178
178
|
__superbaraToastTextElem.textContent = '#{text}';
|
179
179
|
|
180
180
|
__superbaraToastContainerElem.appendChild(__superbaraToastTextElem);
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
181
|
+
|
182
|
+
if (window.document.body) {
|
183
|
+
window.document.body.appendChild(__superbaraToastContainerElem);
|
184
|
+
|
185
|
+
setTimeout(function() {
|
186
|
+
//__superbaraToastContainerElem.remove();
|
187
|
+
__superbaraToastContainerElem.style.visibility = 'hidden';
|
188
|
+
__superbaraToastContainerElem.style.opacity = 0;
|
189
|
+
__superbaraToastContainerElem.style.transition = 'visibility 0s 0.25s, opacity 0.25s linear';
|
190
|
+
// delete(window.__superbaraToastContainerElem);
|
191
|
+
}, #{duration_millis});
|
192
|
+
}
|
190
193
|
"""
|
191
194
|
Capybara.current_session.current_window.session.execute_script js
|
192
195
|
if delay
|
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.9.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-
|
11
|
+
date: 2018-06-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: colorize
|
@@ -309,6 +309,12 @@ files:
|
|
309
309
|
- docs/searchindex.js
|
310
310
|
- docs/superbara.html
|
311
311
|
- docs/tomorrow-night.css
|
312
|
+
- examples/login-and-logout/common.rb
|
313
|
+
- examples/login-and-logout/helpers/login.rb
|
314
|
+
- examples/login-and-logout/helpers/logout.rb
|
315
|
+
- examples/login-and-logout/main.rb
|
316
|
+
- examples/sites/pharos.sh/main.rb
|
317
|
+
- examples/sites/vr.fi/helsinki-tampere/main.rb
|
312
318
|
- exe/superbara
|
313
319
|
- lib/capybara_monkey.rb
|
314
320
|
- lib/pry_monkey.rb
|