際際滷

際際滷Share a Scribd company logo
Integration Test
Cucumber + Webrat + Selenium
about me

 ?          a.k.a tka, tkalu

 ?   http://www.twitter.com/tkalu

 ?   http://www.tkalu.com

 ?
     http://www.handlino.com
Ruby Tuesday

                    gugod
 #6 Integration Test With Cucumber And Webrat


                    weijen
#3         rspec
           Mock Aren't Stub
Source Code


http://github.com/tka/it-cws-demo
Cucumber
 http://cukes.info/
Cucumber
Cucumber

 :


           "   "
Webrat
http://gitrdoc.com/brynary/webrat
http://github.com/brynary/webrat
Webrat

 visit login_url
 ?ll_in ^Login ̄, :with => ^User ̄
 ?ll_in ^Password ̄, :with => ^123456 ̄
 click_button ^Log in ̄

http://gitrdoc.com/brynary/webrat/tree/master
Cucumber + Webrat
Given /^                            $/ do
  visit logout_path
end

And /^                      $/ do
  visit root_path
end

Then /^             "([^"]*)"$/ do | text |
    assert_contain text
end
Cucumber + Webrat

? cucumber -f pretty features/p5.feature

? cucumber -f html 
  features/p5.feature > test.html
,        ....


javascript
Browser
Selenium
http://seleniumhq.org/
Selenium




? Selenium IDE
? elenium Remote Control (RC)
? Selenium Grid
Selenium


                 ? FireFox
? Linux          ? Chrome
? OS X           ? Safari
? Windows        ? Opera
                 ? IE 7,8 (6 not in the list)
Selenium & Ruby


? gem install selenium-client
? require "selenium/client"
Selenium
@browser = Selenium::Client::Driver.new 
    :host => "localhost",
    :port => 4444,
    :browser => "*firefox",
    :url => "http://www.google.com",
    :timeout_in_second => 60

@browser.start_new_browser_session
@browser.open "/"
@browser.type "q", "Ruby Tuesday #11"
@browser.click "btnG", :wait_for => :page
@browser.capture_entire_page_screenshot('/Users/tka/1.png','')
puts @browser.text?("Ruby Tuesday #11 |Registrano")

         http://selenium-client.rubyforge.org/

             ruby script/selenium_demo.rb
Webrat + Selenium
Webrat.con?gure do |con?g|
 con?g.mode = :selenium
 con?g.selenium_server_address = 'localhost'
 con?g.application_framework = :external
end

visit 'http://www.google.com'
?ll_in "q", :with => 'Ruby Tuesday #11'
click_button "Google         "
selenium.wait_for_page_to_load(10)
assert_contain "Ruby Tuesday #11 | Registrano"
save_and_open_screengrab

   ruby script/webrat_selenium_demo.rb
Cucumber + Webrat + Selenium
                features/support/env.rb
Webrat.configure do |config|
  config.mode = :rails
  config.open_error_files = false

  if ENV["USE_SELENIUM"]
    config.mode = :selenium
    config.selenium_browser_key = ENV["SELENIUM_BROWSER"] || "*firefox"
    if ENV["SELENIUM_SERVER"]
      config.selenium_server_address = ENV["SELENIUM_SERVER"]
    end
    config.application_address = ENV["SELENIUM_APPLICATION"] || "localhost"
    config.application_port = ENV["SELENIUM_APPLICATION_PORT"] || "3000"
  end
end


               USE_SELENIUM=1 cucumber
Cucumber pro?le
                     con?g/cucumber.yml

   selenium: -r features/support/env.rb 
             -r features/support/enhanced.rb 
             -r features/step_definitions features/enhanced



                 cucumber -p selenium

http://wiki.github.com/aslakhellesoy/cucumber/setting-up-selenium
VirtualBox

?             Vmware
?             VBoxManage cli
    ?   OSX     /Applications/VirtualBox.app/Contents/MacOS/VBoxManage

    ?
Integration Test Cucumber + Webrat + Selenium
webrat-0.7.0/lib/webrat/selenium/
      location_strategy_javascript/label.js

var labelFor = locatedLabel.getAttribute('for');

// IE--
if (labelFor == null && "v"=="v"){
  labelFor=locatedLabel.htmlFor
}

