Upload
-
View
460
Download
5
Embed Size (px)
Citation preview
Ruby integration
testing tools
2010
2015
2015
2015
_heading1 for h1
_dTerm for dt
_dList for dl
_spandiv for span or div
exists? calls exists1? 3 times
capybara-poltergeist-phantomjs 0.72 0.7 1.68 x x 3.29 x
capybara-racktest 0.05 x x x x x x
capybara-selenium-chrome 1.77 1.73 3.94 7.66 2.77 3.91 4.65
capybara-selenium-firefox 2.76 2.47 4.59 4.87 4.18 x 4.91
capybara-selenium-htmlunit 1.6 x x x x x x
capybara-selenium-ie 4.35 x 21.91 6.91 x 7.01 26.21
capybara-selenium-phantomjs 0.8 1.25 2.82 x x x x
capybara-webkit 0.12 x 0.82 x x 3.24 x
sahi-chrome 0.33 1.3 2.04 3.66 2.34 4.37 1.95
sahi-firefox 0.75 1.41 2.24 2.78 2.78 6.09 2.7
sahi-phantomjs x x x x x x x
watir-selenium-chrome 0.56 0.68 1.32 2.33 1.83 3.11 0.79
watir-selenium-firefox 0.22 0.45 1.27 1.51 2.32 4.11 1.35
watir-selenium-phantomjs 0.2 0.62 0.8 x x 3.79 x
Typical errors in
integration tests
find(‘.item’).click
Capybara.default_wait_time
•click_link(‘.item’)
•click_on(text_or_id)
• have_selector(‘.item’)
sleep 1
wait for something on page
•_sahi._wait($timeout[, $condition])
•Watir::Wait.until { ... }
• Capybara.using_wait_time(seconds) { … }
post.reload.liked?.should be_true
slow ajax
•wait_for_ajax
• wait_until { post.reload.liked? }
page.find(:xpath,
‘html/body/div/nav/a[4]’)
•unreadable xpath
• flexible DOM structure
find(‘nav .settings’)
all(‘.item’).first
ordering items on page
first(‘.item’)
have_selector(‘th:nth-child(4)’)
cross-browser compatibility
have_selector(‘th:first-child+th+th+th’)
have_selector(‘.col-md-9.settings’)
mixing semantics and markup
have_selector(‘.settings’)
find(‘.checkbox’).set(true)
not idempotent for checkbox
find(‘.checkbox’).set(true)
not idempotent for checkbox
find(‘.checkbox’).set(false)
find(‘.checkbox’).set(true)
find(‘input’).value != ‘’
value could be ‘null’ or ‘undefined’
have_field(‘name’, with: ‘value’)
click_link(‘a’)
Font Awesome
width: 12px;
height: 12px;
Decorating radio input
find(“label”, text: “bar”).click
label
input type=“radio” value=“foo”
find(“[value=‘foo’]”).click
find(‘input’).set(‘\r’)
find(‘input’).set(‘\r\n’)
platform dependence
•Capybara.current_driver
•_sahi._isIE
•browser.driver.browser
test gaps
Test 1 Test 2
Test 1
Test 2
before(:each) { login_as @user }
too slow
• combine small tests to one
•use devise helper
something goes wrong
not supported or buggy
• evaluate_script
•execute_script
•browser_js
useful gems:
• vcr
• parallel_tests
• capybara-angular
• capybara-extensions
• watir-capybara-helpers
capybara-webkit
or
selenium-webdriver
useful services:
• browserstack
• sauce labs
• solano labs(tddium)
Questions?
Links
• http://altoros.github.io/2013/running-capybara-tests-in-remote-browsers/
• https://coderwall.com/p/aklybw
• https://gist.github.com/jnicklas/d8da686061f0a59ffdf7
• http://www.browserstack.com/
• https://saucelabs.com/
• https://www.tddium.com/
• http://jnicklas.github.io/capybara/
• http://watirwebdriver.com/
• http://sahipro.com/
• https://github.com/melnikaite/ritt_performance