<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-4612089851160687407</id><updated>2012-02-16T20:39:08.009-08:00</updated><category term='ruby'/><category term='logging'/><category term='file field'/><category term='setup'/><category term='test'/><category term='installation'/><category term='qa'/><category term='logger'/><category term='tutorial'/><category term='cross browser'/><category term='watir'/><category term='automation'/><category term='file selector'/><category term='safariwatir'/><category term='links'/><category term='jssh'/><category term='firewatir'/><title type='text'>Watir Tutorials</title><subtitle type='html'>Find Watir and QA automation Tutorials in this blog.</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://watirtutorials.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4612089851160687407/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://watirtutorials.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Shrikant Wagh</name><uri>http://www.blogger.com/profile/07093525941014864586</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://2.bp.blogspot.com/_nwkJ5BJsnTA/SrxVOxHcIGI/AAAAAAAAAAg/xhBW55r-YDg/S220/Shrikant8080.JPG'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>7</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-4612089851160687407.post-800303978026693026</id><published>2010-01-14T16:25:00.000-08:00</published><updated>2010-01-14T16:41:58.261-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='file selector'/><category scheme='http://www.blogger.com/atom/ns#' term='automation'/><category scheme='http://www.blogger.com/atom/ns#' term='watir'/><title type='text'>Watir Tutorial: Quick trick to identify IE browser version</title><content type='html'>&lt;h2&gt;Watir Tutorials: Quick trick to identify IE browser version&lt;/h2&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt;Sometimes your testcases are browser version dependent and you need to perform tasks depending on the IE browser version. E.g. handling file chooser dialog boxes in IE7 and IE8. I'll discuss this IE7 and IE8 file chooser dialog box compatibility issue in my next blog.&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt;In this kind of situation, the correct approach would be - itentify the version of the browser at runtime and excute the testcase for that browser. So you do not end up with three versions of same testcase, ecah for IE6, IE7 and IE8. It is easy to identify the version of the IE browser at runtime. &lt;/p&gt;&lt;br /&gt;&lt;br /&gt;Following few lines of code will accomplish that:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;code&gt;&lt;br /&gt;$browser = Watir::IE.new()&lt;br /&gt;full_ver = $browser.document.invoke('parentWindow').navigator.appVersion&lt;br /&gt;tmp_str =/MSIE\s(.*?);/.match(full_ver)&lt;br /&gt;$ie_ver = tmp_str[1]&lt;br /&gt;puts "IE VERSION = #{$ie_ver}"&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt;Once you know the browser version then you can use any control structure of your choice to exceute browser specific test cases.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4612089851160687407-800303978026693026?l=watirtutorials.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://watirtutorials.blogspot.com/feeds/800303978026693026/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://watirtutorials.blogspot.com/2010/01/watir-tutorial-quick-trick-to-identify.html#comment-form' title='4 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4612089851160687407/posts/default/800303978026693026'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4612089851160687407/posts/default/800303978026693026'/><link rel='alternate' type='text/html' href='http://watirtutorials.blogspot.com/2010/01/watir-tutorial-quick-trick-to-identify.html' title='Watir Tutorial: Quick trick to identify IE browser version'/><author><name>Shrikant Wagh</name><uri>http://www.blogger.com/profile/07093525941014864586</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://2.bp.blogspot.com/_nwkJ5BJsnTA/SrxVOxHcIGI/AAAAAAAAAAg/xhBW55r-YDg/S220/Shrikant8080.JPG'/></author><thr:total>4</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4612089851160687407.post-5767477535057903021</id><published>2009-11-04T16:52:00.000-08:00</published><updated>2009-11-04T16:56:43.765-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='ruby'/><category scheme='http://www.blogger.com/atom/ns#' term='firewatir'/><category scheme='http://www.blogger.com/atom/ns#' term='logger'/><category scheme='http://www.blogger.com/atom/ns#' term='logging'/><category scheme='http://www.blogger.com/atom/ns#' term='automation'/><category scheme='http://www.blogger.com/atom/ns#' term='tutorial'/><category scheme='http://www.blogger.com/atom/ns#' term='cross browser'/><category scheme='http://www.blogger.com/atom/ns#' term='watir'/><title type='text'>Watir Tutorial: Developing cross-browser Watir-IE/FireWatir-FireFox test case with logging capability</title><content type='html'>&lt;h2&gt;Developing cross-browser Watir-IE/FireWatir-FireFox test case with logging capability&lt;/h2&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;Those who have their test cases written for Watir/IE with logging capability must have bump into this issue. WatirLogger is not available for FireWatir. Suggested solution is - Create your own subclass of Logger instead of using WatirLogger. Or use Log4R.&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;http://wiki.openqa.org/display/WTR/Firewatir+Compatibility&lt;br /&gt;&lt;br /&gt;&lt;p&gt;Which means as a test developer you will have to maintain two set of test cases one for Watir/IE and other for FireWatir/FireFox. And maintaining two sets of scripts for same test scenario is never a good idea. I always prefer to develop a test that works with at least IE and FireFox and not to maintain two different sets.&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;So if you want to write cross-browser test cases with logging functionality, you have one fo the following three options.&lt;br /&gt;&lt;ul&gt;&lt;br /&gt;&lt;li&gt;Do not use WatirLogger and create your own subclass of Logger.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Do not use WatirLogger and use Log4R or any other logger gem available.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Temporarily extend the FireWatir to support logging capabilities&lt;/li&gt;&lt;br /&gt;&lt;/ul&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;In this blogpost I'll explore third option mentioned above.&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;This is what I tried to extend FireWatir to use with logger and do not have to change my test cases for FireWatir&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;1. &lt;/strong&gt;Copy the file logger.rb from Watir gem to &amp;lt;FireWatir-gem-dir&amp;gt;\lib\firewatir and Modify the file to define FireWatirLogger as shown below.&lt;br&gt;&lt;br /&gt;&lt;pre&gt;&lt;code&gt;&lt;br /&gt;module FireWatir&lt;br /&gt;  class FireWatirLogger &lt; Logger&lt;br /&gt;    def initialize(filName, logsToKeep, maxLogSize)&lt;br /&gt;      super(filName, logsToKeep, maxLogSize)&lt;br /&gt;      self.level = Logger::DEBUG&lt;br /&gt;      self.datetime_format = "%d-%b-%Y %H:%M:%S"&lt;br /&gt;      self.debug("FireWatir starting")&lt;br /&gt;    end&lt;br /&gt;  end&lt;br /&gt;&lt;br /&gt;  class DefaultLogger &lt; Logger&lt;br /&gt;    def initialize&lt;br /&gt;      super(STDERR)&lt;br /&gt;      self.level = Logger::WARN&lt;br /&gt;      self.datetime_format = "%d-%b-%Y %H:%M:%S"&lt;br /&gt;      self.info "Log started"&lt;br /&gt;    end&lt;br /&gt;  end&lt;br /&gt;end&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;You can use the same logger.rb without any modification and just include watir/logger, but I choose to copy the logger.rb and modify it. I thought this might be cleaner and less confusing approach.&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;strong&gt;2. &lt;/strong&gt;Add this line to firewatir.rb. This is optional and you can explicitly include this in the file you want to use logger, including firefox.rb. So include this in firewatir.rb and you will not have to worry about it later.&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;code&gt;&lt;br /&gt;require 'firewatir/logger'&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;strong&gt;3. &lt;/strong&gt;Add the following lines of code in firefox.rb&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;a. &lt;/strong&gt;declare the accessor&lt;br /&gt;&lt;pre&gt;&lt;code&gt;&lt;br /&gt;    # access to the logger object&lt;br /&gt;    attr_accessor :logger&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;&lt;strong&gt;b. &lt;/strong&gt;initialize the logger instant in the constructor&lt;br /&gt;&lt;br /&gt;If you choose not to copy and modify the logger from Watir and use it as it is then add this line to FireFox class constructor [initialize method]&lt;br /&gt;&lt;pre&gt;&lt;code&gt;&lt;br /&gt;      @logger = DefaultLogger.new&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;OR if you followed step #1 then you v=can also use the FireWatirLogger as below&lt;br /&gt;&lt;pre&gt;&lt;code&gt;&lt;br /&gt;      @logger = FireWatirLogger.new&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;strong&gt;4. &lt;/strong&gt;define log method for FireFox class in firewatir.rb&lt;br /&gt;&lt;pre&gt;&lt;code&gt;&lt;br /&gt;    def log(what)&lt;br /&gt;      @logger.debug(what) if @logger&lt;br /&gt;    end&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;strong&gt;5. &lt;/strong&gt;Declare global variable $browser_type and set it to IE/FF in your test case or in your top level testlist/test configuration file if you are following unit test framework.&lt;br /&gt;&lt;pre&gt;&lt;code&gt;&lt;br /&gt;e.g. $browser_type = "FF"&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;strong&gt;6. &lt;/strong&gt;Include the related files depending on which browser you want to run this test in&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;code&gt;&lt;br /&gt;if ($bType == "IE")&lt;br /&gt; require 'watir'&lt;br /&gt; require 'watir/exceptions'&lt;br /&gt;elsif ($bType == "FF")&lt;br /&gt; require 'firewatir'&lt;br /&gt; require 'firewatir/exceptions'&lt;br /&gt; require 'firewatir/logger' #if not included in firewatir.rb&lt;br /&gt;else&lt;br /&gt; $browser.logger.fatal( "Invalid browser type only IE or FF")&lt;br /&gt; exit&lt;br /&gt;end&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;strong&gt;7. &lt;/strong&gt;Write method startFireFox_with_logger&lt;br /&gt;In your test case, if you want the same script to run for FF as well as IE, then following trick works for me.&lt;br /&gt;Write the method to start FireFox with logger as you have for Watir&lt;br /&gt;&lt;pre&gt;&lt;code&gt;&lt;br /&gt;def start_ie_with_logger&lt;br /&gt;  $browser = Watir::IE.new()&lt;br /&gt;  $browser.logger = Watir::WatirLogger.new( 'debug.txt', 4, 10000 )&lt;br /&gt;  $browser.logger.level = Logger::INFO&lt;br /&gt;end&lt;br /&gt;&lt;br /&gt;def start_ff_with_logger&lt;br /&gt;  $browser = FireWatir::Firefox.new()&lt;br /&gt;  $browser.logger = FireWatir::FireWatirLogger.new( 'debug.txt', 4, 10000 )&lt;br /&gt;  $browser.logger.level = Logger::INFO&lt;br /&gt;#  any other customization ...&lt;br /&gt;end&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;strong&gt;8. &lt;/strong&gt;Initialize the browser instance depending on the browser type&lt;br /&gt;&lt;pre&gt;&lt;code&gt;&lt;br /&gt;if ($bType == "FF")&lt;br /&gt;puts "creating FF browser instance"&lt;br /&gt; start_ff_with_logger&lt;br /&gt;elsif ($bType == "IE")&lt;br /&gt; puts "creating IE browser instance"&lt;br /&gt; start_ie_with_logger&lt;br /&gt;else&lt;br /&gt; puts "cannot create browser instance"&lt;br /&gt;end&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;strong&gt;9. &lt;/strong&gt;You can use the logger as you would do when using Watir/IE&lt;br /&gt;&lt;pre&gt;&lt;code&gt;&lt;br /&gt;$browser.logger.debug("Executing TC_" + numonic + "_Title: Testcase " + name + " title...")&lt;br /&gt;$browser.logger.info($browser.title)&lt;br /&gt;$browser.logger.fatal( "Invalid browser type only IE or FF")&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;I hope you find this blog post useful. If you got any cool tricks, workarounds, or any issues you experience during test automation with Watir, please do share your experience and thoughts by posting your comments.&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4612089851160687407-5767477535057903021?l=watirtutorials.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://watirtutorials.blogspot.com/feeds/5767477535057903021/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://watirtutorials.blogspot.com/2009/11/watir-tutorial-developing-cross-browser.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4612089851160687407/posts/default/5767477535057903021'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4612089851160687407/posts/default/5767477535057903021'/><link rel='alternate' type='text/html' href='http://watirtutorials.blogspot.com/2009/11/watir-tutorial-developing-cross-browser.html' title='Watir Tutorial: Developing cross-browser Watir-IE/FireWatir-FireFox test case with logging capability'/><author><name>Shrikant Wagh</name><uri>http://www.blogger.com/profile/07093525941014864586</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://2.bp.blogspot.com/_nwkJ5BJsnTA/SrxVOxHcIGI/AAAAAAAAAAg/xhBW55r-YDg/S220/Shrikant8080.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4612089851160687407.post-8137703338296347539</id><published>2009-10-19T12:37:00.000-07:00</published><updated>2009-10-22T00:46:38.578-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='ruby'/><category scheme='http://www.blogger.com/atom/ns#' term='qa'/><category scheme='http://www.blogger.com/atom/ns#' term='file selector'/><category scheme='http://www.blogger.com/atom/ns#' term='firewatir'/><category scheme='http://www.blogger.com/atom/ns#' term='automation'/><category scheme='http://www.blogger.com/atom/ns#' term='tutorial'/><category scheme='http://www.blogger.com/atom/ns#' term='safariwatir'/><category scheme='http://www.blogger.com/atom/ns#' term='watir'/><category scheme='http://www.blogger.com/atom/ns#' term='file field'/><title type='text'>Watir Tutorial: File fields, file selector/chooser test automation</title><content type='html'>As defined in HTML specifications, file field provides a means for users to attach a file to the form's contents. It is generally rendered by text field and an associated button which when clicked invokes a file browser to select a file name. The file name can also be entered directly in the text field. Just like type=text you can use the size attribute to set the visible width of this field in average character widths. You can set an upper limit to the length of file names using the maxlength attribute. Some user agents support the ability to restrict the kinds of files to those matching a comma separated list of MIME content types given with the ACCEPT attribute e.g. accept="image/*" restricts files to images. Further information can be found here &lt;a href='http://www.w3.org/TR/html401/interact/forms.html#h-17.4'&gt;http://www.w3.org/TR/html401/interact/forms.html#h-17.4&lt;/a&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;Here is the list of common file field attributes&lt;br /&gt;&lt;table border="1"&gt;&lt;tr&gt;&lt;th&gt;Attribute&lt;/th&gt;&lt;th&gt;Type&lt;/th&gt;&lt;th&gt;Description&lt;/th&gt;&lt;/tr&gt;&lt;br /&gt;&lt;tr&gt;&lt;td&gt;name&lt;/td&gt;&lt;td&gt;CDATA&lt;/td&gt;&lt;td&gt;Name of the field&lt;/td&gt;&lt;/tr&gt;&lt;br /&gt;&lt;tr&gt;&lt;td&gt;value&lt;/td&gt;&lt;td&gt;CDATA&lt;/td&gt;&lt;td&gt;Stores the value of the field when set, or used to set the default value&lt;/td&gt;&lt;/tr&gt;&lt;br /&gt;&lt;tr&gt;&lt;td&gt;disabled&lt;/td&gt;&lt;td&gt;(disabled)&lt;/td&gt;&lt;td&gt;Will display the file field as disabled&lt;/td&gt;&lt;/tr&gt;&lt;br /&gt;&lt;tr&gt;&lt;td&gt;readonly&lt;/td&gt;&lt;td&gt;(readonly)&lt;/td&gt;&lt;td&gt;User cannot set the file field, will only display the preset value&lt;/td&gt;&lt;/tr&gt;&lt;br /&gt;&lt;tr&gt;&lt;td&gt;size&lt;/td&gt;&lt;td&gt;CDATA&lt;/td&gt;&lt;td&gt;Length of the file field visible on the web form/page&lt;/td&gt;&lt;/tr&gt;&lt;br /&gt;&lt;tr&gt;&lt;td&gt;maxlength&lt;/td&gt;&lt;td&gt;NUMBER&lt;/td&gt;&lt;td&gt;Max chars allowed for file fields&lt;/td&gt;&lt;/tr&gt;&lt;br /&gt;&lt;tr&gt;&lt;td&gt;alt&lt;/td&gt;&lt;td&gt;CDATA&lt;/td&gt;&lt;td&gt;short description&lt;/td&gt;&lt;/tr&gt;&lt;br /&gt;&lt;tr&gt;&lt;td&gt;tabindex&lt;/td&gt;&lt;td&gt;NUMBER&lt;/td&gt;&lt;td&gt;position in tabbing order&lt;/td&gt;&lt;/tr&gt;&lt;br /&gt;&lt;tr&gt;&lt;td&gt;accept&lt;/td&gt;&lt;td&gt;ContentTypes&lt;/td&gt;&lt;td&gt;List of MIME types for file upload&lt;/td&gt;&lt;/tr&gt;&lt;br /&gt;&lt;/table&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;Before we start testing file fields, here are some of the common example of how file fields are used:&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;Simplest form of the file field is&lt;br /&gt;&lt;pre&gt;&lt;code&gt;&lt;br /&gt;&amp;lt;input type ='file' value='some value'/&amp;gt;&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;Here are various examples of the file field that will be used in this tutorial to explain how Watir can access and set the file field on web page using various file field properties/attributes&lt;br /&gt;&lt;pre&gt;&lt;code&gt;&lt;br /&gt;&amp;lt;input type='file' name='file1' value='uploadtest.html' class='file_class'/&amp;gt;&lt;br /&gt;&amp;lt;input type ='file' id='file2' value='uploadtest.html'/&amp;gt;&lt;br /&gt;&amp;lt;input type ='file' name='disabled' value='uploadtest.html' disabled='disabled'/&amp;gt;&lt;br /&gt;&amp;lt;input type="file" name="datafile" size="40"/&amp;gt;&lt;br /&gt;&amp;lt;input type="file" ... style="color:#fff; background:#030"/&amp;gt;&lt;br /&gt;&amp;lt;input type='file' name='readonly' value='uploadtest.html' readonly='readonly'/&amp;gt;&lt;br /&gt;&amp;lt;input type='file' name='file3' value="" class='file_class'/&amp;gt;&lt;br /&gt;&amp;lt;input type=file name=photo size=20 accept="image/*"/&amp;gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;File fields can appear with the forms or outside the form.&lt;br /&gt;&lt;br /&gt;Here is the sample of file field within the form&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;code&gt;&lt;br /&gt;&amp;lt;form name='testform' method='get' action='test.html'&amp;gt;&lt;br /&gt;&amp;lt;input type='file' name='file3' value='uploadtest.html'/&amp;gt;&lt;br /&gt;&amp;lt;input name="upload" type="submit" value="upload"/&amp;gt;&lt;br /&gt;&amp;lt;/form&amp;gt;&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;You can also access file fields using :beforeText and :afterText attributes, where file field appears before/after certain targeted text.&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;code&gt;&lt;br /&gt;&amp;lt;input type='file' name='beforetest' value='uploadtest.html'/&amp;gt;This Text After&lt;br&gt;&lt;br /&gt;This Text Before&amp;lt;input type='file' name='aftertest'  value='uploadtest.html'/&amp;gt;&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;Accessing file field using file field id&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;input type ='file' id='file_field_id' value='uploadtest.html'/&amp;gt;&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;code&gt;&lt;br /&gt; browser.file_field(:id, "file_field_id").exists?&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;Accessing file field using file field id with regular expression&lt;/p&gt;&lt;br /&gt;&lt;pre&gt;&lt;code&gt;&lt;br /&gt; browser.file_field(:id, /_id/).exists?&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;Accessing file field using file field name&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;input type='file' name='file field_name' value='uploadtest.html' class='file_class'/&amp;gt;&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;code&gt;&lt;br /&gt; browser.file_field(:name, "test1").exists?&lt;br /&gt; browser.file field(:name, "file field_name").exists?&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;Accessing file field using file field name and regular expression&lt;br /&gt;&lt;pre&gt;&lt;code&gt;&lt;br /&gt;browser.file field(:name, /_name/).exists?&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;Accessing file field using file field index&lt;br /&gt;&lt;pre&gt;&lt;code&gt;&lt;br /&gt;browser.file field(:index, 1).exists?&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;Querying file field properties&lt;br /&gt;&lt;pre&gt;&lt;code&gt;&lt;br /&gt;browser.file_field(:index, 1).value&lt;br /&gt;browser.file_field(:index, 1).name&lt;br /&gt;browser.file_field(:index, 1).id&lt;br /&gt;browser.file_field(:index, 1).disabled&lt;br /&gt;browser.file_field(:index, 1).type&lt;br /&gt;browser.file_field(:index, 1).class_name&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Get all file fields in the browser&lt;br /&gt;&lt;pre&gt;&lt;code&gt;&lt;br /&gt;browser.file_fields&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Get number of file fields in the page&lt;br /&gt;&lt;pre&gt;&lt;code&gt;&lt;br /&gt;browser.file_fields.length&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;File field iterator&lt;br /&gt;&lt;pre&gt;&lt;code&gt;&lt;br /&gt;    browser.file_fields.length&lt;br /&gt;    index = 1&lt;br /&gt;    browser.file fields.each do |file_field|&lt;br /&gt;      assert_equal(browser.file_field(:index, index).id, file_field.id )&lt;br /&gt;      assert_equal(browser.file_field(:index, index).name, file_field.name )&lt;br /&gt;      index+=1&lt;br /&gt;    end&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;Accessing file fields in forms&lt;br /&gt;&lt;pre&gt;&lt;code&gt;&lt;br /&gt;browser.form(:id, "test_form_id").file_field(:id, "test1").exists?&lt;br /&gt;browser.form(:name, "test_form_id").file_field(:index, 1).exists?&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;Accessing file fields in frames&lt;br /&gt;&lt;pre&gt;&lt;code&gt;&lt;br /&gt;browser.frame(:id, "Frame").file_field(:id, "test1").exists?&lt;br /&gt;browser.frame(:id, "Frame").file_field(:index, 1).exists?&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;Iterating thru file fields in frames&lt;br /&gt;&lt;pre&gt;&lt;code&gt;&lt;br /&gt;    count =0&lt;br /&gt;    browser.frame(:id, "Frame").file_fields.each do |ff|&lt;br /&gt;      ....&lt;br /&gt;      count+=1&lt;br /&gt;    end&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;OR&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;code&gt;&lt;br /&gt; browser.file_fields.each { |f| puts f.to_s }&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Goto the n&lt;sup&gt;th&lt;/sup&gt; file field on the page&lt;br /&gt;&lt;pre&gt;&lt;code&gt;&lt;br /&gt;browser.file_fields[n].to_s&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Print the details of the file field.&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;code&gt;&lt;br /&gt;browser.file_fields(:index, n).to_s&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;This will list type, id, name, value and whether the file field is disabled.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4612089851160687407-8137703338296347539?l=watirtutorials.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://watirtutorials.blogspot.com/feeds/8137703338296347539/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://watirtutorials.blogspot.com/2009/10/watir-tutorial-file-fields-file.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4612089851160687407/posts/default/8137703338296347539'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4612089851160687407/posts/default/8137703338296347539'/><link rel='alternate' type='text/html' href='http://watirtutorials.blogspot.com/2009/10/watir-tutorial-file-fields-file.html' title='Watir Tutorial: File fields, file selector/chooser test automation'/><author><name>Shrikant Wagh</name><uri>http://www.blogger.com/profile/07093525941014864586</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://2.bp.blogspot.com/_nwkJ5BJsnTA/SrxVOxHcIGI/AAAAAAAAAAg/xhBW55r-YDg/S220/Shrikant8080.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4612089851160687407.post-2489896680305866770</id><published>2009-10-16T12:31:00.000-07:00</published><updated>2009-10-16T13:08:12.095-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='ruby'/><category scheme='http://www.blogger.com/atom/ns#' term='qa'/><category scheme='http://www.blogger.com/atom/ns#' term='firewatir'/><category scheme='http://www.blogger.com/atom/ns#' term='automation'/><category scheme='http://www.blogger.com/atom/ns#' term='safariwatir'/><category scheme='http://www.blogger.com/atom/ns#' term='watir'/><category scheme='http://www.blogger.com/atom/ns#' term='test'/><category scheme='http://www.blogger.com/atom/ns#' term='links'/><title type='text'>Watir Tutorial: Web links test automation</title><content type='html'>&lt;p&gt;In this tutorial, we will explore various options to verify and automate web links testing. I tried to add code examples/samples for both HTML source for links and Watir source code to test those scenarios. If you are looking for something specific not covered in this tutorial, drop me an email at shrikantwagh@sbcglobal.net.&lt;br /&gt;&lt;br /&gt;&lt;p&gt;Before we start testing links, here are some of the common formats for the links used&lt;br /&gt;&lt;br /&gt;&lt;p&gt;Simplest for of the link is&lt;br /&gt;&lt;pre&gt;&lt;code&gt;&lt;br /&gt;&amp;lt;a href="url"&amp;gt;Link text&amp;lt;/a&amp;gt;&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;Here are various examples of the links that will be used in this tutorial to explain how Watir can access the link on web page using various link properties/attributes&lt;br /&gt;&lt;pre&gt;&lt;code&gt;&lt;br /&gt;&amp;lt;a href="http://www.somedomain.com/"&amp;gt;Visit somedomain!&amp;lt;/a&amp;gt;&lt;br /&gt;&amp;lt;a href="http://www.somedomain.com/" target="_blank"&amp;gt;Visit somedomain in new window!&amp;lt;/a&amp;gt;&lt;br /&gt;&amp;lt;a href="http://www.somedomain.com/" target="_top"&amp;gt;Go to top!&amp;lt;/a&amp;gt;&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;Anchors&lt;br /&gt;&lt;pre&gt;&lt;code&gt;&lt;br /&gt;&amp;lt;a name="label"&amp;gt;Any content&amp;lt;/a&amp;gt;&lt;br /&gt;&amp;lt;a href="#label"&amp;gt;Any content&amp;lt;/a&amp;gt;&lt;br /&gt;&amp;lt;a href="#tips"&amp;gt;Jump to the Tips Section&amp;lt;/a&amp;gt;&lt;br /&gt;&amp;lt;a href="http://www.somedoamin.com/someurl.htm#tips"&amp;gt;Jump to the Tips Section&amp;lt;/a&amp;gt;&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;You can also use an image as a link:&lt;br /&gt;&lt;pre&gt;&lt;code&gt;&lt;br /&gt;&amp;lt;a href="http://someurl/somepage.html"&amp;gt;&amp;lt;img border="0" src="buttonnext.gif" width="65" height="38"&amp;gt;&amp;lt;/a&amp;gt;&lt;br /&gt;&amp;lt;a href="http://someurl/somepage.html"&amp;gt;&amp;lt;img src="images/button.jpg" border="0" alt=""&amp;gt;&amp;lt;/img&amp;gt;&amp;lt;/a&amp;gt; The button is really a link &lt;br&gt;&lt;/br&gt;&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;This is a mail link:&lt;br /&gt;&lt;pre&gt;&lt;code&gt;&lt;br /&gt;&amp;lt;a href="mailto:someone@somedomain.com?subject=Hello%20again"&amp;gt;Send Mail&amp;lt;/a&amp;gt;&lt;br /&gt;&amp;lt;a href="lhttp://someurl/somepage.html" class="link_class_1"&amp;gt;test1&amp;lt;/a&amp;gt; &lt;br&gt;&lt;/br&gt;&lt;br /&gt;&amp;lt;a href="http://someurl/somepage.html" name="link_name"&amp;gt;Link Using a name&amp;lt;/a&amp;gt;&lt;br /&gt;&amp;lt;a href="lhttp://someurl/somepage.html" title="link_title"&amp;gt;Link Using a title&amp;lt;/a&amp;gt;&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;Accessing link using link text&lt;br /&gt;&lt;pre&gt;&lt;code&gt;&lt;br /&gt;    assert(browser.link(:text, "test1").exists?)&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;Accessing link using link text with regular expression&lt;br /&gt;&lt;pre&gt;&lt;code&gt;&lt;br /&gt;    assert(browser.link(:text, /TEST/i).exists?)&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;Accessing link using link url&lt;br /&gt;&lt;pre&gt;&lt;code&gt;&lt;br /&gt;   assert(browser.link(:url, /someurl.html/).exists?)&lt;br /&gt;   assert(browser.link(:url, "specificurl.html").exists?)&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;Accessing link using link id&lt;br /&gt;&lt;pre&gt;&lt;code&gt;&lt;br /&gt; assert(browser.link(:id, "link_id").exists?)&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;Accessing link using link id with regular expression&lt;br /&gt;&lt;pre&gt;&lt;code&gt;&lt;br /&gt; assert(browser.link(:id, /_id/).exists?)&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;Accessing link using link name&lt;br /&gt;&lt;pre&gt;&lt;code&gt;&lt;br /&gt; assert(browser.link(:name, "link_name").exists?)&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;Accessing link using link name and regular expression&lt;br /&gt;&lt;pre&gt;&lt;code&gt;&lt;br /&gt;assert(browser.link(:name, /_n/).exists?)&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;Accessing link using link title&lt;br /&gt;&lt;pre&gt;&lt;code&gt;&lt;br /&gt;assert(browser.link(:title, "link title").exists?)&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;Accessing link using link title and regular expression&lt;br /&gt;&lt;pre&gt;&lt;code&gt;&lt;br /&gt;assert_false(browser.link(:title, /title/).exists?)&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;Accessing link using link index&lt;br /&gt;&lt;pre&gt;&lt;code&gt;&lt;br /&gt;assert(browser.link(:index, 1).exists?)&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;Clicking the link&lt;br /&gt;&lt;pre&gt;&lt;code&gt;&lt;br /&gt;&lt;br /&gt;    browser.link(:text, "test1").click&lt;br /&gt;    browser.link(:url, /link.html/).click&lt;br /&gt;    browser.link(:index, 1).click&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;Querying link properties&lt;br /&gt;&lt;pre&gt;&lt;code&gt;&lt;br /&gt;browser.link(:index, 1).href&lt;br /&gt;browser.link(:index, 1).value&lt;br /&gt;browser.link(:index, 1).innerText&lt;br /&gt;browser.link(:index, 1).name&lt;br /&gt;browser.link(:index, 1).id&lt;br /&gt;browser.link(:index, 1).disabled&lt;br /&gt;browser.link(:index, 1).type&lt;br /&gt;browser.link(:index, 1).class_name&lt;br /&gt;browser.link(:index, 7).title&lt;br /&gt;rowser.links[7].innerText&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;Link iterator&lt;br /&gt;&lt;pre&gt;&lt;code&gt;&lt;br /&gt;    browser.links.length&lt;br /&gt;    index = 1&lt;br /&gt;    browser.links.each do |link|&lt;br /&gt;      assert_equal(browser.link(:index, index).href      , link.href )&lt;br /&gt;      assert_equal(browser.link(:index, index).id        , link.id )&lt;br /&gt;      assert_equal(browser.link(:index, index).name      , link.name )&lt;br /&gt;      assert_equal(browser.link(:index, index).innerText , link.innerText )&lt;br /&gt;      index+=1&lt;br /&gt;    end&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;Accessing links in frames&lt;br /&gt;&lt;pre&gt;&lt;code&gt;&lt;br /&gt;browser.frame("linkFrame").link(:text, "test1").exists?&lt;br /&gt;browser.frame("linkFrame").link(:index, 1).href&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;Iterating thru links in frames&lt;br /&gt;&lt;pre&gt;&lt;code&gt;&lt;br /&gt;    count =0&lt;br /&gt;    browser.frame("linkFrame").links.each do |l|&lt;br /&gt;      count+=1&lt;br /&gt;    end&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;Display all links in the page&lt;br /&gt;&lt;pre&gt;&lt;code&gt;&lt;br /&gt;    browser.showLinks&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4612089851160687407-2489896680305866770?l=watirtutorials.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://watirtutorials.blogspot.com/feeds/2489896680305866770/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://watirtutorials.blogspot.com/2009/10/watir-tutorial-web-links-test.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4612089851160687407/posts/default/2489896680305866770'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4612089851160687407/posts/default/2489896680305866770'/><link rel='alternate' type='text/html' href='http://watirtutorials.blogspot.com/2009/10/watir-tutorial-web-links-test.html' title='Watir Tutorial: Web links test automation'/><author><name>Shrikant Wagh</name><uri>http://www.blogger.com/profile/07093525941014864586</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://2.bp.blogspot.com/_nwkJ5BJsnTA/SrxVOxHcIGI/AAAAAAAAAAg/xhBW55r-YDg/S220/Shrikant8080.JPG'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4612089851160687407.post-2846580475936553399</id><published>2009-10-02T22:08:00.000-07:00</published><updated>2009-10-02T22:12:00.415-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='qa'/><category scheme='http://www.blogger.com/atom/ns#' term='firewatir'/><category scheme='http://www.blogger.com/atom/ns#' term='installation'/><category scheme='http://www.blogger.com/atom/ns#' term='jssh'/><category scheme='http://www.blogger.com/atom/ns#' term='tutorial'/><category scheme='http://www.blogger.com/atom/ns#' term='watir'/><category scheme='http://www.blogger.com/atom/ns#' term='test'/><category scheme='http://www.blogger.com/atom/ns#' term='setup'/><title type='text'>Watir Tutorials: Watir and FireWatir Installation and Setup</title><content type='html'>&lt;p&gt;Previous blog - &lt;a href="http://watirtutorials.blogspot.com/2009/09/watir-qa-automation-watir-setup-part-i.html"&gt;Watir QA Automation: Watir Setup - Part I: Installing Ruby&lt;/a&gt; explain how to install Ruby on various platforms. This article explains how to install various types of Watir for different browsers and validate your installation. &lt;/p&gt;&lt;br /&gt;&lt;p&gt;Watir support Microsoft Internet Explorer [IE], FireFox and Safari browsers. There are separate Watir frameworks for each of these browsers.&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Watir for IE&lt;/li&gt;&lt;br /&gt;&lt;li&gt;FireWatir for FireFox&lt;/li&gt;&lt;br /&gt;&lt;li&gt;SafariWatir for Safari&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;Since these are separate projects, the version of each of these Watir variations may not be same.  I noticed that some of the features are supported by Watir are not available in FireWatir or vice-versa. This sometimes make writing cross browser test cases more challenging. Later I'll discuss this in details about writing interoperable, reusable and cross browser test cases without maintaining test suites for each browsers. We will postpone this discussion till then.&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;h2&gt;Prerequisites&lt;/h2&gt;&lt;br /&gt;&lt;p&gt;In order to install Watir, you will need gem. Gem should get automatically installed when you install Ruby. Please refer to previous blog for Ruby installation -&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;You can verify whether gem is installed by typing the command gem or gem -v on the command prompt&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;pre&gt;&lt;code&gt;&lt;br /&gt;C:\apptests\trunk\test_suite&gt;gem&lt;br /&gt;RubyGems is a sophisticated package manager for Ruby.  This is a&lt;br /&gt;basic help message containing pointers to more information.&lt;br /&gt;  Usage:&lt;br /&gt;    gem -h/--help&lt;br /&gt;    gem -v/--version&lt;br /&gt;    gem command [arguments...] [options...]&lt;br /&gt;  Examples:&lt;br /&gt;    gem install rake&lt;br /&gt;    gem list --local&lt;br /&gt;    gem build package.gemspec&lt;br /&gt;    gem help install&lt;br /&gt;  Further help:&lt;br /&gt;    gem help commands            list all 'gem' commands&lt;br /&gt;    gem help examples            show some examples of usage&lt;br /&gt;    gem help &lt;COMMAND&gt;           show help on COMMAND&lt;br /&gt;                                   (e.g. 'gem help install')&lt;br /&gt;  Further information:&lt;br /&gt;    http://rubygems.rubyforge.org&lt;br /&gt;C:\apptests\trunk\test_suite&gt;gem -v&lt;br /&gt;0.9.4&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;&lt;p&gt;If you want to grab the newer version of gem or you do not have gem installed, then go to &lt;a href="http://rubygems.rubyforge.org/"&gt;http://rubygems.rubyforge.org/&lt;/a&gt; or &lt;a href="http://docs.rubygems.org/"&gt;http://docs.rubygems.org/&lt;/a&gt; and install gem. You will find the gem binaries, install instructions and documentation for gem here.&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;You can also verify whether you had any Watir frameworks installed using gem list&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;pre&gt;&lt;code&gt;&lt;br /&gt;C:\apptests\trunk\test_suite&gt;gem list |grep watir&lt;br /&gt;commonwatir (1.6.2)&lt;br /&gt;    Common code used by Watir and FireWatir&lt;br /&gt;firewatir (1.6.2)&lt;br /&gt;flash_watir (1.1.0)&lt;br /&gt;    an extension for watir to test flash applications in firefox.&lt;br /&gt;watir (1.6.2)&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;&lt;p&gt;If you have any older versions of Watir installed then I would recommend to uninstall those before installing the newer versions.&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;It is possible that you might have latest-greatest version of watir already installed, so before you start uninstalling the existing version, check the gem list. Latest versions of the available gems are published periodically at &lt;a href="http://gems.rubyforge.vm.bytemark.co.uk/gems/"&gt;http://gems.rubyforge.vm.bytemark.co.uk/gems/&lt;/a&gt; and  &lt;a href="http://gems.rubyforge.org/gems/"&gt;http://gems.rubyforge.org/gems/&lt;/a&gt;&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;h2&gt;Watir for Internet Explorer&lt;/h2&gt;&lt;br /&gt;&lt;p&gt;Installing watir is as easy as execution one command. If you want specific version of watir then specify version number with -v option&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;pre&gt;&lt;code&gt;&lt;br /&gt;gem install watir&lt;br /&gt;gem install watir -v 1.6.2&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt;Verify your Watir installation&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;pre&gt;&lt;code&gt;&lt;br /&gt;gem list --local&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt;this will list all gem installed on your computer&lt;br&gt;&lt;br /&gt;OR&lt;br&gt;&lt;br /&gt;if use gem list watir, will list only watir info.&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;pre&gt;&lt;code&gt;&lt;br /&gt;C:\apptests\trunk\test_suite&gt;gem list watir&lt;br /&gt;*** LOCAL GEMS ***&lt;br /&gt;watir (1.6.2)&lt;br /&gt;    Automated testing tool for web applications.&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;&lt;h2&gt;FireWatir for FireFox&lt;/h2&gt;&lt;br /&gt;&lt;p&gt;FireWatir setup requires one extra step than installing Watir for IE&lt;/p&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Install FireWatir and&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Install JSSH plugins for FireFox&lt;/li&gt;&lt;br /&gt;&lt;/ul&gt;&lt;br /&gt;&lt;p&gt;In following section we will explore each of this in details.&lt;br /&gt;&lt;h3&gt;Installing FireWatir for FireFox&lt;/h3&gt;&lt;br /&gt;&lt;p&gt;Installing firewatir is same process as installing watir, only gem name is different. If you want specific version of firewatir then specify version number with -v option&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;pre&gt;&lt;code&gt;&lt;br /&gt;gem install firewatir&lt;br /&gt;gem install firewatir -v 1.6.2&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;&lt;p&gt;Verify your FireWatir installation&lt;/p&gt;&lt;br /&gt;&lt;pre&gt;&lt;code&gt;&lt;br /&gt;gem list --local&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;&lt;p&gt;this will list all gem installed on your computer&lt;br&gt;&lt;br /&gt;OR &lt;br&gt;&lt;br /&gt;if use gem list watir, will list only firewatir info.&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;pre&gt;&lt;code&gt;&lt;br /&gt;C:\apptests\trunk\test_suite&gt;gem list firewatir&lt;br /&gt;*** LOCAL GEMS ***&lt;br /&gt;firewatir (1.6.2)&lt;br /&gt;    Automated testing tool for web applications using FireFox browser.&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;&lt;h3&gt;Install JSSH for FireFox&lt;/h3&gt;&lt;br /&gt;&lt;p&gt;To run the FireWatir test cases in FireFox you need to install JSSH [javascript shell] plugins for FireFox&lt;/p&gt;&lt;br /&gt;&lt;p&gt;If you do not have FireFox installed yet, then download Firefox browser from &lt;a href="http://www.mozilla.com"&gt;http://www.mozilla.com&lt;/a&gt; and install it.&lt;/p&gt;&lt;br /&gt;Follow the following steps to install JSSH plugins&lt;br /&gt;&lt;ul&gt;&lt;br /&gt;&lt;li&gt;Download .XPI file from &lt;a href="http://code.google.com/p/firewatir/downloads/list"&gt;http://code.google.com/p/firewatir/downloads/list &lt;/a&gt;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Start Firefox browser. &lt;/li&gt;&lt;br /&gt;&lt;li&gt;From File menu select Open File option. &lt;/li&gt;&lt;br /&gt;&lt;li&gt;Navigate to the path where the downloaded .XPI file is located. Select the .XPI file click open. &lt;/li&gt;&lt;br /&gt;&lt;li&gt;Wait till a dialog appear stating that do you want to install this extension. &lt;/li&gt;&lt;br /&gt;&lt;li&gt;Click install. &lt;/li&gt;&lt;br /&gt;&lt;li&gt;The extension will now show up in the installed extensions list. &lt;/li&gt;&lt;br /&gt;&lt;/ul&gt;&lt;br /&gt;For checking the installation of JSSH extension; follow steps below&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Close Firefox.&lt;li&gt;&lt;br /&gt;&lt;li&gt;Restart it from command prompt using "Firefox installation directory/firefox.exe -jssh". Make sure you give "-jssh" as parameter otherwise Firefox will not start JSSh shell. &lt;/li&gt;&lt;br /&gt;&lt;li&gt;To check if JSSh is listening on port 9997 run command &lt;code&gt;"telnet localhost 9997"&lt;/code&gt; from command prompt. &lt;/li&gt;&lt;br /&gt;&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4612089851160687407-2846580475936553399?l=watirtutorials.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://watirtutorials.blogspot.com/feeds/2846580475936553399/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://watirtutorials.blogspot.com/2009/10/watir-tutorials-watir-and-firewatir.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4612089851160687407/posts/default/2846580475936553399'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4612089851160687407/posts/default/2846580475936553399'/><link rel='alternate' type='text/html' href='http://watirtutorials.blogspot.com/2009/10/watir-tutorials-watir-and-firewatir.html' title='Watir Tutorials: Watir and FireWatir Installation and Setup'/><author><name>Shrikant Wagh</name><uri>http://www.blogger.com/profile/07093525941014864586</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://2.bp.blogspot.com/_nwkJ5BJsnTA/SrxVOxHcIGI/AAAAAAAAAAg/xhBW55r-YDg/S220/Shrikant8080.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4612089851160687407.post-3799113531624144291</id><published>2009-09-25T13:38:00.000-07:00</published><updated>2009-09-25T13:42:53.966-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='ruby'/><category scheme='http://www.blogger.com/atom/ns#' term='installation'/><category scheme='http://www.blogger.com/atom/ns#' term='tutorial'/><category scheme='http://www.blogger.com/atom/ns#' term='watir'/><category scheme='http://www.blogger.com/atom/ns#' term='setup'/><title type='text'>Watir Tutorial: Installation and Setup - Part I</title><content type='html'>&lt;h2&gt;Watir installation and setup - Part I&lt;/h2&gt;&lt;br /&gt;&lt;br /&gt;Installing watir is just two step process&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Step #1 - Install Ruby&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Step #2 - Install Watir&lt;/li&gt;&lt;br /&gt;&lt;/ul&gt;&lt;br /&gt;&lt;br /&gt;&lt;h2&gt;Step #1 - Installing Ruby&lt;/h2&gt;&lt;br /&gt;Download ruby binaries or installers.&lt;br /&gt;&lt;br /&gt;&lt;h3&gt;Installing Ruby on Windows&lt;/h3&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;You might have Ruby already installed. It is always good idea to check whether Ruby is already installed in your machine and the version of Ruby if it is available. Execite the following commond from your windows command prompt.&lt;br /&gt; &lt;pre&gt;&lt;code&gt;&lt;br /&gt;C:\Documents and Settings\Shrikant Wagh&gt;ruby -v&lt;br /&gt;ruby 1.8.6 (2007-09-24 patchlevel 111) [i386-mswin32]&lt;br /&gt; &lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;&lt;p&gt;If it is not installed you will get the following message&lt;br /&gt;&lt;pre&gt;&lt;code&gt;&lt;br /&gt;C:\Documents and Settings\Shrikant Wagh&gt;ruby -v&lt;br /&gt;'ruby' is not recognized as an internal or external command,&lt;br /&gt;operable program or batch file.&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;&lt;p&gt;Easiest way to install Ruby on Windows platforms is to use one-click installer. Click on this link to download the one-click installer &lt;br&gt; &lt;a href="http://rubyforge.org/frs/download.php/47082/ruby186-27_rc2.exe"&gt;Ruby 1.8.6 One-Click Installer&lt;/a&gt;&lt;br&gt;&lt;br /&gt;&lt;p&gt;Run the one-click installer and follow the instruction to install Ruby.&lt;br /&gt;&lt;p&gt;After installation is complete, verify your Ruby installtion using the same commant mentioed above.&lt;br /&gt;&lt;p&gt;If you want to explore other option to install Ruby, please visit http://ruby-lang.org/en/downloads.&lt;br /&gt;&lt;h3&gt;Installing Ruby On Linux&lt;/h3&gt;&lt;br /&gt;For most of the Linux flavors, compiled packages/binaries are available to install Ruby.&lt;br /&gt;&lt;p&gt;Red Hat and Fedora Linux&lt;br&gt;&lt;br /&gt;Verify whether Ruby is already installed. &lt;br&gt;&lt;br /&gt;&lt;pre&gt;&lt;code&gt;&lt;br /&gt;rpm -q ruby&lt;br /&gt;package ruby is not installed &lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;&lt;p&gt;If it is not yet instyalled then you can install it using &lt;italics&gt;yum&lt;/italics&gt; update manager. Any installtion tasks requires root access, so you can login with root access or use &lt;italics&gt;sudo&lt;/italics&gt;&lt;br /&gt;&lt;pre&gt;&lt;code&gt;&lt;br /&gt;sudo yum install ruby&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;&lt;p&gt;Follow the instructions prompted by installer to install required packages.&lt;br /&gt;&lt;p&gt;Verify your Ruby installtion once complete.&lt;br /&gt;&lt;pre&gt;&lt;code&gt;&lt;br /&gt;ruby -v&lt;br /&gt;ruby 1.8.1 (2003-12-25) [i386-linux-gnu]&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;&lt;h3&gt;Debian or Ubuntu Linux&lt;/h3&gt;&lt;br /&gt;Verify whether Ruby is already installed. &lt;br&gt;&lt;br /&gt;&lt;pre&gt;&lt;code&gt;&lt;br /&gt;ruby&lt;br /&gt;The program 'ruby' is currently not installed.&lt;br /&gt;You can install it by typing:&lt;br /&gt;sudo apt-get install ruby&lt;br /&gt;-bash: ruby: command not found&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;&lt;p&gt;If it is not yet instyalled then you can install it using &lt;italics&gt;app-get&lt;/italics&gt;. Any installtion tasks requires root access, so you can login with root access or use &lt;italics&gt;sudo&lt;/italics&gt;&lt;br /&gt;&lt;pre&gt;&lt;code&gt;&lt;br /&gt;sudo apt-get install ruby&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;&lt;p&gt;Follow the instructions prompted by installer to install required packages.&lt;br /&gt;&lt;p&gt;Verify your Ruby installtion once complete.&lt;br /&gt;&lt;pre&gt;&lt;code&gt;&lt;br /&gt;ruby -v&lt;br /&gt;ruby 1.8.1 (2003-12-25) [i386-linux-gnu]&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;&lt;h2&gt;Installing Ruby On OS X&lt;/h2&gt;&lt;br /&gt;Your Mac might have Ruby already installed, verify which version on Ruby is installed on your Mac.&lt;br /&gt;&lt;pre&gt;&lt;code&gt;&lt;br /&gt;ruby -v&lt;br /&gt;ruby 1.8.6 (2008-08-11 patchlevel 287) [universal-darwin9.0]&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;&lt;p&gt;You got the right version. Do nothing. If you got older versiona dn want to installt new version then you can use &lt;a href="http://www.macports.org/"&gt;MacPorts&lt;/a&gt; or &lt;a href="http://fink.sourceforge.net/"&gt;Fink&lt;/a&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;On MacPorts, you can install Ruby with&amp;#8230;&lt;/p&gt;&lt;br /&gt;&lt;pre&gt;&lt;code&gt;&lt;br /&gt;% port install ruby&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;&lt;p&gt;Also, you can doenload the source code and compile it locally.&lt;/p&gt;&lt;br /&gt;&lt;p&gt;For source code and more details of installting Ruby on OS X, refer to &lt;a href="http://ruby-lang.org/en/downloads"&gt;Ruby source code"&lt;/a&gt; for source, &lt;a href="http://hivelogic.com/articles/ruby-rails-leopard"&gt;Ruby for Leopard &lt;/a&gt;for building Ruby on Mac OS X 10.5 (Leopard) and &lt;a href="http://hivelogic.com/articles/ruby-rails-mongrel-mysql-osx"&gt;Ruby for Tiger &lt;/a&gt;  for builing Ruby on Mac OS X 10.4 (Tiger) &lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4612089851160687407-3799113531624144291?l=watirtutorials.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://watirtutorials.blogspot.com/feeds/3799113531624144291/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://watirtutorials.blogspot.com/2009/09/watir-tutorial-installation-and-setup.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4612089851160687407/posts/default/3799113531624144291'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4612089851160687407/posts/default/3799113531624144291'/><link rel='alternate' type='text/html' href='http://watirtutorials.blogspot.com/2009/09/watir-tutorial-installation-and-setup.html' title='Watir Tutorial: Installation and Setup - Part I'/><author><name>Shrikant Wagh</name><uri>http://www.blogger.com/profile/07093525941014864586</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://2.bp.blogspot.com/_nwkJ5BJsnTA/SrxVOxHcIGI/AAAAAAAAAAg/xhBW55r-YDg/S220/Shrikant8080.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4612089851160687407.post-403937920765954173</id><published>2009-09-25T00:00:00.000-07:00</published><updated>2009-09-25T00:03:55.628-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='automation'/><category scheme='http://www.blogger.com/atom/ns#' term='tutorial'/><category scheme='http://www.blogger.com/atom/ns#' term='watir'/><title type='text'>Watir Tutorial - How to check for web component rendering</title><content type='html'>For any web page testing, almost very test engineer has the dilemma of how much wait is optimal for the page/certain component to render. How much time will it take to render the component before you can check that components or the enclosed in the components depends on so may parameters and your guess is as good as mine. If you wait for less, you get to many false failures. If you wait more, you test execution get sluggish.&lt;br /&gt;You can always use this trick, few lines if extra code, but make you test execution much efficient - sleep for small duration, check for component in a loop and break out soon it is available.&lt;br /&gt;Here is the test automation scenario. You have a web page with the form and you have to automate filling the form fields and form submission. So if you try to check for components using assert() or try to edit the form fields before the form is rendered on the page, you test will fail just because the page took longer to load. If you take the worst case scenario and put 30 sec of wait time, it will be annoying for person who will execute those test cases, as he/she have to wait for that duration everytime.&lt;br /&gt;Following approach will address this issue, just use any looping structure you are comfortable with, sleep for small duration and check if the form is rendered, break out of the loop soon form is available and continue with rest of the test case.&lt;br /&gt;Sample Code:&lt;br /&gt;tries = 0&lt;br /&gt;until ($browser.form(:id, "service-form").exists? or tries &gt; 5)&lt;br /&gt;      sleep 2&lt;br /&gt;     $browser.logger.info( "waiting...")&lt;br /&gt;     tries = tries + 1&lt;br /&gt;end&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4612089851160687407-403937920765954173?l=watirtutorials.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://watirtutorials.blogspot.com/feeds/403937920765954173/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://watirtutorials.blogspot.com/2009/09/watir-tutorial-how-to-check-for-web.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4612089851160687407/posts/default/403937920765954173'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4612089851160687407/posts/default/403937920765954173'/><link rel='alternate' type='text/html' href='http://watirtutorials.blogspot.com/2009/09/watir-tutorial-how-to-check-for-web.html' title='Watir Tutorial - How to check for web component rendering'/><author><name>Shrikant Wagh</name><uri>http://www.blogger.com/profile/07093525941014864586</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://2.bp.blogspot.com/_nwkJ5BJsnTA/SrxVOxHcIGI/AAAAAAAAAAg/xhBW55r-YDg/S220/Shrikant8080.JPG'/></author><thr:total>1</thr:total></entry></feed>
