SlideShare ist ein Scribd-Unternehmen logo
1 von 26
Downloaden Sie, um offline zu lesen
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
 fill_in “Login”, :with => “User”
 fill_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.configure do |config|
 config.mode = :selenium
 config.selenium_server_address = 'localhost'
 config.application_framework = :external
end

visit 'http://www.google.com'
fill_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 profile
                     config/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

    •
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

Weitere ähnliche Inhalte

Was ist angesagt?

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 ToolsRyan 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 clipsphanhung20
 
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 & SeleniumRoger Barnes
 
Building com Phing - 7Masters PHP
Building com Phing - 7Masters PHPBuilding com Phing - 7Masters PHP
Building com Phing - 7Masters PHPiMasters
 
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 appsJohn 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 PlatformRobert Nyman
 
Detecting headless browsers
Detecting headless browsersDetecting headless browsers
Detecting headless browsersSergey Shekyan
 
Ruby MVC from scratch with Rack
Ruby MVC from scratch with RackRuby MVC from scratch with Rack
Ruby MVC from scratch with RackDonSchado
 
Real time web (Orbited) at BCNE3
Real time web (Orbited) at BCNE3Real time web (Orbited) at BCNE3
Real time web (Orbited) at BCNE3Alex Kavanagh
 
Advanced WordPress Development Environments
Advanced WordPress Development EnvironmentsAdvanced WordPress Development Environments
Advanced WordPress Development EnvironmentsBeau Lebens
 
Browser Automated Testing Frameworks - Nightwatch.js
Browser Automated Testing Frameworks - Nightwatch.jsBrowser Automated Testing Frameworks - Nightwatch.js
Browser Automated Testing Frameworks - Nightwatch.jsLuís Bastião Silva
 
Retrofit Android by Chris Ollenburg
Retrofit Android by Chris OllenburgRetrofit Android by Chris Ollenburg
Retrofit Android by Chris OllenburgTrey Robinson
 
Ionic으로 모바일앱 만들기 #4
Ionic으로 모바일앱 만들기 #4Ionic으로 모바일앱 만들기 #4
Ionic으로 모바일앱 만들기 #4성일 한
 
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 RailsDonSchado
 

Was ist angesagt? (19)

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
 
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
 
Mastering Grunt
Mastering GruntMastering Grunt
Mastering Grunt
 
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
 
Building com Phing - 7Masters PHP
Building com Phing - 7Masters PHPBuilding com Phing - 7Masters PHP
Building com Phing - 7Masters PHP
 
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
 
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
 
Detecting headless browsers
Detecting headless browsersDetecting headless browsers
Detecting headless browsers
 
Ruby MVC from scratch with Rack
Ruby MVC from scratch with RackRuby MVC from scratch with Rack
Ruby MVC from scratch with Rack
 
Real time web (Orbited) at BCNE3
Real time web (Orbited) at BCNE3Real time web (Orbited) at BCNE3
Real time web (Orbited) at BCNE3
 
Advanced WordPress Development Environments
Advanced WordPress Development EnvironmentsAdvanced WordPress Development Environments
Advanced WordPress Development Environments
 
Vuejs testing
Vuejs testingVuejs testing
Vuejs testing
 
Browser Automated Testing Frameworks - Nightwatch.js
Browser Automated Testing Frameworks - Nightwatch.jsBrowser Automated Testing Frameworks - Nightwatch.js
Browser Automated Testing Frameworks - Nightwatch.js
 
Retrofit Android by Chris Ollenburg
Retrofit Android by Chris OllenburgRetrofit Android by Chris Ollenburg
Retrofit Android by Chris Ollenburg
 
Express JS
Express JSExpress JS
Express JS
 
Introduction to Retrofit
Introduction to RetrofitIntroduction to Retrofit
Introduction to Retrofit
 
Zombiejs
ZombiejsZombiejs
Zombiejs
 
Ionic으로 모바일앱 만들기 #4
Ionic으로 모바일앱 만들기 #4Ionic으로 모바일앱 만들기 #4
Ionic으로 모바일앱 만들기 #4
 
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
 

Ähnlich wie Integration Test Cucumber + Webrat + Selenium

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 patternsStoyan 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 RubyFabio Akita
 
Selenium and Sauce Labs
Selenium and Sauce LabsSelenium and Sauce Labs
Selenium and Sauce Labshugs
 
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 RubyFabio Akita
 
Vue 淺談前端建置工具
Vue 淺談前端建置工具Vue 淺談前端建置工具
Vue 淺談前端建置工具andyyou
 
[Coscup 2012] JavascriptMVC
[Coscup 2012] JavascriptMVC[Coscup 2012] JavascriptMVC
[Coscup 2012] JavascriptMVCAlive Kuo
 
Go Web Development
Go Web DevelopmentGo Web Development
Go Web DevelopmentCheng-Yi Yu
 
JavaScript Performance Patterns
JavaScript Performance PatternsJavaScript Performance Patterns
JavaScript Performance PatternsStoyan Stefanov
 
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 APPPavel 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 JenkinsFrancesco Bruni
 
Tdc 2013 - Ecossistema Ruby
Tdc 2013 - Ecossistema RubyTdc 2013 - Ecossistema Ruby
Tdc 2013 - Ecossistema RubyFabio Akita
 
Resource Registries: Plone Conference 2014
Resource Registries: Plone Conference 2014Resource Registries: Plone Conference 2014
Resource Registries: Plone Conference 2014Rob 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
 

Ähnlich wie 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)
 
Browser-level testing
Browser-level testingBrowser-level testing
Browser-level testing
 
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)
 
JavaScript performance patterns
JavaScript performance patternsJavaScript performance patterns
JavaScript performance patterns
 
ApacheCon 2005
ApacheCon 2005ApacheCon 2005
ApacheCon 2005
 
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
 
Selenium and Sauce Labs
Selenium and Sauce LabsSelenium and Sauce Labs
Selenium and Sauce Labs
 
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
 
Vue 淺談前端建置工具
Vue 淺談前端建置工具Vue 淺談前端建置工具
Vue 淺談前端建置工具
 
[Coscup 2012] JavascriptMVC
[Coscup 2012] JavascriptMVC[Coscup 2012] JavascriptMVC
[Coscup 2012] JavascriptMVC
 
Go Web Development
Go Web DevelopmentGo Web Development
Go Web Development
 
JavaScript Performance Patterns
JavaScript Performance PatternsJavaScript Performance Patterns
JavaScript Performance Patterns
 
Selenium再入門
Selenium再入門Selenium再入門
Selenium再入門
 
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)
 
HTML 5 - Overview
HTML 5 - OverviewHTML 5 - Overview
HTML 5 - Overview
 
GIT, RVM, FIRST HEROKU APP
GIT, RVM, FIRST HEROKU APPGIT, RVM, FIRST HEROKU APP
GIT, RVM, FIRST HEROKU APP
 
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
 
Tdc 2013 - Ecossistema Ruby
Tdc 2013 - Ecossistema RubyTdc 2013 - Ecossistema Ruby
Tdc 2013 - Ecossistema Ruby
 
Resource Registries: Plone Conference 2014
Resource Registries: Plone Conference 2014Resource Registries: Plone Conference 2014
Resource Registries: Plone Conference 2014
 
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
 

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 fill_in “Login”, :with => “User” fill_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.configure do |config| config.mode = :selenium config.selenium_server_address = 'localhost' config.application_framework = :external end visit 'http://www.google.com' fill_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 profile config/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 •
  • 23.
  • 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