if (labelFor == null && locatedLabel.hasChildNodes()) {
? cronjob
 ?        VM
 ?        VM      selenium
 ?       cucumber + webrat + selenium
 ?              ,
Q&A

More Related Content

What's hot (18)

Cool like a Frontend Developer: Grunt, RequireJS, Bower and other Tools
Cool like a Frontend Developer: Grunt, RequireJS, Bower and other ToolsCool like a Frontend Developer: Grunt, RequireJS, Bower and other Tools
Cool like a Frontend Developer: Grunt, RequireJS, Bower and other Tools
Ryan Weaver
?
Search and play more than 50 clips
Search and play more than 50 clipsSearch and play more than 50 clips
Search and play more than 50 clips
phanhung20
?
Mastering Grunt
Mastering GruntMastering Grunt
Mastering Grunt
Spencer Handley
?
Scraping recalcitrant web sites with Python & Selenium
Scraping recalcitrant web sites with Python & SeleniumScraping recalcitrant web sites with Python & Selenium
Scraping recalcitrant web sites with Python & Selenium
Roger Barnes
?
Building com Phing - 7Masters PHP
Building com Phing - 7Masters PHPBuilding com Phing - 7Masters PHP
Building com Phing - 7Masters PHP
iMasters
?
The Peanut Butter Cup of Web-dev: Plack and single page web apps
The Peanut Butter Cup of Web-dev: Plack and single page web appsThe Peanut Butter Cup of Web-dev: Plack and single page web apps
The Peanut Butter Cup of Web-dev: Plack and single page web apps
John Anderson
?
JavaScript APIs - The Web is the Platform
JavaScript APIs - The Web is the PlatformJavaScript APIs - The Web is the Platform
JavaScript APIs - The Web is the Platform
Robert Nyman
?
Detecting headless browsers
Detecting headless browsersDetecting headless browsers
Detecting headless browsers
Sergey Shekyan
?
Ruby MVC from scratch with Rack
Ruby MVC from scratch with RackRuby MVC from scratch with Rack
Ruby MVC from scratch with Rack
DonSchado
?
Real time web (Orbited) at BCNE3
Real time web (Orbited) at BCNE3Real time web (Orbited) at BCNE3
Real time web (Orbited) at BCNE3
Alex Kavanagh
?
Advanced WordPress Development Environments
Advanced WordPress Development EnvironmentsAdvanced WordPress Development Environments
Advanced WordPress Development Environments
Beau Lebens
?
Vuejs testing
Vuejs testingVuejs testing
Vuejs testing
Greg TAPPERO
?
Browser Automated Testing Frameworks - Nightwatch.js
Browser Automated Testing Frameworks - Nightwatch.jsBrowser Automated Testing Frameworks - Nightwatch.js
Browser Automated Testing Frameworks - Nightwatch.js
Lu┴s Basti?o Silva
?
Retrofit Android by Chris Ollenburg
Retrofit Android by Chris OllenburgRetrofit Android by Chris Ollenburg
Retrofit Android by Chris Ollenburg
Trey Robinson
?
Express JS
Express JSExpress JS
Express JS
Designveloper
?
Introduction to Retrofit
Introduction to RetrofitIntroduction to Retrofit
Introduction to Retrofit
Kazuhiro Serizawa
?
Zombiejs
ZombiejsZombiejs
Zombiejs
Виктор Ткаченко
?
Rails Girls: Programming, Web Applications and Ruby on Rails
Rails Girls: Programming, Web Applications and Ruby on RailsRails Girls: Programming, Web Applications and Ruby on Rails
Rails Girls: Programming, Web Applications and Ruby on Rails
DonSchado
?
Cool like a Frontend Developer: Grunt, RequireJS, Bower and other Tools
Cool like a Frontend Developer: Grunt, RequireJS, Bower and other ToolsCool like a Frontend Developer: Grunt, RequireJS, Bower and other Tools
Cool like a Frontend Developer: Grunt, RequireJS, Bower and other Tools
Ryan Weaver
?
Search and play more than 50 clips
Search and play more than 50 clipsSearch and play more than 50 clips
Search and play more than 50 clips
phanhung20
?
Scraping recalcitrant web sites with Python & Selenium
Scraping recalcitrant web sites with Python & SeleniumScraping recalcitrant web sites with Python & Selenium
Scraping recalcitrant web sites with Python & Selenium
Roger Barnes
?
Building com Phing - 7Masters PHP
Building com Phing - 7Masters PHPBuilding com Phing - 7Masters PHP
Building com Phing - 7Masters PHP
iMasters
?
The Peanut Butter Cup of Web-dev: Plack and single page web apps
The Peanut Butter Cup of Web-dev: Plack and single page web appsThe Peanut Butter Cup of Web-dev: Plack and single page web apps
The Peanut Butter Cup of Web-dev: Plack and single page web apps
John Anderson
?
JavaScript APIs - The Web is the Platform
JavaScript APIs - The Web is the PlatformJavaScript APIs - The Web is the Platform
JavaScript APIs - The Web is the Platform
Robert Nyman
?
Detecting headless browsers
Detecting headless browsersDetecting headless browsers
Detecting headless browsers
Sergey Shekyan
?
Ruby MVC from scratch with Rack
Ruby MVC from scratch with RackRuby MVC from scratch with Rack
Ruby MVC from scratch with Rack
DonSchado
?
Real time web (Orbited) at BCNE3
Real time web (Orbited) at BCNE3Real time web (Orbited) at BCNE3
Real time web (Orbited) at BCNE3
Alex Kavanagh
?
Advanced WordPress Development Environments
Advanced WordPress Development EnvironmentsAdvanced WordPress Development Environments
Advanced WordPress Development Environments
Beau Lebens
?
Browser Automated Testing Frameworks - Nightwatch.js
Browser Automated Testing Frameworks - Nightwatch.jsBrowser Automated Testing Frameworks - Nightwatch.js
Browser Automated Testing Frameworks - Nightwatch.js
Lu┴s Basti?o Silva
?
Retrofit Android by Chris Ollenburg
Retrofit Android by Chris OllenburgRetrofit Android by Chris Ollenburg
Retrofit Android by Chris Ollenburg
Trey Robinson
?
Rails Girls: Programming, Web Applications and Ruby on Rails
Rails Girls: Programming, Web Applications and Ruby on RailsRails Girls: Programming, Web Applications and Ruby on Rails
Rails Girls: Programming, Web Applications and Ruby on Rails
DonSchado
?

Similar to Integration Test Cucumber + Webrat + Selenium (20)

Chrome Devtools Protocol via Selenium/Appium (English)
Chrome Devtools Protocol via Selenium/Appium (English)Chrome Devtools Protocol via Selenium/Appium (English)
Chrome Devtools Protocol via Selenium/Appium (English)
Kazuaki Matsuo
?
Browser-level testing
Browser-level testingBrowser-level testing
Browser-level testing
Martin Kleppmann
?
jQuery Makes Writing JavaScript Fun Again (for HTML5 User Group)
jQuery Makes Writing JavaScript Fun Again (for HTML5 User Group)jQuery Makes Writing JavaScript Fun Again (for HTML5 User Group)
jQuery Makes Writing JavaScript Fun Again (for HTML5 User Group)
Doris Chen
?
JavaScript performance patterns
JavaScript performance patternsJavaScript performance patterns
JavaScript performance patterns
Stoyan Stefanov
?
ApacheCon 2005
ApacheCon 2005ApacheCon 2005
ApacheCon 2005
Adam Trachtenberg
?
Consegi 2010 - Dicas de Desenvolvimento Web com Ruby
Consegi 2010 - Dicas de Desenvolvimento Web com RubyConsegi 2010 - Dicas de Desenvolvimento Web com Ruby
Consegi 2010 - Dicas de Desenvolvimento Web com Ruby
Fabio Akita
?
Selenium and Sauce Labs
Selenium and Sauce LabsSelenium and Sauce Labs
Selenium and Sauce Labs
hugs
?
Fisl 11 - Dicas de Desenvolvimento Web com Ruby
Fisl 11 - Dicas de Desenvolvimento Web com RubyFisl 11 - Dicas de Desenvolvimento Web com Ruby
Fisl 11 - Dicas de Desenvolvimento Web com Ruby
Fabio Akita
?
Vue \念極秀崔垢醤
Vue \念極秀崔垢醤Vue \念極秀崔垢醤
Vue \念極秀崔垢醤
andyyou
?
[Coscup 2012] JavascriptMVC
[Coscup 2012] JavascriptMVC[Coscup 2012] JavascriptMVC
[Coscup 2012] JavascriptMVC
Alive Kuo
?
Go Web Development
Go Web DevelopmentGo Web Development
Go Web Development
Cheng-Yi Yu
?
JavaScript Performance Patterns
JavaScript Performance PatternsJavaScript Performance Patterns
JavaScript Performance Patterns
Stoyan Stefanov
?
皆艶鉛艶稼庄顎馨壅秘壇
皆艶鉛艶稼庄顎馨壅秘壇皆艶鉛艶稼庄顎馨壅秘壇
皆艶鉛艶稼庄顎馨壅秘壇
Norio Suzuki
?
Chrome Devtools Protocol via Selenium/Appium (Japanese)
Chrome Devtools Protocol via Selenium/Appium (Japanese)Chrome Devtools Protocol via Selenium/Appium (Japanese)
Chrome Devtools Protocol via Selenium/Appium (Japanese)
Kazuaki Matsuo
?
HTML 5 - Overview
HTML 5 - OverviewHTML 5 - Overview
HTML 5 - Overview
Marcelio Leal
?
GIT, RVM, FIRST HEROKU APP
GIT, RVM, FIRST HEROKU APPGIT, RVM, FIRST HEROKU APP
GIT, RVM, FIRST HEROKU APP
Pavel Tyk
?
Continuous Integration/Deployment with Docker and Jenkins
Continuous Integration/Deployment with Docker and JenkinsContinuous Integration/Deployment with Docker and Jenkins
Continuous Integration/Deployment with Docker and Jenkins
Francesco Bruni
?
Tdc 2013 - Ecossistema Ruby
Tdc 2013 - Ecossistema RubyTdc 2013 - Ecossistema Ruby
Tdc 2013 - Ecossistema Ruby
Fabio Akita
?
Resource Registries: Plone Conference 2014
Resource Registries: Plone Conference 2014Resource Registries: Plone Conference 2014
Resource Registries: Plone Conference 2014
Rob Gietema
?
Workshop KrakYourNet2016 - Web applications hacking Ruby on Rails example
Workshop KrakYourNet2016 - Web applications hacking Ruby on Rails example Workshop KrakYourNet2016 - Web applications hacking Ruby on Rails example
Workshop KrakYourNet2016 - Web applications hacking Ruby on Rails example
Anna Klepacka
?
Chrome Devtools Protocol via Selenium/Appium (English)
Chrome Devtools Protocol via Selenium/Appium (English)Chrome Devtools Protocol via Selenium/Appium (English)
Chrome Devtools Protocol via Selenium/Appium (English)
Kazuaki Matsuo
?
jQuery Makes Writing JavaScript Fun Again (for HTML5 User Group)
jQuery Makes Writing JavaScript Fun Again (for HTML5 User Group)jQuery Makes Writing JavaScript Fun Again (for HTML5 User Group)
jQuery Makes Writing JavaScript Fun Again (for HTML5 User Group)
Doris Chen
?
JavaScript performance patterns
JavaScript performance patternsJavaScript performance patterns
JavaScript performance patterns
Stoyan Stefanov
?
Consegi 2010 - Dicas de Desenvolvimento Web com Ruby
Consegi 2010 - Dicas de Desenvolvimento Web com RubyConsegi 2010 - Dicas de Desenvolvimento Web com Ruby
Consegi 2010 - Dicas de Desenvolvimento Web com Ruby
Fabio Akita
?
Selenium and Sauce Labs
Selenium and Sauce LabsSelenium and Sauce Labs
Selenium and Sauce Labs
hugs
?
Fisl 11 - Dicas de Desenvolvimento Web com Ruby
Fisl 11 - Dicas de Desenvolvimento Web com RubyFisl 11 - Dicas de Desenvolvimento Web com Ruby
Fisl 11 - Dicas de Desenvolvimento Web com Ruby
Fabio Akita
?
Vue \念極秀崔垢醤
Vue \念極秀崔垢醤Vue \念極秀崔垢醤
Vue \念極秀崔垢醤
andyyou
?
[Coscup 2012] JavascriptMVC
[Coscup 2012] JavascriptMVC[Coscup 2012] JavascriptMVC
[Coscup 2012] JavascriptMVC
Alive Kuo
?
JavaScript Performance Patterns
JavaScript Performance PatternsJavaScript Performance Patterns
JavaScript Performance Patterns
Stoyan Stefanov
?
皆艶鉛艶稼庄顎馨壅秘壇
皆艶鉛艶稼庄顎馨壅秘壇皆艶鉛艶稼庄顎馨壅秘壇
皆艶鉛艶稼庄顎馨壅秘壇
Norio Suzuki
?
Chrome Devtools Protocol via Selenium/Appium (Japanese)
Chrome Devtools Protocol via Selenium/Appium (Japanese)Chrome Devtools Protocol via Selenium/Appium (Japanese)
Chrome Devtools Protocol via Selenium/Appium (Japanese)
Kazuaki Matsuo
?
GIT, RVM, FIRST HEROKU APP
GIT, RVM, FIRST HEROKU APPGIT, RVM, FIRST HEROKU APP
GIT, RVM, FIRST HEROKU APP
Pavel Tyk
?
Continuous Integration/Deployment with Docker and Jenkins
Continuous Integration/Deployment with Docker and JenkinsContinuous Integration/Deployment with Docker and Jenkins
Continuous Integration/Deployment with Docker and Jenkins
Francesco Bruni
?
Tdc 2013 - Ecossistema Ruby
Tdc 2013 - Ecossistema RubyTdc 2013 - Ecossistema Ruby
Tdc 2013 - Ecossistema Ruby
Fabio Akita
?
Resource Registries: Plone Conference 2014
Resource Registries: Plone Conference 2014Resource Registries: Plone Conference 2014
Resource Registries: Plone Conference 2014
Rob Gietema
?
Workshop KrakYourNet2016 - Web applications hacking Ruby on Rails example
Workshop KrakYourNet2016 - Web applications hacking Ruby on Rails example Workshop KrakYourNet2016 - Web applications hacking Ruby on Rails example
Workshop KrakYourNet2016 - Web applications hacking Ruby on Rails example
Anna Klepacka
?

Integration Test Cucumber + Webrat + Selenium

  • 1. Integration Test Cucumber + Webrat + Selenium
  • 2. about me ? a.k.a tka, tkalu ? http://www.twitter.com/tkalu ? http://www.tkalu.com ? http://www.handlino.com
  • 3. Ruby Tuesday gugod #6 Integration Test With Cucumber And Webrat weijen #3 rspec Mock Aren't Stub
  • 9. Webrat visit login_url ?ll_in ^Login ̄, :with => ^User ̄ ?ll_in ^Password ̄, :with => ^123456 ̄ click_button ^Log in ̄ http://gitrdoc.com/brynary/webrat/tree/master
  • 10. Cucumber + Webrat Given /^ $/ do visit logout_path end And /^ $/ do visit root_path end Then /^ "([^"]*)"$/ do | text | assert_contain text end
  • 11. Cucumber + Webrat ? cucumber -f pretty features/p5.feature ? cucumber -f html features/p5.feature > test.html
  • 12. , .... javascript
  • 15. Selenium ? Selenium IDE ? elenium Remote Control (RC) ? Selenium Grid
  • 16. Selenium ? FireFox ? Linux ? Chrome ? OS X ? Safari ? Windows ? Opera ? IE 7,8 (6 not in the list)
  • 17. Selenium & Ruby ? gem install selenium-client ? require "selenium/client"
  • 18. Selenium @browser = Selenium::Client::Driver.new :host => "localhost", :port => 4444, :browser => "*firefox", :url => "http://www.google.com", :timeout_in_second => 60 @browser.start_new_browser_session @browser.open "/" @browser.type "q", "Ruby Tuesday #11" @browser.click "btnG", :wait_for => :page @browser.capture_entire_page_screenshot('/Users/tka/1.png','') puts @browser.text?("Ruby Tuesday #11 |Registrano") http://selenium-client.rubyforge.org/ ruby script/selenium_demo.rb
  • 19. Webrat + Selenium Webrat.con?gure do |con?g| con?g.mode = :selenium con?g.selenium_server_address = 'localhost' con?g.application_framework = :external end visit 'http://www.google.com' ?ll_in "q", :with => 'Ruby Tuesday #11' click_button "Google " selenium.wait_for_page_to_load(10) assert_contain "Ruby Tuesday #11 | Registrano" save_and_open_screengrab ruby script/webrat_selenium_demo.rb
  • 20. Cucumber + Webrat + Selenium features/support/env.rb Webrat.configure do |config| config.mode = :rails config.open_error_files = false if ENV["USE_SELENIUM"] config.mode = :selenium config.selenium_browser_key = ENV["SELENIUM_BROWSER"] || "*firefox" if ENV["SELENIUM_SERVER"] config.selenium_server_address = ENV["SELENIUM_SERVER"] end config.application_address = ENV["SELENIUM_APPLICATION"] || "localhost" config.application_port = ENV["SELENIUM_APPLICATION_PORT"] || "3000" end end USE_SELENIUM=1 cucumber
  • 21. Cucumber pro?le con?g/cucumber.yml selenium: -r features/support/env.rb -r features/support/enhanced.rb -r features/step_definitions features/enhanced cucumber -p selenium http://wiki.github.com/aslakhellesoy/cucumber/setting-up-selenium
  • 22. VirtualBox ? Vmware ? VBoxManage cli ? OSX /Applications/VirtualBox.app/Contents/MacOS/VBoxManage ?
  • 24. webrat-0.7.0/lib/webrat/selenium/ location_strategy_javascript/label.js var labelFor = locatedLabel.getAttribute('for'); // IE-- if (labelFor == null && "v"=="v"){ labelFor=locatedLabel.htmlFor } if (labelFor == null && locatedLabel.hasChildNodes()) {
  • 25. ? cronjob ? VM ? VM selenium ? cucumber + webrat + selenium ? ,
  • 26. Q&A