Mais conteúdo relacionado
Semelhante a Integration Test Cucumber + Webrat + Selenium (20)
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
- 16. Selenium
• FireFox
• Linux • Chrome
• OS X • Safari
• Windows • Opera
• IE 7,8 (6 not in the list)
- 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
•
- 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
• ,