Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Functional testing with capybara
Search
koffeinfrei
August 22, 2012
Programming
220
3
Share
Functional testing with capybara
Functional testing with capybara, shown by examples from the metaflop project.
koffeinfrei
August 22, 2012
More Decks by koffeinfrei
See All by koffeinfrei
Volt Showcase - Planning Poker
koffeinfrei
0
53
Other Decks in Programming
See All in Programming
Spec-driven Development: How AI Changes Everything (And Nothing)
simas
PRO
0
430
Agentic Elixir
whatyouhide
0
420
AI時代のPhpStorm最新事情 #phpcon_odawara
yusuke
0
240
書き換えて学ぶTemporal #fukts
pirosikick
1
280
クラウドネイティブなエンジニアに向ける Raycastの魅力と実際の活用事例
nealle
2
230
(Re)make Regexp in Ruby: Democratizing internals for the JIT
makenowjust
3
890
Import assertionsが消えた日~ECMAScriptの仕様はどう決まり、なぜ覆るのか~
bicstone
1
130
AIを導入する前にやるべきこと
negima
2
310
iOS機能開発のAI環境と起きた変化
ryunakayama
0
190
ハーネスエンジニアリングとは?
kinopeee
13
6.4k
The Less-Told Story of Socket Timeouts
coe401_
3
810
t *testing.T は どこからやってくるの?
otakakot
1
830
Featured
See All Featured
The Invisible Side of Design
smashingmag
303
52k
Agile that works and the tools we love
rasmusluckow
331
21k
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
162
16k
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
9
1.3k
DBのスキルで生き残る技術 - AI時代におけるテーブル設計の勘所
soudai
PRO
64
54k
Data-driven link building: lessons from a $708K investment (BrightonSEO talk)
szymonslowik
1
1k
Side Projects
sachag
455
43k
A Modern Web Designer's Workflow
chriscoyier
698
190k
Six Lessons from altMBA
skipperchong
29
4.2k
svc-hook: hooking system calls on ARM64 by binary rewriting
retrage
2
230
Public Speaking Without Barfing On Your Shoes - THAT 2023
reverentgeek
1
380
Principles of Awesome APIs and How to Build Them.
keavy
128
17k
Transcript
capybara
None
overview automated user interaction automatically waits for asynchronous tasks driver
agnostic high level access to ui elements
test frameworks cucumber rspec test::unit minitest::spec
drivers
rack_test default fast, no server no js mechanize rack_test with
remote server
selenium 2.0 aka webdriver firefox, chrome, ie, ...
webkit headless QtWebKitk logging / messages screenshots cookies resizing the
window
poltergeist headless phantomjs screenshots resizing the window remote debugging (web
inspector) no X (CI integration)
dsl
navigating visit('/projects') visit(post_comments_path(post))
clicking links and buttons click_link('id-of-link') click_link('Link Text') click_button('Save') click_on('Link Text')
# links or buttons
interacting with forms fill_in('Username', :with => 'user') choose('A Radio Button')
check('A Checkbox') attach_file('Image', '/path/to/image.jpg') select('Option', :from => 'Select Box')
querying (rspec matchers) page.should have_selector('table tr') page.should have_selector( :xpath, '//table/tr')
page.should have_xpath('//table/tr') page.should have_css('table tr.foo') page.should have_content('foo')
finding find_field('First Name').value find_link('Hello').visible? find_button('Send').click find("#overlay").find("h1").click all('a').each { |a| a[:href]
}
scoping within("li#employee") do fill_in 'Name', :with => 'Jimmy' end
scripting page.execute_script("$('body').empty()") result = page.evaluate_script('4 + 4');
debugging save_and_open_page # snapshot print page.html
setup
Capybara.default_driver = :selenium # sinatra Capybara.app = App # remote
app Capybara.app_host = 'http://www.google.com'
per spec Capybara.javascript_driver = :selenium # ... describe 'requires js',
:js => true do it 'will use the default js driver' it 'will switch to one specific driver', :driver => :webkit end
set browser Capybara.register_driver :selenium do |app| Capybara::Selenium::Driver.new( app, :browser =>
:chrome ) end
in the wild
metaflop web based platform for metafonts and related type projects
modulator experimental font generation export as otf, webfont
spec sample 1 context 'when i change the unit width'
do it 'should show the loading indicator' do fill_in 'param-unit-width', :with => 2 page.should have_selector( '.preview-loading-text') end end
spec sample 2 context 'when i enable anatomy' do it
'shows the anatomy image' do within '#menu' do click_link 'on' end page.should have_selector '#info-panel' end end
spec sample 3 context 'when i click the "webfont" link'
do it 'should call the font generator url' do click_link('webfont') current_url.should include 'modulator/export/font/web' end end
problems
general dialogs (downloads) new openend windows driver specialties
selenium slow, startup slow, random errors no http response no
.trigger() (e.g. mouse over) installation
solution avoid selenium use headless test visual concerns manually
links capybara homepage webkit poltergeist selenium chrome driver metaflop
@alexisreigel koffeinfrei koffeinfrei.org