Project

superbara

0.01
No release in over 3 years
Low commit activity in last 3 years
There's a lot of open issues
Better way to build Capybara tests
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 1.15.0, ~> 1.15
>= 12.3.0, ~> 12.3

Runtime

~> 1.3, >= 1.3.1
>= 0.8.0, ~> 0.8
= 3.29, = 3.29.0
~> 0.8, >= 0.8.1
~> 1.8, >= 1.8.7
~> 0.1, >= 0.1.2
>= 0
>= 3.6.0, ~> 3.6
~> 1.4, >= 1.4.4
~> 0.5, >= 0.5.5
>= 3.7.0, ~> 3.7
= 4.0.0.alpha3
~> 2.0, >= 2.0.1
 Project Readme

Superbara

Web app test scripting that does not hurt.

Demo of Superbara

  • Stands on the shoulders of Capybara
  • All batteries included: just start scripting, nothing extra required
  • A powerful command line interface with interactive debugger
  • The most natural test language that is still programming, see:
visit "mysite.com"
wait 3 do
  has_text? "welcome"
end

scroll 20
click_link "enter"

name_field = find "input#name"
name_field.type "Sarah", :enter

if has_text? "Welcome, Sarah"
  run "logout"
else
  assert "no greeting visible"
end

Install & Usage

gem install superbara
superbara init example
superbara start example
superbara usage

Documentation

See https://matti.github.io/superbara for getting started and language reference.

Some things that Superbara does that Capybara does not:

# find+click in one line!
click 'h1'

# wait up to 3 seconds for block to return something else than nil or false
wait 3 do
  has_text? "Welcome"
end

wait 3.1 do
  find "#username"
end

# simulates real typing
textarea = find "textarea"
textarea.type "hello", :backspace, :backspace, :backspace, "sinki", :enter

# scrolling
scroll 50
scroll -20, duration: 4

# works also without http://
visit 'example.com'

# highlights when in interactive mode or SUPERBARA_VISUAL env is set
find "h1"

# runs project/file.rb
run "vars"

# possible to run just once per session (superbara start) to speed up
run "login", {}, once: true

# ..and do something when already ran
run "login", {}, once: true do
  # when already logged in
  visit "http://www.example.com/main"
end

# opens debugger when exception happens or when the test finishes or
debug

# back, forward, reload (and not only go_back, go_forward, refresh)
back
forward
reload

# natural sleeps, sleep between 2 and 4 seconds
think 2..4

Everything that works in Capybara, works in Superbara, see https://github.com/teamcapybara/capybara/#the-dsl

Quick Reference:

click_link 'id-of-link'
click_link 'Link Text'
click_button 'Save'
click_on 'Link Text' || click_on 'Button Value'
click_text 'get started'

find 'h1'
find_field('First Name').value
find_field(id: 'my_field').value
find_link('Hello', :visible => :all).visible?
find_link(class: ['some_class', 'some_other_class'], visible: :all).visible?

find_button('Send').click
find_button(value: '1234').click

find(:xpath, ".//table/tr").click
find("#overlay").find("h1").click
for a in all('a') do
  if a[:href].include? "about"
    a.click
  end
end

img_boxed = find('img') do |el|
  el['data-box'] == true
end

within '#menu' do
  click 'a', text: 'Pricing'
end

within_table 'Employee' do
  fill_in 'Name', with: 'Sarah'
end

within_fieldset 'Employee' do
  ...
end

facebook_window = window_opened_by do
  click_button 'Like'
end

within_window facebook_window do
  find('#login_email').type 'a@example.com'
  find('#login_password').type 'qwerty'
  click_button 'Submit'
end

execute_script "document.querySelector("#name").style.border = '1px solid red';"

value = evaluate_script "window.innerHeight"

accept_alert do
  click_link 'Show Alert'
end

dismiss_confirm do
  click_link 'Show Confirm'
end

message = accept_prompt with: 'Linda Liukas' do
  click_link 'Author Quiz!'
end
message = 'Who is the author of Hello Ruby?'

has_selector? 'table tr'
has_no_selector? 'table tr'

has_selector? :xpath, './/table/tr'

has_xpath? './/table/tr'
has_no_xpath? './/table/tr'
has_css? 'table tr.foo'
has_no_css? 'table tr.foo'

has_content? 'foo'
has_no_content? 'foo'
has_text? 'foo'
has_no_text? 'foo'

fill_in 'First Name', with: 'Johwn'
choose 'A Radio Button'
check 'A Checkbox'
uncheck 'A Checkbox'
attach_file 'Image', File.join(Dir.pwd,'image.jpg')
select 'Option', from: 'Select Box'