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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b54a0a96ac8a218737403e0ca7fec18fab1f87c8248f7f9ce94d9de0d4441a1e
4
- data.tar.gz: 6e48efea3c3f0971709b27e3211427728ef77315d4831e8f3b347c5666065131
3
+ metadata.gz: b471220fa7a1ad1859a0c2b42685210eb6785ad3b2b00409af719c6bb2c8a228
4
+ data.tar.gz: 9d5fcfd54166dfb7293dd52d0d13808c486634111d0d76b2f90094ed2deb42ec
5
5
  SHA512:
6
- metadata.gz: 70c3466d8bc49ca62cbf1a384580e7e3859d9f982503ef1fa199280a92e0dfc6e2c7d7e5169c45db71455ba62d87dea170e6ebaf22dbc550701228667414f794
7
- data.tar.gz: 965c67b7d7bc3ed033c4f375f2964493c9d9887635129bd93f6fad7d3fa1e3afb88aa18bcaa4f85945f2d65e5736069d8e7c21e7c8dd65d39c7df3d62879728d
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.8.1)
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.1.1)
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.0)
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.23)
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, :superbara]
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,6 @@
1
+ # bring focus to the browser, but just once in a session
2
+ focus once: true
3
+
4
+ # these can be used in our tests, for example here in helpers/login.rb
5
+ $username = 'tomsmith'
6
+ $password = 'SuperSecretPassword!'
@@ -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,5 @@
1
+ click_link 'Logout'
2
+
3
+ wait 3 do
4
+ has_text? 'You logged out'
5
+ end
@@ -0,0 +1,14 @@
1
+ run 'common'
2
+ visit 'the-internet.herokuapp.com'
3
+
4
+ # by default waits 5 seconds
5
+ wait do
6
+ has_text? 'Welcome to the-internet'
7
+ end
8
+
9
+ run 'helpers/login'
10
+
11
+ # do nothing for 2 seconds
12
+ sleep 2
13
+
14
+ run 'helpers/logout'
@@ -0,0 +1,14 @@
1
+ focus once: true
2
+
3
+ visit 'pharos.sh'
4
+
5
+ wait 3 do
6
+ has_text? 'The simple, solid, certified Kubernetes'
7
+ end
8
+
9
+ click "a", text: "Pricing"
10
+
11
+ 3.times do
12
+ buttons = all "button"
13
+ buttons.first.click
14
+ 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
@@ -9,7 +9,7 @@ module Superbara
9
9
  end
10
10
 
11
11
  def show(opts={})
12
- execute_script "scrollTo(#{self.location.x}, #{self.location.y-200})"
12
+ Capybara.execute_script "scrollTo(#{self.location.x}, #{self.location.y-200})"
13
13
  Superbara::Helpers.highlight_element(self)
14
14
  end
15
15
  end
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 = page.execute_script js
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
@@ -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|
@@ -1,3 +1,3 @@
1
1
  module Superbara
2
- VERSION = "0.8.1"
2
+ VERSION = "0.9.0"
3
3
  end
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
- window.document.body.appendChild(__superbaraToastContainerElem);
182
-
183
- setTimeout(function() {
184
- //__superbaraToastContainerElem.remove();
185
- __superbaraToastContainerElem.style.visibility = 'hidden';
186
- __superbaraToastContainerElem.style.opacity = 0;
187
- __superbaraToastContainerElem.style.transition = 'visibility 0s 0.25s, opacity 0.25s linear';
188
- // delete(window.__superbaraToastContainerElem);
189
- }, #{duration_millis});
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.8.1
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-05-30 00:00:00.000000000 Z
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