Watir Óï·¨£¨Web Application Testing in Ruby)
Watir Óï·¨£¨Web Application Testing in Ruby)
# watirµÄ°²×°
watieµÄ°²×°Çë²é¿´ -> Ruby libraryµÄ°²×°
# ʹÓÃWatir¹¤¾ß£¬ÐèÒªÔڽű¾ÖмÓÉÏ
require 'watir'
# ´´½¨Ò»¸öIEµÄʵÀý
ie = Watir::IE.new
»òÕßÔÚ´´½¨µÄͬʱֱ½Óתµ½Ò³Ãæ
ie = Watir::IE.start('http://www.text.com/')
WatirʹÓÃstart·½·¨Í¬Ê±´´½¨Ò»¸öä¯ÀÀÆ÷ʵÀý²¢×ªµ½Ò»¸öÒ³Ãæ¡£
IEä¯ÀÀËÙ¶È
ie.speed = :fast
ie.speed = :slow
# Ò³Ãæµ¼º½
ie.goto('http://www.text.com/')
×¢: ie.goto»¹¿ÉÒÔÔËÐÐjavascriptµÄ´úÂëÈç: ie.goto("javascript: ie.document.write("Hello World");")
# È¡µÃµ±Ç°ÍøÒ³µÄÍøÖ·
ie.url
# µã»÷³¬Á´½Ó
ie.link(:text , "Pickaxe").click
ie.link(:href, /http:\/\/pragmaticprogrammer\.com/).click
ie.link(:name => 'foo', :index => 1).click
# ³¬Á´½ÓµÄuri
ie.link(:text , "Pickaxe").href
ie.link(:index, 1).href
ie.link(:text => "reply", :index => 2).href
# ³¬Á´½ÓµÄÎı¾
ie.link(:href , /http:\/\/pragmaticprogrammer\.com/).text
¶ÔÓ¦µÄHTML´úÂëΪ£º
<a href='http://pragmaticprogrammer.com/titles/ruby/'>Pickaxe</a>
# img±êÇ©
ie.image(:name, 'image').src
ie.image(:index, 2).src
¶ÔÓ¦µÄHTML´úÂëΪ£º
<img name = img src='http://pragmaticprogrammer.com/titles/ruby/top.gif'>
<img name = img src='http://pragmaticprogrammer.com/titles/ruby/head.gif'>
# ÉèÖø´Ñ¡¿ò
ie.checkbox(:name, "checkme").set
ie.checkbox(:name, "checkme", "1").set # ʹÓÃnameºÍvalueÊôÐÔÉèÖø´Ñ¡¿ò
# Çå³ý¸´Ñ¡¿ò
ie.checkbox(:name, "checkme").clear
ie.checkbox(:name, "checkme", "1").clear # ʹÓÃnameºÍvalueÊôÐÔÇå³ý¸´Ñ¡¿ò
¶ÔÓ¦µÄHTML´úÂëΪ£º
<input type = "checkbox" name = "checkme" value = "1">
# ÉèÖõ¥Ñ¡¿ò
ie.radio(:name, "clickme").set
ie.radio(:name=>'clickme', :index=>2).set
ie.radio(:name, "clickme", "1").set # ʹÓÃnameºÍidÊôÐÔÉèÖõ¥Ñ¡¿ò
# ʹÓÃnameÊôÐÔÇå³ýµ¥Ñ¡¿ò
ie.radio(:name, "clickme").clear
ie.radio(:name, "clickme", "1").clear # ʹÓÃnameºÍidÊôÐÔÇå³ýµ¥Ñ¡¿ò
¶ÔÓ¦µÄHTML´úÂëΪ£º
<input type = "radio" name = "clickme" id = "1">
Ïà¹ØÎĵµ£º
ÏÂÃæ½éÉÜRuby formµÄÁ½ÖÖд·¨¡£
Ruby formд·¨Ò»£ºÊ¹ÓÃform_for
< % form_for :order, :url => { :action => :save_order } do |form| %> < p> < %= label :order ......
Ç°ÑÔ
ÔÚ¡¶RoutingµÄÔØÈë¡·ÖУ¬ÎÒ´óÖ½éÉÜÁËÒ»ÏÂRailsÖÐ×î¼òµ¥µÄrouteÊÇÈçºÎ¼ÓÔصġ£ÕâƪÎÄÕ£¬ÎÒ½«À´½²Ò»½²RailsϵͳÖиüΪ¸´ÔÓµÄnamed routeºÍÓëRESTfulÏà¹ØµÄresourceÊÇÈçºÎ±»¼ÓÔصġ£ÎªÁ˲»Öظ´Ì«¶àµÄ±ÊÄ«£¬ÕâƪÎÄÕ½«ÔÚÇ°ÎĵĻù´¡ÉϽøÐУ¬Èç¹û·¢ÏÖµ¥¶À¿´´ËÎÄʱ£¬ÓÐÉÙÐíÔÆÀïÎíÀ½¨ÒéÏÈ¿´Ò»¿´ÎÒµÄǰƪÎÄÕ£ºR ......
¿ª·¢»·¾³
Ruby: Ruby1.9.1
Rails: Rails2.3.5
Mysql:Mysql5.0.9
Driver:mysql-2.8.1-x86-mingw32.gem
IDE:Rubymine2.0.1
Ò»¡¢´´½¨Êý¾Ý±íUsers
ÀûÓÃRubyMine×Ô´øµÄScaffold¹¤¾ß´´½¨Êý¾Ý±íUsers£¬Ò²¿ÉÒÔÊÖ¶¯´´½¨
¶þ¡¢´´½¨ControllerºÍView
RubyÏîÄ¿—>ÓÒ¼ü—>Create Model
Íê³Éºó½«×Ô¶¯Éú³ÉÏàÓ¦µÄÎ ......
http://www.robertsosinski.com/2008/12/21/understanding-ruby-blocks-procs-and-lambdas/
Understanding Ruby Blocks, Procs and Lambdas
Blocks, Procs and lambdas (referred to as closures
in Computer Science) are one of the most powerful aspects of Ruby, and
also one of the most misunderstood. This ......