watircraft 是基于watir的BDD(行為驅動開發(fā))
安裝:
要先裝ruby環(huán)境
gem install bret-watircraft --remote
使用:
以google為例
1.運行- cmd,輸入:watircraft google。google為項目名稱,這里會生成批量的文件和目錄。
2.打開config/environments.yml,編輯文件如下:
test:
url: http://www.google.com
3.dos里輸入:cd google
4.dos里輸入:scriptgenerate spec search
5.編輯test/specs/search_spec.rb
如下:
$LOAD_PATH.unshift File.dirname(__FILE__) unless
$LOAD_PATH.include? File.dirname(__FILE__)
require 'spec_helper'
describe "Search" do
# TODO: Change this string to describe your test
it "should find WatirCraft" do
# TODO: Add your test steps here. Remove "pending"
browser.text_field(:name, 'q').set 'WatirCraft'
browser.button(:name, 'btnG').click
browser.text.should include('Test automation for web applications')
end
# TODO: Add additional tests here. Each test should look like
# it "test description" do
# ... test steps ...
# end
end
6. 執(zhí)行search_spec.rb
rake spec
或 ruby test/specs/search_spec.rb