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
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
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
Offline should be the norm: building local-first apps with CRDTs & Kotlin Multiplatform
renaudmathieu
0
180
年間50登壇、単著出版、雑誌寄稿、Podcast出演、YouTube、CM、カンファレンス主催……全部やってみたので面白さ等を比較してみよう / I’ve tried them all, so let’s compare how interesting they are.
nrslib
4
760
CursorとClaudeCodeとCodexとOpenCodeを実際に比較してみた
terisuke
1
340
Xdebug と IDE による デバッグ実行の仕組みを見る / Exploring-How-Debugging-Works-with-Xdebug-and-an-IDE
shin1x1
0
360
セグメントとターゲットを意識するプロポーザルの書き方 〜採択の鍵は、誰に刺すかを見極めるマーケティング戦略にある〜
m3m0r7
PRO
0
390
飯MCP
yusukebe
0
490
事業会社でのセキュリティ長期インターンについて
masachikaura
0
240
Java 21/25 Virtual Threads 소개
debop
0
340
3分でわかるatama plusのQA/about atama plus QA
atamaplus
0
130
ふりがな Deep Dive try! Swift Tokyo 2026
watura
0
170
へんな働き方
yusukebe
6
2.9k
メッセージングを利用して時間的結合を分離しよう #phperkaigi
kajitack
3
570
Featured
See All Featured
AI in Enterprises - Java and Open Source to the Rescue
ivargrimstad
0
1.2k
The Organizational Zoo: Understanding Human Behavior Agility Through Metaphoric Constructive Conversations (based on the works of Arthur Shelley, Ph.D)
kimpetersen
PRO
0
310
Lessons Learnt from Crawling 1000+ Websites
charlesmeaden
PRO
1
1.2k
How to audit for AI Accessibility on your Front & Back End
davetheseo
0
240
Art, The Web, and Tiny UX
lynnandtonic
304
21k
Navigating Team Friction
lara
192
16k
Designing Dashboards & Data Visualisations in Web Apps
destraynor
231
54k
Six Lessons from altMBA
skipperchong
29
4.2k
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
38
2.8k
Why Mistakes Are the Best Teachers: Turning Failure into a Pathway for Growth
auna
0
110
Money Talks: Using Revenue to Get Sh*t Done
nikkihalliwell
0
200
Organizational Design Perspectives: An Ontology of Organizational Design Elements
kimpetersen
PRO
1
670
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