«ruby integration testing tools»
TRANSCRIPT
![Page 1: «Ruby integration testing tools»](https://reader034.vdocuments.site/reader034/viewer/2022042716/55a69a061a28ab90668b461d/html5/thumbnails/1.jpg)
Ruby integration
testing tools
![Page 2: «Ruby integration testing tools»](https://reader034.vdocuments.site/reader034/viewer/2022042716/55a69a061a28ab90668b461d/html5/thumbnails/2.jpg)
2010
![Page 3: «Ruby integration testing tools»](https://reader034.vdocuments.site/reader034/viewer/2022042716/55a69a061a28ab90668b461d/html5/thumbnails/3.jpg)
2015
![Page 4: «Ruby integration testing tools»](https://reader034.vdocuments.site/reader034/viewer/2022042716/55a69a061a28ab90668b461d/html5/thumbnails/4.jpg)
![Page 5: «Ruby integration testing tools»](https://reader034.vdocuments.site/reader034/viewer/2022042716/55a69a061a28ab90668b461d/html5/thumbnails/5.jpg)
2015
![Page 6: «Ruby integration testing tools»](https://reader034.vdocuments.site/reader034/viewer/2022042716/55a69a061a28ab90668b461d/html5/thumbnails/6.jpg)
![Page 7: «Ruby integration testing tools»](https://reader034.vdocuments.site/reader034/viewer/2022042716/55a69a061a28ab90668b461d/html5/thumbnails/7.jpg)
2015
![Page 8: «Ruby integration testing tools»](https://reader034.vdocuments.site/reader034/viewer/2022042716/55a69a061a28ab90668b461d/html5/thumbnails/8.jpg)
_heading1 for h1
_dTerm for dt
_dList for dl
_spandiv for span or div
exists? calls exists1? 3 times
![Page 9: «Ruby integration testing tools»](https://reader034.vdocuments.site/reader034/viewer/2022042716/55a69a061a28ab90668b461d/html5/thumbnails/9.jpg)
![Page 10: «Ruby integration testing tools»](https://reader034.vdocuments.site/reader034/viewer/2022042716/55a69a061a28ab90668b461d/html5/thumbnails/10.jpg)
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
![Page 11: «Ruby integration testing tools»](https://reader034.vdocuments.site/reader034/viewer/2022042716/55a69a061a28ab90668b461d/html5/thumbnails/11.jpg)
Typical errors in
integration tests
![Page 12: «Ruby integration testing tools»](https://reader034.vdocuments.site/reader034/viewer/2022042716/55a69a061a28ab90668b461d/html5/thumbnails/12.jpg)
find(‘.item’).click
Capybara.default_wait_time
•click_link(‘.item’)
•click_on(text_or_id)
• have_selector(‘.item’)
![Page 13: «Ruby integration testing tools»](https://reader034.vdocuments.site/reader034/viewer/2022042716/55a69a061a28ab90668b461d/html5/thumbnails/13.jpg)
![Page 14: «Ruby integration testing tools»](https://reader034.vdocuments.site/reader034/viewer/2022042716/55a69a061a28ab90668b461d/html5/thumbnails/14.jpg)
sleep 1
wait for something on page
•_sahi._wait($timeout[, $condition])
•Watir::Wait.until { ... }
• Capybara.using_wait_time(seconds) { … }
![Page 15: «Ruby integration testing tools»](https://reader034.vdocuments.site/reader034/viewer/2022042716/55a69a061a28ab90668b461d/html5/thumbnails/15.jpg)
post.reload.liked?.should be_true
slow ajax
•wait_for_ajax
• wait_until { post.reload.liked? }
![Page 16: «Ruby integration testing tools»](https://reader034.vdocuments.site/reader034/viewer/2022042716/55a69a061a28ab90668b461d/html5/thumbnails/16.jpg)
page.find(:xpath,
‘html/body/div/nav/a[4]’)
•unreadable xpath
• flexible DOM structure
find(‘nav .settings’)
![Page 17: «Ruby integration testing tools»](https://reader034.vdocuments.site/reader034/viewer/2022042716/55a69a061a28ab90668b461d/html5/thumbnails/17.jpg)
all(‘.item’).first
ordering items on page
first(‘.item’)
![Page 18: «Ruby integration testing tools»](https://reader034.vdocuments.site/reader034/viewer/2022042716/55a69a061a28ab90668b461d/html5/thumbnails/18.jpg)
have_selector(‘th:nth-child(4)’)
cross-browser compatibility
have_selector(‘th:first-child+th+th+th’)
![Page 19: «Ruby integration testing tools»](https://reader034.vdocuments.site/reader034/viewer/2022042716/55a69a061a28ab90668b461d/html5/thumbnails/19.jpg)
have_selector(‘.col-md-9.settings’)
mixing semantics and markup
have_selector(‘.settings’)
![Page 20: «Ruby integration testing tools»](https://reader034.vdocuments.site/reader034/viewer/2022042716/55a69a061a28ab90668b461d/html5/thumbnails/20.jpg)
find(‘.checkbox’).set(true)
not idempotent for checkbox
![Page 21: «Ruby integration testing tools»](https://reader034.vdocuments.site/reader034/viewer/2022042716/55a69a061a28ab90668b461d/html5/thumbnails/21.jpg)
![Page 22: «Ruby integration testing tools»](https://reader034.vdocuments.site/reader034/viewer/2022042716/55a69a061a28ab90668b461d/html5/thumbnails/22.jpg)
find(‘.checkbox’).set(true)
not idempotent for checkbox
find(‘.checkbox’).set(false)
find(‘.checkbox’).set(true)
![Page 23: «Ruby integration testing tools»](https://reader034.vdocuments.site/reader034/viewer/2022042716/55a69a061a28ab90668b461d/html5/thumbnails/23.jpg)
find(‘input’).value != ‘’
value could be ‘null’ or ‘undefined’
have_field(‘name’, with: ‘value’)
![Page 24: «Ruby integration testing tools»](https://reader034.vdocuments.site/reader034/viewer/2022042716/55a69a061a28ab90668b461d/html5/thumbnails/24.jpg)
click_link(‘a’)
Font Awesome
width: 12px;
height: 12px;
![Page 25: «Ruby integration testing tools»](https://reader034.vdocuments.site/reader034/viewer/2022042716/55a69a061a28ab90668b461d/html5/thumbnails/25.jpg)
Decorating radio input
find(“label”, text: “bar”).click
label
input type=“radio” value=“foo”
find(“[value=‘foo’]”).click
![Page 26: «Ruby integration testing tools»](https://reader034.vdocuments.site/reader034/viewer/2022042716/55a69a061a28ab90668b461d/html5/thumbnails/26.jpg)
find(‘input’).set(‘\r’)
find(‘input’).set(‘\r\n’)
platform dependence
•Capybara.current_driver
•_sahi._isIE
•browser.driver.browser
![Page 27: «Ruby integration testing tools»](https://reader034.vdocuments.site/reader034/viewer/2022042716/55a69a061a28ab90668b461d/html5/thumbnails/27.jpg)
test gaps
Test 1 Test 2
Test 1
Test 2
![Page 28: «Ruby integration testing tools»](https://reader034.vdocuments.site/reader034/viewer/2022042716/55a69a061a28ab90668b461d/html5/thumbnails/28.jpg)
before(:each) { login_as @user }
too slow
• combine small tests to one
•use devise helper
![Page 29: «Ruby integration testing tools»](https://reader034.vdocuments.site/reader034/viewer/2022042716/55a69a061a28ab90668b461d/html5/thumbnails/29.jpg)
something goes wrong
not supported or buggy
• evaluate_script
•execute_script
•browser_js
![Page 30: «Ruby integration testing tools»](https://reader034.vdocuments.site/reader034/viewer/2022042716/55a69a061a28ab90668b461d/html5/thumbnails/30.jpg)
useful gems:
• vcr
• parallel_tests
• capybara-angular
• capybara-extensions
• watir-capybara-helpers
![Page 31: «Ruby integration testing tools»](https://reader034.vdocuments.site/reader034/viewer/2022042716/55a69a061a28ab90668b461d/html5/thumbnails/31.jpg)
capybara-webkit
or
selenium-webdriver
![Page 32: «Ruby integration testing tools»](https://reader034.vdocuments.site/reader034/viewer/2022042716/55a69a061a28ab90668b461d/html5/thumbnails/32.jpg)
useful services:
• browserstack
• sauce labs
• solano labs(tddium)
![Page 33: «Ruby integration testing tools»](https://reader034.vdocuments.site/reader034/viewer/2022042716/55a69a061a28ab90668b461d/html5/thumbnails/33.jpg)
Questions?
![Page 34: «Ruby integration testing tools»](https://reader034.vdocuments.site/reader034/viewer/2022042716/55a69a061a28ab90668b461d/html5/thumbnails/34.jpg)
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