Integration Test Cucumber + Webrat + Selenium

  • 4,878 views
Uploaded on

 

  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
No Downloads

Views

Total Views
4,878
On Slideshare
0
From Embeds
0
Number of Embeds
0

Actions

Shares
Downloads
80
Comments
1
Likes
7

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

Transcript

  • 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
  • 4. Source Code http://github.com/tka/it-cws-demo
  • 5. Cucumber http://cukes.info/
  • 6. Cucumber
  • 7. Cucumber : " "
  • 8. Webrat http://gitrdoc.com/brynary/webrat http://github.com/brynary/webrat
  • 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
  • 13. Browser
  • 14. Selenium http://seleniumhq.org/
  • 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. 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()) {
  • 24. • cronjob • VM • VM selenium • cucumber + webrat + selenium • ,
  • 25. Q&A