Ruby watir ²âÊÔ¿ò¼Ü
ת×Ô http://www.advidea.cn/biancheng/200943135232.html
Ruby watir ²âÊÔ¿ò¼Ü
´ó¶àÊýÈ˶¼»á°²×° ruby,
Ҳͨ¹ýRuby °²×° gem,
Ò²°²×°ÁËruby IDE¿ª·¢¹¤¾ß£ºnetbeans,
µ«¾ÍÊDz»ÄÜÅÜwatir»·¾³£¬¿ñÔμÓÍÂÖС£¡£¡£
´íÎóÈçÏ£º
in `require': no such file to load -- watir (LoadError)
·´Õý¾ÍÊÇÕÒ²»µ½watir,ÕâÀïΪ´ó¼ÒÏ×ÉÏÖÕ¼«½â¾ö·½°¸£º
1¡£Ê×ÏÈ°²×°£ºruby186-26.exe
ÏÂÔصØÖ·£ºhttp://www.ruby-lang.org/zh_CN/downloads/
Ñ¡ÔñWindows ϵͳµÄ Ruby 1.8.6 Ò»²½°²×°
ÏÂÔز¢°²×°¾ÍOK¡£
2¡£°²×°¿ª·¢¹¤¾ß£ºnetbeans.
ÒòΪnetbeansÊÇ»ùÓÚJAVAµÄ£¬ËùÒÔÐèÒªÏÈÏÂÔØÒ»¸öJAVA JDK¡£
ÏÂÔصØÖ·£º×Ô¼ºgoogleÀïÈ¥ËÑһϣº JAVA JDK ÏÂÔØ¡£ÏÂÔØ1.5°æ±¾ÒÔÉϾÍOK¡£
3¡£ÏÂÔØnetbeans.²¢°²×°£º
ºÜ¼òµ¥£¬ÏÂÔصØÖ·£º
http://www.netbeans.info/downloads/dev.php ÓÒ±ßÀ¸Ö±½ÓµãÐøÐø°´Å¥£¬
Ñ¡ÔñµÚÒ»¸ö£¬È»ºó½øÈëÏÂÃæÒ³Ãæ
http://bits.netbeans.org/download/trunk/nightly/2009-03-17_02-01-11/
Ñ¡ÔñÖ§³ÖrubyµÄIDEÑ¡ÏȻºóÏÂÔؾͿÉÒÔÁË¡£
°²×°Íê±Ïºó£¬½ø²Ëµ¥Tools -> Update Center
µãNext£¬µÈËùÓпÉÉý¼¶Ä£¿é³öÀ´ºó£¬ÕÒµ½RubyÎļþ¼Ð£¬µãÑ¡µ½ÐèÒª¸üеÄÄ£¿éÖУ¨Ò»¹²»áÓоŸöÎļþ±»Ñ¡Ôñ£©
°´Ö¸ÁîÍê³É¸üУ¬ÖØÆôNetBeans¡£
4¡£OKÀ²¡£ÏÖÔھͲîGEMÁË¡£
ÍøÂçÉϽéÉÜÁËN¶àÖÖ·½·¨£¬¾ÍÊDz»¹ÜÓá£
ÕâÀïÌṩ¸öÍêÃÀ°æ±¾£ºµã»÷ÏÂÔØ ruby watir gem °²×°°ü advidea.rar
ÏÂÔغó½âѹֱ½ÓÔËÐУº
advidea.bat Îļþ£¬¼´¿ÉÍê³É°²×° ruby watir ×Ô¶¯»¯¿ò¼Ü¡£
5¡£OKÀ²£¬ÏÖÔÚ¿ªÊ¼ Ruby ¿ª·¢¹¤¾ß netbeans:
н¨Ò»¸öruby application,Ö±½ÓÍê³É¡£
ÔÚmain.rbÀïÊäÈ룺
require 'watir'
test_site = 'http://www.advidea.cn/'
# open the IE browser
ie = Watir::IE.new
# print some comments
puts "## Beginning of test: advidea"
puts " "
puts "Step 1: go to the test site: " + test_site
ie.goto(test_site)
puts " Action: entered " + test_site + " in the address bar."
È»ºóÖ±½ÓÔËÐÐÊÔһϣ¿
ûÓÐЧ¹û¡£»á³öÏÖÕÒ²»µ½ watir Ìáʾ
ÎÒÃÇÑ¡ÖÐÓÒ±ßÀ¸Ð½¨µÄRuby ÏîÄ¿ÓÒ¼üÊôÐÔ£¬
ÔËÐбêÇ©Ï£ºRuby ƽ̨ѡÔñÎÒÃÇ×Ô¼ºµÄ£¬¶ø·ÇÄÚÖõġ£±£´æ¡£
È»ºóÔÙÔËÐÐÒ»
Ïà¹ØÎĵµ£º
#Ò»¡¢¶¨ÒåÒ»¸öÀà
class Person
def initialize(name,age=18)
@name=name;
@age=age;
@motherland="china";
end
def talk
puts "my name is "+@name+" and I am "+@age.to_s
&nb ......
The following is improved version of the code created by David Mullet, from
http://rubyonwindows.blogspot.com/2007/03/ruby-ado-and-sqlserver.html
require 'win32ole'
class SqlServer
# This class manages database connection and queries
attr_accessor :connection, :data, :fields
attr_wr ......
Ruby£¬Ò»ÖÖ為簡單¿ì½ÝÎï¼þ導Ïò編³Ì£¨ÃæÏò¶ÔÏó³ÌÐòÉè¼Æ£©¶ø創µÄ½Å±¾語ÑÔ£¬ÔÚ20ÊÀ¼Í90Äê´úÓÉÈÕ±¾ÈËËɱ¾Ðк루¤Þ¤Ä¤â¤È¤æ¤¤Ò¤í£¯Yukihiro Matsumoto£©¿ª·¢£¬×ñÊØGPLÐÒéºÍRuby License¡£ËüµÄÁé¸ÐÓëÌØÐÔÀ´×ÔÓÚPerl¡¢Smalltalk¡¢Eiffel¡¢Ada ÒÔ¼° Lisp ......
ת Adding Sound to Your Ruby Apps
Have you ever thought about including sounds in your Ruby application? Used sparingly, sound may enhance your applications by adding audio cues or a custom touch. You could, for example, play a beep or chime that announces the completion of a lengthy process. Per ......