<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.expertiza.ncsu.edu/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Jjbeaver</id>
	<title>Expertiza_Wiki - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.expertiza.ncsu.edu/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Jjbeaver"/>
	<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=Special:Contributions/Jjbeaver"/>
	<updated>2026-05-25T01:07:36Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.41.0</generator>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/oss_E1463_vpd&amp;diff=91544</id>
		<title>CSC/ECE 517 Fall 2014/oss E1463 vpd</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/oss_E1463_vpd&amp;diff=91544"/>
		<updated>2014-11-06T06:22:21Z</updated>

		<summary type="html">&lt;p&gt;Jjbeaver: /* Conclusion */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= '''E1463: Refactoring TreeDisplayController''' =&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
=Project Links=&lt;br /&gt;
[http://ec2-54-186-80-176.us-west-2.compute.amazonaws.com:3000/ Our Expertiza Fork on AWS]&amp;lt;br&amp;gt;&lt;br /&gt;
[https://github.com/Druotic/expertiza Github Repo]&amp;lt;br&amp;gt;&lt;br /&gt;
[https://github.com/expertiza/expertiza/pull/449 Expertize Pull Request] &amp;lt;br&amp;gt;&lt;br /&gt;
[http://ec2-54-186-80-176.us-west-2.compute.amazonaws.com:3000/ Project Running on AWS]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Setup - How To View Our Expertiza Fork Running on AWS=&lt;br /&gt;
NOTE: The scope of our project was only to refactor select code. There are no feature additions or changes, so it should work just like production Expertiza.&lt;br /&gt;
&lt;br /&gt;
1) Go to [http://ec2-54-186-80-176.us-west-2.compute.amazonaws.com:3000/ our Expertiza project running on AWS]&lt;br /&gt;
&lt;br /&gt;
2) Login as Admin&amp;lt;br&amp;gt;&lt;br /&gt;
'''User:''' user2&amp;lt;br&amp;gt;&lt;br /&gt;
'''Password:''' password&lt;br /&gt;
&lt;br /&gt;
3) Click on &amp;quot;Manage...&amp;quot; if you are not automatically directed to the tree display.&lt;br /&gt;
&lt;br /&gt;
=Project Description=&lt;br /&gt;
&lt;br /&gt;
For this project, our team refactored the TreeDisplayController class in the [http://expertiza.ncsu.edu/ Expertiza] OSS project. This class provides access to questionnaires, review rubrics, author feedback, courses, assignments, and course evaluations. The tree display lists all of these categories with the ability for the user to &amp;quot;drill down&amp;quot; into the subcategories or just expand/collapse as needed.&lt;br /&gt;
&lt;br /&gt;
'''Example Image Of Tree Display:&lt;br /&gt;
'''&lt;br /&gt;
[[File:Expertiza.PNG ]]&lt;br /&gt;
&lt;br /&gt;
=Refactoring TreeDisplayController Tasks=&lt;br /&gt;
&lt;br /&gt;
As part of the refactoring task, we had to address the following issues for enhancing code readability and maintainability. The tasks included:&lt;br /&gt;
#Changing List to Index using a [http://www.restapitutorial.com/lessons/whatisrest.html RESTful] approach.&lt;br /&gt;
#Combined all of the goto methods&lt;br /&gt;
#Use of [http://guides.rubyonrails.org/routing.html#path-and-url-helpers routing helpers]&lt;br /&gt;
#Ensuring that instantiation of instance variables is minimized.&lt;br /&gt;
&lt;br /&gt;
In the end, we enhanced this list a bit and resulted in doing the following: 		&lt;br /&gt;
#Changed `list` method to `index`	&lt;br /&gt;
#Removed all of the `goto` methods and `drill`, and had them go through `index` instead because they are essentially just filtered versions of a listing (and the previous implementation just redirected each `goto` back to `list` anyway)	&lt;br /&gt;
#Used path helpers where possible	&lt;br /&gt;
#Removed instance variables and used local variables instead.  This should be better for scope reasons.  Note that there are still 1-2 instance variables used in the view, `@show` and `@assignment` which don't appear to be used anywhere.  (`@show` doesn't seem to ever be set, `@assignment` seems to only be used locally)  However, we didn't touch this because it didn't deal directly with our changes to the controller.	&lt;br /&gt;
#Introduced some local variables as params to the view which allow dropdowns to keep their selected option after the page reloads (the logic was there before, but it was using instance variables which were never set!). This is for the search/filtering options on the &amp;quot;Manage...&amp;quot; screen.&lt;br /&gt;
&lt;br /&gt;
==1) Changing List to Index==&lt;br /&gt;
&lt;br /&gt;
In order to make the codebase more [http://www.restapitutorial.com/lessons/whatisrest.html RESTful], we have replaced all the controller action redirections with a tree_display_index_path which enormously reduces the code content and as well as provides an organized approach to action redirections. &lt;br /&gt;
&lt;br /&gt;
[[File:List_to_Index.png]]&lt;br /&gt;
&lt;br /&gt;
As seen below, we were able to '''remove''' list from Routes.rb:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
resources :tree_display do &lt;br /&gt;
collection do &lt;br /&gt;
  get ':action' &lt;br /&gt;
    - post 'list' &lt;br /&gt;
  end &lt;br /&gt;
end &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==2) Combined All of the Goto Methods==&lt;br /&gt;
We also combined all of the goto methods into one, in accordance with the [http://en.wikipedia.org/wiki/Don't_repeat_yourself DRY] principle. This removed a significant amount of duplicate code.&lt;br /&gt;
&lt;br /&gt;
Shown below are 3 of the 10 very similar methods we removed from '''tree_display_controller.rb''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
- # direct access to questionnaires &lt;br /&gt;
- def goto_questionnaires &lt;br /&gt;
- node_object = TreeFolder.find_by_name('Questionnaires') &lt;br /&gt;
- session[:root] = FolderNode.find_by_node_object_id(node_object.id).id &lt;br /&gt;
- redirect_to :controller =&amp;gt; 'tree_display', :action =&amp;gt; 'list' &lt;br /&gt;
- end &lt;br /&gt;
- &lt;br /&gt;
- # direct access to review rubrics &lt;br /&gt;
- def goto_review_rubrics &lt;br /&gt;
- node_object = TreeFolder.find_by_name('Review') &lt;br /&gt;
- session[:root] = FolderNode.find_by_node_object_id(node_object.id).id &lt;br /&gt;
- redirect_to :controller =&amp;gt; 'tree_display', :action =&amp;gt; 'list' &lt;br /&gt;
- end &lt;br /&gt;
- &lt;br /&gt;
- # direct access to metareview rubrics &lt;br /&gt;
- def goto_metareview_rubrics &lt;br /&gt;
- node_object = TreeFolder.find_by_name('Metareview') &lt;br /&gt;
- session[:root] = FolderNode.find_by_node_object_id(node_object.id).id &lt;br /&gt;
- redirect_to :controller =&amp;gt; 'tree_display', :action =&amp;gt; 'list' &lt;br /&gt;
- end &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
These methods were replaced by a variable containing a list mapping all the session variable strings to database labels. The goto_assignments method was replaced with an index method to accept this variable, rather then calling each goto method individually.&lt;br /&gt;
&lt;br /&gt;
'''Added''' variable:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
+ @@Groups = { &lt;br /&gt;
+   'Questionnaires' =&amp;gt; 'Questionnaires', &lt;br /&gt;
+   'Review rubrics' =&amp;gt; 'Review', &lt;br /&gt;
+   'Metareview rubrics' =&amp;gt; 'Metareview', &lt;br /&gt;
+   'Teammate review rubrics' =&amp;gt; 'Teammate Review', &lt;br /&gt;
+   'Author feedbacks' =&amp;gt; 'Author Feedback', &lt;br /&gt;
+   'Global survey' =&amp;gt; 'Global Survey', &lt;br /&gt;
+   'Surveys' =&amp;gt; 'Survey', &lt;br /&gt;
+   'Course evaluations' =&amp;gt; 'Course Evaluation', &lt;br /&gt;
+   'Courses' =&amp;gt; 'Courses', &lt;br /&gt;
+   'Bookmarkrating' =&amp;gt; 'Bookmarkrating', &lt;br /&gt;
+   'Assignments' =&amp;gt; 'Assignments' &lt;br /&gt;
+ } &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Removed''' goto_assignments method:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
- # direct access to assignments &lt;br /&gt;
- def goto_assignments &lt;br /&gt;
-   node_object = TreeFolder.find_by_name('Assignments') &lt;br /&gt;
-   session[:root] = FolderNode.find_by_node_object_id(node_object.id).id &lt;br /&gt;
-   redirect_to :controller =&amp;gt; 'tree_display', :action =&amp;gt; 'list' &lt;br /&gt;
- end &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Added''' index method:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
+ def index &lt;br /&gt;
+   session[:root] = params[:root] &lt;br /&gt;
+   group = getGroup session[:menu] &lt;br /&gt;
+   node_object = TreeFolder.find_by_name(group) &lt;br /&gt;
+   if not group.blank? and not node_object.blank? &lt;br /&gt;
+     session[:root] = FolderNode.find_by_node_object_id(node_object.id).id &lt;br /&gt;
+ end &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==3) Use Routing Helpers==&lt;br /&gt;
We refactored the tree display controller class to use route helpers rather than calling &amp;quot;:action =&amp;gt; 'list', :controller =&amp;gt; 'tree_display'&amp;quot;, or something similar. This involved many edits in the tree_display_controller.rb file and related controller and view files. As seen below, we utilized routing helpers and replaced '' ':controller=&amp;gt;'course', :action=&amp;gt;'new', :private =&amp;gt; 0'' with ''new_course_path(private: 0)''.&lt;br /&gt;
&lt;br /&gt;
'''_courses_folder_actions.html.erb''' changes:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;ul&amp;gt; &lt;br /&gt;
   &amp;lt;div&amp;gt; &lt;br /&gt;
   &amp;lt;%= link_to image_tag('/assets/tree_view/add-public-24.png'), &lt;br /&gt;
  - { :controller=&amp;gt;'course', :action=&amp;gt;'new', :private =&amp;gt; 0 }, &lt;br /&gt;
  - { :title =&amp;gt; 'Create Public Course', id: 'create-public-course' } %&amp;gt; &lt;br /&gt;
  + new_course_path(private: 0), &lt;br /&gt;
  + { title: 'Create Public Course', id: 'create-public-course' } %&amp;gt; &lt;br /&gt;
   &amp;lt;%= link_to image_tag('/assets/tree_view/add-private-24.png'), &lt;br /&gt;
  - { :controller=&amp;gt;'course', :action=&amp;gt;'new', :private =&amp;gt; 1 }, &lt;br /&gt;
  - { :title =&amp;gt; 'Create Private Course', id: 'create-private-course' } %&amp;gt; &lt;br /&gt;
  + new_course_path(private: 1), &lt;br /&gt;
  + { title: 'Create Private Course', id: 'create-private-course' } %&amp;gt; &lt;br /&gt;
   &amp;lt;/div&amp;gt; &lt;br /&gt;
   &amp;lt;/ul&amp;gt; &lt;br /&gt;
   &amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt; &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Another example of routing helpers in '''_bread_crumbs.html.erb'''. &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Before:'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;%= link_to curr_node.get_name, :controller =&amp;gt; 'tree_display', :action =&amp;gt; 'drill', :root =&amp;gt; curr_node.id %&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''After''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;%= link_to curr_node.get_name, tree_display_index_path(root: curr_node.id)%&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==4) Minimizing the count of Instance Variables==&lt;br /&gt;
=== Instance Variables in Ruby ===&lt;br /&gt;
An instance variable has a name beginning with @, and its scope is confined to whatever object self refers to. Two different objects, even if they belong to the same class, are allowed to have different values for their instance variables. From outside the object, instance variables cannot be altered or even observed (i.e., ruby's instance variables are never public) except by whatever methods are explicitly provided by the programmer. As with globals, instance variables have the nil value until they are initialized.&lt;br /&gt;
&lt;br /&gt;
Instance variables do not need to be declared. This indicates a flexible object structure; in fact, each instance variable is dynamically appended to an object when it is first assigned.&lt;br /&gt;
&lt;br /&gt;
We have observed that in Expertiza, there were several code files related to the Tree Display controller which were observed to be using multiple instance variables which could be reduced. Our team aimed to limit the instantiation of such variables to only necessary places in our code.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The following was added to the ''index'' function of '''tree_display_controller.rb''' in order to replace the use of instance variables with local variables:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
locals  search:       search,&lt;br /&gt;
        sortvar:      sortvar,&lt;br /&gt;
        sortorder:    sortorder,&lt;br /&gt;
        root_node:    root_node,&lt;br /&gt;
        child_nodes:  child_nodes,&lt;br /&gt;
        filternode:   params[:filternode],&lt;br /&gt;
        searchnode:   params[:searchnode]&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Where the ''locals'' method is defined as follows:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
private&lt;br /&gt;
&lt;br /&gt;
  # render local variable hash for view&lt;br /&gt;
  # reference: http://thepugautomatic.com/2013/05/locals/&lt;br /&gt;
  def locals(values)&lt;br /&gt;
    render locals: values&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Many of the view files were changed to make use of the local variables. &lt;br /&gt;
&lt;br /&gt;
Here is an example of how _bread_crumbs.html.erb was changed. Note the removal of the &amp;quot;@&amp;quot; characters.&lt;br /&gt;
&lt;br /&gt;
'''Before:'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;% if @root_node %&amp;gt;&lt;br /&gt;
   &amp;lt;%= link_to &amp;quot;Return to top&amp;quot;, tree_display_index_path %&amp;gt;&lt;br /&gt;
   &amp;lt;%&lt;br /&gt;
      curr_node = @root_node&lt;br /&gt;
   while curr_node.parent_id&lt;br /&gt;
     curr_node = Node.find(curr_node.parent_id) %&amp;gt;&lt;br /&gt;
   &amp;amp;nbsp;&amp;amp;nbsp;&lt;br /&gt;
   &amp;lt;%= link_to curr_node.get_name, tree_display_index_path(root: curr_node.id)%&amp;gt;&lt;br /&gt;
 &amp;lt;% end %&amp;gt;&lt;br /&gt;
&amp;amp;nbsp;&amp;amp;nbsp;&amp;lt;%= @root_node.get_name %&amp;gt;&amp;lt;%&lt;br /&gt;
end %&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''After:'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;% if root_node %&amp;gt;&lt;br /&gt;
   &amp;lt;%= link_to &amp;quot;Return to top&amp;quot;, tree_display_index_path %&amp;gt;&lt;br /&gt;
   &amp;lt;%&lt;br /&gt;
      curr_node = root_node&lt;br /&gt;
   while curr_node.parent_id&lt;br /&gt;
     curr_node = Node.find(curr_node.parent_id) %&amp;gt;&lt;br /&gt;
   &amp;amp;nbsp;&amp;amp;nbsp;&lt;br /&gt;
   &amp;lt;%= link_to curr_node.get_name, tree_display_index_path(root: curr_node.id)%&amp;gt;&lt;br /&gt;
 &amp;lt;% end %&amp;gt;&lt;br /&gt;
&amp;amp;nbsp;&amp;amp;nbsp;&amp;lt;%= root_node.get_name %&amp;gt;&amp;lt;%&lt;br /&gt;
 end %&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Unexpected Database Changes=&lt;br /&gt;
&lt;br /&gt;
Unfortunately, each method of the tree_display controller has a reference to it stored in the database, along with a route.  Essentially, the routes are being stored in the database and a wildcard is used in the routes table to allow this to happen.  The following is a sample of some of the changes made (as part of tasks 1 and 2 given above) which were required in the db/seeds.rb file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
-ControllerAction.create(:site_controller_id =&amp;gt; SiteController.find_by_name('tree_display').id, :name =&amp;gt; 'goto_teammate_reviews', :permission_id =&amp;gt; nil, :url_to_use =&amp;gt; '')&lt;br /&gt;
-ControllerAction.create(:site_controller_id =&amp;gt; SiteController.find_by_name('tree_display').id, :name =&amp;gt; 'goto_metareview_rubrics', :permission_id =&amp;gt; nil, :url_to_use =&amp;gt; '')&lt;br /&gt;
-ControllerAction.create(:site_controller_id =&amp;gt; SiteController.find_by_name('tree_display').id, :name =&amp;gt; 'goto_teammatereview_rubrics', :permission_id =&amp;gt; nil, :url_to_use =&amp;gt; '')&lt;br /&gt;
+ControllerAction.create(:site_controller_id =&amp;gt; SiteController.find_by_name('tree_display').id, :name =&amp;gt; 'index', :permission_id =&amp;gt; nil, :url_to_use =&amp;gt; '')&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In addition, these name attributes are used in other tables, such as the menu_items table.  As a result, for every method in the tree_display_controller, changes like the following had to be made:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 MenuItem.create(:parent_id =&amp;gt; MenuItem.find_by_name('manage/questionnaires').id, :name =&amp;gt; 'manage/questionnaires/course evaluations', :label =&amp;gt; 'Course evaluations', :seq =&amp;gt; 7, :content_page_id =&amp;gt; nil,&lt;br /&gt;
-                :controller_action_id =&amp;gt; ControllerAction.where(site_controller_id: SiteController.find_by_name('tree_display').id, name:  'goto_surveys').first.id)&lt;br /&gt;
+                :controller_action_id =&amp;gt; ControllerAction.where(site_controller_id: SiteController.find_by_name('tree_display').id, name:  'index').first.id)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Instead, we believe it would be better for this to be defined in the routes file.  Having routes defined in the database is not transparent at all, and causes much confusion for developers that are new to the project - especially those which are new to Rails as well.  This should be inspected for possible future refactorings.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Future Considerations=&lt;br /&gt;
&lt;br /&gt;
As mentioned in the &amp;quot;Unexpected Database Changes&amp;quot; section, routing should be removed from the database and the routes.rb file should be used instead.  There are several other controllers/actions which are treated the same way.&lt;br /&gt;
&lt;br /&gt;
In the views for tree_display, there are two instances variables which look like they could be removed - ''@show'' and ''@assignment''. ''@show'' appears to never be set anywhere, despite it being used in ''tree_display_controller'', ''_entry.html.erb'', and ''_listing.html.erb''.  Perhaps it was previously used, but then it became obsolete and was never removed.  ''@assignment'' is set inside of the view it is being used, ''actions/_assignments_actions.html.erb'', but it appears to never be used elsewhere.  In this case, ''@assignment'' should probably be replaced with a local variable.  However, we did not touch on either of these issues because they were outside the scope of our task (''@show'' is never set inside the controller and ''@assignment'' doesn't appear in the controller whatsoever).  We focused primarily on only refactoring the controller and places in the view which were affected.  In some cases, we went above and beyond and refactored additional parts of the tree_display views which were not required.  However, we had to draw a line at some point due to time constraints.&lt;br /&gt;
&lt;br /&gt;
'''_listing.html.erb'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&amp;lt;% child_nodes = node.get_children(sortvar,sortorder,@show,nil,nil,search) %&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''_entry.html.erb'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&amp;lt;% child_nodes = node.get_children(sortvar,sortorder,session[:user].id,@show,search) %&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''actions/_assignments_actions.html.erb'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  &amp;lt;% @assignment = Assignment.find(node.node_object_id) %&amp;gt;&lt;br /&gt;
  &amp;lt;!--ACS Show the create team option in the assignment for the instructor only if&lt;br /&gt;
  the assignment allows teams to be formed with more than 1 participant--&amp;gt;&lt;br /&gt;
  &amp;lt;% if @assignment.max_team_size &amp;gt; 1 %&amp;gt;&lt;br /&gt;
  ...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''tree_display_controller.rb'''&lt;br /&gt;
&amp;lt;pre&amp;gt;child_nodes = root_node.get_children(sortvar,sortorder,session[:user].id,@show,nil,search)&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Conclusion=&lt;br /&gt;
In conclusion, we were able to successfully refactor the tree_display_controller and related controllers and views. We improved and expanded the use of RESTful and DRY design choices, implemented the use of routing helpers, ensured that instantiation of instance variables is minimized, and overall improved the quality and efficiency of the Expertiza codebase.  We also discovered a number of potential issues and additional areas for improvement.&lt;/div&gt;</summary>
		<author><name>Jjbeaver</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/oss_E1463_vpd&amp;diff=91540</id>
		<title>CSC/ECE 517 Fall 2014/oss E1463 vpd</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/oss_E1463_vpd&amp;diff=91540"/>
		<updated>2014-11-06T05:47:35Z</updated>

		<summary type="html">&lt;p&gt;Jjbeaver: /* Future Considerations */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= '''E1463: Refactoring TreeDisplayController''' =&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
=Project Links=&lt;br /&gt;
[http://ec2-54-186-80-176.us-west-2.compute.amazonaws.com:3000/ Our Expertiza Fork on AWS]&amp;lt;br&amp;gt;&lt;br /&gt;
[https://github.com/Druotic/expertiza Github Repo]&amp;lt;br&amp;gt;&lt;br /&gt;
[https://github.com/expertiza/expertiza/pull/449 Expertize Pull Request] &amp;lt;br&amp;gt;&lt;br /&gt;
[http://ec2-54-186-80-176.us-west-2.compute.amazonaws.com:3000/ Project Running on AWS]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Setup - How To View Our Expertiza Fork Running on AWS=&lt;br /&gt;
NOTE: The scope of our project was only to refactor select code. There are no feature additions or changes, so it should work just like production Expertiza.&lt;br /&gt;
&lt;br /&gt;
1) Go to [http://ec2-54-186-80-176.us-west-2.compute.amazonaws.com:3000/ our Expertiza project running on AWS]&lt;br /&gt;
&lt;br /&gt;
2) Login as Admin&amp;lt;br&amp;gt;&lt;br /&gt;
'''User:''' user2&amp;lt;br&amp;gt;&lt;br /&gt;
'''Password:''' password&lt;br /&gt;
&lt;br /&gt;
3) Click on &amp;quot;Manage...&amp;quot; if you are not automatically directed to the tree display.&lt;br /&gt;
&lt;br /&gt;
=Project Description=&lt;br /&gt;
&lt;br /&gt;
For this project, our team refactored the TreeDisplayController class in the [http://expertiza.ncsu.edu/ Expertiza] OSS project. This class provides access to questionnaires, review rubrics, author feedback, courses, assignments, and course evaluations. The tree display lists all of these categories with the ability for the user to &amp;quot;drill down&amp;quot; into the subcategories or just expand/collapse as needed.&lt;br /&gt;
&lt;br /&gt;
'''Example Image Of Tree Display:&lt;br /&gt;
'''&lt;br /&gt;
[[File:Expertiza.PNG ]]&lt;br /&gt;
&lt;br /&gt;
=Refactoring TreeDisplayController Tasks=&lt;br /&gt;
&lt;br /&gt;
As part of the refactoring task, we had to address the following issues for enhancing code readability and maintainability. The tasks included:&lt;br /&gt;
#Changing List to Index using a [http://www.restapitutorial.com/lessons/whatisrest.html RESTful] approach.&lt;br /&gt;
#Combined all of the goto methods&lt;br /&gt;
#Use of [http://guides.rubyonrails.org/routing.html#path-and-url-helpers routing helpers]&lt;br /&gt;
#Ensuring that instantiation of instance variables is minimized.&lt;br /&gt;
&lt;br /&gt;
In the end, we enhanced this list a bit and resulted in doing the following: 		&lt;br /&gt;
#Changed `list` method to `index`	&lt;br /&gt;
#Removed all of the `goto` methods and `drill`, and had them go through `index` instead because they are essentially just filtered versions of a listing (and the previous implementation just redirected each `goto` back to `list` anyway)	&lt;br /&gt;
#Used path helpers where possible	&lt;br /&gt;
#Removed instance variables and used local variables instead.  This should be better for scope reasons.  Note that there are still 1-2 instance variables used in the view, `@show` and `@assignment` which don't appear to be used anywhere.  (`@show` doesn't seem to ever be set, `@assignment` seems to only be used locally)  However, we didn't touch this because it didn't deal directly with our changes to the controller.	&lt;br /&gt;
#Introduced some local variables as params to the view which allow dropdowns to keep their selected option after the page reloads (the logic was there before, but it was using instance variables which were never set!). This is for the search/filtering options on the &amp;quot;Manage...&amp;quot; screen.&lt;br /&gt;
&lt;br /&gt;
==1) Changing List to Index==&lt;br /&gt;
&lt;br /&gt;
In order to make the codebase more [http://www.restapitutorial.com/lessons/whatisrest.html RESTful], we have replaced all the controller action redirections with a tree_display_index_path which enormously reduces the code content and as well as provides an organized approach to action redirections. &lt;br /&gt;
&lt;br /&gt;
[[File:List_to_Index.png]]&lt;br /&gt;
&lt;br /&gt;
As seen below, we were able to '''remove''' list from Routes.rb:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
resources :tree_display do &lt;br /&gt;
collection do &lt;br /&gt;
  get ':action' &lt;br /&gt;
    - post 'list' &lt;br /&gt;
  end &lt;br /&gt;
end &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==2) Combined All of the Goto Methods==&lt;br /&gt;
We also combined all of the goto methods into one, in accordance with the [http://en.wikipedia.org/wiki/Don't_repeat_yourself DRY] principle. This removed a significant amount of duplicate code.&lt;br /&gt;
&lt;br /&gt;
Shown below are 3 of the 10 very similar methods we removed from '''tree_display_controller.rb''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
- # direct access to questionnaires &lt;br /&gt;
- def goto_questionnaires &lt;br /&gt;
- node_object = TreeFolder.find_by_name('Questionnaires') &lt;br /&gt;
- session[:root] = FolderNode.find_by_node_object_id(node_object.id).id &lt;br /&gt;
- redirect_to :controller =&amp;gt; 'tree_display', :action =&amp;gt; 'list' &lt;br /&gt;
- end &lt;br /&gt;
- &lt;br /&gt;
- # direct access to review rubrics &lt;br /&gt;
- def goto_review_rubrics &lt;br /&gt;
- node_object = TreeFolder.find_by_name('Review') &lt;br /&gt;
- session[:root] = FolderNode.find_by_node_object_id(node_object.id).id &lt;br /&gt;
- redirect_to :controller =&amp;gt; 'tree_display', :action =&amp;gt; 'list' &lt;br /&gt;
- end &lt;br /&gt;
- &lt;br /&gt;
- # direct access to metareview rubrics &lt;br /&gt;
- def goto_metareview_rubrics &lt;br /&gt;
- node_object = TreeFolder.find_by_name('Metareview') &lt;br /&gt;
- session[:root] = FolderNode.find_by_node_object_id(node_object.id).id &lt;br /&gt;
- redirect_to :controller =&amp;gt; 'tree_display', :action =&amp;gt; 'list' &lt;br /&gt;
- end &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
These methods were replaced by a variable containing a list mapping all the session variable strings to database labels. The goto_assignments method was replaced with an index method to accept this variable, rather then calling each goto method individually.&lt;br /&gt;
&lt;br /&gt;
'''Added''' variable:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
+ @@Groups = { &lt;br /&gt;
+   'Questionnaires' =&amp;gt; 'Questionnaires', &lt;br /&gt;
+   'Review rubrics' =&amp;gt; 'Review', &lt;br /&gt;
+   'Metareview rubrics' =&amp;gt; 'Metareview', &lt;br /&gt;
+   'Teammate review rubrics' =&amp;gt; 'Teammate Review', &lt;br /&gt;
+   'Author feedbacks' =&amp;gt; 'Author Feedback', &lt;br /&gt;
+   'Global survey' =&amp;gt; 'Global Survey', &lt;br /&gt;
+   'Surveys' =&amp;gt; 'Survey', &lt;br /&gt;
+   'Course evaluations' =&amp;gt; 'Course Evaluation', &lt;br /&gt;
+   'Courses' =&amp;gt; 'Courses', &lt;br /&gt;
+   'Bookmarkrating' =&amp;gt; 'Bookmarkrating', &lt;br /&gt;
+   'Assignments' =&amp;gt; 'Assignments' &lt;br /&gt;
+ } &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Removed''' goto_assignments method:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
- # direct access to assignments &lt;br /&gt;
- def goto_assignments &lt;br /&gt;
-   node_object = TreeFolder.find_by_name('Assignments') &lt;br /&gt;
-   session[:root] = FolderNode.find_by_node_object_id(node_object.id).id &lt;br /&gt;
-   redirect_to :controller =&amp;gt; 'tree_display', :action =&amp;gt; 'list' &lt;br /&gt;
- end &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Added''' index method:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
+ def index &lt;br /&gt;
+   session[:root] = params[:root] &lt;br /&gt;
+   group = getGroup session[:menu] &lt;br /&gt;
+   node_object = TreeFolder.find_by_name(group) &lt;br /&gt;
+   if not group.blank? and not node_object.blank? &lt;br /&gt;
+     session[:root] = FolderNode.find_by_node_object_id(node_object.id).id &lt;br /&gt;
+ end &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==3) Use Routing Helpers==&lt;br /&gt;
We refactored the tree display controller class to use route helpers rather than calling &amp;quot;:action =&amp;gt; 'list', :controller =&amp;gt; 'tree_display'&amp;quot;, or something similar. This involved many edits in the tree_display_controller.rb file and related controller and view files. As seen below, we utilized routing helpers and replaced '' ':controller=&amp;gt;'course', :action=&amp;gt;'new', :private =&amp;gt; 0'' with ''new_course_path(private: 0)''.&lt;br /&gt;
&lt;br /&gt;
'''_courses_folder_actions.html.erb''' changes:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;ul&amp;gt; &lt;br /&gt;
   &amp;lt;div&amp;gt; &lt;br /&gt;
   &amp;lt;%= link_to image_tag('/assets/tree_view/add-public-24.png'), &lt;br /&gt;
  - { :controller=&amp;gt;'course', :action=&amp;gt;'new', :private =&amp;gt; 0 }, &lt;br /&gt;
  - { :title =&amp;gt; 'Create Public Course', id: 'create-public-course' } %&amp;gt; &lt;br /&gt;
  + new_course_path(private: 0), &lt;br /&gt;
  + { title: 'Create Public Course', id: 'create-public-course' } %&amp;gt; &lt;br /&gt;
   &amp;lt;%= link_to image_tag('/assets/tree_view/add-private-24.png'), &lt;br /&gt;
  - { :controller=&amp;gt;'course', :action=&amp;gt;'new', :private =&amp;gt; 1 }, &lt;br /&gt;
  - { :title =&amp;gt; 'Create Private Course', id: 'create-private-course' } %&amp;gt; &lt;br /&gt;
  + new_course_path(private: 1), &lt;br /&gt;
  + { title: 'Create Private Course', id: 'create-private-course' } %&amp;gt; &lt;br /&gt;
   &amp;lt;/div&amp;gt; &lt;br /&gt;
   &amp;lt;/ul&amp;gt; &lt;br /&gt;
   &amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt; &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Another example of routing helpers in '''_bread_crumbs.html.erb'''. &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Before:'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;%= link_to curr_node.get_name, :controller =&amp;gt; 'tree_display', :action =&amp;gt; 'drill', :root =&amp;gt; curr_node.id %&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''After''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;%= link_to curr_node.get_name, tree_display_index_path(root: curr_node.id)%&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==4) Minimizing the count of Instance Variables==&lt;br /&gt;
=== Instance Variables in Ruby ===&lt;br /&gt;
An instance variable has a name beginning with @, and its scope is confined to whatever object self refers to. Two different objects, even if they belong to the same class, are allowed to have different values for their instance variables. From outside the object, instance variables cannot be altered or even observed (i.e., ruby's instance variables are never public) except by whatever methods are explicitly provided by the programmer. As with globals, instance variables have the nil value until they are initialized.&lt;br /&gt;
&lt;br /&gt;
Instance variables do not need to be declared. This indicates a flexible object structure; in fact, each instance variable is dynamically appended to an object when it is first assigned.&lt;br /&gt;
&lt;br /&gt;
We have observed that in Expertiza, there were several code files related to the Tree Display controller which were observed to be using multiple instance variables which could be reduced. Our team aimed to limit the instantiation of such variables to only necessary places in our code.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The following was added to the ''index'' function of '''tree_display_controller.rb''' in order to replace the use of instance variables with local variables:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
locals  search:       search,&lt;br /&gt;
        sortvar:      sortvar,&lt;br /&gt;
        sortorder:    sortorder,&lt;br /&gt;
        root_node:    root_node,&lt;br /&gt;
        child_nodes:  child_nodes,&lt;br /&gt;
        filternode:   params[:filternode],&lt;br /&gt;
        searchnode:   params[:searchnode]&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Where the ''locals'' method is defined as follows:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
private&lt;br /&gt;
&lt;br /&gt;
  # render local variable hash for view&lt;br /&gt;
  # reference: http://thepugautomatic.com/2013/05/locals/&lt;br /&gt;
  def locals(values)&lt;br /&gt;
    render locals: values&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Many of the view files were changed to make use of the local variables. &lt;br /&gt;
&lt;br /&gt;
Here is an example of how _bread_crumbs.html.erb was changed. Note the removal of the &amp;quot;@&amp;quot; characters.&lt;br /&gt;
&lt;br /&gt;
'''Before:'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;% if @root_node %&amp;gt;&lt;br /&gt;
   &amp;lt;%= link_to &amp;quot;Return to top&amp;quot;, tree_display_index_path %&amp;gt;&lt;br /&gt;
   &amp;lt;%&lt;br /&gt;
      curr_node = @root_node&lt;br /&gt;
   while curr_node.parent_id&lt;br /&gt;
     curr_node = Node.find(curr_node.parent_id) %&amp;gt;&lt;br /&gt;
   &amp;amp;nbsp;&amp;amp;nbsp;&lt;br /&gt;
   &amp;lt;%= link_to curr_node.get_name, tree_display_index_path(root: curr_node.id)%&amp;gt;&lt;br /&gt;
 &amp;lt;% end %&amp;gt;&lt;br /&gt;
&amp;amp;nbsp;&amp;amp;nbsp;&amp;lt;%= @root_node.get_name %&amp;gt;&amp;lt;%&lt;br /&gt;
end %&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''After:'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;% if root_node %&amp;gt;&lt;br /&gt;
   &amp;lt;%= link_to &amp;quot;Return to top&amp;quot;, tree_display_index_path %&amp;gt;&lt;br /&gt;
   &amp;lt;%&lt;br /&gt;
      curr_node = root_node&lt;br /&gt;
   while curr_node.parent_id&lt;br /&gt;
     curr_node = Node.find(curr_node.parent_id) %&amp;gt;&lt;br /&gt;
   &amp;amp;nbsp;&amp;amp;nbsp;&lt;br /&gt;
   &amp;lt;%= link_to curr_node.get_name, tree_display_index_path(root: curr_node.id)%&amp;gt;&lt;br /&gt;
 &amp;lt;% end %&amp;gt;&lt;br /&gt;
&amp;amp;nbsp;&amp;amp;nbsp;&amp;lt;%= root_node.get_name %&amp;gt;&amp;lt;%&lt;br /&gt;
 end %&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Unexpected Database Changes=&lt;br /&gt;
&lt;br /&gt;
Unfortunately, each method of the tree_display controller has a reference to it stored in the database, along with a route.  Essentially, the routes are being stored in the database and a wildcard is used in the routes table to allow this to happen.  The following is a sample of some of the changes made (as part of tasks 1 and 2 given above) which were required in the db/seeds.rb file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
-ControllerAction.create(:site_controller_id =&amp;gt; SiteController.find_by_name('tree_display').id, :name =&amp;gt; 'goto_teammate_reviews', :permission_id =&amp;gt; nil, :url_to_use =&amp;gt; '')&lt;br /&gt;
-ControllerAction.create(:site_controller_id =&amp;gt; SiteController.find_by_name('tree_display').id, :name =&amp;gt; 'goto_metareview_rubrics', :permission_id =&amp;gt; nil, :url_to_use =&amp;gt; '')&lt;br /&gt;
-ControllerAction.create(:site_controller_id =&amp;gt; SiteController.find_by_name('tree_display').id, :name =&amp;gt; 'goto_teammatereview_rubrics', :permission_id =&amp;gt; nil, :url_to_use =&amp;gt; '')&lt;br /&gt;
+ControllerAction.create(:site_controller_id =&amp;gt; SiteController.find_by_name('tree_display').id, :name =&amp;gt; 'index', :permission_id =&amp;gt; nil, :url_to_use =&amp;gt; '')&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In addition, these name attributes are used in other tables, such as the menu_items table.  As a result, for every method in the tree_display_controller, changes like the following had to be made:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 MenuItem.create(:parent_id =&amp;gt; MenuItem.find_by_name('manage/questionnaires').id, :name =&amp;gt; 'manage/questionnaires/course evaluations', :label =&amp;gt; 'Course evaluations', :seq =&amp;gt; 7, :content_page_id =&amp;gt; nil,&lt;br /&gt;
-                :controller_action_id =&amp;gt; ControllerAction.where(site_controller_id: SiteController.find_by_name('tree_display').id, name:  'goto_surveys').first.id)&lt;br /&gt;
+                :controller_action_id =&amp;gt; ControllerAction.where(site_controller_id: SiteController.find_by_name('tree_display').id, name:  'index').first.id)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Instead, we believe it would be better for this to be defined in the routes file.  Having routes defined in the database is not transparent at all, and causes much confusion for developers that are new to the project - especially those which are new to Rails as well.  This should be inspected for possible future refactorings.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Future Considerations=&lt;br /&gt;
&lt;br /&gt;
As mentioned in the &amp;quot;Unexpected Database Changes&amp;quot; section, routing should be removed from the database and the routes.rb file should be used instead.  There are several other controllers/actions which are treated the same way.&lt;br /&gt;
&lt;br /&gt;
In the views for tree_display, there are two instances variables which look like they could be removed - ''@show'' and ''@assignment''. ''@show'' appears to never be set anywhere, despite it being used in ''tree_display_controller'', ''_entry.html.erb'', and ''_listing.html.erb''.  Perhaps it was previously used, but then it became obsolete and was never removed.  ''@assignment'' is set inside of the view it is being used, ''actions/_assignments_actions.html.erb'', but it appears to never be used elsewhere.  In this case, ''@assignment'' should probably be replaced with a local variable.  However, we did not touch on either of these issues because they were outside the scope of our task (''@show'' is never set inside the controller and ''@assignment'' doesn't appear in the controller whatsoever).  We focused primarily on only refactoring the controller and places in the view which were affected.  In some cases, we went above and beyond and refactored additional parts of the tree_display views which were not required.  However, we had to draw a line at some point due to time constraints.&lt;br /&gt;
&lt;br /&gt;
'''_listing.html.erb'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&amp;lt;% child_nodes = node.get_children(sortvar,sortorder,@show,nil,nil,search) %&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''_entry.html.erb'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&amp;lt;% child_nodes = node.get_children(sortvar,sortorder,session[:user].id,@show,search) %&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''actions/_assignments_actions.html.erb'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  &amp;lt;% @assignment = Assignment.find(node.node_object_id) %&amp;gt;&lt;br /&gt;
  &amp;lt;!--ACS Show the create team option in the assignment for the instructor only if&lt;br /&gt;
  the assignment allows teams to be formed with more than 1 participant--&amp;gt;&lt;br /&gt;
  &amp;lt;% if @assignment.max_team_size &amp;gt; 1 %&amp;gt;&lt;br /&gt;
  ...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''tree_display_controller.rb'''&lt;br /&gt;
&amp;lt;pre&amp;gt;child_nodes = root_node.get_children(sortvar,sortorder,session[:user].id,@show,nil,search)&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Conclusion=&lt;br /&gt;
In conclusion, we were able to successfully refactor the tree_display_controller and related controllers and views. We improved and expanded the use of RESTful and DRY design choices, implemented the use of routing helpers, ensured that instantiation of instance variables is minimized, and overall improved the quality and efficiency of the Expertiza codebase.&lt;/div&gt;</summary>
		<author><name>Jjbeaver</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/oss_E1463_vpd&amp;diff=91539</id>
		<title>CSC/ECE 517 Fall 2014/oss E1463 vpd</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/oss_E1463_vpd&amp;diff=91539"/>
		<updated>2014-11-06T05:45:55Z</updated>

		<summary type="html">&lt;p&gt;Jjbeaver: /* Future Considerations */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= '''E1463: Refactoring TreeDisplayController''' =&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
=Project Links=&lt;br /&gt;
[http://ec2-54-186-80-176.us-west-2.compute.amazonaws.com:3000/ Our Expertiza Fork on AWS]&amp;lt;br&amp;gt;&lt;br /&gt;
[https://github.com/Druotic/expertiza Github Repo]&amp;lt;br&amp;gt;&lt;br /&gt;
[https://github.com/expertiza/expertiza/pull/449 Expertize Pull Request] &amp;lt;br&amp;gt;&lt;br /&gt;
[http://ec2-54-186-80-176.us-west-2.compute.amazonaws.com:3000/ Project Running on AWS]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Setup - How To View Our Expertiza Fork Running on AWS=&lt;br /&gt;
NOTE: The scope of our project was only to refactor select code. There are no feature additions or changes, so it should work just like production Expertiza.&lt;br /&gt;
&lt;br /&gt;
1) Go to [http://ec2-54-186-80-176.us-west-2.compute.amazonaws.com:3000/ our Expertiza project running on AWS]&lt;br /&gt;
&lt;br /&gt;
2) Login as Admin&amp;lt;br&amp;gt;&lt;br /&gt;
'''User:''' user2&amp;lt;br&amp;gt;&lt;br /&gt;
'''Password:''' password&lt;br /&gt;
&lt;br /&gt;
3) Click on &amp;quot;Manage...&amp;quot; if you are not automatically directed to the tree display.&lt;br /&gt;
&lt;br /&gt;
=Project Description=&lt;br /&gt;
&lt;br /&gt;
For this project, our team refactored the TreeDisplayController class in the [http://expertiza.ncsu.edu/ Expertiza] OSS project. This class provides access to questionnaires, review rubrics, author feedback, courses, assignments, and course evaluations. The tree display lists all of these categories with the ability for the user to &amp;quot;drill down&amp;quot; into the subcategories or just expand/collapse as needed.&lt;br /&gt;
&lt;br /&gt;
'''Example Image Of Tree Display:&lt;br /&gt;
'''&lt;br /&gt;
[[File:Expertiza.PNG ]]&lt;br /&gt;
&lt;br /&gt;
=Refactoring TreeDisplayController Tasks=&lt;br /&gt;
&lt;br /&gt;
As part of the refactoring task, we had to address the following issues for enhancing code readability and maintainability. The tasks included:&lt;br /&gt;
#Changing List to Index using a [http://www.restapitutorial.com/lessons/whatisrest.html RESTful] approach.&lt;br /&gt;
#Combined all of the goto methods&lt;br /&gt;
#Use of [http://guides.rubyonrails.org/routing.html#path-and-url-helpers routing helpers]&lt;br /&gt;
#Ensuring that instantiation of instance variables is minimized.&lt;br /&gt;
&lt;br /&gt;
In the end, we enhanced this list a bit and resulted in doing the following: 		&lt;br /&gt;
#Changed `list` method to `index`	&lt;br /&gt;
#Removed all of the `goto` methods and `drill`, and had them go through `index` instead because they are essentially just filtered versions of a listing (and the previous implementation just redirected each `goto` back to `list` anyway)	&lt;br /&gt;
#Used path helpers where possible	&lt;br /&gt;
#Removed instance variables and used local variables instead.  This should be better for scope reasons.  Note that there are still 1-2 instance variables used in the view, `@show` and `@assignment` which don't appear to be used anywhere.  (`@show` doesn't seem to ever be set, `@assignment` seems to only be used locally)  However, we didn't touch this because it didn't deal directly with our changes to the controller.	&lt;br /&gt;
#Introduced some local variables as params to the view which allow dropdowns to keep their selected option after the page reloads (the logic was there before, but it was using instance variables which were never set!). This is for the search/filtering options on the &amp;quot;Manage...&amp;quot; screen.&lt;br /&gt;
&lt;br /&gt;
==1) Changing List to Index==&lt;br /&gt;
&lt;br /&gt;
In order to make the codebase more [http://www.restapitutorial.com/lessons/whatisrest.html RESTful], we have replaced all the controller action redirections with a tree_display_index_path which enormously reduces the code content and as well as provides an organized approach to action redirections. &lt;br /&gt;
&lt;br /&gt;
[[File:List_to_Index.png]]&lt;br /&gt;
&lt;br /&gt;
As seen below, we were able to '''remove''' list from Routes.rb:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
resources :tree_display do &lt;br /&gt;
collection do &lt;br /&gt;
  get ':action' &lt;br /&gt;
    - post 'list' &lt;br /&gt;
  end &lt;br /&gt;
end &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==2) Combined All of the Goto Methods==&lt;br /&gt;
We also combined all of the goto methods into one, in accordance with the [http://en.wikipedia.org/wiki/Don't_repeat_yourself DRY] principle. This removed a significant amount of duplicate code.&lt;br /&gt;
&lt;br /&gt;
Shown below are 3 of the 10 very similar methods we removed from '''tree_display_controller.rb''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
- # direct access to questionnaires &lt;br /&gt;
- def goto_questionnaires &lt;br /&gt;
- node_object = TreeFolder.find_by_name('Questionnaires') &lt;br /&gt;
- session[:root] = FolderNode.find_by_node_object_id(node_object.id).id &lt;br /&gt;
- redirect_to :controller =&amp;gt; 'tree_display', :action =&amp;gt; 'list' &lt;br /&gt;
- end &lt;br /&gt;
- &lt;br /&gt;
- # direct access to review rubrics &lt;br /&gt;
- def goto_review_rubrics &lt;br /&gt;
- node_object = TreeFolder.find_by_name('Review') &lt;br /&gt;
- session[:root] = FolderNode.find_by_node_object_id(node_object.id).id &lt;br /&gt;
- redirect_to :controller =&amp;gt; 'tree_display', :action =&amp;gt; 'list' &lt;br /&gt;
- end &lt;br /&gt;
- &lt;br /&gt;
- # direct access to metareview rubrics &lt;br /&gt;
- def goto_metareview_rubrics &lt;br /&gt;
- node_object = TreeFolder.find_by_name('Metareview') &lt;br /&gt;
- session[:root] = FolderNode.find_by_node_object_id(node_object.id).id &lt;br /&gt;
- redirect_to :controller =&amp;gt; 'tree_display', :action =&amp;gt; 'list' &lt;br /&gt;
- end &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
These methods were replaced by a variable containing a list mapping all the session variable strings to database labels. The goto_assignments method was replaced with an index method to accept this variable, rather then calling each goto method individually.&lt;br /&gt;
&lt;br /&gt;
'''Added''' variable:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
+ @@Groups = { &lt;br /&gt;
+   'Questionnaires' =&amp;gt; 'Questionnaires', &lt;br /&gt;
+   'Review rubrics' =&amp;gt; 'Review', &lt;br /&gt;
+   'Metareview rubrics' =&amp;gt; 'Metareview', &lt;br /&gt;
+   'Teammate review rubrics' =&amp;gt; 'Teammate Review', &lt;br /&gt;
+   'Author feedbacks' =&amp;gt; 'Author Feedback', &lt;br /&gt;
+   'Global survey' =&amp;gt; 'Global Survey', &lt;br /&gt;
+   'Surveys' =&amp;gt; 'Survey', &lt;br /&gt;
+   'Course evaluations' =&amp;gt; 'Course Evaluation', &lt;br /&gt;
+   'Courses' =&amp;gt; 'Courses', &lt;br /&gt;
+   'Bookmarkrating' =&amp;gt; 'Bookmarkrating', &lt;br /&gt;
+   'Assignments' =&amp;gt; 'Assignments' &lt;br /&gt;
+ } &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Removed''' goto_assignments method:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
- # direct access to assignments &lt;br /&gt;
- def goto_assignments &lt;br /&gt;
-   node_object = TreeFolder.find_by_name('Assignments') &lt;br /&gt;
-   session[:root] = FolderNode.find_by_node_object_id(node_object.id).id &lt;br /&gt;
-   redirect_to :controller =&amp;gt; 'tree_display', :action =&amp;gt; 'list' &lt;br /&gt;
- end &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Added''' index method:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
+ def index &lt;br /&gt;
+   session[:root] = params[:root] &lt;br /&gt;
+   group = getGroup session[:menu] &lt;br /&gt;
+   node_object = TreeFolder.find_by_name(group) &lt;br /&gt;
+   if not group.blank? and not node_object.blank? &lt;br /&gt;
+     session[:root] = FolderNode.find_by_node_object_id(node_object.id).id &lt;br /&gt;
+ end &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==3) Use Routing Helpers==&lt;br /&gt;
We refactored the tree display controller class to use route helpers rather than calling &amp;quot;:action =&amp;gt; 'list', :controller =&amp;gt; 'tree_display'&amp;quot;, or something similar. This involved many edits in the tree_display_controller.rb file and related controller and view files. As seen below, we utilized routing helpers and replaced '' ':controller=&amp;gt;'course', :action=&amp;gt;'new', :private =&amp;gt; 0'' with ''new_course_path(private: 0)''.&lt;br /&gt;
&lt;br /&gt;
'''_courses_folder_actions.html.erb''' changes:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;ul&amp;gt; &lt;br /&gt;
   &amp;lt;div&amp;gt; &lt;br /&gt;
   &amp;lt;%= link_to image_tag('/assets/tree_view/add-public-24.png'), &lt;br /&gt;
  - { :controller=&amp;gt;'course', :action=&amp;gt;'new', :private =&amp;gt; 0 }, &lt;br /&gt;
  - { :title =&amp;gt; 'Create Public Course', id: 'create-public-course' } %&amp;gt; &lt;br /&gt;
  + new_course_path(private: 0), &lt;br /&gt;
  + { title: 'Create Public Course', id: 'create-public-course' } %&amp;gt; &lt;br /&gt;
   &amp;lt;%= link_to image_tag('/assets/tree_view/add-private-24.png'), &lt;br /&gt;
  - { :controller=&amp;gt;'course', :action=&amp;gt;'new', :private =&amp;gt; 1 }, &lt;br /&gt;
  - { :title =&amp;gt; 'Create Private Course', id: 'create-private-course' } %&amp;gt; &lt;br /&gt;
  + new_course_path(private: 1), &lt;br /&gt;
  + { title: 'Create Private Course', id: 'create-private-course' } %&amp;gt; &lt;br /&gt;
   &amp;lt;/div&amp;gt; &lt;br /&gt;
   &amp;lt;/ul&amp;gt; &lt;br /&gt;
   &amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt; &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Another example of routing helpers in '''_bread_crumbs.html.erb'''. &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Before:'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;%= link_to curr_node.get_name, :controller =&amp;gt; 'tree_display', :action =&amp;gt; 'drill', :root =&amp;gt; curr_node.id %&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''After''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;%= link_to curr_node.get_name, tree_display_index_path(root: curr_node.id)%&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==4) Minimizing the count of Instance Variables==&lt;br /&gt;
=== Instance Variables in Ruby ===&lt;br /&gt;
An instance variable has a name beginning with @, and its scope is confined to whatever object self refers to. Two different objects, even if they belong to the same class, are allowed to have different values for their instance variables. From outside the object, instance variables cannot be altered or even observed (i.e., ruby's instance variables are never public) except by whatever methods are explicitly provided by the programmer. As with globals, instance variables have the nil value until they are initialized.&lt;br /&gt;
&lt;br /&gt;
Instance variables do not need to be declared. This indicates a flexible object structure; in fact, each instance variable is dynamically appended to an object when it is first assigned.&lt;br /&gt;
&lt;br /&gt;
We have observed that in Expertiza, there were several code files related to the Tree Display controller which were observed to be using multiple instance variables which could be reduced. Our team aimed to limit the instantiation of such variables to only necessary places in our code.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The following was added to the ''index'' function of '''tree_display_controller.rb''' in order to replace the use of instance variables with local variables:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
locals  search:       search,&lt;br /&gt;
        sortvar:      sortvar,&lt;br /&gt;
        sortorder:    sortorder,&lt;br /&gt;
        root_node:    root_node,&lt;br /&gt;
        child_nodes:  child_nodes,&lt;br /&gt;
        filternode:   params[:filternode],&lt;br /&gt;
        searchnode:   params[:searchnode]&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Where the ''locals'' method is defined as follows:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
private&lt;br /&gt;
&lt;br /&gt;
  # render local variable hash for view&lt;br /&gt;
  # reference: http://thepugautomatic.com/2013/05/locals/&lt;br /&gt;
  def locals(values)&lt;br /&gt;
    render locals: values&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Many of the view files were changed to make use of the local variables. &lt;br /&gt;
&lt;br /&gt;
Here is an example of how _bread_crumbs.html.erb was changed. Note the removal of the &amp;quot;@&amp;quot; characters.&lt;br /&gt;
&lt;br /&gt;
'''Before:'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;% if @root_node %&amp;gt;&lt;br /&gt;
   &amp;lt;%= link_to &amp;quot;Return to top&amp;quot;, tree_display_index_path %&amp;gt;&lt;br /&gt;
   &amp;lt;%&lt;br /&gt;
      curr_node = @root_node&lt;br /&gt;
   while curr_node.parent_id&lt;br /&gt;
     curr_node = Node.find(curr_node.parent_id) %&amp;gt;&lt;br /&gt;
   &amp;amp;nbsp;&amp;amp;nbsp;&lt;br /&gt;
   &amp;lt;%= link_to curr_node.get_name, tree_display_index_path(root: curr_node.id)%&amp;gt;&lt;br /&gt;
 &amp;lt;% end %&amp;gt;&lt;br /&gt;
&amp;amp;nbsp;&amp;amp;nbsp;&amp;lt;%= @root_node.get_name %&amp;gt;&amp;lt;%&lt;br /&gt;
end %&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''After:'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;% if root_node %&amp;gt;&lt;br /&gt;
   &amp;lt;%= link_to &amp;quot;Return to top&amp;quot;, tree_display_index_path %&amp;gt;&lt;br /&gt;
   &amp;lt;%&lt;br /&gt;
      curr_node = root_node&lt;br /&gt;
   while curr_node.parent_id&lt;br /&gt;
     curr_node = Node.find(curr_node.parent_id) %&amp;gt;&lt;br /&gt;
   &amp;amp;nbsp;&amp;amp;nbsp;&lt;br /&gt;
   &amp;lt;%= link_to curr_node.get_name, tree_display_index_path(root: curr_node.id)%&amp;gt;&lt;br /&gt;
 &amp;lt;% end %&amp;gt;&lt;br /&gt;
&amp;amp;nbsp;&amp;amp;nbsp;&amp;lt;%= root_node.get_name %&amp;gt;&amp;lt;%&lt;br /&gt;
 end %&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Unexpected Database Changes=&lt;br /&gt;
&lt;br /&gt;
Unfortunately, each method of the tree_display controller has a reference to it stored in the database, along with a route.  Essentially, the routes are being stored in the database and a wildcard is used in the routes table to allow this to happen.  The following is a sample of some of the changes made (as part of tasks 1 and 2 given above) which were required in the db/seeds.rb file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
-ControllerAction.create(:site_controller_id =&amp;gt; SiteController.find_by_name('tree_display').id, :name =&amp;gt; 'goto_teammate_reviews', :permission_id =&amp;gt; nil, :url_to_use =&amp;gt; '')&lt;br /&gt;
-ControllerAction.create(:site_controller_id =&amp;gt; SiteController.find_by_name('tree_display').id, :name =&amp;gt; 'goto_metareview_rubrics', :permission_id =&amp;gt; nil, :url_to_use =&amp;gt; '')&lt;br /&gt;
-ControllerAction.create(:site_controller_id =&amp;gt; SiteController.find_by_name('tree_display').id, :name =&amp;gt; 'goto_teammatereview_rubrics', :permission_id =&amp;gt; nil, :url_to_use =&amp;gt; '')&lt;br /&gt;
+ControllerAction.create(:site_controller_id =&amp;gt; SiteController.find_by_name('tree_display').id, :name =&amp;gt; 'index', :permission_id =&amp;gt; nil, :url_to_use =&amp;gt; '')&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In addition, these name attributes are used in other tables, such as the menu_items table.  As a result, for every method in the tree_display_controller, changes like the following had to be made:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 MenuItem.create(:parent_id =&amp;gt; MenuItem.find_by_name('manage/questionnaires').id, :name =&amp;gt; 'manage/questionnaires/course evaluations', :label =&amp;gt; 'Course evaluations', :seq =&amp;gt; 7, :content_page_id =&amp;gt; nil,&lt;br /&gt;
-                :controller_action_id =&amp;gt; ControllerAction.where(site_controller_id: SiteController.find_by_name('tree_display').id, name:  'goto_surveys').first.id)&lt;br /&gt;
+                :controller_action_id =&amp;gt; ControllerAction.where(site_controller_id: SiteController.find_by_name('tree_display').id, name:  'index').first.id)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Instead, we believe it would be better for this to be defined in the routes file.  Having routes defined in the database is not transparent at all, and causes much confusion for developers that are new to the project - especially those which are new to Rails as well.  This should be inspected for possible future refactorings.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Future Considerations=&lt;br /&gt;
&lt;br /&gt;
As mentioned in the &amp;quot;Unexpected Database Changes&amp;quot; section, routing should be removed from the database and the routes.rb file should be used instead.  There are several other controllers/actions which are treated the same way.&lt;br /&gt;
&lt;br /&gt;
In the views for tree_display, there are two instances variables which look like they could be removed - ''@show'' and ''@assignment''. ''@show'' appears to never be set anywhere, despite it being used in ''tree_display_controller'', ''_entry.html.erb'', and ''_listing.html.erb''.  Perhaps it was previously used, but then it became obsolete and was never removed.  ''@assignment'' is set inside of the view it is being used, ''actions/_assignments_actions.html.erb'', but it appears to never be used elsewhere.  In this case, ''@assignment'' should probably be replaced with a local variable.  However, we did not touch on either of these issues because they were outside the scope of our task.  We focused primarily on only refactoring the controller and places in the view which were affected.  In some case, we went above and beyond and refactored additional parts of the tree_display views which were not required.  However, we had to draw a line at some point due to time constraints.&lt;br /&gt;
&lt;br /&gt;
'''_listing.html.erb'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&amp;lt;% child_nodes = node.get_children(sortvar,sortorder,@show,nil,nil,search) %&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''_entry.html.erb'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&amp;lt;% child_nodes = node.get_children(sortvar,sortorder,session[:user].id,@show,search) %&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''actions/_assignments_actions.html.erb'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  &amp;lt;% @assignment = Assignment.find(node.node_object_id) %&amp;gt;&lt;br /&gt;
  &amp;lt;!--ACS Show the create team option in the assignment for the instructor only if&lt;br /&gt;
  the assignment allows teams to be formed with more than 1 participant--&amp;gt;&lt;br /&gt;
  &amp;lt;% if @assignment.max_team_size &amp;gt; 1 %&amp;gt;&lt;br /&gt;
  ...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''tree_display_controller.rb'''&lt;br /&gt;
&amp;lt;pre&amp;gt;child_nodes = root_node.get_children(sortvar,sortorder,session[:user].id,@show,nil,search)&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Conclusion=&lt;br /&gt;
In conclusion, we were able to successfully refactor the tree_display_controller and related controllers and views. We improved and expanded the use of RESTful and DRY design choices, implemented the use of routing helpers, ensured that instantiation of instance variables is minimized, and overall improved the quality and efficiency of the Expertiza codebase.&lt;/div&gt;</summary>
		<author><name>Jjbeaver</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/oss_E1463_vpd&amp;diff=91538</id>
		<title>CSC/ECE 517 Fall 2014/oss E1463 vpd</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/oss_E1463_vpd&amp;diff=91538"/>
		<updated>2014-11-06T05:45:24Z</updated>

		<summary type="html">&lt;p&gt;Jjbeaver: /* Future Considerations */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= '''E1463: Refactoring TreeDisplayController''' =&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
=Project Links=&lt;br /&gt;
[http://ec2-54-186-80-176.us-west-2.compute.amazonaws.com:3000/ Our Expertiza Fork on AWS]&amp;lt;br&amp;gt;&lt;br /&gt;
[https://github.com/Druotic/expertiza Github Repo]&amp;lt;br&amp;gt;&lt;br /&gt;
[https://github.com/expertiza/expertiza/pull/449 Expertize Pull Request] &amp;lt;br&amp;gt;&lt;br /&gt;
[http://ec2-54-186-80-176.us-west-2.compute.amazonaws.com:3000/ Project Running on AWS]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Setup - How To View Our Expertiza Fork Running on AWS=&lt;br /&gt;
NOTE: The scope of our project was only to refactor select code. There are no feature additions or changes, so it should work just like production Expertiza.&lt;br /&gt;
&lt;br /&gt;
1) Go to [http://ec2-54-186-80-176.us-west-2.compute.amazonaws.com:3000/ our Expertiza project running on AWS]&lt;br /&gt;
&lt;br /&gt;
2) Login as Admin&amp;lt;br&amp;gt;&lt;br /&gt;
'''User:''' user2&amp;lt;br&amp;gt;&lt;br /&gt;
'''Password:''' password&lt;br /&gt;
&lt;br /&gt;
3) Click on &amp;quot;Manage...&amp;quot; if you are not automatically directed to the tree display.&lt;br /&gt;
&lt;br /&gt;
=Project Description=&lt;br /&gt;
&lt;br /&gt;
For this project, our team refactored the TreeDisplayController class in the [http://expertiza.ncsu.edu/ Expertiza] OSS project. This class provides access to questionnaires, review rubrics, author feedback, courses, assignments, and course evaluations. The tree display lists all of these categories with the ability for the user to &amp;quot;drill down&amp;quot; into the subcategories or just expand/collapse as needed.&lt;br /&gt;
&lt;br /&gt;
'''Example Image Of Tree Display:&lt;br /&gt;
'''&lt;br /&gt;
[[File:Expertiza.PNG ]]&lt;br /&gt;
&lt;br /&gt;
=Refactoring TreeDisplayController Tasks=&lt;br /&gt;
&lt;br /&gt;
As part of the refactoring task, we had to address the following issues for enhancing code readability and maintainability. The tasks included:&lt;br /&gt;
#Changing List to Index using a [http://www.restapitutorial.com/lessons/whatisrest.html RESTful] approach.&lt;br /&gt;
#Combined all of the goto methods&lt;br /&gt;
#Use of [http://guides.rubyonrails.org/routing.html#path-and-url-helpers routing helpers]&lt;br /&gt;
#Ensuring that instantiation of instance variables is minimized.&lt;br /&gt;
&lt;br /&gt;
In the end, we enhanced this list a bit and resulted in doing the following: 		&lt;br /&gt;
#Changed `list` method to `index`	&lt;br /&gt;
#Removed all of the `goto` methods and `drill`, and had them go through `index` instead because they are essentially just filtered versions of a listing (and the previous implementation just redirected each `goto` back to `list` anyway)	&lt;br /&gt;
#Used path helpers where possible	&lt;br /&gt;
#Removed instance variables and used local variables instead.  This should be better for scope reasons.  Note that there are still 1-2 instance variables used in the view, `@show` and `@assignment` which don't appear to be used anywhere.  (`@show` doesn't seem to ever be set, `@assignment` seems to only be used locally)  However, we didn't touch this because it didn't deal directly with our changes to the controller.	&lt;br /&gt;
#Introduced some local variables as params to the view which allow dropdowns to keep their selected option after the page reloads (the logic was there before, but it was using instance variables which were never set!). This is for the search/filtering options on the &amp;quot;Manage...&amp;quot; screen.&lt;br /&gt;
&lt;br /&gt;
==1) Changing List to Index==&lt;br /&gt;
&lt;br /&gt;
In order to make the codebase more [http://www.restapitutorial.com/lessons/whatisrest.html RESTful], we have replaced all the controller action redirections with a tree_display_index_path which enormously reduces the code content and as well as provides an organized approach to action redirections. &lt;br /&gt;
&lt;br /&gt;
[[File:List_to_Index.png]]&lt;br /&gt;
&lt;br /&gt;
As seen below, we were able to '''remove''' list from Routes.rb:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
resources :tree_display do &lt;br /&gt;
collection do &lt;br /&gt;
  get ':action' &lt;br /&gt;
    - post 'list' &lt;br /&gt;
  end &lt;br /&gt;
end &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==2) Combined All of the Goto Methods==&lt;br /&gt;
We also combined all of the goto methods into one, in accordance with the [http://en.wikipedia.org/wiki/Don't_repeat_yourself DRY] principle. This removed a significant amount of duplicate code.&lt;br /&gt;
&lt;br /&gt;
Shown below are 3 of the 10 very similar methods we removed from '''tree_display_controller.rb''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
- # direct access to questionnaires &lt;br /&gt;
- def goto_questionnaires &lt;br /&gt;
- node_object = TreeFolder.find_by_name('Questionnaires') &lt;br /&gt;
- session[:root] = FolderNode.find_by_node_object_id(node_object.id).id &lt;br /&gt;
- redirect_to :controller =&amp;gt; 'tree_display', :action =&amp;gt; 'list' &lt;br /&gt;
- end &lt;br /&gt;
- &lt;br /&gt;
- # direct access to review rubrics &lt;br /&gt;
- def goto_review_rubrics &lt;br /&gt;
- node_object = TreeFolder.find_by_name('Review') &lt;br /&gt;
- session[:root] = FolderNode.find_by_node_object_id(node_object.id).id &lt;br /&gt;
- redirect_to :controller =&amp;gt; 'tree_display', :action =&amp;gt; 'list' &lt;br /&gt;
- end &lt;br /&gt;
- &lt;br /&gt;
- # direct access to metareview rubrics &lt;br /&gt;
- def goto_metareview_rubrics &lt;br /&gt;
- node_object = TreeFolder.find_by_name('Metareview') &lt;br /&gt;
- session[:root] = FolderNode.find_by_node_object_id(node_object.id).id &lt;br /&gt;
- redirect_to :controller =&amp;gt; 'tree_display', :action =&amp;gt; 'list' &lt;br /&gt;
- end &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
These methods were replaced by a variable containing a list mapping all the session variable strings to database labels. The goto_assignments method was replaced with an index method to accept this variable, rather then calling each goto method individually.&lt;br /&gt;
&lt;br /&gt;
'''Added''' variable:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
+ @@Groups = { &lt;br /&gt;
+   'Questionnaires' =&amp;gt; 'Questionnaires', &lt;br /&gt;
+   'Review rubrics' =&amp;gt; 'Review', &lt;br /&gt;
+   'Metareview rubrics' =&amp;gt; 'Metareview', &lt;br /&gt;
+   'Teammate review rubrics' =&amp;gt; 'Teammate Review', &lt;br /&gt;
+   'Author feedbacks' =&amp;gt; 'Author Feedback', &lt;br /&gt;
+   'Global survey' =&amp;gt; 'Global Survey', &lt;br /&gt;
+   'Surveys' =&amp;gt; 'Survey', &lt;br /&gt;
+   'Course evaluations' =&amp;gt; 'Course Evaluation', &lt;br /&gt;
+   'Courses' =&amp;gt; 'Courses', &lt;br /&gt;
+   'Bookmarkrating' =&amp;gt; 'Bookmarkrating', &lt;br /&gt;
+   'Assignments' =&amp;gt; 'Assignments' &lt;br /&gt;
+ } &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Removed''' goto_assignments method:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
- # direct access to assignments &lt;br /&gt;
- def goto_assignments &lt;br /&gt;
-   node_object = TreeFolder.find_by_name('Assignments') &lt;br /&gt;
-   session[:root] = FolderNode.find_by_node_object_id(node_object.id).id &lt;br /&gt;
-   redirect_to :controller =&amp;gt; 'tree_display', :action =&amp;gt; 'list' &lt;br /&gt;
- end &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Added''' index method:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
+ def index &lt;br /&gt;
+   session[:root] = params[:root] &lt;br /&gt;
+   group = getGroup session[:menu] &lt;br /&gt;
+   node_object = TreeFolder.find_by_name(group) &lt;br /&gt;
+   if not group.blank? and not node_object.blank? &lt;br /&gt;
+     session[:root] = FolderNode.find_by_node_object_id(node_object.id).id &lt;br /&gt;
+ end &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==3) Use Routing Helpers==&lt;br /&gt;
We refactored the tree display controller class to use route helpers rather than calling &amp;quot;:action =&amp;gt; 'list', :controller =&amp;gt; 'tree_display'&amp;quot;, or something similar. This involved many edits in the tree_display_controller.rb file and related controller and view files. As seen below, we utilized routing helpers and replaced '' ':controller=&amp;gt;'course', :action=&amp;gt;'new', :private =&amp;gt; 0'' with ''new_course_path(private: 0)''.&lt;br /&gt;
&lt;br /&gt;
'''_courses_folder_actions.html.erb''' changes:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;ul&amp;gt; &lt;br /&gt;
   &amp;lt;div&amp;gt; &lt;br /&gt;
   &amp;lt;%= link_to image_tag('/assets/tree_view/add-public-24.png'), &lt;br /&gt;
  - { :controller=&amp;gt;'course', :action=&amp;gt;'new', :private =&amp;gt; 0 }, &lt;br /&gt;
  - { :title =&amp;gt; 'Create Public Course', id: 'create-public-course' } %&amp;gt; &lt;br /&gt;
  + new_course_path(private: 0), &lt;br /&gt;
  + { title: 'Create Public Course', id: 'create-public-course' } %&amp;gt; &lt;br /&gt;
   &amp;lt;%= link_to image_tag('/assets/tree_view/add-private-24.png'), &lt;br /&gt;
  - { :controller=&amp;gt;'course', :action=&amp;gt;'new', :private =&amp;gt; 1 }, &lt;br /&gt;
  - { :title =&amp;gt; 'Create Private Course', id: 'create-private-course' } %&amp;gt; &lt;br /&gt;
  + new_course_path(private: 1), &lt;br /&gt;
  + { title: 'Create Private Course', id: 'create-private-course' } %&amp;gt; &lt;br /&gt;
   &amp;lt;/div&amp;gt; &lt;br /&gt;
   &amp;lt;/ul&amp;gt; &lt;br /&gt;
   &amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt; &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Another example of routing helpers in '''_bread_crumbs.html.erb'''. &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Before:'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;%= link_to curr_node.get_name, :controller =&amp;gt; 'tree_display', :action =&amp;gt; 'drill', :root =&amp;gt; curr_node.id %&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''After''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;%= link_to curr_node.get_name, tree_display_index_path(root: curr_node.id)%&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==4) Minimizing the count of Instance Variables==&lt;br /&gt;
=== Instance Variables in Ruby ===&lt;br /&gt;
An instance variable has a name beginning with @, and its scope is confined to whatever object self refers to. Two different objects, even if they belong to the same class, are allowed to have different values for their instance variables. From outside the object, instance variables cannot be altered or even observed (i.e., ruby's instance variables are never public) except by whatever methods are explicitly provided by the programmer. As with globals, instance variables have the nil value until they are initialized.&lt;br /&gt;
&lt;br /&gt;
Instance variables do not need to be declared. This indicates a flexible object structure; in fact, each instance variable is dynamically appended to an object when it is first assigned.&lt;br /&gt;
&lt;br /&gt;
We have observed that in Expertiza, there were several code files related to the Tree Display controller which were observed to be using multiple instance variables which could be reduced. Our team aimed to limit the instantiation of such variables to only necessary places in our code.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The following was added to the ''index'' function of '''tree_display_controller.rb''' in order to replace the use of instance variables with local variables:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
locals  search:       search,&lt;br /&gt;
        sortvar:      sortvar,&lt;br /&gt;
        sortorder:    sortorder,&lt;br /&gt;
        root_node:    root_node,&lt;br /&gt;
        child_nodes:  child_nodes,&lt;br /&gt;
        filternode:   params[:filternode],&lt;br /&gt;
        searchnode:   params[:searchnode]&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Where the ''locals'' method is defined as follows:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
private&lt;br /&gt;
&lt;br /&gt;
  # render local variable hash for view&lt;br /&gt;
  # reference: http://thepugautomatic.com/2013/05/locals/&lt;br /&gt;
  def locals(values)&lt;br /&gt;
    render locals: values&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Many of the view files were changed to make use of the local variables. &lt;br /&gt;
&lt;br /&gt;
Here is an example of how _bread_crumbs.html.erb was changed. Note the removal of the &amp;quot;@&amp;quot; characters.&lt;br /&gt;
&lt;br /&gt;
'''Before:'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;% if @root_node %&amp;gt;&lt;br /&gt;
   &amp;lt;%= link_to &amp;quot;Return to top&amp;quot;, tree_display_index_path %&amp;gt;&lt;br /&gt;
   &amp;lt;%&lt;br /&gt;
      curr_node = @root_node&lt;br /&gt;
   while curr_node.parent_id&lt;br /&gt;
     curr_node = Node.find(curr_node.parent_id) %&amp;gt;&lt;br /&gt;
   &amp;amp;nbsp;&amp;amp;nbsp;&lt;br /&gt;
   &amp;lt;%= link_to curr_node.get_name, tree_display_index_path(root: curr_node.id)%&amp;gt;&lt;br /&gt;
 &amp;lt;% end %&amp;gt;&lt;br /&gt;
&amp;amp;nbsp;&amp;amp;nbsp;&amp;lt;%= @root_node.get_name %&amp;gt;&amp;lt;%&lt;br /&gt;
end %&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''After:'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;% if root_node %&amp;gt;&lt;br /&gt;
   &amp;lt;%= link_to &amp;quot;Return to top&amp;quot;, tree_display_index_path %&amp;gt;&lt;br /&gt;
   &amp;lt;%&lt;br /&gt;
      curr_node = root_node&lt;br /&gt;
   while curr_node.parent_id&lt;br /&gt;
     curr_node = Node.find(curr_node.parent_id) %&amp;gt;&lt;br /&gt;
   &amp;amp;nbsp;&amp;amp;nbsp;&lt;br /&gt;
   &amp;lt;%= link_to curr_node.get_name, tree_display_index_path(root: curr_node.id)%&amp;gt;&lt;br /&gt;
 &amp;lt;% end %&amp;gt;&lt;br /&gt;
&amp;amp;nbsp;&amp;amp;nbsp;&amp;lt;%= root_node.get_name %&amp;gt;&amp;lt;%&lt;br /&gt;
 end %&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Unexpected Database Changes=&lt;br /&gt;
&lt;br /&gt;
Unfortunately, each method of the tree_display controller has a reference to it stored in the database, along with a route.  Essentially, the routes are being stored in the database and a wildcard is used in the routes table to allow this to happen.  The following is a sample of some of the changes made (as part of tasks 1 and 2 given above) which were required in the db/seeds.rb file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
-ControllerAction.create(:site_controller_id =&amp;gt; SiteController.find_by_name('tree_display').id, :name =&amp;gt; 'goto_teammate_reviews', :permission_id =&amp;gt; nil, :url_to_use =&amp;gt; '')&lt;br /&gt;
-ControllerAction.create(:site_controller_id =&amp;gt; SiteController.find_by_name('tree_display').id, :name =&amp;gt; 'goto_metareview_rubrics', :permission_id =&amp;gt; nil, :url_to_use =&amp;gt; '')&lt;br /&gt;
-ControllerAction.create(:site_controller_id =&amp;gt; SiteController.find_by_name('tree_display').id, :name =&amp;gt; 'goto_teammatereview_rubrics', :permission_id =&amp;gt; nil, :url_to_use =&amp;gt; '')&lt;br /&gt;
+ControllerAction.create(:site_controller_id =&amp;gt; SiteController.find_by_name('tree_display').id, :name =&amp;gt; 'index', :permission_id =&amp;gt; nil, :url_to_use =&amp;gt; '')&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In addition, these name attributes are used in other tables, such as the menu_items table.  As a result, for every method in the tree_display_controller, changes like the following had to be made:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 MenuItem.create(:parent_id =&amp;gt; MenuItem.find_by_name('manage/questionnaires').id, :name =&amp;gt; 'manage/questionnaires/course evaluations', :label =&amp;gt; 'Course evaluations', :seq =&amp;gt; 7, :content_page_id =&amp;gt; nil,&lt;br /&gt;
-                :controller_action_id =&amp;gt; ControllerAction.where(site_controller_id: SiteController.find_by_name('tree_display').id, name:  'goto_surveys').first.id)&lt;br /&gt;
+                :controller_action_id =&amp;gt; ControllerAction.where(site_controller_id: SiteController.find_by_name('tree_display').id, name:  'index').first.id)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Instead, we believe it would be better for this to be defined in the routes file.  Having routes defined in the database is not transparent at all, and causes much confusion for developers that are new to the project - especially those which are new to Rails as well.  This should be inspected for possible future refactorings.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Future Considerations=&lt;br /&gt;
&lt;br /&gt;
As mentioned in the &amp;quot;Unexpected Database Changes&amp;quot; section, routing should be removed from the database and the routes.rb file should be used instead.  There are several other controllers/actions which are treated the same way.&lt;br /&gt;
&lt;br /&gt;
In the views for tree_display, there are two instances variables which look like they could be removed - ''@show'' and ''@assignment''. ''@show'' appears to never be set anywhere, despite it being used in ''tree_display_controller'', ''_entry.html.erb'', and ''_listing.html.erb''.  Perhaps it was previously used, but then it became obsolete and was removed.  ''@assignment'' is set inside of the view it is being used, ''actions/_assignments_actions.html.erb'', but it appears to never be used elsewhere.  In this case, ''@assignment'' should probably be replaced with a local variable.  However, we did not touch on either of these issues because they were outside the scope of our task.  We focused primarily on only refactoring the controller and places in the view which were affected.  In some case, we went above and beyond and refactored additional parts of the tree_display views which were not required.  However, we had to draw a line at some point due to time constraints.&lt;br /&gt;
&lt;br /&gt;
'''_listing.html.erb'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&amp;lt;% child_nodes = node.get_children(sortvar,sortorder,@show,nil,nil,search) %&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''_entry.html.erb'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&amp;lt;% child_nodes = node.get_children(sortvar,sortorder,session[:user].id,@show,search) %&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''actions/_assignments_actions.html.erb'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  &amp;lt;% @assignment = Assignment.find(node.node_object_id) %&amp;gt;&lt;br /&gt;
  &amp;lt;!--ACS Show the create team option in the assignment for the instructor only if&lt;br /&gt;
  the assignment allows teams to be formed with more than 1 participant--&amp;gt;&lt;br /&gt;
  &amp;lt;% if @assignment.max_team_size &amp;gt; 1 %&amp;gt;&lt;br /&gt;
  ...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''tree_display_controller.rb'''&lt;br /&gt;
&amp;lt;pre&amp;gt;child_nodes = root_node.get_children(sortvar,sortorder,session[:user].id,@show,nil,search)&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Conclusion=&lt;br /&gt;
In conclusion, we were able to successfully refactor the tree_display_controller and related controllers and views. We improved and expanded the use of RESTful and DRY design choices, implemented the use of routing helpers, ensured that instantiation of instance variables is minimized, and overall improved the quality and efficiency of the Expertiza codebase.&lt;/div&gt;</summary>
		<author><name>Jjbeaver</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/oss_E1463_vpd&amp;diff=91537</id>
		<title>CSC/ECE 517 Fall 2014/oss E1463 vpd</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/oss_E1463_vpd&amp;diff=91537"/>
		<updated>2014-11-06T05:44:50Z</updated>

		<summary type="html">&lt;p&gt;Jjbeaver: /* Instance Variables in Ruby */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= '''E1463: Refactoring TreeDisplayController''' =&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
=Project Links=&lt;br /&gt;
[http://ec2-54-186-80-176.us-west-2.compute.amazonaws.com:3000/ Our Expertiza Fork on AWS]&amp;lt;br&amp;gt;&lt;br /&gt;
[https://github.com/Druotic/expertiza Github Repo]&amp;lt;br&amp;gt;&lt;br /&gt;
[https://github.com/expertiza/expertiza/pull/449 Expertize Pull Request] &amp;lt;br&amp;gt;&lt;br /&gt;
[http://ec2-54-186-80-176.us-west-2.compute.amazonaws.com:3000/ Project Running on AWS]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Setup - How To View Our Expertiza Fork Running on AWS=&lt;br /&gt;
NOTE: The scope of our project was only to refactor select code. There are no feature additions or changes, so it should work just like production Expertiza.&lt;br /&gt;
&lt;br /&gt;
1) Go to [http://ec2-54-186-80-176.us-west-2.compute.amazonaws.com:3000/ our Expertiza project running on AWS]&lt;br /&gt;
&lt;br /&gt;
2) Login as Admin&amp;lt;br&amp;gt;&lt;br /&gt;
'''User:''' user2&amp;lt;br&amp;gt;&lt;br /&gt;
'''Password:''' password&lt;br /&gt;
&lt;br /&gt;
3) Click on &amp;quot;Manage...&amp;quot; if you are not automatically directed to the tree display.&lt;br /&gt;
&lt;br /&gt;
=Project Description=&lt;br /&gt;
&lt;br /&gt;
For this project, our team refactored the TreeDisplayController class in the [http://expertiza.ncsu.edu/ Expertiza] OSS project. This class provides access to questionnaires, review rubrics, author feedback, courses, assignments, and course evaluations. The tree display lists all of these categories with the ability for the user to &amp;quot;drill down&amp;quot; into the subcategories or just expand/collapse as needed.&lt;br /&gt;
&lt;br /&gt;
'''Example Image Of Tree Display:&lt;br /&gt;
'''&lt;br /&gt;
[[File:Expertiza.PNG ]]&lt;br /&gt;
&lt;br /&gt;
=Refactoring TreeDisplayController Tasks=&lt;br /&gt;
&lt;br /&gt;
As part of the refactoring task, we had to address the following issues for enhancing code readability and maintainability. The tasks included:&lt;br /&gt;
#Changing List to Index using a [http://www.restapitutorial.com/lessons/whatisrest.html RESTful] approach.&lt;br /&gt;
#Combined all of the goto methods&lt;br /&gt;
#Use of [http://guides.rubyonrails.org/routing.html#path-and-url-helpers routing helpers]&lt;br /&gt;
#Ensuring that instantiation of instance variables is minimized.&lt;br /&gt;
&lt;br /&gt;
In the end, we enhanced this list a bit and resulted in doing the following: 		&lt;br /&gt;
#Changed `list` method to `index`	&lt;br /&gt;
#Removed all of the `goto` methods and `drill`, and had them go through `index` instead because they are essentially just filtered versions of a listing (and the previous implementation just redirected each `goto` back to `list` anyway)	&lt;br /&gt;
#Used path helpers where possible	&lt;br /&gt;
#Removed instance variables and used local variables instead.  This should be better for scope reasons.  Note that there are still 1-2 instance variables used in the view, `@show` and `@assignment` which don't appear to be used anywhere.  (`@show` doesn't seem to ever be set, `@assignment` seems to only be used locally)  However, we didn't touch this because it didn't deal directly with our changes to the controller.	&lt;br /&gt;
#Introduced some local variables as params to the view which allow dropdowns to keep their selected option after the page reloads (the logic was there before, but it was using instance variables which were never set!). This is for the search/filtering options on the &amp;quot;Manage...&amp;quot; screen.&lt;br /&gt;
&lt;br /&gt;
==1) Changing List to Index==&lt;br /&gt;
&lt;br /&gt;
In order to make the codebase more [http://www.restapitutorial.com/lessons/whatisrest.html RESTful], we have replaced all the controller action redirections with a tree_display_index_path which enormously reduces the code content and as well as provides an organized approach to action redirections. &lt;br /&gt;
&lt;br /&gt;
[[File:List_to_Index.png]]&lt;br /&gt;
&lt;br /&gt;
As seen below, we were able to '''remove''' list from Routes.rb:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
resources :tree_display do &lt;br /&gt;
collection do &lt;br /&gt;
  get ':action' &lt;br /&gt;
    - post 'list' &lt;br /&gt;
  end &lt;br /&gt;
end &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==2) Combined All of the Goto Methods==&lt;br /&gt;
We also combined all of the goto methods into one, in accordance with the [http://en.wikipedia.org/wiki/Don't_repeat_yourself DRY] principle. This removed a significant amount of duplicate code.&lt;br /&gt;
&lt;br /&gt;
Shown below are 3 of the 10 very similar methods we removed from '''tree_display_controller.rb''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
- # direct access to questionnaires &lt;br /&gt;
- def goto_questionnaires &lt;br /&gt;
- node_object = TreeFolder.find_by_name('Questionnaires') &lt;br /&gt;
- session[:root] = FolderNode.find_by_node_object_id(node_object.id).id &lt;br /&gt;
- redirect_to :controller =&amp;gt; 'tree_display', :action =&amp;gt; 'list' &lt;br /&gt;
- end &lt;br /&gt;
- &lt;br /&gt;
- # direct access to review rubrics &lt;br /&gt;
- def goto_review_rubrics &lt;br /&gt;
- node_object = TreeFolder.find_by_name('Review') &lt;br /&gt;
- session[:root] = FolderNode.find_by_node_object_id(node_object.id).id &lt;br /&gt;
- redirect_to :controller =&amp;gt; 'tree_display', :action =&amp;gt; 'list' &lt;br /&gt;
- end &lt;br /&gt;
- &lt;br /&gt;
- # direct access to metareview rubrics &lt;br /&gt;
- def goto_metareview_rubrics &lt;br /&gt;
- node_object = TreeFolder.find_by_name('Metareview') &lt;br /&gt;
- session[:root] = FolderNode.find_by_node_object_id(node_object.id).id &lt;br /&gt;
- redirect_to :controller =&amp;gt; 'tree_display', :action =&amp;gt; 'list' &lt;br /&gt;
- end &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
These methods were replaced by a variable containing a list mapping all the session variable strings to database labels. The goto_assignments method was replaced with an index method to accept this variable, rather then calling each goto method individually.&lt;br /&gt;
&lt;br /&gt;
'''Added''' variable:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
+ @@Groups = { &lt;br /&gt;
+   'Questionnaires' =&amp;gt; 'Questionnaires', &lt;br /&gt;
+   'Review rubrics' =&amp;gt; 'Review', &lt;br /&gt;
+   'Metareview rubrics' =&amp;gt; 'Metareview', &lt;br /&gt;
+   'Teammate review rubrics' =&amp;gt; 'Teammate Review', &lt;br /&gt;
+   'Author feedbacks' =&amp;gt; 'Author Feedback', &lt;br /&gt;
+   'Global survey' =&amp;gt; 'Global Survey', &lt;br /&gt;
+   'Surveys' =&amp;gt; 'Survey', &lt;br /&gt;
+   'Course evaluations' =&amp;gt; 'Course Evaluation', &lt;br /&gt;
+   'Courses' =&amp;gt; 'Courses', &lt;br /&gt;
+   'Bookmarkrating' =&amp;gt; 'Bookmarkrating', &lt;br /&gt;
+   'Assignments' =&amp;gt; 'Assignments' &lt;br /&gt;
+ } &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Removed''' goto_assignments method:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
- # direct access to assignments &lt;br /&gt;
- def goto_assignments &lt;br /&gt;
-   node_object = TreeFolder.find_by_name('Assignments') &lt;br /&gt;
-   session[:root] = FolderNode.find_by_node_object_id(node_object.id).id &lt;br /&gt;
-   redirect_to :controller =&amp;gt; 'tree_display', :action =&amp;gt; 'list' &lt;br /&gt;
- end &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Added''' index method:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
+ def index &lt;br /&gt;
+   session[:root] = params[:root] &lt;br /&gt;
+   group = getGroup session[:menu] &lt;br /&gt;
+   node_object = TreeFolder.find_by_name(group) &lt;br /&gt;
+   if not group.blank? and not node_object.blank? &lt;br /&gt;
+     session[:root] = FolderNode.find_by_node_object_id(node_object.id).id &lt;br /&gt;
+ end &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==3) Use Routing Helpers==&lt;br /&gt;
We refactored the tree display controller class to use route helpers rather than calling &amp;quot;:action =&amp;gt; 'list', :controller =&amp;gt; 'tree_display'&amp;quot;, or something similar. This involved many edits in the tree_display_controller.rb file and related controller and view files. As seen below, we utilized routing helpers and replaced '' ':controller=&amp;gt;'course', :action=&amp;gt;'new', :private =&amp;gt; 0'' with ''new_course_path(private: 0)''.&lt;br /&gt;
&lt;br /&gt;
'''_courses_folder_actions.html.erb''' changes:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;ul&amp;gt; &lt;br /&gt;
   &amp;lt;div&amp;gt; &lt;br /&gt;
   &amp;lt;%= link_to image_tag('/assets/tree_view/add-public-24.png'), &lt;br /&gt;
  - { :controller=&amp;gt;'course', :action=&amp;gt;'new', :private =&amp;gt; 0 }, &lt;br /&gt;
  - { :title =&amp;gt; 'Create Public Course', id: 'create-public-course' } %&amp;gt; &lt;br /&gt;
  + new_course_path(private: 0), &lt;br /&gt;
  + { title: 'Create Public Course', id: 'create-public-course' } %&amp;gt; &lt;br /&gt;
   &amp;lt;%= link_to image_tag('/assets/tree_view/add-private-24.png'), &lt;br /&gt;
  - { :controller=&amp;gt;'course', :action=&amp;gt;'new', :private =&amp;gt; 1 }, &lt;br /&gt;
  - { :title =&amp;gt; 'Create Private Course', id: 'create-private-course' } %&amp;gt; &lt;br /&gt;
  + new_course_path(private: 1), &lt;br /&gt;
  + { title: 'Create Private Course', id: 'create-private-course' } %&amp;gt; &lt;br /&gt;
   &amp;lt;/div&amp;gt; &lt;br /&gt;
   &amp;lt;/ul&amp;gt; &lt;br /&gt;
   &amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt; &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Another example of routing helpers in '''_bread_crumbs.html.erb'''. &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Before:'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;%= link_to curr_node.get_name, :controller =&amp;gt; 'tree_display', :action =&amp;gt; 'drill', :root =&amp;gt; curr_node.id %&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''After''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;%= link_to curr_node.get_name, tree_display_index_path(root: curr_node.id)%&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==4) Minimizing the count of Instance Variables==&lt;br /&gt;
=== Instance Variables in Ruby ===&lt;br /&gt;
An instance variable has a name beginning with @, and its scope is confined to whatever object self refers to. Two different objects, even if they belong to the same class, are allowed to have different values for their instance variables. From outside the object, instance variables cannot be altered or even observed (i.e., ruby's instance variables are never public) except by whatever methods are explicitly provided by the programmer. As with globals, instance variables have the nil value until they are initialized.&lt;br /&gt;
&lt;br /&gt;
Instance variables do not need to be declared. This indicates a flexible object structure; in fact, each instance variable is dynamically appended to an object when it is first assigned.&lt;br /&gt;
&lt;br /&gt;
We have observed that in Expertiza, there were several code files related to the Tree Display controller which were observed to be using multiple instance variables which could be reduced. Our team aimed to limit the instantiation of such variables to only necessary places in our code.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The following was added to the ''index'' function of '''tree_display_controller.rb''' in order to replace the use of instance variables with local variables:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
locals  search:       search,&lt;br /&gt;
        sortvar:      sortvar,&lt;br /&gt;
        sortorder:    sortorder,&lt;br /&gt;
        root_node:    root_node,&lt;br /&gt;
        child_nodes:  child_nodes,&lt;br /&gt;
        filternode:   params[:filternode],&lt;br /&gt;
        searchnode:   params[:searchnode]&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Where the ''locals'' method is defined as follows:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
private&lt;br /&gt;
&lt;br /&gt;
  # render local variable hash for view&lt;br /&gt;
  # reference: http://thepugautomatic.com/2013/05/locals/&lt;br /&gt;
  def locals(values)&lt;br /&gt;
    render locals: values&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Many of the view files were changed to make use of the local variables. &lt;br /&gt;
&lt;br /&gt;
Here is an example of how _bread_crumbs.html.erb was changed. Note the removal of the &amp;quot;@&amp;quot; characters.&lt;br /&gt;
&lt;br /&gt;
'''Before:'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;% if @root_node %&amp;gt;&lt;br /&gt;
   &amp;lt;%= link_to &amp;quot;Return to top&amp;quot;, tree_display_index_path %&amp;gt;&lt;br /&gt;
   &amp;lt;%&lt;br /&gt;
      curr_node = @root_node&lt;br /&gt;
   while curr_node.parent_id&lt;br /&gt;
     curr_node = Node.find(curr_node.parent_id) %&amp;gt;&lt;br /&gt;
   &amp;amp;nbsp;&amp;amp;nbsp;&lt;br /&gt;
   &amp;lt;%= link_to curr_node.get_name, tree_display_index_path(root: curr_node.id)%&amp;gt;&lt;br /&gt;
 &amp;lt;% end %&amp;gt;&lt;br /&gt;
&amp;amp;nbsp;&amp;amp;nbsp;&amp;lt;%= @root_node.get_name %&amp;gt;&amp;lt;%&lt;br /&gt;
end %&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''After:'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;% if root_node %&amp;gt;&lt;br /&gt;
   &amp;lt;%= link_to &amp;quot;Return to top&amp;quot;, tree_display_index_path %&amp;gt;&lt;br /&gt;
   &amp;lt;%&lt;br /&gt;
      curr_node = root_node&lt;br /&gt;
   while curr_node.parent_id&lt;br /&gt;
     curr_node = Node.find(curr_node.parent_id) %&amp;gt;&lt;br /&gt;
   &amp;amp;nbsp;&amp;amp;nbsp;&lt;br /&gt;
   &amp;lt;%= link_to curr_node.get_name, tree_display_index_path(root: curr_node.id)%&amp;gt;&lt;br /&gt;
 &amp;lt;% end %&amp;gt;&lt;br /&gt;
&amp;amp;nbsp;&amp;amp;nbsp;&amp;lt;%= root_node.get_name %&amp;gt;&amp;lt;%&lt;br /&gt;
 end %&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Unexpected Database Changes=&lt;br /&gt;
&lt;br /&gt;
Unfortunately, each method of the tree_display controller has a reference to it stored in the database, along with a route.  Essentially, the routes are being stored in the database and a wildcard is used in the routes table to allow this to happen.  The following is a sample of some of the changes made (as part of tasks 1 and 2 given above) which were required in the db/seeds.rb file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
-ControllerAction.create(:site_controller_id =&amp;gt; SiteController.find_by_name('tree_display').id, :name =&amp;gt; 'goto_teammate_reviews', :permission_id =&amp;gt; nil, :url_to_use =&amp;gt; '')&lt;br /&gt;
-ControllerAction.create(:site_controller_id =&amp;gt; SiteController.find_by_name('tree_display').id, :name =&amp;gt; 'goto_metareview_rubrics', :permission_id =&amp;gt; nil, :url_to_use =&amp;gt; '')&lt;br /&gt;
-ControllerAction.create(:site_controller_id =&amp;gt; SiteController.find_by_name('tree_display').id, :name =&amp;gt; 'goto_teammatereview_rubrics', :permission_id =&amp;gt; nil, :url_to_use =&amp;gt; '')&lt;br /&gt;
+ControllerAction.create(:site_controller_id =&amp;gt; SiteController.find_by_name('tree_display').id, :name =&amp;gt; 'index', :permission_id =&amp;gt; nil, :url_to_use =&amp;gt; '')&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In addition, these name attributes are used in other tables, such as the menu_items table.  As a result, for every method in the tree_display_controller, changes like the following had to be made:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 MenuItem.create(:parent_id =&amp;gt; MenuItem.find_by_name('manage/questionnaires').id, :name =&amp;gt; 'manage/questionnaires/course evaluations', :label =&amp;gt; 'Course evaluations', :seq =&amp;gt; 7, :content_page_id =&amp;gt; nil,&lt;br /&gt;
-                :controller_action_id =&amp;gt; ControllerAction.where(site_controller_id: SiteController.find_by_name('tree_display').id, name:  'goto_surveys').first.id)&lt;br /&gt;
+                :controller_action_id =&amp;gt; ControllerAction.where(site_controller_id: SiteController.find_by_name('tree_display').id, name:  'index').first.id)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Instead, we believe it would be better for this to be defined in the routes file.  Having routes defined in the database is not transparent at all, and causes much confusion for developers that are new to the project - especially those which are new to Rails as well.  This should be inspected for possible future refactorings.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Future Considerations=&lt;br /&gt;
&lt;br /&gt;
As mentioned in the &amp;quot;Unexpected Database Changes&amp;quot; section, routing should be removed from the database and the routes.rb file should be used instead.  There are several other controllers/actions which are treated the same way.&lt;br /&gt;
&lt;br /&gt;
In the views for tree_display, there are two instances variables which look like they could be removed - ''@show'' and ''@assignment''. ''@show'' appears to never be set anywhere, despite it being used in ''tree_display_controller'', ''_entry.html.erb', and ''_listing.html.erb''.  Perhaps it was previously used, but then it became obsolete and was removed.  ''@assignment'' is set inside of the view it is being used, ''actions/_assignments_actions.html.erb'', but it appears to never be used elsewhere.  In this case, ''@assignment'' should probably be replaced with a local variable.  However, we did not touch on either of these issues because they were outside the scope of our task.  We focused primarily on only refactoring the controller and places in the view which were affected.  In some case, we went above and beyond and refactored additional parts of the tree_display views which were not required.  However, we had to draw a line at some point due to time constraints.&lt;br /&gt;
&lt;br /&gt;
'''_listing.html.erb'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&amp;lt;% child_nodes = node.get_children(sortvar,sortorder,@show,nil,nil,search) %&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''_entry.html.erb'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&amp;lt;% child_nodes = node.get_children(sortvar,sortorder,session[:user].id,@show,search) %&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''actions/_assignments_actions.html.erb'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  &amp;lt;% @assignment = Assignment.find(node.node_object_id) %&amp;gt;&lt;br /&gt;
  &amp;lt;!--ACS Show the create team option in the assignment for the instructor only if&lt;br /&gt;
  the assignment allows teams to be formed with more than 1 participant--&amp;gt;&lt;br /&gt;
  &amp;lt;% if @assignment.max_team_size &amp;gt; 1 %&amp;gt;&lt;br /&gt;
  ...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''tree_display_controller.rb'''&lt;br /&gt;
&amp;lt;pre&amp;gt;child_nodes = root_node.get_children(sortvar,sortorder,session[:user].id,@show,nil,search)&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Conclusion=&lt;br /&gt;
In conclusion, we were able to successfully refactor the tree_display_controller and related controllers and views. We improved and expanded the use of RESTful and DRY design choices, implemented the use of routing helpers, ensured that instantiation of instance variables is minimized, and overall improved the quality and efficiency of the Expertiza codebase.&lt;/div&gt;</summary>
		<author><name>Jjbeaver</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/oss_E1463_vpd&amp;diff=91535</id>
		<title>CSC/ECE 517 Fall 2014/oss E1463 vpd</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/oss_E1463_vpd&amp;diff=91535"/>
		<updated>2014-11-06T05:44:33Z</updated>

		<summary type="html">&lt;p&gt;Jjbeaver: /* Instance Variables in Ruby */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= '''E1463: Refactoring TreeDisplayController''' =&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
=Project Links=&lt;br /&gt;
[http://ec2-54-186-80-176.us-west-2.compute.amazonaws.com:3000/ Our Expertiza Fork on AWS]&amp;lt;br&amp;gt;&lt;br /&gt;
[https://github.com/Druotic/expertiza Github Repo]&amp;lt;br&amp;gt;&lt;br /&gt;
[https://github.com/expertiza/expertiza/pull/449 Expertize Pull Request] &amp;lt;br&amp;gt;&lt;br /&gt;
[http://ec2-54-186-80-176.us-west-2.compute.amazonaws.com:3000/ Project Running on AWS]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Setup - How To View Our Expertiza Fork Running on AWS=&lt;br /&gt;
NOTE: The scope of our project was only to refactor select code. There are no feature additions or changes, so it should work just like production Expertiza.&lt;br /&gt;
&lt;br /&gt;
1) Go to [http://ec2-54-186-80-176.us-west-2.compute.amazonaws.com:3000/ our Expertiza project running on AWS]&lt;br /&gt;
&lt;br /&gt;
2) Login as Admin&amp;lt;br&amp;gt;&lt;br /&gt;
'''User:''' user2&amp;lt;br&amp;gt;&lt;br /&gt;
'''Password:''' password&lt;br /&gt;
&lt;br /&gt;
3) Click on &amp;quot;Manage...&amp;quot; if you are not automatically directed to the tree display.&lt;br /&gt;
&lt;br /&gt;
=Project Description=&lt;br /&gt;
&lt;br /&gt;
For this project, our team refactored the TreeDisplayController class in the [http://expertiza.ncsu.edu/ Expertiza] OSS project. This class provides access to questionnaires, review rubrics, author feedback, courses, assignments, and course evaluations. The tree display lists all of these categories with the ability for the user to &amp;quot;drill down&amp;quot; into the subcategories or just expand/collapse as needed.&lt;br /&gt;
&lt;br /&gt;
'''Example Image Of Tree Display:&lt;br /&gt;
'''&lt;br /&gt;
[[File:Expertiza.PNG ]]&lt;br /&gt;
&lt;br /&gt;
=Refactoring TreeDisplayController Tasks=&lt;br /&gt;
&lt;br /&gt;
As part of the refactoring task, we had to address the following issues for enhancing code readability and maintainability. The tasks included:&lt;br /&gt;
#Changing List to Index using a [http://www.restapitutorial.com/lessons/whatisrest.html RESTful] approach.&lt;br /&gt;
#Combined all of the goto methods&lt;br /&gt;
#Use of [http://guides.rubyonrails.org/routing.html#path-and-url-helpers routing helpers]&lt;br /&gt;
#Ensuring that instantiation of instance variables is minimized.&lt;br /&gt;
&lt;br /&gt;
In the end, we enhanced this list a bit and resulted in doing the following: 		&lt;br /&gt;
#Changed `list` method to `index`	&lt;br /&gt;
#Removed all of the `goto` methods and `drill`, and had them go through `index` instead because they are essentially just filtered versions of a listing (and the previous implementation just redirected each `goto` back to `list` anyway)	&lt;br /&gt;
#Used path helpers where possible	&lt;br /&gt;
#Removed instance variables and used local variables instead.  This should be better for scope reasons.  Note that there are still 1-2 instance variables used in the view, `@show` and `@assignment` which don't appear to be used anywhere.  (`@show` doesn't seem to ever be set, `@assignment` seems to only be used locally)  However, we didn't touch this because it didn't deal directly with our changes to the controller.	&lt;br /&gt;
#Introduced some local variables as params to the view which allow dropdowns to keep their selected option after the page reloads (the logic was there before, but it was using instance variables which were never set!). This is for the search/filtering options on the &amp;quot;Manage...&amp;quot; screen.&lt;br /&gt;
&lt;br /&gt;
==1) Changing List to Index==&lt;br /&gt;
&lt;br /&gt;
In order to make the codebase more [http://www.restapitutorial.com/lessons/whatisrest.html RESTful], we have replaced all the controller action redirections with a tree_display_index_path which enormously reduces the code content and as well as provides an organized approach to action redirections. &lt;br /&gt;
&lt;br /&gt;
[[File:List_to_Index.png]]&lt;br /&gt;
&lt;br /&gt;
As seen below, we were able to '''remove''' list from Routes.rb:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
resources :tree_display do &lt;br /&gt;
collection do &lt;br /&gt;
  get ':action' &lt;br /&gt;
    - post 'list' &lt;br /&gt;
  end &lt;br /&gt;
end &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==2) Combined All of the Goto Methods==&lt;br /&gt;
We also combined all of the goto methods into one, in accordance with the [http://en.wikipedia.org/wiki/Don't_repeat_yourself DRY] principle. This removed a significant amount of duplicate code.&lt;br /&gt;
&lt;br /&gt;
Shown below are 3 of the 10 very similar methods we removed from '''tree_display_controller.rb''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
- # direct access to questionnaires &lt;br /&gt;
- def goto_questionnaires &lt;br /&gt;
- node_object = TreeFolder.find_by_name('Questionnaires') &lt;br /&gt;
- session[:root] = FolderNode.find_by_node_object_id(node_object.id).id &lt;br /&gt;
- redirect_to :controller =&amp;gt; 'tree_display', :action =&amp;gt; 'list' &lt;br /&gt;
- end &lt;br /&gt;
- &lt;br /&gt;
- # direct access to review rubrics &lt;br /&gt;
- def goto_review_rubrics &lt;br /&gt;
- node_object = TreeFolder.find_by_name('Review') &lt;br /&gt;
- session[:root] = FolderNode.find_by_node_object_id(node_object.id).id &lt;br /&gt;
- redirect_to :controller =&amp;gt; 'tree_display', :action =&amp;gt; 'list' &lt;br /&gt;
- end &lt;br /&gt;
- &lt;br /&gt;
- # direct access to metareview rubrics &lt;br /&gt;
- def goto_metareview_rubrics &lt;br /&gt;
- node_object = TreeFolder.find_by_name('Metareview') &lt;br /&gt;
- session[:root] = FolderNode.find_by_node_object_id(node_object.id).id &lt;br /&gt;
- redirect_to :controller =&amp;gt; 'tree_display', :action =&amp;gt; 'list' &lt;br /&gt;
- end &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
These methods were replaced by a variable containing a list mapping all the session variable strings to database labels. The goto_assignments method was replaced with an index method to accept this variable, rather then calling each goto method individually.&lt;br /&gt;
&lt;br /&gt;
'''Added''' variable:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
+ @@Groups = { &lt;br /&gt;
+   'Questionnaires' =&amp;gt; 'Questionnaires', &lt;br /&gt;
+   'Review rubrics' =&amp;gt; 'Review', &lt;br /&gt;
+   'Metareview rubrics' =&amp;gt; 'Metareview', &lt;br /&gt;
+   'Teammate review rubrics' =&amp;gt; 'Teammate Review', &lt;br /&gt;
+   'Author feedbacks' =&amp;gt; 'Author Feedback', &lt;br /&gt;
+   'Global survey' =&amp;gt; 'Global Survey', &lt;br /&gt;
+   'Surveys' =&amp;gt; 'Survey', &lt;br /&gt;
+   'Course evaluations' =&amp;gt; 'Course Evaluation', &lt;br /&gt;
+   'Courses' =&amp;gt; 'Courses', &lt;br /&gt;
+   'Bookmarkrating' =&amp;gt; 'Bookmarkrating', &lt;br /&gt;
+   'Assignments' =&amp;gt; 'Assignments' &lt;br /&gt;
+ } &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Removed''' goto_assignments method:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
- # direct access to assignments &lt;br /&gt;
- def goto_assignments &lt;br /&gt;
-   node_object = TreeFolder.find_by_name('Assignments') &lt;br /&gt;
-   session[:root] = FolderNode.find_by_node_object_id(node_object.id).id &lt;br /&gt;
-   redirect_to :controller =&amp;gt; 'tree_display', :action =&amp;gt; 'list' &lt;br /&gt;
- end &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Added''' index method:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
+ def index &lt;br /&gt;
+   session[:root] = params[:root] &lt;br /&gt;
+   group = getGroup session[:menu] &lt;br /&gt;
+   node_object = TreeFolder.find_by_name(group) &lt;br /&gt;
+   if not group.blank? and not node_object.blank? &lt;br /&gt;
+     session[:root] = FolderNode.find_by_node_object_id(node_object.id).id &lt;br /&gt;
+ end &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==3) Use Routing Helpers==&lt;br /&gt;
We refactored the tree display controller class to use route helpers rather than calling &amp;quot;:action =&amp;gt; 'list', :controller =&amp;gt; 'tree_display'&amp;quot;, or something similar. This involved many edits in the tree_display_controller.rb file and related controller and view files. As seen below, we utilized routing helpers and replaced '' ':controller=&amp;gt;'course', :action=&amp;gt;'new', :private =&amp;gt; 0'' with ''new_course_path(private: 0)''.&lt;br /&gt;
&lt;br /&gt;
'''_courses_folder_actions.html.erb''' changes:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;ul&amp;gt; &lt;br /&gt;
   &amp;lt;div&amp;gt; &lt;br /&gt;
   &amp;lt;%= link_to image_tag('/assets/tree_view/add-public-24.png'), &lt;br /&gt;
  - { :controller=&amp;gt;'course', :action=&amp;gt;'new', :private =&amp;gt; 0 }, &lt;br /&gt;
  - { :title =&amp;gt; 'Create Public Course', id: 'create-public-course' } %&amp;gt; &lt;br /&gt;
  + new_course_path(private: 0), &lt;br /&gt;
  + { title: 'Create Public Course', id: 'create-public-course' } %&amp;gt; &lt;br /&gt;
   &amp;lt;%= link_to image_tag('/assets/tree_view/add-private-24.png'), &lt;br /&gt;
  - { :controller=&amp;gt;'course', :action=&amp;gt;'new', :private =&amp;gt; 1 }, &lt;br /&gt;
  - { :title =&amp;gt; 'Create Private Course', id: 'create-private-course' } %&amp;gt; &lt;br /&gt;
  + new_course_path(private: 1), &lt;br /&gt;
  + { title: 'Create Private Course', id: 'create-private-course' } %&amp;gt; &lt;br /&gt;
   &amp;lt;/div&amp;gt; &lt;br /&gt;
   &amp;lt;/ul&amp;gt; &lt;br /&gt;
   &amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt; &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Another example of routing helpers in '''_bread_crumbs.html.erb'''. &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Before:'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;%= link_to curr_node.get_name, :controller =&amp;gt; 'tree_display', :action =&amp;gt; 'drill', :root =&amp;gt; curr_node.id %&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''After''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;%= link_to curr_node.get_name, tree_display_index_path(root: curr_node.id)%&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==4) Minimizing the count of Instance Variables==&lt;br /&gt;
=== Instance Variables in Ruby ===&lt;br /&gt;
An instance variable has a name beginning with @, and its scope is confined to whatever object self refers to. Two different objects, even if they belong to the same class, are allowed to have different values for their instance variables. From outside the object, instance variables cannot be altered or even observed (i.e., ruby's instance variables are never public) except by whatever methods are explicitly provided by the programmer. As with globals, instance variables have the nil value until they are initialized.&lt;br /&gt;
&lt;br /&gt;
Instance variables do not need to be declared. This indicates a flexible object structure; in fact, each instance variable is dynamically appended to an object when it is first assigned.&lt;br /&gt;
&lt;br /&gt;
We have observed that in Expertiza, there were several code files related to the Tree Display controller which were observed to be using multiple instance variables which could be reduced. Our team aimed to limit the instantiation of such variables to only necessary places in our code.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The following was added to the ''index'' function of '''tree_display_controller.rb''' in order to replace the use of instance variables with local variables:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
locals  search:       search,&lt;br /&gt;
        sortvar:      sortvar,&lt;br /&gt;
        sortorder:    sortorder,&lt;br /&gt;
        root_node:    root_node,&lt;br /&gt;
        child_nodes:  child_nodes,&lt;br /&gt;
        filternode:   params[:filternode],&lt;br /&gt;
        searchnode:   params[:searchnode]&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Where locals is defined as follows:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
private&lt;br /&gt;
&lt;br /&gt;
  # render local variable hash for view&lt;br /&gt;
  # reference: http://thepugautomatic.com/2013/05/locals/&lt;br /&gt;
  def locals(values)&lt;br /&gt;
    render locals: values&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Many of the view files were changed to make use of the local variables. &lt;br /&gt;
&lt;br /&gt;
Here is an example of how _bread_crumbs.html.erb was changed. Note the removal of the &amp;quot;@&amp;quot; characters.&lt;br /&gt;
&lt;br /&gt;
'''Before:'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;% if @root_node %&amp;gt;&lt;br /&gt;
   &amp;lt;%= link_to &amp;quot;Return to top&amp;quot;, tree_display_index_path %&amp;gt;&lt;br /&gt;
   &amp;lt;%&lt;br /&gt;
      curr_node = @root_node&lt;br /&gt;
   while curr_node.parent_id&lt;br /&gt;
     curr_node = Node.find(curr_node.parent_id) %&amp;gt;&lt;br /&gt;
   &amp;amp;nbsp;&amp;amp;nbsp;&lt;br /&gt;
   &amp;lt;%= link_to curr_node.get_name, tree_display_index_path(root: curr_node.id)%&amp;gt;&lt;br /&gt;
 &amp;lt;% end %&amp;gt;&lt;br /&gt;
&amp;amp;nbsp;&amp;amp;nbsp;&amp;lt;%= @root_node.get_name %&amp;gt;&amp;lt;%&lt;br /&gt;
end %&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''After:'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;% if root_node %&amp;gt;&lt;br /&gt;
   &amp;lt;%= link_to &amp;quot;Return to top&amp;quot;, tree_display_index_path %&amp;gt;&lt;br /&gt;
   &amp;lt;%&lt;br /&gt;
      curr_node = root_node&lt;br /&gt;
   while curr_node.parent_id&lt;br /&gt;
     curr_node = Node.find(curr_node.parent_id) %&amp;gt;&lt;br /&gt;
   &amp;amp;nbsp;&amp;amp;nbsp;&lt;br /&gt;
   &amp;lt;%= link_to curr_node.get_name, tree_display_index_path(root: curr_node.id)%&amp;gt;&lt;br /&gt;
 &amp;lt;% end %&amp;gt;&lt;br /&gt;
&amp;amp;nbsp;&amp;amp;nbsp;&amp;lt;%= root_node.get_name %&amp;gt;&amp;lt;%&lt;br /&gt;
 end %&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Unexpected Database Changes=&lt;br /&gt;
&lt;br /&gt;
Unfortunately, each method of the tree_display controller has a reference to it stored in the database, along with a route.  Essentially, the routes are being stored in the database and a wildcard is used in the routes table to allow this to happen.  The following is a sample of some of the changes made (as part of tasks 1 and 2 given above) which were required in the db/seeds.rb file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
-ControllerAction.create(:site_controller_id =&amp;gt; SiteController.find_by_name('tree_display').id, :name =&amp;gt; 'goto_teammate_reviews', :permission_id =&amp;gt; nil, :url_to_use =&amp;gt; '')&lt;br /&gt;
-ControllerAction.create(:site_controller_id =&amp;gt; SiteController.find_by_name('tree_display').id, :name =&amp;gt; 'goto_metareview_rubrics', :permission_id =&amp;gt; nil, :url_to_use =&amp;gt; '')&lt;br /&gt;
-ControllerAction.create(:site_controller_id =&amp;gt; SiteController.find_by_name('tree_display').id, :name =&amp;gt; 'goto_teammatereview_rubrics', :permission_id =&amp;gt; nil, :url_to_use =&amp;gt; '')&lt;br /&gt;
+ControllerAction.create(:site_controller_id =&amp;gt; SiteController.find_by_name('tree_display').id, :name =&amp;gt; 'index', :permission_id =&amp;gt; nil, :url_to_use =&amp;gt; '')&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In addition, these name attributes are used in other tables, such as the menu_items table.  As a result, for every method in the tree_display_controller, changes like the following had to be made:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 MenuItem.create(:parent_id =&amp;gt; MenuItem.find_by_name('manage/questionnaires').id, :name =&amp;gt; 'manage/questionnaires/course evaluations', :label =&amp;gt; 'Course evaluations', :seq =&amp;gt; 7, :content_page_id =&amp;gt; nil,&lt;br /&gt;
-                :controller_action_id =&amp;gt; ControllerAction.where(site_controller_id: SiteController.find_by_name('tree_display').id, name:  'goto_surveys').first.id)&lt;br /&gt;
+                :controller_action_id =&amp;gt; ControllerAction.where(site_controller_id: SiteController.find_by_name('tree_display').id, name:  'index').first.id)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Instead, we believe it would be better for this to be defined in the routes file.  Having routes defined in the database is not transparent at all, and causes much confusion for developers that are new to the project - especially those which are new to Rails as well.  This should be inspected for possible future refactorings.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Future Considerations=&lt;br /&gt;
&lt;br /&gt;
As mentioned in the &amp;quot;Unexpected Database Changes&amp;quot; section, routing should be removed from the database and the routes.rb file should be used instead.  There are several other controllers/actions which are treated the same way.&lt;br /&gt;
&lt;br /&gt;
In the views for tree_display, there are two instances variables which look like they could be removed - ''@show'' and ''@assignment''. ''@show'' appears to never be set anywhere, despite it being used in ''tree_display_controller'', ''_entry.html.erb', and ''_listing.html.erb''.  Perhaps it was previously used, but then it became obsolete and was removed.  ''@assignment'' is set inside of the view it is being used, ''actions/_assignments_actions.html.erb'', but it appears to never be used elsewhere.  In this case, ''@assignment'' should probably be replaced with a local variable.  However, we did not touch on either of these issues because they were outside the scope of our task.  We focused primarily on only refactoring the controller and places in the view which were affected.  In some case, we went above and beyond and refactored additional parts of the tree_display views which were not required.  However, we had to draw a line at some point due to time constraints.&lt;br /&gt;
&lt;br /&gt;
'''_listing.html.erb'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&amp;lt;% child_nodes = node.get_children(sortvar,sortorder,@show,nil,nil,search) %&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''_entry.html.erb'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&amp;lt;% child_nodes = node.get_children(sortvar,sortorder,session[:user].id,@show,search) %&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''actions/_assignments_actions.html.erb'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  &amp;lt;% @assignment = Assignment.find(node.node_object_id) %&amp;gt;&lt;br /&gt;
  &amp;lt;!--ACS Show the create team option in the assignment for the instructor only if&lt;br /&gt;
  the assignment allows teams to be formed with more than 1 participant--&amp;gt;&lt;br /&gt;
  &amp;lt;% if @assignment.max_team_size &amp;gt; 1 %&amp;gt;&lt;br /&gt;
  ...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''tree_display_controller.rb'''&lt;br /&gt;
&amp;lt;pre&amp;gt;child_nodes = root_node.get_children(sortvar,sortorder,session[:user].id,@show,nil,search)&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Conclusion=&lt;br /&gt;
In conclusion, we were able to successfully refactor the tree_display_controller and related controllers and views. We improved and expanded the use of RESTful and DRY design choices, implemented the use of routing helpers, ensured that instantiation of instance variables is minimized, and overall improved the quality and efficiency of the Expertiza codebase.&lt;/div&gt;</summary>
		<author><name>Jjbeaver</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/oss_E1463_vpd&amp;diff=91528</id>
		<title>CSC/ECE 517 Fall 2014/oss E1463 vpd</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/oss_E1463_vpd&amp;diff=91528"/>
		<updated>2014-11-06T05:42:49Z</updated>

		<summary type="html">&lt;p&gt;Jjbeaver: /* Instance Variables in Ruby */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= '''E1463: Refactoring TreeDisplayController''' =&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
=Project Links=&lt;br /&gt;
[http://ec2-54-186-80-176.us-west-2.compute.amazonaws.com:3000/ Our Expertiza Fork on AWS]&amp;lt;br&amp;gt;&lt;br /&gt;
[https://github.com/Druotic/expertiza Github Repo]&amp;lt;br&amp;gt;&lt;br /&gt;
[https://github.com/expertiza/expertiza/pull/449 Expertize Pull Request] &amp;lt;br&amp;gt;&lt;br /&gt;
[http://ec2-54-186-80-176.us-west-2.compute.amazonaws.com:3000/ Project Running on AWS]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Setup - How To View Our Expertiza Fork Running on AWS=&lt;br /&gt;
NOTE: The scope of our project was only to refactor select code. There are no feature additions or changes, so it should work just like production Expertiza.&lt;br /&gt;
&lt;br /&gt;
1) Go to [http://ec2-54-186-80-176.us-west-2.compute.amazonaws.com:3000/ our Expertiza project running on AWS]&lt;br /&gt;
&lt;br /&gt;
2) Login as Admin&amp;lt;br&amp;gt;&lt;br /&gt;
'''User:''' user2&amp;lt;br&amp;gt;&lt;br /&gt;
'''Password:''' password&lt;br /&gt;
&lt;br /&gt;
3) Click on &amp;quot;Manage...&amp;quot; if you are not automatically directed to the tree display.&lt;br /&gt;
&lt;br /&gt;
=Project Description=&lt;br /&gt;
&lt;br /&gt;
For this project, our team refactored the TreeDisplayController class in the [http://expertiza.ncsu.edu/ Expertiza] OSS project. This class provides access to questionnaires, review rubrics, author feedback, courses, assignments, and course evaluations. The tree display lists all of these categories with the ability for the user to &amp;quot;drill down&amp;quot; into the subcategories or just expand/collapse as needed.&lt;br /&gt;
&lt;br /&gt;
'''Example Image Of Tree Display:&lt;br /&gt;
'''&lt;br /&gt;
[[File:Expertiza.PNG ]]&lt;br /&gt;
&lt;br /&gt;
=Refactoring TreeDisplayController Tasks=&lt;br /&gt;
&lt;br /&gt;
As part of the refactoring task, we had to address the following issues for enhancing code readability and maintainability. The tasks included:&lt;br /&gt;
#Changing List to Index using a [http://www.restapitutorial.com/lessons/whatisrest.html RESTful] approach.&lt;br /&gt;
#Combined all of the goto methods&lt;br /&gt;
#Use of [http://guides.rubyonrails.org/routing.html#path-and-url-helpers routing helpers]&lt;br /&gt;
#Ensuring that instantiation of instance variables is minimized.&lt;br /&gt;
&lt;br /&gt;
In the end, we enhanced this list a bit and resulted in doing the following: 		&lt;br /&gt;
#Changed `list` method to `index`	&lt;br /&gt;
#Removed all of the `goto` methods and `drill`, and had them go through `index` instead because they are essentially just filtered versions of a listing (and the previous implementation just redirected each `goto` back to `list` anyway)	&lt;br /&gt;
#Used path helpers where possible	&lt;br /&gt;
#Removed instance variables and used local variables instead.  This should be better for scope reasons.  Note that there are still 1-2 instance variables used in the view, `@show` and `@assignment` which don't appear to be used anywhere.  (`@show` doesn't seem to ever be set, `@assignment` seems to only be used locally)  However, we didn't touch this because it didn't deal directly with our changes to the controller.	&lt;br /&gt;
#Introduced some local variables as params to the view which allow dropdowns to keep their selected option after the page reloads (the logic was there before, but it was using instance variables which were never set!). This is for the search/filtering options on the &amp;quot;Manage...&amp;quot; screen.&lt;br /&gt;
&lt;br /&gt;
==1) Changing List to Index==&lt;br /&gt;
&lt;br /&gt;
In order to make the codebase more [http://www.restapitutorial.com/lessons/whatisrest.html RESTful], we have replaced all the controller action redirections with a tree_display_index_path which enormously reduces the code content and as well as provides an organized approach to action redirections. &lt;br /&gt;
&lt;br /&gt;
[[File:List_to_Index.png]]&lt;br /&gt;
&lt;br /&gt;
As seen below, we were able to '''remove''' list from Routes.rb:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
resources :tree_display do &lt;br /&gt;
collection do &lt;br /&gt;
  get ':action' &lt;br /&gt;
    - post 'list' &lt;br /&gt;
  end &lt;br /&gt;
end &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==2) Combined All of the Goto Methods==&lt;br /&gt;
We also combined all of the goto methods into one, in accordance with the [http://en.wikipedia.org/wiki/Don't_repeat_yourself DRY] principle. This removed a significant amount of duplicate code.&lt;br /&gt;
&lt;br /&gt;
Shown below are 3 of the 10 very similar methods we removed from '''tree_display_controller.rb''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
- # direct access to questionnaires &lt;br /&gt;
- def goto_questionnaires &lt;br /&gt;
- node_object = TreeFolder.find_by_name('Questionnaires') &lt;br /&gt;
- session[:root] = FolderNode.find_by_node_object_id(node_object.id).id &lt;br /&gt;
- redirect_to :controller =&amp;gt; 'tree_display', :action =&amp;gt; 'list' &lt;br /&gt;
- end &lt;br /&gt;
- &lt;br /&gt;
- # direct access to review rubrics &lt;br /&gt;
- def goto_review_rubrics &lt;br /&gt;
- node_object = TreeFolder.find_by_name('Review') &lt;br /&gt;
- session[:root] = FolderNode.find_by_node_object_id(node_object.id).id &lt;br /&gt;
- redirect_to :controller =&amp;gt; 'tree_display', :action =&amp;gt; 'list' &lt;br /&gt;
- end &lt;br /&gt;
- &lt;br /&gt;
- # direct access to metareview rubrics &lt;br /&gt;
- def goto_metareview_rubrics &lt;br /&gt;
- node_object = TreeFolder.find_by_name('Metareview') &lt;br /&gt;
- session[:root] = FolderNode.find_by_node_object_id(node_object.id).id &lt;br /&gt;
- redirect_to :controller =&amp;gt; 'tree_display', :action =&amp;gt; 'list' &lt;br /&gt;
- end &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
These methods were replaced by a variable containing a list mapping all the session variable strings to database labels. The goto_assignments method was replaced with an index method to accept this variable, rather then calling each goto method individually.&lt;br /&gt;
&lt;br /&gt;
'''Added''' variable:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
+ @@Groups = { &lt;br /&gt;
+   'Questionnaires' =&amp;gt; 'Questionnaires', &lt;br /&gt;
+   'Review rubrics' =&amp;gt; 'Review', &lt;br /&gt;
+   'Metareview rubrics' =&amp;gt; 'Metareview', &lt;br /&gt;
+   'Teammate review rubrics' =&amp;gt; 'Teammate Review', &lt;br /&gt;
+   'Author feedbacks' =&amp;gt; 'Author Feedback', &lt;br /&gt;
+   'Global survey' =&amp;gt; 'Global Survey', &lt;br /&gt;
+   'Surveys' =&amp;gt; 'Survey', &lt;br /&gt;
+   'Course evaluations' =&amp;gt; 'Course Evaluation', &lt;br /&gt;
+   'Courses' =&amp;gt; 'Courses', &lt;br /&gt;
+   'Bookmarkrating' =&amp;gt; 'Bookmarkrating', &lt;br /&gt;
+   'Assignments' =&amp;gt; 'Assignments' &lt;br /&gt;
+ } &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Removed''' goto_assignments method:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
- # direct access to assignments &lt;br /&gt;
- def goto_assignments &lt;br /&gt;
-   node_object = TreeFolder.find_by_name('Assignments') &lt;br /&gt;
-   session[:root] = FolderNode.find_by_node_object_id(node_object.id).id &lt;br /&gt;
-   redirect_to :controller =&amp;gt; 'tree_display', :action =&amp;gt; 'list' &lt;br /&gt;
- end &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Added''' index method:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
+ def index &lt;br /&gt;
+   session[:root] = params[:root] &lt;br /&gt;
+   group = getGroup session[:menu] &lt;br /&gt;
+   node_object = TreeFolder.find_by_name(group) &lt;br /&gt;
+   if not group.blank? and not node_object.blank? &lt;br /&gt;
+     session[:root] = FolderNode.find_by_node_object_id(node_object.id).id &lt;br /&gt;
+ end &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==3) Use Routing Helpers==&lt;br /&gt;
We refactored the tree display controller class to use route helpers rather than calling &amp;quot;:action =&amp;gt; 'list', :controller =&amp;gt; 'tree_display'&amp;quot;, or something similar. This involved many edits in the tree_display_controller.rb file and related controller and view files. As seen below, we utilized routing helpers and replaced '' ':controller=&amp;gt;'course', :action=&amp;gt;'new', :private =&amp;gt; 0'' with ''new_course_path(private: 0)''.&lt;br /&gt;
&lt;br /&gt;
'''_courses_folder_actions.html.erb''' changes:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;ul&amp;gt; &lt;br /&gt;
   &amp;lt;div&amp;gt; &lt;br /&gt;
   &amp;lt;%= link_to image_tag('/assets/tree_view/add-public-24.png'), &lt;br /&gt;
  - { :controller=&amp;gt;'course', :action=&amp;gt;'new', :private =&amp;gt; 0 }, &lt;br /&gt;
  - { :title =&amp;gt; 'Create Public Course', id: 'create-public-course' } %&amp;gt; &lt;br /&gt;
  + new_course_path(private: 0), &lt;br /&gt;
  + { title: 'Create Public Course', id: 'create-public-course' } %&amp;gt; &lt;br /&gt;
   &amp;lt;%= link_to image_tag('/assets/tree_view/add-private-24.png'), &lt;br /&gt;
  - { :controller=&amp;gt;'course', :action=&amp;gt;'new', :private =&amp;gt; 1 }, &lt;br /&gt;
  - { :title =&amp;gt; 'Create Private Course', id: 'create-private-course' } %&amp;gt; &lt;br /&gt;
  + new_course_path(private: 1), &lt;br /&gt;
  + { title: 'Create Private Course', id: 'create-private-course' } %&amp;gt; &lt;br /&gt;
   &amp;lt;/div&amp;gt; &lt;br /&gt;
   &amp;lt;/ul&amp;gt; &lt;br /&gt;
   &amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt; &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Another example of routing helpers in '''_bread_crumbs.html.erb'''. &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Before:'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;%= link_to curr_node.get_name, :controller =&amp;gt; 'tree_display', :action =&amp;gt; 'drill', :root =&amp;gt; curr_node.id %&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''After''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;%= link_to curr_node.get_name, tree_display_index_path(root: curr_node.id)%&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==4) Minimizing the count of Instance Variables==&lt;br /&gt;
=== Instance Variables in Ruby ===&lt;br /&gt;
An instance variable has a name beginning with @, and its scope is confined to whatever object self refers to. Two different objects, even if they belong to the same class, are allowed to have different values for their instance variables. From outside the object, instance variables cannot be altered or even observed (i.e., ruby's instance variables are never public) except by whatever methods are explicitly provided by the programmer. As with globals, instance variables have the nil value until they are initialized.&lt;br /&gt;
&lt;br /&gt;
Instance variables do not need to be declared. This indicates a flexible object structure; in fact, each instance variable is dynamically appended to an object when it is first assigned.&lt;br /&gt;
&lt;br /&gt;
We have observed that in Expertiza, there were several code files related to the Tree Display controller which were observed to be using multiple instance variables which could be reduced. Our team aimed to limit the instantiation of such variables to only necessary places in our code.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The following was added to the ''index'' function of '''tree_display_controller.rb''' in order to replace the use of instance variables with local variables:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
locals  search:       search,&lt;br /&gt;
        sortvar:      sortvar,&lt;br /&gt;
        sortorder:    sortorder,&lt;br /&gt;
        root_node:    root_node,&lt;br /&gt;
        child_nodes:  child_nodes,&lt;br /&gt;
        filternode:   params[:filternode],&lt;br /&gt;
        searchnode:   params[:searchnode]&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Many of the view files were changed to make use of the local variables. &lt;br /&gt;
&lt;br /&gt;
Here is an example of how _bread_crumbs.html.erb was changed. Note the removal of the &amp;quot;@&amp;quot; characters.&lt;br /&gt;
&lt;br /&gt;
'''Before:'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;% if @root_node %&amp;gt;&lt;br /&gt;
   &amp;lt;%= link_to &amp;quot;Return to top&amp;quot;, tree_display_index_path %&amp;gt;&lt;br /&gt;
   &amp;lt;%&lt;br /&gt;
      curr_node = @root_node&lt;br /&gt;
   while curr_node.parent_id&lt;br /&gt;
     curr_node = Node.find(curr_node.parent_id) %&amp;gt;&lt;br /&gt;
   &amp;amp;nbsp;&amp;amp;nbsp;&lt;br /&gt;
   &amp;lt;%= link_to curr_node.get_name, tree_display_index_path(root: curr_node.id)%&amp;gt;&lt;br /&gt;
 &amp;lt;% end %&amp;gt;&lt;br /&gt;
&amp;amp;nbsp;&amp;amp;nbsp;&amp;lt;%= @root_node.get_name %&amp;gt;&amp;lt;%&lt;br /&gt;
end %&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''After:'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;% if root_node %&amp;gt;&lt;br /&gt;
   &amp;lt;%= link_to &amp;quot;Return to top&amp;quot;, tree_display_index_path %&amp;gt;&lt;br /&gt;
   &amp;lt;%&lt;br /&gt;
      curr_node = root_node&lt;br /&gt;
   while curr_node.parent_id&lt;br /&gt;
     curr_node = Node.find(curr_node.parent_id) %&amp;gt;&lt;br /&gt;
   &amp;amp;nbsp;&amp;amp;nbsp;&lt;br /&gt;
   &amp;lt;%= link_to curr_node.get_name, tree_display_index_path(root: curr_node.id)%&amp;gt;&lt;br /&gt;
 &amp;lt;% end %&amp;gt;&lt;br /&gt;
&amp;amp;nbsp;&amp;amp;nbsp;&amp;lt;%= root_node.get_name %&amp;gt;&amp;lt;%&lt;br /&gt;
 end %&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Unexpected Database Changes=&lt;br /&gt;
&lt;br /&gt;
Unfortunately, each method of the tree_display controller has a reference to it stored in the database, along with a route.  Essentially, the routes are being stored in the database and a wildcard is used in the routes table to allow this to happen.  The following is a sample of some of the changes made (as part of tasks 1 and 2 given above) which were required in the db/seeds.rb file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
-ControllerAction.create(:site_controller_id =&amp;gt; SiteController.find_by_name('tree_display').id, :name =&amp;gt; 'goto_teammate_reviews', :permission_id =&amp;gt; nil, :url_to_use =&amp;gt; '')&lt;br /&gt;
-ControllerAction.create(:site_controller_id =&amp;gt; SiteController.find_by_name('tree_display').id, :name =&amp;gt; 'goto_metareview_rubrics', :permission_id =&amp;gt; nil, :url_to_use =&amp;gt; '')&lt;br /&gt;
-ControllerAction.create(:site_controller_id =&amp;gt; SiteController.find_by_name('tree_display').id, :name =&amp;gt; 'goto_teammatereview_rubrics', :permission_id =&amp;gt; nil, :url_to_use =&amp;gt; '')&lt;br /&gt;
+ControllerAction.create(:site_controller_id =&amp;gt; SiteController.find_by_name('tree_display').id, :name =&amp;gt; 'index', :permission_id =&amp;gt; nil, :url_to_use =&amp;gt; '')&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In addition, these name attributes are used in other tables, such as the menu_items table.  As a result, for every method in the tree_display_controller, changes like the following had to be made:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 MenuItem.create(:parent_id =&amp;gt; MenuItem.find_by_name('manage/questionnaires').id, :name =&amp;gt; 'manage/questionnaires/course evaluations', :label =&amp;gt; 'Course evaluations', :seq =&amp;gt; 7, :content_page_id =&amp;gt; nil,&lt;br /&gt;
-                :controller_action_id =&amp;gt; ControllerAction.where(site_controller_id: SiteController.find_by_name('tree_display').id, name:  'goto_surveys').first.id)&lt;br /&gt;
+                :controller_action_id =&amp;gt; ControllerAction.where(site_controller_id: SiteController.find_by_name('tree_display').id, name:  'index').first.id)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Instead, we believe it would be better for this to be defined in the routes file.  Having routes defined in the database is not transparent at all, and causes much confusion for developers that are new to the project - especially those which are new to Rails as well.  This should be inspected for possible future refactorings.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Future Considerations=&lt;br /&gt;
&lt;br /&gt;
As mentioned in the &amp;quot;Unexpected Database Changes&amp;quot; section, routing should be removed from the database and the routes.rb file should be used instead.  There are several other controllers/actions which are treated the same way.&lt;br /&gt;
&lt;br /&gt;
In the views for tree_display, there are two instances variables which look like they could be removed - ''@show'' and ''@assignment''. ''@show'' appears to never be set anywhere, despite it being used in ''tree_display_controller'', ''_entry.html.erb', and ''_listing.html.erb''.  Perhaps it was previously used, but then it became obsolete and was removed.  ''@assignment'' is set inside of the view it is being used, ''actions/_assignments_actions.html.erb'', but it appears to never be used elsewhere.  In this case, ''@assignment'' should probably be replaced with a local variable.  However, we did not touch on either of these issues because they were outside the scope of our task.  We focused primarily on only refactoring the controller and places in the view which were affected.  In some case, we went above and beyond and refactored additional parts of the tree_display views which were not required.  However, we had to draw a line at some point due to time constraints.&lt;br /&gt;
&lt;br /&gt;
'''_listing.html.erb'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&amp;lt;% child_nodes = node.get_children(sortvar,sortorder,@show,nil,nil,search) %&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''_entry.html.erb'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&amp;lt;% child_nodes = node.get_children(sortvar,sortorder,session[:user].id,@show,search) %&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''actions/_assignments_actions.html.erb'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  &amp;lt;% @assignment = Assignment.find(node.node_object_id) %&amp;gt;&lt;br /&gt;
  &amp;lt;!--ACS Show the create team option in the assignment for the instructor only if&lt;br /&gt;
  the assignment allows teams to be formed with more than 1 participant--&amp;gt;&lt;br /&gt;
  &amp;lt;% if @assignment.max_team_size &amp;gt; 1 %&amp;gt;&lt;br /&gt;
  ...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''tree_display_controller.rb'''&lt;br /&gt;
&amp;lt;pre&amp;gt;child_nodes = root_node.get_children(sortvar,sortorder,session[:user].id,@show,nil,search)&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Conclusion=&lt;br /&gt;
In conclusion, we were able to successfully refactor the tree_display_controller and related controllers and views. We improved and expanded the use of RESTful and DRY design choices, implemented the use of routing helpers, ensured that instantiation of instance variables is minimized, and overall improved the quality and efficiency of the Expertiza codebase.&lt;/div&gt;</summary>
		<author><name>Jjbeaver</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/oss_E1463_vpd&amp;diff=91525</id>
		<title>CSC/ECE 517 Fall 2014/oss E1463 vpd</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/oss_E1463_vpd&amp;diff=91525"/>
		<updated>2014-11-06T05:36:11Z</updated>

		<summary type="html">&lt;p&gt;Jjbeaver: /* Future Considerations */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= '''E1463: Refactoring TreeDisplayController''' =&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
=Project Links=&lt;br /&gt;
[http://ec2-54-186-80-176.us-west-2.compute.amazonaws.com:3000/ Our Expertiza Fork on AWS]&amp;lt;br&amp;gt;&lt;br /&gt;
[https://github.com/Druotic/expertiza Github Repo]&amp;lt;br&amp;gt;&lt;br /&gt;
[https://github.com/expertiza/expertiza/pull/449 Expertize Pull Request] &amp;lt;br&amp;gt;&lt;br /&gt;
[http://ec2-54-186-80-176.us-west-2.compute.amazonaws.com:3000/ Project Running on AWS]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Setup - How To View Our Expertiza Fork Running on AWS=&lt;br /&gt;
NOTE: The scope of our project was only to refactor select code. There are no feature additions or changes, so it should work just like production Expertiza.&lt;br /&gt;
&lt;br /&gt;
1) Go to [http://ec2-54-186-80-176.us-west-2.compute.amazonaws.com:3000/ our Expertiza project running on AWS]&lt;br /&gt;
&lt;br /&gt;
2) Login as Admin&amp;lt;br&amp;gt;&lt;br /&gt;
'''User:''' user2&amp;lt;br&amp;gt;&lt;br /&gt;
'''Password:''' password&lt;br /&gt;
&lt;br /&gt;
3) Click on &amp;quot;Manage...&amp;quot; if you are not automatically directed to the tree display.&lt;br /&gt;
&lt;br /&gt;
=Project Description=&lt;br /&gt;
&lt;br /&gt;
For this project, our team refactored the TreeDisplayController class in the [http://expertiza.ncsu.edu/ Expertiza] OSS project. This class provides access to questionnaires, review rubrics, author feedback, courses, assignments, and course evaluations. The tree display lists all of these categories with the ability for the user to &amp;quot;drill down&amp;quot; into the subcategories or just expand/collapse as needed.&lt;br /&gt;
&lt;br /&gt;
'''Example Image Of Tree Display:&lt;br /&gt;
'''&lt;br /&gt;
[[File:Expertiza.PNG ]]&lt;br /&gt;
&lt;br /&gt;
=Refactoring TreeDisplayController Tasks=&lt;br /&gt;
&lt;br /&gt;
As part of the refactoring task, we had to address the following issues for enhancing code readability and maintainability. The tasks included:&lt;br /&gt;
#Changing List to Index using a [http://www.restapitutorial.com/lessons/whatisrest.html RESTful] approach.&lt;br /&gt;
#Combined all of the goto methods&lt;br /&gt;
#Use of [http://guides.rubyonrails.org/routing.html#path-and-url-helpers routing helpers]&lt;br /&gt;
#Ensuring that instantiation of instance variables is minimized.&lt;br /&gt;
&lt;br /&gt;
In the end, we enhanced this list a bit and resulted in doing the following: 		&lt;br /&gt;
#Changed `list` method to `index`	&lt;br /&gt;
#Removed all of the `goto` methods and `drill`, and had them go through `index` instead because they are essentially just filtered versions of a listing (and the previous implementation just redirected each `goto` back to `list` anyway)	&lt;br /&gt;
#Used path helpers where possible	&lt;br /&gt;
#Removed instance variables and used local variables instead.  This should be better for scope reasons.  Note that there are still 1-2 instance variables used in the view, `@show` and `@assignment` which don't appear to be used anywhere.  (`@show` doesn't seem to ever be set, `@assignment` seems to only be used locally)  However, we didn't touch this because it didn't deal directly with our changes to the controller.	&lt;br /&gt;
#Introduced some local variables as params to the view which allow dropdowns to keep their selected option after the page reloads (the logic was there before, but it was using instance variables which were never set!). This is for the search/filtering options on the &amp;quot;Manage...&amp;quot; screen.&lt;br /&gt;
&lt;br /&gt;
==1) Changing List to Index==&lt;br /&gt;
&lt;br /&gt;
In order to make the codebase more [http://www.restapitutorial.com/lessons/whatisrest.html RESTful], we have replaced all the controller action redirections with a tree_display_index_path which enormously reduces the code content and as well as provides an organized approach to action redirections. &lt;br /&gt;
&lt;br /&gt;
[[File:List_to_Index.png]]&lt;br /&gt;
&lt;br /&gt;
As seen below, we were able to '''remove''' list from Routes.rb:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
resources :tree_display do &lt;br /&gt;
collection do &lt;br /&gt;
  get ':action' &lt;br /&gt;
    - post 'list' &lt;br /&gt;
  end &lt;br /&gt;
end &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==2) Combined All of the Goto Methods==&lt;br /&gt;
We also combined all of the goto methods into one, in accordance with the [http://en.wikipedia.org/wiki/Don't_repeat_yourself DRY] principle. This removed a significant amount of duplicate code.&lt;br /&gt;
&lt;br /&gt;
Shown below are 3 of the 10 very similar methods we removed from '''tree_display_controller.rb''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
- # direct access to questionnaires &lt;br /&gt;
- def goto_questionnaires &lt;br /&gt;
- node_object = TreeFolder.find_by_name('Questionnaires') &lt;br /&gt;
- session[:root] = FolderNode.find_by_node_object_id(node_object.id).id &lt;br /&gt;
- redirect_to :controller =&amp;gt; 'tree_display', :action =&amp;gt; 'list' &lt;br /&gt;
- end &lt;br /&gt;
- &lt;br /&gt;
- # direct access to review rubrics &lt;br /&gt;
- def goto_review_rubrics &lt;br /&gt;
- node_object = TreeFolder.find_by_name('Review') &lt;br /&gt;
- session[:root] = FolderNode.find_by_node_object_id(node_object.id).id &lt;br /&gt;
- redirect_to :controller =&amp;gt; 'tree_display', :action =&amp;gt; 'list' &lt;br /&gt;
- end &lt;br /&gt;
- &lt;br /&gt;
- # direct access to metareview rubrics &lt;br /&gt;
- def goto_metareview_rubrics &lt;br /&gt;
- node_object = TreeFolder.find_by_name('Metareview') &lt;br /&gt;
- session[:root] = FolderNode.find_by_node_object_id(node_object.id).id &lt;br /&gt;
- redirect_to :controller =&amp;gt; 'tree_display', :action =&amp;gt; 'list' &lt;br /&gt;
- end &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
These methods were replaced by a variable containing a list mapping all the session variable strings to database labels. The goto_assignments method was replaced with an index method to accept this variable, rather then calling each goto method individually.&lt;br /&gt;
&lt;br /&gt;
'''Added''' variable:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
+ @@Groups = { &lt;br /&gt;
+   'Questionnaires' =&amp;gt; 'Questionnaires', &lt;br /&gt;
+   'Review rubrics' =&amp;gt; 'Review', &lt;br /&gt;
+   'Metareview rubrics' =&amp;gt; 'Metareview', &lt;br /&gt;
+   'Teammate review rubrics' =&amp;gt; 'Teammate Review', &lt;br /&gt;
+   'Author feedbacks' =&amp;gt; 'Author Feedback', &lt;br /&gt;
+   'Global survey' =&amp;gt; 'Global Survey', &lt;br /&gt;
+   'Surveys' =&amp;gt; 'Survey', &lt;br /&gt;
+   'Course evaluations' =&amp;gt; 'Course Evaluation', &lt;br /&gt;
+   'Courses' =&amp;gt; 'Courses', &lt;br /&gt;
+   'Bookmarkrating' =&amp;gt; 'Bookmarkrating', &lt;br /&gt;
+   'Assignments' =&amp;gt; 'Assignments' &lt;br /&gt;
+ } &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Removed''' goto_assignments method:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
- # direct access to assignments &lt;br /&gt;
- def goto_assignments &lt;br /&gt;
-   node_object = TreeFolder.find_by_name('Assignments') &lt;br /&gt;
-   session[:root] = FolderNode.find_by_node_object_id(node_object.id).id &lt;br /&gt;
-   redirect_to :controller =&amp;gt; 'tree_display', :action =&amp;gt; 'list' &lt;br /&gt;
- end &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Added''' index method:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
+ def index &lt;br /&gt;
+   session[:root] = params[:root] &lt;br /&gt;
+   group = getGroup session[:menu] &lt;br /&gt;
+   node_object = TreeFolder.find_by_name(group) &lt;br /&gt;
+   if not group.blank? and not node_object.blank? &lt;br /&gt;
+     session[:root] = FolderNode.find_by_node_object_id(node_object.id).id &lt;br /&gt;
+ end &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==3) Use Routing Helpers==&lt;br /&gt;
We refactored the tree display controller class to use route helpers rather than calling &amp;quot;:action =&amp;gt; 'list', :controller =&amp;gt; 'tree_display'&amp;quot;, or something similar. This involved many edits in the tree_display_controller.rb file and related controller and view files. As seen below, we utilized routing helpers and replaced '' ':controller=&amp;gt;'course', :action=&amp;gt;'new', :private =&amp;gt; 0'' with ''new_course_path(private: 0)''.&lt;br /&gt;
&lt;br /&gt;
'''_courses_folder_actions.html.erb''' changes:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;ul&amp;gt; &lt;br /&gt;
   &amp;lt;div&amp;gt; &lt;br /&gt;
   &amp;lt;%= link_to image_tag('/assets/tree_view/add-public-24.png'), &lt;br /&gt;
  - { :controller=&amp;gt;'course', :action=&amp;gt;'new', :private =&amp;gt; 0 }, &lt;br /&gt;
  - { :title =&amp;gt; 'Create Public Course', id: 'create-public-course' } %&amp;gt; &lt;br /&gt;
  + new_course_path(private: 0), &lt;br /&gt;
  + { title: 'Create Public Course', id: 'create-public-course' } %&amp;gt; &lt;br /&gt;
   &amp;lt;%= link_to image_tag('/assets/tree_view/add-private-24.png'), &lt;br /&gt;
  - { :controller=&amp;gt;'course', :action=&amp;gt;'new', :private =&amp;gt; 1 }, &lt;br /&gt;
  - { :title =&amp;gt; 'Create Private Course', id: 'create-private-course' } %&amp;gt; &lt;br /&gt;
  + new_course_path(private: 1), &lt;br /&gt;
  + { title: 'Create Private Course', id: 'create-private-course' } %&amp;gt; &lt;br /&gt;
   &amp;lt;/div&amp;gt; &lt;br /&gt;
   &amp;lt;/ul&amp;gt; &lt;br /&gt;
   &amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt; &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Another example of routing helpers in '''_bread_crumbs.html.erb'''. &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Before:'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;%= link_to curr_node.get_name, :controller =&amp;gt; 'tree_display', :action =&amp;gt; 'drill', :root =&amp;gt; curr_node.id %&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''After''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;%= link_to curr_node.get_name, tree_display_index_path(root: curr_node.id)%&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==4) Minimizing the count of Instance Variables==&lt;br /&gt;
=== Instance Variables in Ruby ===&lt;br /&gt;
An instance variable has a name beginning with @, and its scope is confined to whatever object self refers to. Two different objects, even if they belong to the same class, are allowed to have different values for their instance variables. From outside the object, instance variables cannot be altered or even observed (i.e., ruby's instance variables are never public) except by whatever methods are explicitly provided by the programmer. As with globals, instance variables have the nil value until they are initialized.&lt;br /&gt;
&lt;br /&gt;
Instance variables do not need to be declared. This indicates a flexible object structure; in fact, each instance variable is dynamically appended to an object when it is first assigned.&lt;br /&gt;
&lt;br /&gt;
We have observed that in Expertiza, there were several code files related to the Tree Display controller which were observed to be using multiple instance variables which could be reduced. Our team aimed to limit the instantiation of such variables to only necessary places in our code.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The following was added to the ''index'' function of '''tree_display_controller.rb''' in order to replace the use of instance variables with local variables:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
locals  search:       @search,&lt;br /&gt;
        sortvar:      @sortvar,&lt;br /&gt;
        sortorder:    @sortorder,&lt;br /&gt;
        root_node:    @root_node,&lt;br /&gt;
        child_nodes:  @child_nodes,&lt;br /&gt;
        filternode:   params[:filternode],&lt;br /&gt;
        searchnode:   params[:searchnode]&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Many of the view files were changed to make use of the local variables. &lt;br /&gt;
&lt;br /&gt;
Here is an example of how _bread_crumbs.html.erb was changed. Note the removal of the &amp;quot;@&amp;quot; characters.&lt;br /&gt;
&lt;br /&gt;
'''Before:'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;% if @root_node %&amp;gt;&lt;br /&gt;
   &amp;lt;%= link_to &amp;quot;Return to top&amp;quot;, tree_display_index_path %&amp;gt;&lt;br /&gt;
   &amp;lt;%&lt;br /&gt;
      curr_node = @root_node&lt;br /&gt;
   while curr_node.parent_id&lt;br /&gt;
     curr_node = Node.find(curr_node.parent_id) %&amp;gt;&lt;br /&gt;
   &amp;amp;nbsp;&amp;amp;nbsp;&lt;br /&gt;
   &amp;lt;%= link_to curr_node.get_name, tree_display_index_path(root: curr_node.id)%&amp;gt;&lt;br /&gt;
 &amp;lt;% end %&amp;gt;&lt;br /&gt;
&amp;amp;nbsp;&amp;amp;nbsp;&amp;lt;%= @root_node.get_name %&amp;gt;&amp;lt;%&lt;br /&gt;
end %&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''After:'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;% if root_node %&amp;gt;&lt;br /&gt;
   &amp;lt;%= link_to &amp;quot;Return to top&amp;quot;, tree_display_index_path %&amp;gt;&lt;br /&gt;
   &amp;lt;%&lt;br /&gt;
      curr_node = root_node&lt;br /&gt;
   while curr_node.parent_id&lt;br /&gt;
     curr_node = Node.find(curr_node.parent_id) %&amp;gt;&lt;br /&gt;
   &amp;amp;nbsp;&amp;amp;nbsp;&lt;br /&gt;
   &amp;lt;%= link_to curr_node.get_name, tree_display_index_path(root: curr_node.id)%&amp;gt;&lt;br /&gt;
 &amp;lt;% end %&amp;gt;&lt;br /&gt;
&amp;amp;nbsp;&amp;amp;nbsp;&amp;lt;%= root_node.get_name %&amp;gt;&amp;lt;%&lt;br /&gt;
 end %&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Unexpected Database Changes=&lt;br /&gt;
&lt;br /&gt;
Unfortunately, each method of the tree_display controller has a reference to it stored in the database, along with a route.  Essentially, the routes are being stored in the database and a wildcard is used in the routes table to allow this to happen.  The following is a sample of some of the changes made (as part of tasks 1 and 2 given above) which were required in the db/seeds.rb file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
-ControllerAction.create(:site_controller_id =&amp;gt; SiteController.find_by_name('tree_display').id, :name =&amp;gt; 'goto_teammate_reviews', :permission_id =&amp;gt; nil, :url_to_use =&amp;gt; '')&lt;br /&gt;
-ControllerAction.create(:site_controller_id =&amp;gt; SiteController.find_by_name('tree_display').id, :name =&amp;gt; 'goto_metareview_rubrics', :permission_id =&amp;gt; nil, :url_to_use =&amp;gt; '')&lt;br /&gt;
-ControllerAction.create(:site_controller_id =&amp;gt; SiteController.find_by_name('tree_display').id, :name =&amp;gt; 'goto_teammatereview_rubrics', :permission_id =&amp;gt; nil, :url_to_use =&amp;gt; '')&lt;br /&gt;
+ControllerAction.create(:site_controller_id =&amp;gt; SiteController.find_by_name('tree_display').id, :name =&amp;gt; 'index', :permission_id =&amp;gt; nil, :url_to_use =&amp;gt; '')&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In addition, these name attributes are used in other tables, such as the menu_items table.  As a result, for every method in the tree_display_controller, changes like the following had to be made:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 MenuItem.create(:parent_id =&amp;gt; MenuItem.find_by_name('manage/questionnaires').id, :name =&amp;gt; 'manage/questionnaires/course evaluations', :label =&amp;gt; 'Course evaluations', :seq =&amp;gt; 7, :content_page_id =&amp;gt; nil,&lt;br /&gt;
-                :controller_action_id =&amp;gt; ControllerAction.where(site_controller_id: SiteController.find_by_name('tree_display').id, name:  'goto_surveys').first.id)&lt;br /&gt;
+                :controller_action_id =&amp;gt; ControllerAction.where(site_controller_id: SiteController.find_by_name('tree_display').id, name:  'index').first.id)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Instead, we believe it would be better for this to be defined in the routes file.  Having routes defined in the database is not transparent at all, and causes much confusion for developers that are new to the project - especially those which are new to Rails as well.  This should be inspected for possible future refactorings.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Future Considerations=&lt;br /&gt;
&lt;br /&gt;
As mentioned in the &amp;quot;Unexpected Database Changes&amp;quot; section, routing should be removed from the database and the routes.rb file should be used instead.  There are several other controllers/actions which are treated the same way.&lt;br /&gt;
&lt;br /&gt;
In the views for tree_display, there are two instances variables which look like they could be removed - ''@show'' and ''@assignment''. ''@show'' appears to never be set anywhere, despite it being used in ''tree_display_controller'', ''_entry.html.erb', and ''_listing.html.erb''.  Perhaps it was previously used, but then it became obsolete and was removed.  ''@assignment'' is set inside of the view it is being used, ''actions/_assignments_actions.html.erb'', but it appears to never be used elsewhere.  In this case, ''@assignment'' should probably be replaced with a local variable.  However, we did not touch on either of these issues because they were outside the scope of our task.  We focused primarily on only refactoring the controller and places in the view which were affected.  In some case, we went above and beyond and refactored additional parts of the tree_display views which were not required.  However, we had to draw a line at some point due to time constraints.&lt;br /&gt;
&lt;br /&gt;
'''_listing.html.erb'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&amp;lt;% child_nodes = node.get_children(sortvar,sortorder,@show,nil,nil,search) %&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''_entry.html.erb'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&amp;lt;% child_nodes = node.get_children(sortvar,sortorder,session[:user].id,@show,search) %&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''actions/_assignments_actions.html.erb'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  &amp;lt;% @assignment = Assignment.find(node.node_object_id) %&amp;gt;&lt;br /&gt;
  &amp;lt;!--ACS Show the create team option in the assignment for the instructor only if&lt;br /&gt;
  the assignment allows teams to be formed with more than 1 participant--&amp;gt;&lt;br /&gt;
  &amp;lt;% if @assignment.max_team_size &amp;gt; 1 %&amp;gt;&lt;br /&gt;
  ...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''tree_display_controller.rb'''&lt;br /&gt;
&amp;lt;pre&amp;gt;child_nodes = root_node.get_children(sortvar,sortorder,session[:user].id,@show,nil,search)&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Conclusion=&lt;br /&gt;
In conclusion, we were able to successfully refactor the tree_display_controller and related controllers and views. We improved and expanded the use of RESTful and DRY design choices, implemented the use of routing helpers, ensured that instantiation of instance variables is minimized, and overall improved the quality and efficiency of the Expertiza codebase.&lt;/div&gt;</summary>
		<author><name>Jjbeaver</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/oss_E1463_vpd&amp;diff=91524</id>
		<title>CSC/ECE 517 Fall 2014/oss E1463 vpd</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/oss_E1463_vpd&amp;diff=91524"/>
		<updated>2014-11-06T05:31:18Z</updated>

		<summary type="html">&lt;p&gt;Jjbeaver: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= '''E1463: Refactoring TreeDisplayController''' =&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
=Project Links=&lt;br /&gt;
[http://ec2-54-186-80-176.us-west-2.compute.amazonaws.com:3000/ Our Expertiza Fork on AWS]&amp;lt;br&amp;gt;&lt;br /&gt;
[https://github.com/Druotic/expertiza Github Repo]&amp;lt;br&amp;gt;&lt;br /&gt;
[https://github.com/expertiza/expertiza/pull/449 Expertize Pull Request] &amp;lt;br&amp;gt;&lt;br /&gt;
[http://ec2-54-186-80-176.us-west-2.compute.amazonaws.com:3000/ Project Running on AWS]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Setup - How To View Our Expertiza Fork Running on AWS=&lt;br /&gt;
NOTE: The scope of our project was only to refactor select code. There are no feature additions or changes, so it should work just like production Expertiza.&lt;br /&gt;
&lt;br /&gt;
1) Go to [http://ec2-54-186-80-176.us-west-2.compute.amazonaws.com:3000/ our Expertiza project running on AWS]&lt;br /&gt;
&lt;br /&gt;
2) Login as Admin&amp;lt;br&amp;gt;&lt;br /&gt;
'''User:''' user2&amp;lt;br&amp;gt;&lt;br /&gt;
'''Password:''' password&lt;br /&gt;
&lt;br /&gt;
3) Click on &amp;quot;Manage...&amp;quot; if you are not automatically directed to the tree display.&lt;br /&gt;
&lt;br /&gt;
=Project Description=&lt;br /&gt;
&lt;br /&gt;
For this project, our team refactored the TreeDisplayController class in the [http://expertiza.ncsu.edu/ Expertiza] OSS project. This class provides access to questionnaires, review rubrics, author feedback, courses, assignments, and course evaluations. The tree display lists all of these categories with the ability for the user to &amp;quot;drill down&amp;quot; into the subcategories or just expand/collapse as needed.&lt;br /&gt;
&lt;br /&gt;
'''Example Image Of Tree Display:&lt;br /&gt;
'''&lt;br /&gt;
[[File:Expertiza.PNG ]]&lt;br /&gt;
&lt;br /&gt;
=Refactoring TreeDisplayController Tasks=&lt;br /&gt;
&lt;br /&gt;
As part of the refactoring task, we had to address the following issues for enhancing code readability and maintainability. The tasks included:&lt;br /&gt;
#Changing List to Index using a [http://www.restapitutorial.com/lessons/whatisrest.html RESTful] approach.&lt;br /&gt;
#Combined all of the goto methods&lt;br /&gt;
#Use of [http://guides.rubyonrails.org/routing.html#path-and-url-helpers routing helpers]&lt;br /&gt;
#Ensuring that instantiation of instance variables is minimized.&lt;br /&gt;
&lt;br /&gt;
In the end, we enhanced this list a bit and resulted in doing the following: 		&lt;br /&gt;
#Changed `list` method to `index`	&lt;br /&gt;
#Removed all of the `goto` methods and `drill`, and had them go through `index` instead because they are essentially just filtered versions of a listing (and the previous implementation just redirected each `goto` back to `list` anyway)	&lt;br /&gt;
#Used path helpers where possible	&lt;br /&gt;
#Removed instance variables and used local variables instead.  This should be better for scope reasons.  Note that there are still 1-2 instance variables used in the view, `@show` and `@assignment` which don't appear to be used anywhere.  (`@show` doesn't seem to ever be set, `@assignment` seems to only be used locally)  However, we didn't touch this because it didn't deal directly with our changes to the controller.	&lt;br /&gt;
#Introduced some local variables as params to the view which allow dropdowns to keep their selected option after the page reloads (the logic was there before, but it was using instance variables which were never set!). This is for the search/filtering options on the &amp;quot;Manage...&amp;quot; screen.&lt;br /&gt;
&lt;br /&gt;
==1) Changing List to Index==&lt;br /&gt;
&lt;br /&gt;
In order to make the codebase more [http://www.restapitutorial.com/lessons/whatisrest.html RESTful], we have replaced all the controller action redirections with a tree_display_index_path which enormously reduces the code content and as well as provides an organized approach to action redirections. &lt;br /&gt;
&lt;br /&gt;
[[File:List_to_Index.png]]&lt;br /&gt;
&lt;br /&gt;
As seen below, we were able to '''remove''' list from Routes.rb:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
resources :tree_display do &lt;br /&gt;
collection do &lt;br /&gt;
  get ':action' &lt;br /&gt;
    - post 'list' &lt;br /&gt;
  end &lt;br /&gt;
end &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==2) Combined All of the Goto Methods==&lt;br /&gt;
We also combined all of the goto methods into one, in accordance with the [http://en.wikipedia.org/wiki/Don't_repeat_yourself DRY] principle. This removed a significant amount of duplicate code.&lt;br /&gt;
&lt;br /&gt;
Shown below are 3 of the 10 very similar methods we removed from '''tree_display_controller.rb''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
- # direct access to questionnaires &lt;br /&gt;
- def goto_questionnaires &lt;br /&gt;
- node_object = TreeFolder.find_by_name('Questionnaires') &lt;br /&gt;
- session[:root] = FolderNode.find_by_node_object_id(node_object.id).id &lt;br /&gt;
- redirect_to :controller =&amp;gt; 'tree_display', :action =&amp;gt; 'list' &lt;br /&gt;
- end &lt;br /&gt;
- &lt;br /&gt;
- # direct access to review rubrics &lt;br /&gt;
- def goto_review_rubrics &lt;br /&gt;
- node_object = TreeFolder.find_by_name('Review') &lt;br /&gt;
- session[:root] = FolderNode.find_by_node_object_id(node_object.id).id &lt;br /&gt;
- redirect_to :controller =&amp;gt; 'tree_display', :action =&amp;gt; 'list' &lt;br /&gt;
- end &lt;br /&gt;
- &lt;br /&gt;
- # direct access to metareview rubrics &lt;br /&gt;
- def goto_metareview_rubrics &lt;br /&gt;
- node_object = TreeFolder.find_by_name('Metareview') &lt;br /&gt;
- session[:root] = FolderNode.find_by_node_object_id(node_object.id).id &lt;br /&gt;
- redirect_to :controller =&amp;gt; 'tree_display', :action =&amp;gt; 'list' &lt;br /&gt;
- end &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
These methods were replaced by a variable containing a list mapping all the session variable strings to database labels. The goto_assignments method was replaced with an index method to accept this variable, rather then calling each goto method individually.&lt;br /&gt;
&lt;br /&gt;
'''Added''' variable:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
+ @@Groups = { &lt;br /&gt;
+   'Questionnaires' =&amp;gt; 'Questionnaires', &lt;br /&gt;
+   'Review rubrics' =&amp;gt; 'Review', &lt;br /&gt;
+   'Metareview rubrics' =&amp;gt; 'Metareview', &lt;br /&gt;
+   'Teammate review rubrics' =&amp;gt; 'Teammate Review', &lt;br /&gt;
+   'Author feedbacks' =&amp;gt; 'Author Feedback', &lt;br /&gt;
+   'Global survey' =&amp;gt; 'Global Survey', &lt;br /&gt;
+   'Surveys' =&amp;gt; 'Survey', &lt;br /&gt;
+   'Course evaluations' =&amp;gt; 'Course Evaluation', &lt;br /&gt;
+   'Courses' =&amp;gt; 'Courses', &lt;br /&gt;
+   'Bookmarkrating' =&amp;gt; 'Bookmarkrating', &lt;br /&gt;
+   'Assignments' =&amp;gt; 'Assignments' &lt;br /&gt;
+ } &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Removed''' goto_assignments method:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
- # direct access to assignments &lt;br /&gt;
- def goto_assignments &lt;br /&gt;
-   node_object = TreeFolder.find_by_name('Assignments') &lt;br /&gt;
-   session[:root] = FolderNode.find_by_node_object_id(node_object.id).id &lt;br /&gt;
-   redirect_to :controller =&amp;gt; 'tree_display', :action =&amp;gt; 'list' &lt;br /&gt;
- end &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Added''' index method:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
+ def index &lt;br /&gt;
+   session[:root] = params[:root] &lt;br /&gt;
+   group = getGroup session[:menu] &lt;br /&gt;
+   node_object = TreeFolder.find_by_name(group) &lt;br /&gt;
+   if not group.blank? and not node_object.blank? &lt;br /&gt;
+     session[:root] = FolderNode.find_by_node_object_id(node_object.id).id &lt;br /&gt;
+ end &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==3) Use Routing Helpers==&lt;br /&gt;
We refactored the tree display controller class to use route helpers rather than calling &amp;quot;:action =&amp;gt; 'list', :controller =&amp;gt; 'tree_display'&amp;quot;, or something similar. This involved many edits in the tree_display_controller.rb file and related controller and view files. As seen below, we utilized routing helpers and replaced '' ':controller=&amp;gt;'course', :action=&amp;gt;'new', :private =&amp;gt; 0'' with ''new_course_path(private: 0)''.&lt;br /&gt;
&lt;br /&gt;
'''_courses_folder_actions.html.erb''' changes:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;ul&amp;gt; &lt;br /&gt;
   &amp;lt;div&amp;gt; &lt;br /&gt;
   &amp;lt;%= link_to image_tag('/assets/tree_view/add-public-24.png'), &lt;br /&gt;
  - { :controller=&amp;gt;'course', :action=&amp;gt;'new', :private =&amp;gt; 0 }, &lt;br /&gt;
  - { :title =&amp;gt; 'Create Public Course', id: 'create-public-course' } %&amp;gt; &lt;br /&gt;
  + new_course_path(private: 0), &lt;br /&gt;
  + { title: 'Create Public Course', id: 'create-public-course' } %&amp;gt; &lt;br /&gt;
   &amp;lt;%= link_to image_tag('/assets/tree_view/add-private-24.png'), &lt;br /&gt;
  - { :controller=&amp;gt;'course', :action=&amp;gt;'new', :private =&amp;gt; 1 }, &lt;br /&gt;
  - { :title =&amp;gt; 'Create Private Course', id: 'create-private-course' } %&amp;gt; &lt;br /&gt;
  + new_course_path(private: 1), &lt;br /&gt;
  + { title: 'Create Private Course', id: 'create-private-course' } %&amp;gt; &lt;br /&gt;
   &amp;lt;/div&amp;gt; &lt;br /&gt;
   &amp;lt;/ul&amp;gt; &lt;br /&gt;
   &amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt; &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Another example of routing helpers in '''_bread_crumbs.html.erb'''. &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Before:'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;%= link_to curr_node.get_name, :controller =&amp;gt; 'tree_display', :action =&amp;gt; 'drill', :root =&amp;gt; curr_node.id %&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''After''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;%= link_to curr_node.get_name, tree_display_index_path(root: curr_node.id)%&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==4) Minimizing the count of Instance Variables==&lt;br /&gt;
=== Instance Variables in Ruby ===&lt;br /&gt;
An instance variable has a name beginning with @, and its scope is confined to whatever object self refers to. Two different objects, even if they belong to the same class, are allowed to have different values for their instance variables. From outside the object, instance variables cannot be altered or even observed (i.e., ruby's instance variables are never public) except by whatever methods are explicitly provided by the programmer. As with globals, instance variables have the nil value until they are initialized.&lt;br /&gt;
&lt;br /&gt;
Instance variables do not need to be declared. This indicates a flexible object structure; in fact, each instance variable is dynamically appended to an object when it is first assigned.&lt;br /&gt;
&lt;br /&gt;
We have observed that in Expertiza, there were several code files related to the Tree Display controller which were observed to be using multiple instance variables which could be reduced. Our team aimed to limit the instantiation of such variables to only necessary places in our code.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The following was added to the ''index'' function of '''tree_display_controller.rb''' in order to replace the use of instance variables with local variables:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
locals  search:       @search,&lt;br /&gt;
        sortvar:      @sortvar,&lt;br /&gt;
        sortorder:    @sortorder,&lt;br /&gt;
        root_node:    @root_node,&lt;br /&gt;
        child_nodes:  @child_nodes,&lt;br /&gt;
        filternode:   params[:filternode],&lt;br /&gt;
        searchnode:   params[:searchnode]&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Many of the view files were changed to make use of the local variables. &lt;br /&gt;
&lt;br /&gt;
Here is an example of how _bread_crumbs.html.erb was changed. Note the removal of the &amp;quot;@&amp;quot; characters.&lt;br /&gt;
&lt;br /&gt;
'''Before:'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;% if @root_node %&amp;gt;&lt;br /&gt;
   &amp;lt;%= link_to &amp;quot;Return to top&amp;quot;, tree_display_index_path %&amp;gt;&lt;br /&gt;
   &amp;lt;%&lt;br /&gt;
      curr_node = @root_node&lt;br /&gt;
   while curr_node.parent_id&lt;br /&gt;
     curr_node = Node.find(curr_node.parent_id) %&amp;gt;&lt;br /&gt;
   &amp;amp;nbsp;&amp;amp;nbsp;&lt;br /&gt;
   &amp;lt;%= link_to curr_node.get_name, tree_display_index_path(root: curr_node.id)%&amp;gt;&lt;br /&gt;
 &amp;lt;% end %&amp;gt;&lt;br /&gt;
&amp;amp;nbsp;&amp;amp;nbsp;&amp;lt;%= @root_node.get_name %&amp;gt;&amp;lt;%&lt;br /&gt;
end %&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''After:'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;% if root_node %&amp;gt;&lt;br /&gt;
   &amp;lt;%= link_to &amp;quot;Return to top&amp;quot;, tree_display_index_path %&amp;gt;&lt;br /&gt;
   &amp;lt;%&lt;br /&gt;
      curr_node = root_node&lt;br /&gt;
   while curr_node.parent_id&lt;br /&gt;
     curr_node = Node.find(curr_node.parent_id) %&amp;gt;&lt;br /&gt;
   &amp;amp;nbsp;&amp;amp;nbsp;&lt;br /&gt;
   &amp;lt;%= link_to curr_node.get_name, tree_display_index_path(root: curr_node.id)%&amp;gt;&lt;br /&gt;
 &amp;lt;% end %&amp;gt;&lt;br /&gt;
&amp;amp;nbsp;&amp;amp;nbsp;&amp;lt;%= root_node.get_name %&amp;gt;&amp;lt;%&lt;br /&gt;
 end %&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Unexpected Database Changes=&lt;br /&gt;
&lt;br /&gt;
Unfortunately, each method of the tree_display controller has a reference to it stored in the database, along with a route.  Essentially, the routes are being stored in the database and a wildcard is used in the routes table to allow this to happen.  The following is a sample of some of the changes made (as part of tasks 1 and 2 given above) which were required in the db/seeds.rb file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
-ControllerAction.create(:site_controller_id =&amp;gt; SiteController.find_by_name('tree_display').id, :name =&amp;gt; 'goto_teammate_reviews', :permission_id =&amp;gt; nil, :url_to_use =&amp;gt; '')&lt;br /&gt;
-ControllerAction.create(:site_controller_id =&amp;gt; SiteController.find_by_name('tree_display').id, :name =&amp;gt; 'goto_metareview_rubrics', :permission_id =&amp;gt; nil, :url_to_use =&amp;gt; '')&lt;br /&gt;
-ControllerAction.create(:site_controller_id =&amp;gt; SiteController.find_by_name('tree_display').id, :name =&amp;gt; 'goto_teammatereview_rubrics', :permission_id =&amp;gt; nil, :url_to_use =&amp;gt; '')&lt;br /&gt;
+ControllerAction.create(:site_controller_id =&amp;gt; SiteController.find_by_name('tree_display').id, :name =&amp;gt; 'index', :permission_id =&amp;gt; nil, :url_to_use =&amp;gt; '')&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In addition, these name attributes are used in other tables, such as the menu_items table.  As a result, for every method in the tree_display_controller, changes like the following had to be made:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 MenuItem.create(:parent_id =&amp;gt; MenuItem.find_by_name('manage/questionnaires').id, :name =&amp;gt; 'manage/questionnaires/course evaluations', :label =&amp;gt; 'Course evaluations', :seq =&amp;gt; 7, :content_page_id =&amp;gt; nil,&lt;br /&gt;
-                :controller_action_id =&amp;gt; ControllerAction.where(site_controller_id: SiteController.find_by_name('tree_display').id, name:  'goto_surveys').first.id)&lt;br /&gt;
+                :controller_action_id =&amp;gt; ControllerAction.where(site_controller_id: SiteController.find_by_name('tree_display').id, name:  'index').first.id)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Instead, we believe it would be better for this to be defined in the routes file.  Having routes defined in the database is not transparent at all, and causes much confusion for developers that are new to the project - especially those which are new to Rails as well.  This should be inspected for possible future refactorings.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Future Considerations=&lt;br /&gt;
&lt;br /&gt;
As mentioned in the &amp;quot;Unexpected Database Changes&amp;quot; section, routing should be removed from the database and the routes.rb file should be used instead.  There are several other controllers/actions which are treated the same way.&lt;br /&gt;
&lt;br /&gt;
In the views for tree_display, there are two instances variables which look like they could be removed - '@show' and '@assignment'. '@show' appears to never be set anywhere, despite it being used in tree_display_controller, _entry.html.erb, and _listing.html.erb.  Perhaps it was previously used, but then it became obsolete and was removed.  '@assignment' is set inside of the view it is being used, actions/_assignments_actions.html.erb, but it appears to never be used elsewhere.  In this case, '@assignment' should probably be replaced with a local variable.  However, we did not touch on either of these issues because they were outside the scope of our task.  We focused primarily on only refactoring the controller and places in the view which were affected.  In some case, we went above and beyond and refactored additional parts of the tree_display views which were not required.  However, we had to draw a line at some point due to time constraints.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;_listing.html.erb&amp;lt;/b&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&amp;lt;% child_nodes = node.get_children(sortvar,sortorder,@show,nil,nil,search) %&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;_entry.html.erb&amp;lt;/b&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&amp;lt;% child_nodes = node.get_children(sortvar,sortorder,session[:user].id,@show,search) %&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;_assignments_actions.html.erb&amp;lt;/b&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  &amp;lt;% @assignment = Assignment.find(node.node_object_id) %&amp;gt;&lt;br /&gt;
  &amp;lt;!--ACS Show the create team option in the assignment for the instructor only if&lt;br /&gt;
  the assignment allows teams to be formed with more than 1 participant--&amp;gt;&lt;br /&gt;
  &amp;lt;% if @assignment.max_team_size &amp;gt; 1 %&amp;gt;&lt;br /&gt;
  ...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Conclusion=&lt;br /&gt;
In conclusion, we were able to successfully refactor the tree_display_controller and related controllers and views. We improved and expanded the use of RESTful and DRY design choices, implemented the use of routing helpers, ensured that instantiation of instance variables is minimized, and overall improved the quality and efficiency of the Expertiza codebase.&lt;/div&gt;</summary>
		<author><name>Jjbeaver</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/oss_E1463_vpd&amp;diff=91522</id>
		<title>CSC/ECE 517 Fall 2014/oss E1463 vpd</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/oss_E1463_vpd&amp;diff=91522"/>
		<updated>2014-11-06T05:10:08Z</updated>

		<summary type="html">&lt;p&gt;Jjbeaver: /* Unexpected Database Changes */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= '''E1463: Refactoring TreeDisplayController''' =&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
=Project Links=&lt;br /&gt;
[http://ec2-54-186-80-176.us-west-2.compute.amazonaws.com:3000/ Our Expertiza Fork on AWS]&amp;lt;br&amp;gt;&lt;br /&gt;
[https://github.com/Druotic/expertiza Github Repo]&amp;lt;br&amp;gt;&lt;br /&gt;
[https://github.com/expertiza/expertiza/pull/449 Expertize Pull Request] &amp;lt;br&amp;gt;&lt;br /&gt;
[http://ec2-54-186-80-176.us-west-2.compute.amazonaws.com:3000/ Project Running on AWS]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Setup - How To View Our Expertiza Fork Running on AWS=&lt;br /&gt;
NOTE: The scope of our project was only to refactor select code. There are no feature additions or changes, so it should work just like production Expertiza.&lt;br /&gt;
&lt;br /&gt;
1) Go to [http://ec2-54-186-80-176.us-west-2.compute.amazonaws.com:3000/ our Expertiza project running on AWS]&lt;br /&gt;
&lt;br /&gt;
2) Login as Admin&amp;lt;br&amp;gt;&lt;br /&gt;
'''User:''' user2&amp;lt;br&amp;gt;&lt;br /&gt;
'''Password:''' password&lt;br /&gt;
&lt;br /&gt;
3) Click on &amp;quot;Manage...&amp;quot; if you are not automatically directed to the tree display.&lt;br /&gt;
&lt;br /&gt;
=Project Description=&lt;br /&gt;
&lt;br /&gt;
For this project, our team refactored the TreeDisplayController class in the [http://expertiza.ncsu.edu/ Expertiza] OSS project. This class provides access to questionnaires, review rubrics, author feedback, courses, assignments, and course evaluations. The tree display lists all of these categories with the ability for the user to &amp;quot;drill down&amp;quot; into the subcategories or just expand/collapse as needed.&lt;br /&gt;
&lt;br /&gt;
'''Example Image Of Tree Display:&lt;br /&gt;
'''&lt;br /&gt;
[[File:Expertiza.PNG ]]&lt;br /&gt;
&lt;br /&gt;
=Refactoring TreeDisplayController Tasks=&lt;br /&gt;
&lt;br /&gt;
As part of the refactoring task, we had to address the following issues for enhancing code readability and maintainability. The tasks included:&lt;br /&gt;
#Changing List to Index using a [http://www.restapitutorial.com/lessons/whatisrest.html RESTful] approach.&lt;br /&gt;
#Combined all of the goto methods&lt;br /&gt;
#Use of [http://guides.rubyonrails.org/routing.html#path-and-url-helpers routing helpers]&lt;br /&gt;
#Ensuring that instantiation of instance variables is minimized.&lt;br /&gt;
&lt;br /&gt;
In the end, we enhanced this list a bit and resulted in doing the following: 		&lt;br /&gt;
#Changed `list` method to `index`	&lt;br /&gt;
#Removed all of the `goto` methods and `drill`, and had them go through `index` instead because they are essentially just filtered versions of a listing (and the previous implementation just redirected each `goto` back to `list` anyway)	&lt;br /&gt;
#Used path helpers where possible	&lt;br /&gt;
#Removed instance variables and used local variables instead.  This should be better for scope reasons.  Note that there are still 1-2 instance variables used in the view, `@show` and `@assignment` which don't appear to be used anywhere.  (`@show` doesn't seem to ever be set, `@assignment` seems to only be used locally)  However, we didn't touch this because it didn't deal directly with our changes to the controller.	&lt;br /&gt;
#Introduced some local variables as params to the view which allow dropdowns to keep their selected option after the page reloads (the logic was there before, but it was using instance variables which were never set!). This is for the search/filtering options on the &amp;quot;Manage...&amp;quot; screen.&lt;br /&gt;
&lt;br /&gt;
==1) Changing List to Index==&lt;br /&gt;
&lt;br /&gt;
In order to make the codebase more [http://www.restapitutorial.com/lessons/whatisrest.html RESTful], we have replaced all the controller action redirections with a tree_display_index_path which enormously reduces the code content and as well as provides an organized approach to action redirections. &lt;br /&gt;
&lt;br /&gt;
[[File:List_to_Index.png]]&lt;br /&gt;
&lt;br /&gt;
As seen below, we were able to '''remove''' list from Routes.rb:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
resources :tree_display do &lt;br /&gt;
collection do &lt;br /&gt;
  get ':action' &lt;br /&gt;
    - post 'list' &lt;br /&gt;
  end &lt;br /&gt;
end &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==2) Combined All of the Goto Methods==&lt;br /&gt;
We also combined all of the goto methods into one, in accordance with the [http://en.wikipedia.org/wiki/Don't_repeat_yourself DRY] principle. This removed a significant amount of duplicate code.&lt;br /&gt;
&lt;br /&gt;
Shown below are 3 of the 10 very similar methods we removed from '''tree_display_controller.rb''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
- # direct access to questionnaires &lt;br /&gt;
- def goto_questionnaires &lt;br /&gt;
- node_object = TreeFolder.find_by_name('Questionnaires') &lt;br /&gt;
- session[:root] = FolderNode.find_by_node_object_id(node_object.id).id &lt;br /&gt;
- redirect_to :controller =&amp;gt; 'tree_display', :action =&amp;gt; 'list' &lt;br /&gt;
- end &lt;br /&gt;
- &lt;br /&gt;
- # direct access to review rubrics &lt;br /&gt;
- def goto_review_rubrics &lt;br /&gt;
- node_object = TreeFolder.find_by_name('Review') &lt;br /&gt;
- session[:root] = FolderNode.find_by_node_object_id(node_object.id).id &lt;br /&gt;
- redirect_to :controller =&amp;gt; 'tree_display', :action =&amp;gt; 'list' &lt;br /&gt;
- end &lt;br /&gt;
- &lt;br /&gt;
- # direct access to metareview rubrics &lt;br /&gt;
- def goto_metareview_rubrics &lt;br /&gt;
- node_object = TreeFolder.find_by_name('Metareview') &lt;br /&gt;
- session[:root] = FolderNode.find_by_node_object_id(node_object.id).id &lt;br /&gt;
- redirect_to :controller =&amp;gt; 'tree_display', :action =&amp;gt; 'list' &lt;br /&gt;
- end &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
These methods were replaced by a variable containing a list mapping all the session variable strings to database labels. The goto_assignments method was replaced with an index method to accept this variable, rather then calling each goto method individually.&lt;br /&gt;
&lt;br /&gt;
'''Added''' variable:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
+ @@Groups = { &lt;br /&gt;
+   'Questionnaires' =&amp;gt; 'Questionnaires', &lt;br /&gt;
+   'Review rubrics' =&amp;gt; 'Review', &lt;br /&gt;
+   'Metareview rubrics' =&amp;gt; 'Metareview', &lt;br /&gt;
+   'Teammate review rubrics' =&amp;gt; 'Teammate Review', &lt;br /&gt;
+   'Author feedbacks' =&amp;gt; 'Author Feedback', &lt;br /&gt;
+   'Global survey' =&amp;gt; 'Global Survey', &lt;br /&gt;
+   'Surveys' =&amp;gt; 'Survey', &lt;br /&gt;
+   'Course evaluations' =&amp;gt; 'Course Evaluation', &lt;br /&gt;
+   'Courses' =&amp;gt; 'Courses', &lt;br /&gt;
+   'Bookmarkrating' =&amp;gt; 'Bookmarkrating', &lt;br /&gt;
+   'Assignments' =&amp;gt; 'Assignments' &lt;br /&gt;
+ } &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Removed''' goto_assignments method:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
- # direct access to assignments &lt;br /&gt;
- def goto_assignments &lt;br /&gt;
-   node_object = TreeFolder.find_by_name('Assignments') &lt;br /&gt;
-   session[:root] = FolderNode.find_by_node_object_id(node_object.id).id &lt;br /&gt;
-   redirect_to :controller =&amp;gt; 'tree_display', :action =&amp;gt; 'list' &lt;br /&gt;
- end &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Added''' index method:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
+ def index &lt;br /&gt;
+   session[:root] = params[:root] &lt;br /&gt;
+   group = getGroup session[:menu] &lt;br /&gt;
+   node_object = TreeFolder.find_by_name(group) &lt;br /&gt;
+   if not group.blank? and not node_object.blank? &lt;br /&gt;
+     session[:root] = FolderNode.find_by_node_object_id(node_object.id).id &lt;br /&gt;
+ end &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==3) Use Routing Helpers==&lt;br /&gt;
We refactored the tree display controller class to use route helpers rather than calling &amp;quot;:action =&amp;gt; 'list', :controller =&amp;gt; 'tree_display'&amp;quot;, or something similar. This involved many edits in the tree_display_controller.rb file and related controller and view files. As seen below, we utilized routing helpers and replaced '' ':controller=&amp;gt;'course', :action=&amp;gt;'new', :private =&amp;gt; 0'' with ''new_course_path(private: 0)''.&lt;br /&gt;
&lt;br /&gt;
'''_courses_folder_actions.html.erb''' changes:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;ul&amp;gt; &lt;br /&gt;
   &amp;lt;div&amp;gt; &lt;br /&gt;
   &amp;lt;%= link_to image_tag('/assets/tree_view/add-public-24.png'), &lt;br /&gt;
  - { :controller=&amp;gt;'course', :action=&amp;gt;'new', :private =&amp;gt; 0 }, &lt;br /&gt;
  - { :title =&amp;gt; 'Create Public Course', id: 'create-public-course' } %&amp;gt; &lt;br /&gt;
  + new_course_path(private: 0), &lt;br /&gt;
  + { title: 'Create Public Course', id: 'create-public-course' } %&amp;gt; &lt;br /&gt;
   &amp;lt;%= link_to image_tag('/assets/tree_view/add-private-24.png'), &lt;br /&gt;
  - { :controller=&amp;gt;'course', :action=&amp;gt;'new', :private =&amp;gt; 1 }, &lt;br /&gt;
  - { :title =&amp;gt; 'Create Private Course', id: 'create-private-course' } %&amp;gt; &lt;br /&gt;
  + new_course_path(private: 1), &lt;br /&gt;
  + { title: 'Create Private Course', id: 'create-private-course' } %&amp;gt; &lt;br /&gt;
   &amp;lt;/div&amp;gt; &lt;br /&gt;
   &amp;lt;/ul&amp;gt; &lt;br /&gt;
   &amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt; &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Another example of routing helpers in '''_bread_crumbs.html.erb'''. &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Before:'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;%= link_to curr_node.get_name, :controller =&amp;gt; 'tree_display', :action =&amp;gt; 'drill', :root =&amp;gt; curr_node.id %&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''After''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;%= link_to curr_node.get_name, tree_display_index_path(root: curr_node.id)%&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==4) Minimizing the count of Instance Variables==&lt;br /&gt;
=== Instance Variables in Ruby ===&lt;br /&gt;
An instance variable has a name beginning with @, and its scope is confined to whatever object self refers to. Two different objects, even if they belong to the same class, are allowed to have different values for their instance variables. From outside the object, instance variables cannot be altered or even observed (i.e., ruby's instance variables are never public) except by whatever methods are explicitly provided by the programmer. As with globals, instance variables have the nil value until they are initialized.&lt;br /&gt;
&lt;br /&gt;
Instance variables do not need to be declared. This indicates a flexible object structure; in fact, each instance variable is dynamically appended to an object when it is first assigned.&lt;br /&gt;
&lt;br /&gt;
We have observed that in Expertiza, there were several code files related to the Tree Display controller which were observed to be using multiple instance variables which could be reduced. Our team aimed to limit the instantiation of such variables to only necessary places in our code.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The following was added to the ''index'' function of '''tree_display_controller.rb''' in order to replace the use of instance variables with local variables:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
locals  search:       @search,&lt;br /&gt;
        sortvar:      @sortvar,&lt;br /&gt;
        sortorder:    @sortorder,&lt;br /&gt;
        root_node:    @root_node,&lt;br /&gt;
        child_nodes:  @child_nodes,&lt;br /&gt;
        filternode:   params[:filternode],&lt;br /&gt;
        searchnode:   params[:searchnode]&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Many of the view files were changed to make use of the local variables. &lt;br /&gt;
&lt;br /&gt;
Here is an example of how _bread_crumbs.html.erb was changed. Note the removal of the &amp;quot;@&amp;quot; characters.&lt;br /&gt;
&lt;br /&gt;
'''Before:'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;% if @root_node %&amp;gt;&lt;br /&gt;
   &amp;lt;%= link_to &amp;quot;Return to top&amp;quot;, tree_display_index_path %&amp;gt;&lt;br /&gt;
   &amp;lt;%&lt;br /&gt;
      curr_node = @root_node&lt;br /&gt;
   while curr_node.parent_id&lt;br /&gt;
     curr_node = Node.find(curr_node.parent_id) %&amp;gt;&lt;br /&gt;
   &amp;amp;nbsp;&amp;amp;nbsp;&lt;br /&gt;
   &amp;lt;%= link_to curr_node.get_name, tree_display_index_path(root: curr_node.id)%&amp;gt;&lt;br /&gt;
 &amp;lt;% end %&amp;gt;&lt;br /&gt;
&amp;amp;nbsp;&amp;amp;nbsp;&amp;lt;%= @root_node.get_name %&amp;gt;&amp;lt;%&lt;br /&gt;
end %&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''After:'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;% if root_node %&amp;gt;&lt;br /&gt;
   &amp;lt;%= link_to &amp;quot;Return to top&amp;quot;, tree_display_index_path %&amp;gt;&lt;br /&gt;
   &amp;lt;%&lt;br /&gt;
      curr_node = root_node&lt;br /&gt;
   while curr_node.parent_id&lt;br /&gt;
     curr_node = Node.find(curr_node.parent_id) %&amp;gt;&lt;br /&gt;
   &amp;amp;nbsp;&amp;amp;nbsp;&lt;br /&gt;
   &amp;lt;%= link_to curr_node.get_name, tree_display_index_path(root: curr_node.id)%&amp;gt;&lt;br /&gt;
 &amp;lt;% end %&amp;gt;&lt;br /&gt;
&amp;amp;nbsp;&amp;amp;nbsp;&amp;lt;%= root_node.get_name %&amp;gt;&amp;lt;%&lt;br /&gt;
 end %&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Unexpected Database Changes=&lt;br /&gt;
&lt;br /&gt;
Unfortunately, each method of the tree_display controller has a reference to it stored in the database, along with a route.  Essentially, the routes are being stored in the database and a wildcard is used in the routes table to allow this to happen.  The following is a sample of some of the changes made (as part of tasks 1 and 2 given above) which were required in the db/seeds.rb file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
-ControllerAction.create(:site_controller_id =&amp;gt; SiteController.find_by_name('tree_display').id, :name =&amp;gt; 'goto_teammate_reviews', :permission_id =&amp;gt; nil, :url_to_use =&amp;gt; '')&lt;br /&gt;
-ControllerAction.create(:site_controller_id =&amp;gt; SiteController.find_by_name('tree_display').id, :name =&amp;gt; 'goto_metareview_rubrics', :permission_id =&amp;gt; nil, :url_to_use =&amp;gt; '')&lt;br /&gt;
-ControllerAction.create(:site_controller_id =&amp;gt; SiteController.find_by_name('tree_display').id, :name =&amp;gt; 'goto_teammatereview_rubrics', :permission_id =&amp;gt; nil, :url_to_use =&amp;gt; '')&lt;br /&gt;
+ControllerAction.create(:site_controller_id =&amp;gt; SiteController.find_by_name('tree_display').id, :name =&amp;gt; 'index', :permission_id =&amp;gt; nil, :url_to_use =&amp;gt; '')&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In addition, these name attributes are used in other tables, such as the menu_items table.  As a result, for every method in the tree_display_controller, changes like the following had to be made:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 MenuItem.create(:parent_id =&amp;gt; MenuItem.find_by_name('manage/questionnaires').id, :name =&amp;gt; 'manage/questionnaires/course evaluations', :label =&amp;gt; 'Course evaluations', :seq =&amp;gt; 7, :content_page_id =&amp;gt; nil,&lt;br /&gt;
-                :controller_action_id =&amp;gt; ControllerAction.where(site_controller_id: SiteController.find_by_name('tree_display').id, name:  'goto_surveys').first.id)&lt;br /&gt;
+                :controller_action_id =&amp;gt; ControllerAction.where(site_controller_id: SiteController.find_by_name('tree_display').id, name:  'index').first.id)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Instead, we believe it would be better for this to be defined in the routes file.  Having routes defined in the database is not transparent at all, and causes much confusion for developers that are new to the project - especially those which are new to Rails as well.  This should be inspected for possible future refactorings.&lt;br /&gt;
&lt;br /&gt;
=Conclusion=&lt;br /&gt;
In conclusion, we were able to successfully refactor the tree_display_controller and related controllers and views. We improved and expanded the use of RESTful and DRY design choices, implemented the use of routing helpers, ensured that instantiation of instance variables is minimized, and overall improved the quality and efficiency of the Expertiza codebase.&lt;/div&gt;</summary>
		<author><name>Jjbeaver</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/oss_E1463_vpd&amp;diff=91521</id>
		<title>CSC/ECE 517 Fall 2014/oss E1463 vpd</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/oss_E1463_vpd&amp;diff=91521"/>
		<updated>2014-11-06T05:08:39Z</updated>

		<summary type="html">&lt;p&gt;Jjbeaver: /* Refactoring TreeDisplayController Tasks */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= '''E1463: Refactoring TreeDisplayController''' =&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
=Project Links=&lt;br /&gt;
[http://ec2-54-186-80-176.us-west-2.compute.amazonaws.com:3000/ Our Expertiza Fork on AWS]&amp;lt;br&amp;gt;&lt;br /&gt;
[https://github.com/Druotic/expertiza Github Repo]&amp;lt;br&amp;gt;&lt;br /&gt;
[https://github.com/expertiza/expertiza/pull/449 Expertize Pull Request] &amp;lt;br&amp;gt;&lt;br /&gt;
[http://ec2-54-186-80-176.us-west-2.compute.amazonaws.com:3000/ Project Running on AWS]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Setup - How To View Our Expertiza Fork Running on AWS=&lt;br /&gt;
NOTE: The scope of our project was only to refactor select code. There are no feature additions or changes, so it should work just like production Expertiza.&lt;br /&gt;
&lt;br /&gt;
1) Go to [http://ec2-54-186-80-176.us-west-2.compute.amazonaws.com:3000/ our Expertiza project running on AWS]&lt;br /&gt;
&lt;br /&gt;
2) Login as Admin&amp;lt;br&amp;gt;&lt;br /&gt;
'''User:''' user2&amp;lt;br&amp;gt;&lt;br /&gt;
'''Password:''' password&lt;br /&gt;
&lt;br /&gt;
3) Click on &amp;quot;Manage...&amp;quot; if you are not automatically directed to the tree display.&lt;br /&gt;
&lt;br /&gt;
=Project Description=&lt;br /&gt;
&lt;br /&gt;
For this project, our team refactored the TreeDisplayController class in the [http://expertiza.ncsu.edu/ Expertiza] OSS project. This class provides access to questionnaires, review rubrics, author feedback, courses, assignments, and course evaluations. The tree display lists all of these categories with the ability for the user to &amp;quot;drill down&amp;quot; into the subcategories or just expand/collapse as needed.&lt;br /&gt;
&lt;br /&gt;
'''Example Image Of Tree Display:&lt;br /&gt;
'''&lt;br /&gt;
[[File:Expertiza.PNG ]]&lt;br /&gt;
&lt;br /&gt;
=Refactoring TreeDisplayController Tasks=&lt;br /&gt;
&lt;br /&gt;
As part of the refactoring task, we had to address the following issues for enhancing code readability and maintainability. The tasks included:&lt;br /&gt;
#Changing List to Index using a [http://www.restapitutorial.com/lessons/whatisrest.html RESTful] approach.&lt;br /&gt;
#Combined all of the goto methods&lt;br /&gt;
#Use of [http://guides.rubyonrails.org/routing.html#path-and-url-helpers routing helpers]&lt;br /&gt;
#Ensuring that instantiation of instance variables is minimized.&lt;br /&gt;
&lt;br /&gt;
In the end, we enhanced this list a bit and resulted in doing the following: 		&lt;br /&gt;
#Changed `list` method to `index`	&lt;br /&gt;
#Removed all of the `goto` methods and `drill`, and had them go through `index` instead because they are essentially just filtered versions of a listing (and the previous implementation just redirected each `goto` back to `list` anyway)	&lt;br /&gt;
#Used path helpers where possible	&lt;br /&gt;
#Removed instance variables and used local variables instead.  This should be better for scope reasons.  Note that there are still 1-2 instance variables used in the view, `@show` and `@assignment` which don't appear to be used anywhere.  (`@show` doesn't seem to ever be set, `@assignment` seems to only be used locally)  However, we didn't touch this because it didn't deal directly with our changes to the controller.	&lt;br /&gt;
#Introduced some local variables as params to the view which allow dropdowns to keep their selected option after the page reloads (the logic was there before, but it was using instance variables which were never set!). This is for the search/filtering options on the &amp;quot;Manage...&amp;quot; screen.&lt;br /&gt;
&lt;br /&gt;
==1) Changing List to Index==&lt;br /&gt;
&lt;br /&gt;
In order to make the codebase more [http://www.restapitutorial.com/lessons/whatisrest.html RESTful], we have replaced all the controller action redirections with a tree_display_index_path which enormously reduces the code content and as well as provides an organized approach to action redirections. &lt;br /&gt;
&lt;br /&gt;
[[File:List_to_Index.png]]&lt;br /&gt;
&lt;br /&gt;
As seen below, we were able to '''remove''' list from Routes.rb:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
resources :tree_display do &lt;br /&gt;
collection do &lt;br /&gt;
  get ':action' &lt;br /&gt;
    - post 'list' &lt;br /&gt;
  end &lt;br /&gt;
end &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==2) Combined All of the Goto Methods==&lt;br /&gt;
We also combined all of the goto methods into one, in accordance with the [http://en.wikipedia.org/wiki/Don't_repeat_yourself DRY] principle. This removed a significant amount of duplicate code.&lt;br /&gt;
&lt;br /&gt;
Shown below are 3 of the 10 very similar methods we removed from '''tree_display_controller.rb''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
- # direct access to questionnaires &lt;br /&gt;
- def goto_questionnaires &lt;br /&gt;
- node_object = TreeFolder.find_by_name('Questionnaires') &lt;br /&gt;
- session[:root] = FolderNode.find_by_node_object_id(node_object.id).id &lt;br /&gt;
- redirect_to :controller =&amp;gt; 'tree_display', :action =&amp;gt; 'list' &lt;br /&gt;
- end &lt;br /&gt;
- &lt;br /&gt;
- # direct access to review rubrics &lt;br /&gt;
- def goto_review_rubrics &lt;br /&gt;
- node_object = TreeFolder.find_by_name('Review') &lt;br /&gt;
- session[:root] = FolderNode.find_by_node_object_id(node_object.id).id &lt;br /&gt;
- redirect_to :controller =&amp;gt; 'tree_display', :action =&amp;gt; 'list' &lt;br /&gt;
- end &lt;br /&gt;
- &lt;br /&gt;
- # direct access to metareview rubrics &lt;br /&gt;
- def goto_metareview_rubrics &lt;br /&gt;
- node_object = TreeFolder.find_by_name('Metareview') &lt;br /&gt;
- session[:root] = FolderNode.find_by_node_object_id(node_object.id).id &lt;br /&gt;
- redirect_to :controller =&amp;gt; 'tree_display', :action =&amp;gt; 'list' &lt;br /&gt;
- end &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
These methods were replaced by a variable containing a list mapping all the session variable strings to database labels. The goto_assignments method was replaced with an index method to accept this variable, rather then calling each goto method individually.&lt;br /&gt;
&lt;br /&gt;
'''Added''' variable:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
+ @@Groups = { &lt;br /&gt;
+   'Questionnaires' =&amp;gt; 'Questionnaires', &lt;br /&gt;
+   'Review rubrics' =&amp;gt; 'Review', &lt;br /&gt;
+   'Metareview rubrics' =&amp;gt; 'Metareview', &lt;br /&gt;
+   'Teammate review rubrics' =&amp;gt; 'Teammate Review', &lt;br /&gt;
+   'Author feedbacks' =&amp;gt; 'Author Feedback', &lt;br /&gt;
+   'Global survey' =&amp;gt; 'Global Survey', &lt;br /&gt;
+   'Surveys' =&amp;gt; 'Survey', &lt;br /&gt;
+   'Course evaluations' =&amp;gt; 'Course Evaluation', &lt;br /&gt;
+   'Courses' =&amp;gt; 'Courses', &lt;br /&gt;
+   'Bookmarkrating' =&amp;gt; 'Bookmarkrating', &lt;br /&gt;
+   'Assignments' =&amp;gt; 'Assignments' &lt;br /&gt;
+ } &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Removed''' goto_assignments method:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
- # direct access to assignments &lt;br /&gt;
- def goto_assignments &lt;br /&gt;
-   node_object = TreeFolder.find_by_name('Assignments') &lt;br /&gt;
-   session[:root] = FolderNode.find_by_node_object_id(node_object.id).id &lt;br /&gt;
-   redirect_to :controller =&amp;gt; 'tree_display', :action =&amp;gt; 'list' &lt;br /&gt;
- end &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Added''' index method:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
+ def index &lt;br /&gt;
+   session[:root] = params[:root] &lt;br /&gt;
+   group = getGroup session[:menu] &lt;br /&gt;
+   node_object = TreeFolder.find_by_name(group) &lt;br /&gt;
+   if not group.blank? and not node_object.blank? &lt;br /&gt;
+     session[:root] = FolderNode.find_by_node_object_id(node_object.id).id &lt;br /&gt;
+ end &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==3) Use Routing Helpers==&lt;br /&gt;
We refactored the tree display controller class to use route helpers rather than calling &amp;quot;:action =&amp;gt; 'list', :controller =&amp;gt; 'tree_display'&amp;quot;, or something similar. This involved many edits in the tree_display_controller.rb file and related controller and view files. As seen below, we utilized routing helpers and replaced '' ':controller=&amp;gt;'course', :action=&amp;gt;'new', :private =&amp;gt; 0'' with ''new_course_path(private: 0)''.&lt;br /&gt;
&lt;br /&gt;
'''_courses_folder_actions.html.erb''' changes:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;ul&amp;gt; &lt;br /&gt;
   &amp;lt;div&amp;gt; &lt;br /&gt;
   &amp;lt;%= link_to image_tag('/assets/tree_view/add-public-24.png'), &lt;br /&gt;
  - { :controller=&amp;gt;'course', :action=&amp;gt;'new', :private =&amp;gt; 0 }, &lt;br /&gt;
  - { :title =&amp;gt; 'Create Public Course', id: 'create-public-course' } %&amp;gt; &lt;br /&gt;
  + new_course_path(private: 0), &lt;br /&gt;
  + { title: 'Create Public Course', id: 'create-public-course' } %&amp;gt; &lt;br /&gt;
   &amp;lt;%= link_to image_tag('/assets/tree_view/add-private-24.png'), &lt;br /&gt;
  - { :controller=&amp;gt;'course', :action=&amp;gt;'new', :private =&amp;gt; 1 }, &lt;br /&gt;
  - { :title =&amp;gt; 'Create Private Course', id: 'create-private-course' } %&amp;gt; &lt;br /&gt;
  + new_course_path(private: 1), &lt;br /&gt;
  + { title: 'Create Private Course', id: 'create-private-course' } %&amp;gt; &lt;br /&gt;
   &amp;lt;/div&amp;gt; &lt;br /&gt;
   &amp;lt;/ul&amp;gt; &lt;br /&gt;
   &amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt; &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Another example of routing helpers in '''_bread_crumbs.html.erb'''. &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Before:'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;%= link_to curr_node.get_name, :controller =&amp;gt; 'tree_display', :action =&amp;gt; 'drill', :root =&amp;gt; curr_node.id %&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''After''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;%= link_to curr_node.get_name, tree_display_index_path(root: curr_node.id)%&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==4) Minimizing the count of Instance Variables==&lt;br /&gt;
=== Instance Variables in Ruby ===&lt;br /&gt;
An instance variable has a name beginning with @, and its scope is confined to whatever object self refers to. Two different objects, even if they belong to the same class, are allowed to have different values for their instance variables. From outside the object, instance variables cannot be altered or even observed (i.e., ruby's instance variables are never public) except by whatever methods are explicitly provided by the programmer. As with globals, instance variables have the nil value until they are initialized.&lt;br /&gt;
&lt;br /&gt;
Instance variables do not need to be declared. This indicates a flexible object structure; in fact, each instance variable is dynamically appended to an object when it is first assigned.&lt;br /&gt;
&lt;br /&gt;
We have observed that in Expertiza, there were several code files related to the Tree Display controller which were observed to be using multiple instance variables which could be reduced. Our team aimed to limit the instantiation of such variables to only necessary places in our code.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The following was added to the ''index'' function of '''tree_display_controller.rb''' in order to replace the use of instance variables with local variables:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
locals  search:       @search,&lt;br /&gt;
        sortvar:      @sortvar,&lt;br /&gt;
        sortorder:    @sortorder,&lt;br /&gt;
        root_node:    @root_node,&lt;br /&gt;
        child_nodes:  @child_nodes,&lt;br /&gt;
        filternode:   params[:filternode],&lt;br /&gt;
        searchnode:   params[:searchnode]&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Many of the view files were changed to make use of the local variables. &lt;br /&gt;
&lt;br /&gt;
Here is an example of how _bread_crumbs.html.erb was changed. Note the removal of the &amp;quot;@&amp;quot; characters.&lt;br /&gt;
&lt;br /&gt;
'''Before:'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;% if @root_node %&amp;gt;&lt;br /&gt;
   &amp;lt;%= link_to &amp;quot;Return to top&amp;quot;, tree_display_index_path %&amp;gt;&lt;br /&gt;
   &amp;lt;%&lt;br /&gt;
      curr_node = @root_node&lt;br /&gt;
   while curr_node.parent_id&lt;br /&gt;
     curr_node = Node.find(curr_node.parent_id) %&amp;gt;&lt;br /&gt;
   &amp;amp;nbsp;&amp;amp;nbsp;&lt;br /&gt;
   &amp;lt;%= link_to curr_node.get_name, tree_display_index_path(root: curr_node.id)%&amp;gt;&lt;br /&gt;
 &amp;lt;% end %&amp;gt;&lt;br /&gt;
&amp;amp;nbsp;&amp;amp;nbsp;&amp;lt;%= @root_node.get_name %&amp;gt;&amp;lt;%&lt;br /&gt;
end %&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''After:'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;% if root_node %&amp;gt;&lt;br /&gt;
   &amp;lt;%= link_to &amp;quot;Return to top&amp;quot;, tree_display_index_path %&amp;gt;&lt;br /&gt;
   &amp;lt;%&lt;br /&gt;
      curr_node = root_node&lt;br /&gt;
   while curr_node.parent_id&lt;br /&gt;
     curr_node = Node.find(curr_node.parent_id) %&amp;gt;&lt;br /&gt;
   &amp;amp;nbsp;&amp;amp;nbsp;&lt;br /&gt;
   &amp;lt;%= link_to curr_node.get_name, tree_display_index_path(root: curr_node.id)%&amp;gt;&lt;br /&gt;
 &amp;lt;% end %&amp;gt;&lt;br /&gt;
&amp;amp;nbsp;&amp;amp;nbsp;&amp;lt;%= root_node.get_name %&amp;gt;&amp;lt;%&lt;br /&gt;
 end %&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Unexpected Database Changes=&lt;br /&gt;
&lt;br /&gt;
Unfortunately, each method of the tree_display controller has a reference to it stored in the database, along with a route.  Essentially, the routes are being stored in the database and a wildcard is used in the routes table to allow this to happen.  The following is a sample of some of the changes made (as part of tasks 1 and 2 given above) which were required in the db/seeds.rb file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
-ControllerAction.create(:site_controller_id =&amp;gt; SiteController.find_by_name('tree_display').id, :name =&amp;gt; 'goto_teammate_reviews', :permission_id =&amp;gt; nil, :url_to_use =&amp;gt; '')&lt;br /&gt;
-ControllerAction.create(:site_controller_id =&amp;gt; SiteController.find_by_name('tree_display').id, :name =&amp;gt; 'goto_metareview_rubrics', :permission_id =&amp;gt; nil, :url_to_use =&amp;gt; '')&lt;br /&gt;
-ControllerAction.create(:site_controller_id =&amp;gt; SiteController.find_by_name('tree_display').id, :name =&amp;gt; 'goto_teammatereview_rubrics', :permission_id =&amp;gt; nil, :url_to_use =&amp;gt; '')&lt;br /&gt;
+ControllerAction.create(:site_controller_id =&amp;gt; SiteController.find_by_name('tree_display').id, :name =&amp;gt; 'index', :permission_id =&amp;gt; nil, :url_to_use =&amp;gt; '')&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In addition, these names are used in other tables, such as the menu_items table.  As a result, changes like the following had to be made for each of the methods in the TreeDisplayController.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 MenuItem.create(:parent_id =&amp;gt; MenuItem.find_by_name('manage/questionnaires').id, :name =&amp;gt; 'manage/questionnaires/course evaluations', :label =&amp;gt; 'Course evaluations', :seq =&amp;gt; 7, :content_page_id =&amp;gt; nil,&lt;br /&gt;
-                :controller_action_id =&amp;gt; ControllerAction.where(site_controller_id: SiteController.find_by_name('tree_display').id, name:  'goto_surveys').first.id)&lt;br /&gt;
+                :controller_action_id =&amp;gt; ControllerAction.where(site_controller_id: SiteController.find_by_name('tree_display').id, name:  'index').first.id)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Instead, we believe it would be better for this to be defined in the routes file.  Having routes defined in the database is not transparent at all, and causes much confusion for developers that are new to the project - especially those which are new to Rails as well.  This should be inspected for possible future refactorings.&lt;br /&gt;
&lt;br /&gt;
=Conclusion=&lt;br /&gt;
In conclusion, we were able to successfully refactor the tree_display_controller and related controllers and views. We improved and expanded the use of RESTful and DRY design choices, implemented the use of routing helpers, ensured that instantiation of instance variables is minimized, and overall improved the quality and efficiency of the Expertiza codebase.&lt;/div&gt;</summary>
		<author><name>Jjbeaver</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/oss_E1463_vpd&amp;diff=91514</id>
		<title>CSC/ECE 517 Fall 2014/oss E1463 vpd</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/oss_E1463_vpd&amp;diff=91514"/>
		<updated>2014-11-06T04:48:55Z</updated>

		<summary type="html">&lt;p&gt;Jjbeaver: /* Refactoring TreeDisplayController Tasks */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= '''E1463: Refactoring TreeDisplayController''' =&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
=Project Links=&lt;br /&gt;
[http://ec2-54-186-80-176.us-west-2.compute.amazonaws.com:3000/ Our Expertiza Fork on AWS]&amp;lt;br&amp;gt;&lt;br /&gt;
[https://github.com/Druotic/expertiza Github Repo]&amp;lt;br&amp;gt;&lt;br /&gt;
[https://github.com/expertiza/expertiza/pull/449 Expertize Pull Request] &amp;lt;br&amp;gt;&lt;br /&gt;
[http://ec2-54-186-80-176.us-west-2.compute.amazonaws.com:3000/ Project Running on AWS]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Setup - How To View Our Expertiza Fork Running on AWS=&lt;br /&gt;
NOTE: The scope of our project was only to refactor select code. There are no feature additions or changes, so it should work just like production Expertiza.&lt;br /&gt;
&lt;br /&gt;
1) Go to [http://ec2-54-186-80-176.us-west-2.compute.amazonaws.com:3000/ our Expertiza project running on AWS]&lt;br /&gt;
&lt;br /&gt;
2) Login as Admin&amp;lt;br&amp;gt;&lt;br /&gt;
'''User:''' user2&amp;lt;br&amp;gt;&lt;br /&gt;
'''Password:''' password&lt;br /&gt;
&lt;br /&gt;
3) Click on &amp;quot;Manage...&amp;quot; if you are not automatically directed to the tree display.&lt;br /&gt;
&lt;br /&gt;
=Project Description=&lt;br /&gt;
&lt;br /&gt;
For this project, our team refactored the TreeDisplayController class in the [http://expertiza.ncsu.edu/ Expertiza] OSS project. This class provides access to questionnaires, review rubrics, author feedback, courses, assignments, and course evaluations. The tree display lists all of these categories with the ability for the user to &amp;quot;drill down&amp;quot; into the subcategories or just expand/collapse as needed.&lt;br /&gt;
&lt;br /&gt;
'''Example Image Of Tree Display:&lt;br /&gt;
'''&lt;br /&gt;
[[File:Expertiza.PNG ]]&lt;br /&gt;
&lt;br /&gt;
=Refactoring TreeDisplayController Tasks=&lt;br /&gt;
&lt;br /&gt;
As part of the refactoring task, we had to address the following issues for enhancing code readability and maintainability. The tasks included:&lt;br /&gt;
#Changing List to Index using a [http://www.restapitutorial.com/lessons/whatisrest.html RESTful] approach.&lt;br /&gt;
#Combined all of the goto methods&lt;br /&gt;
#Use of [http://guides.rubyonrails.org/routing.html#path-and-url-helpers routing helpers]&lt;br /&gt;
#Ensuring that instantiation of instance variables is minimized.&lt;br /&gt;
&lt;br /&gt;
In the end, we enhanced this list a bit and resulted in doing the following: 		&lt;br /&gt;
#Changed `list` method to `index`	&lt;br /&gt;
#Removed all of the `goto` methods and `drill`, and had them go through `index` instead because they are essentially just filtered versions of a listing (and the previous implementation just redirected each `goto` back to `list` anyway)	&lt;br /&gt;
#Used path helpers where possible	&lt;br /&gt;
#Removed instance variables and used local variables instead.  This should be better for scope reasons.  Note that there are still 1-2 instance variables used in the view, `@show` and `@assignment` which don't appear to be used anywhere.  (`@show` doesn't seem to ever be set, `@assignment` seems to only be used locally)  However, we didn't touch this because it didn't deal directly with our changes to the controller.	&lt;br /&gt;
#Introduced some local variables as params to the view which allow dropdowns to keep their selected option after the page reloads (the logic was there before, but it was using instance variables which were never set!). This is for the search/filtering options on the &amp;quot;Manage...&amp;quot; screen.&lt;br /&gt;
&lt;br /&gt;
==1) Changing List to Index==&lt;br /&gt;
&lt;br /&gt;
In order to make the codebase more [http://www.restapitutorial.com/lessons/whatisrest.html RESTful], we have replaced all the controller action redirections with a tree_display_index_path which enormously reduces the code content and as well as provides an organized approach to action redirections. &lt;br /&gt;
&lt;br /&gt;
[[File:List_to_Index.png]]&lt;br /&gt;
&lt;br /&gt;
As seen below, we were able to '''remove''' list from Routes.rb:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
resources :tree_display do &lt;br /&gt;
collection do &lt;br /&gt;
  get ':action' &lt;br /&gt;
    - post 'list' &lt;br /&gt;
  end &lt;br /&gt;
end &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==2) Combined All of the Goto Methods==&lt;br /&gt;
We also combined all of the goto methods into one, in accordance with the [http://en.wikipedia.org/wiki/Don't_repeat_yourself DRY] principle. This removed a significant amount of duplicate code.&lt;br /&gt;
&lt;br /&gt;
Shown below are 3 of the 10 very similar methods we removed from '''tree_display_controller.rb''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
- # direct access to questionnaires &lt;br /&gt;
- def goto_questionnaires &lt;br /&gt;
- node_object = TreeFolder.find_by_name('Questionnaires') &lt;br /&gt;
- session[:root] = FolderNode.find_by_node_object_id(node_object.id).id &lt;br /&gt;
- redirect_to :controller =&amp;gt; 'tree_display', :action =&amp;gt; 'list' &lt;br /&gt;
- end &lt;br /&gt;
- &lt;br /&gt;
- # direct access to review rubrics &lt;br /&gt;
- def goto_review_rubrics &lt;br /&gt;
- node_object = TreeFolder.find_by_name('Review') &lt;br /&gt;
- session[:root] = FolderNode.find_by_node_object_id(node_object.id).id &lt;br /&gt;
- redirect_to :controller =&amp;gt; 'tree_display', :action =&amp;gt; 'list' &lt;br /&gt;
- end &lt;br /&gt;
- &lt;br /&gt;
- # direct access to metareview rubrics &lt;br /&gt;
- def goto_metareview_rubrics &lt;br /&gt;
- node_object = TreeFolder.find_by_name('Metareview') &lt;br /&gt;
- session[:root] = FolderNode.find_by_node_object_id(node_object.id).id &lt;br /&gt;
- redirect_to :controller =&amp;gt; 'tree_display', :action =&amp;gt; 'list' &lt;br /&gt;
- end &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
These methods were replaced by a variable containing a list mapping all the session variable strings to database labels. The goto_assignments method was replaced with an index method to accept this variable, rather then calling each goto method individually.&lt;br /&gt;
&lt;br /&gt;
'''Added''' variable:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
+ @@Groups = { &lt;br /&gt;
+   'Questionnaires' =&amp;gt; 'Questionnaires', &lt;br /&gt;
+   'Review rubrics' =&amp;gt; 'Review', &lt;br /&gt;
+   'Metareview rubrics' =&amp;gt; 'Metareview', &lt;br /&gt;
+   'Teammate review rubrics' =&amp;gt; 'Teammate Review', &lt;br /&gt;
+   'Author feedbacks' =&amp;gt; 'Author Feedback', &lt;br /&gt;
+   'Global survey' =&amp;gt; 'Global Survey', &lt;br /&gt;
+   'Surveys' =&amp;gt; 'Survey', &lt;br /&gt;
+   'Course evaluations' =&amp;gt; 'Course Evaluation', &lt;br /&gt;
+   'Courses' =&amp;gt; 'Courses', &lt;br /&gt;
+   'Bookmarkrating' =&amp;gt; 'Bookmarkrating', &lt;br /&gt;
+   'Assignments' =&amp;gt; 'Assignments' &lt;br /&gt;
+ } &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Removed''' goto_assignments method:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
- # direct access to assignments &lt;br /&gt;
- def goto_assignments &lt;br /&gt;
-   node_object = TreeFolder.find_by_name('Assignments') &lt;br /&gt;
-   session[:root] = FolderNode.find_by_node_object_id(node_object.id).id &lt;br /&gt;
-   redirect_to :controller =&amp;gt; 'tree_display', :action =&amp;gt; 'list' &lt;br /&gt;
- end &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Added''' index method:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
+ def index &lt;br /&gt;
+   session[:root] = params[:root] &lt;br /&gt;
+   group = getGroup session[:menu] &lt;br /&gt;
+   node_object = TreeFolder.find_by_name(group) &lt;br /&gt;
+   if not group.blank? and not node_object.blank? &lt;br /&gt;
+     session[:root] = FolderNode.find_by_node_object_id(node_object.id).id &lt;br /&gt;
+ end &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==3) Use Routing Helpers==&lt;br /&gt;
We refactored the tree display controller class to use route helpers rather than calling &amp;quot;:action =&amp;gt; 'list', :controller =&amp;gt; 'tree_display'&amp;quot;, or something similar. This involved many edits in the tree_display_controller.rb file and related controller and view files. As seen below, we utilized routing helpers and replaced '' ':controller=&amp;gt;'course', :action=&amp;gt;'new', :private =&amp;gt; 0'' with ''new_course_path(private: 0)''.&lt;br /&gt;
&lt;br /&gt;
'''_courses_folder_actions.html.erb''' changes:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;ul&amp;gt; &lt;br /&gt;
   &amp;lt;div&amp;gt; &lt;br /&gt;
   &amp;lt;%= link_to image_tag('/assets/tree_view/add-public-24.png'), &lt;br /&gt;
  - { :controller=&amp;gt;'course', :action=&amp;gt;'new', :private =&amp;gt; 0 }, &lt;br /&gt;
  - { :title =&amp;gt; 'Create Public Course', id: 'create-public-course' } %&amp;gt; &lt;br /&gt;
  + new_course_path(private: 0), &lt;br /&gt;
  + { title: 'Create Public Course', id: 'create-public-course' } %&amp;gt; &lt;br /&gt;
   &amp;lt;%= link_to image_tag('/assets/tree_view/add-private-24.png'), &lt;br /&gt;
  - { :controller=&amp;gt;'course', :action=&amp;gt;'new', :private =&amp;gt; 1 }, &lt;br /&gt;
  - { :title =&amp;gt; 'Create Private Course', id: 'create-private-course' } %&amp;gt; &lt;br /&gt;
  + new_course_path(private: 1), &lt;br /&gt;
  + { title: 'Create Private Course', id: 'create-private-course' } %&amp;gt; &lt;br /&gt;
   &amp;lt;/div&amp;gt; &lt;br /&gt;
   &amp;lt;/ul&amp;gt; &lt;br /&gt;
   &amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt; &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Another example of routing helpers in '''_bread_crumbs.html.erb'''. &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Before:'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;%= link_to curr_node.get_name, :controller =&amp;gt; 'tree_display', :action =&amp;gt; 'drill', :root =&amp;gt; curr_node.id %&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''After''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;%= link_to curr_node.get_name, tree_display_index_path(root: curr_node.id)%&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==4) Minimizing the count of Instance Variables==&lt;br /&gt;
=== Instance Variables in Ruby ===&lt;br /&gt;
An instance variable has a name beginning with @, and its scope is confined to whatever object self refers to. Two different objects, even if they belong to the same class, are allowed to have different values for their instance variables. From outside the object, instance variables cannot be altered or even observed (i.e., ruby's instance variables are never public) except by whatever methods are explicitly provided by the programmer. As with globals, instance variables have the nil value until they are initialized.&lt;br /&gt;
&lt;br /&gt;
Instance variables do not need to be declared. This indicates a flexible object structure; in fact, each instance variable is dynamically appended to an object when it is first assigned.&lt;br /&gt;
&lt;br /&gt;
We have observed that in Expertiza, there were several code files related to the Tree Display controller which were observed to be using multiple instance variables which could be reduced. Our team aimed to limit the instantiation of such variables to only necessary places in our code.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The following was added to the ''index'' function of '''tree_display_controller.rb''' in order to replace the use of instance variables with local variables:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
locals  search:       @search,&lt;br /&gt;
        sortvar:      @sortvar,&lt;br /&gt;
        sortorder:    @sortorder,&lt;br /&gt;
        root_node:    @root_node,&lt;br /&gt;
        child_nodes:  @child_nodes,&lt;br /&gt;
        filternode:   params[:filternode],&lt;br /&gt;
        searchnode:   params[:searchnode]&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Many of the view files were changed to make use of the local variables. &lt;br /&gt;
&lt;br /&gt;
Here is an example of how _bread_crumbs.html.erb was changed. Note the removal of the &amp;quot;@&amp;quot; characters.&lt;br /&gt;
&lt;br /&gt;
'''Before:'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;% if @root_node %&amp;gt;&lt;br /&gt;
   &amp;lt;%= link_to &amp;quot;Return to top&amp;quot;, tree_display_index_path %&amp;gt;&lt;br /&gt;
   &amp;lt;%&lt;br /&gt;
      curr_node = @root_node&lt;br /&gt;
   while curr_node.parent_id&lt;br /&gt;
     curr_node = Node.find(curr_node.parent_id) %&amp;gt;&lt;br /&gt;
   &amp;amp;nbsp;&amp;amp;nbsp;&lt;br /&gt;
   &amp;lt;%= link_to curr_node.get_name, tree_display_index_path(root: curr_node.id)%&amp;gt;&lt;br /&gt;
 &amp;lt;% end %&amp;gt;&lt;br /&gt;
&amp;amp;nbsp;&amp;amp;nbsp;&amp;lt;%= @root_node.get_name %&amp;gt;&amp;lt;%&lt;br /&gt;
end %&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''After:'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;% if root_node %&amp;gt;&lt;br /&gt;
   &amp;lt;%= link_to &amp;quot;Return to top&amp;quot;, tree_display_index_path %&amp;gt;&lt;br /&gt;
   &amp;lt;%&lt;br /&gt;
      curr_node = root_node&lt;br /&gt;
   while curr_node.parent_id&lt;br /&gt;
     curr_node = Node.find(curr_node.parent_id) %&amp;gt;&lt;br /&gt;
   &amp;amp;nbsp;&amp;amp;nbsp;&lt;br /&gt;
   &amp;lt;%= link_to curr_node.get_name, tree_display_index_path(root: curr_node.id)%&amp;gt;&lt;br /&gt;
 &amp;lt;% end %&amp;gt;&lt;br /&gt;
&amp;amp;nbsp;&amp;amp;nbsp;&amp;lt;%= root_node.get_name %&amp;gt;&amp;lt;%&lt;br /&gt;
 end %&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Conclusion=&lt;br /&gt;
In conclusion, we were able to successfully refactor the tree_display_controller and related controllers and views. We improved and expanded the use of RESTful and DRY design choices, implemented the use of routing helpers, ensured that instantiation of instance variables is minimized, and overall improved the quality and efficiency of the Expertiza codebase.&lt;/div&gt;</summary>
		<author><name>Jjbeaver</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/oss_E1463_vpd&amp;diff=91513</id>
		<title>CSC/ECE 517 Fall 2014/oss E1463 vpd</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/oss_E1463_vpd&amp;diff=91513"/>
		<updated>2014-11-06T04:47:56Z</updated>

		<summary type="html">&lt;p&gt;Jjbeaver: /* Refactoring TreeDisplayController Tasks */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= '''E1463: Refactoring TreeDisplayController''' =&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
=Project Links=&lt;br /&gt;
[http://ec2-54-186-80-176.us-west-2.compute.amazonaws.com:3000/ Our Expertiza Fork on AWS]&amp;lt;br&amp;gt;&lt;br /&gt;
[https://github.com/Druotic/expertiza Github Repo]&amp;lt;br&amp;gt;&lt;br /&gt;
[https://github.com/expertiza/expertiza/pull/449 Expertize Pull Request] &amp;lt;br&amp;gt;&lt;br /&gt;
[http://ec2-54-186-80-176.us-west-2.compute.amazonaws.com:3000/ Project Running on AWS]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Setup - How To View Our Expertiza Fork Running on AWS=&lt;br /&gt;
NOTE: The scope of our project was only to refactor select code. There are no feature additions or changes, so it should work just like production Expertiza.&lt;br /&gt;
&lt;br /&gt;
1) Go to [http://ec2-54-186-80-176.us-west-2.compute.amazonaws.com:3000/ our Expertiza project running on AWS]&lt;br /&gt;
&lt;br /&gt;
2) Login as Admin&amp;lt;br&amp;gt;&lt;br /&gt;
'''User:''' user2&amp;lt;br&amp;gt;&lt;br /&gt;
'''Password:''' password&lt;br /&gt;
&lt;br /&gt;
3) Click on &amp;quot;Manage...&amp;quot; if you are not automatically directed to the tree display.&lt;br /&gt;
&lt;br /&gt;
=Project Description=&lt;br /&gt;
&lt;br /&gt;
For this project, our team refactored the TreeDisplayController class in the [http://expertiza.ncsu.edu/ Expertiza] OSS project. This class provides access to questionnaires, review rubrics, author feedback, courses, assignments, and course evaluations. The tree display lists all of these categories with the ability for the user to &amp;quot;drill down&amp;quot; into the subcategories or just expand/collapse as needed.&lt;br /&gt;
&lt;br /&gt;
'''Example Image Of Tree Display:&lt;br /&gt;
'''&lt;br /&gt;
[[File:Expertiza.PNG ]]&lt;br /&gt;
&lt;br /&gt;
=Refactoring TreeDisplayController Tasks=&lt;br /&gt;
&lt;br /&gt;
As part of the refactoring task, we had to address the following issues for enhancing code readability and maintainability. The tasks included:&lt;br /&gt;
#Changing List to Index using a [http://www.restapitutorial.com/lessons/whatisrest.html RESTful] approach.&lt;br /&gt;
#Combined all of the goto methods&lt;br /&gt;
#Use of [http://guides.rubyonrails.org/routing.html#path-and-url-helpers routing helpers]&lt;br /&gt;
#Ensuring that instantiation of instance variables is minimized.&lt;br /&gt;
&lt;br /&gt;
In the end, we enhanced this list a bit and resulted in doing the following: 		&lt;br /&gt;
#Changed `list` method to `index`&lt;br /&gt;
#Removed `drill` - combined with `index`	&lt;br /&gt;
#Removed all of the `goto` methods and had them go through `index` instead because they are essentially just filtered versions of a listing (and the previous implementation just redirected each `goto` back to `list` anyway)	&lt;br /&gt;
#Used path helpers where possible	&lt;br /&gt;
#Removed instance variables and used local variables instead.  This should be better for scope reasons.  Note that there are still 1-2 instance variables used in the view, `@show` and `@assignment` which don't appear to be used anywhere.  (`@show` doesn't seem to ever be set, `@assignment` seems to only be used locally)  However, we didn't touch this because it didn't deal directly with our changes to the controller.	&lt;br /&gt;
#Introduced some local variables as params to the view which allow dropdowns to keep their selected option after the page reloads (the logic was there before, but it was using instance variables which were never set!). This is for the search/filtering options on the &amp;quot;Manage...&amp;quot; screen.&lt;br /&gt;
&lt;br /&gt;
==1) Changing List to Index==&lt;br /&gt;
&lt;br /&gt;
In order to make the codebase more [http://www.restapitutorial.com/lessons/whatisrest.html RESTful], we have replaced all the controller action redirections with a tree_display_index_path which enormously reduces the code content and as well as provides an organized approach to action redirections. &lt;br /&gt;
&lt;br /&gt;
[[File:List_to_Index.png]]&lt;br /&gt;
&lt;br /&gt;
As seen below, we were able to '''remove''' list from Routes.rb:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
resources :tree_display do &lt;br /&gt;
collection do &lt;br /&gt;
  get ':action' &lt;br /&gt;
    - post 'list' &lt;br /&gt;
  end &lt;br /&gt;
end &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==2) Combined All of the Goto Methods==&lt;br /&gt;
We also combined all of the goto methods into one, in accordance with the [http://en.wikipedia.org/wiki/Don't_repeat_yourself DRY] principle. This removed a significant amount of duplicate code.&lt;br /&gt;
&lt;br /&gt;
Shown below are 3 of the 10 very similar methods we removed from '''tree_display_controller.rb''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
- # direct access to questionnaires &lt;br /&gt;
- def goto_questionnaires &lt;br /&gt;
- node_object = TreeFolder.find_by_name('Questionnaires') &lt;br /&gt;
- session[:root] = FolderNode.find_by_node_object_id(node_object.id).id &lt;br /&gt;
- redirect_to :controller =&amp;gt; 'tree_display', :action =&amp;gt; 'list' &lt;br /&gt;
- end &lt;br /&gt;
- &lt;br /&gt;
- # direct access to review rubrics &lt;br /&gt;
- def goto_review_rubrics &lt;br /&gt;
- node_object = TreeFolder.find_by_name('Review') &lt;br /&gt;
- session[:root] = FolderNode.find_by_node_object_id(node_object.id).id &lt;br /&gt;
- redirect_to :controller =&amp;gt; 'tree_display', :action =&amp;gt; 'list' &lt;br /&gt;
- end &lt;br /&gt;
- &lt;br /&gt;
- # direct access to metareview rubrics &lt;br /&gt;
- def goto_metareview_rubrics &lt;br /&gt;
- node_object = TreeFolder.find_by_name('Metareview') &lt;br /&gt;
- session[:root] = FolderNode.find_by_node_object_id(node_object.id).id &lt;br /&gt;
- redirect_to :controller =&amp;gt; 'tree_display', :action =&amp;gt; 'list' &lt;br /&gt;
- end &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
These methods were replaced by a variable containing a list mapping all the session variable strings to database labels. The goto_assignments method was replaced with an index method to accept this variable, rather then calling each goto method individually.&lt;br /&gt;
&lt;br /&gt;
'''Added''' variable:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
+ @@Groups = { &lt;br /&gt;
+   'Questionnaires' =&amp;gt; 'Questionnaires', &lt;br /&gt;
+   'Review rubrics' =&amp;gt; 'Review', &lt;br /&gt;
+   'Metareview rubrics' =&amp;gt; 'Metareview', &lt;br /&gt;
+   'Teammate review rubrics' =&amp;gt; 'Teammate Review', &lt;br /&gt;
+   'Author feedbacks' =&amp;gt; 'Author Feedback', &lt;br /&gt;
+   'Global survey' =&amp;gt; 'Global Survey', &lt;br /&gt;
+   'Surveys' =&amp;gt; 'Survey', &lt;br /&gt;
+   'Course evaluations' =&amp;gt; 'Course Evaluation', &lt;br /&gt;
+   'Courses' =&amp;gt; 'Courses', &lt;br /&gt;
+   'Bookmarkrating' =&amp;gt; 'Bookmarkrating', &lt;br /&gt;
+   'Assignments' =&amp;gt; 'Assignments' &lt;br /&gt;
+ } &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Removed''' goto_assignments method:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
- # direct access to assignments &lt;br /&gt;
- def goto_assignments &lt;br /&gt;
-   node_object = TreeFolder.find_by_name('Assignments') &lt;br /&gt;
-   session[:root] = FolderNode.find_by_node_object_id(node_object.id).id &lt;br /&gt;
-   redirect_to :controller =&amp;gt; 'tree_display', :action =&amp;gt; 'list' &lt;br /&gt;
- end &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Added''' index method:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
+ def index &lt;br /&gt;
+   session[:root] = params[:root] &lt;br /&gt;
+   group = getGroup session[:menu] &lt;br /&gt;
+   node_object = TreeFolder.find_by_name(group) &lt;br /&gt;
+   if not group.blank? and not node_object.blank? &lt;br /&gt;
+     session[:root] = FolderNode.find_by_node_object_id(node_object.id).id &lt;br /&gt;
+ end &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==3) Use Routing Helpers==&lt;br /&gt;
We refactored the tree display controller class to use route helpers rather than calling &amp;quot;:action =&amp;gt; 'list', :controller =&amp;gt; 'tree_display'&amp;quot;, or something similar. This involved many edits in the tree_display_controller.rb file and related controller and view files. As seen below, we utilized routing helpers and replaced '' ':controller=&amp;gt;'course', :action=&amp;gt;'new', :private =&amp;gt; 0'' with ''new_course_path(private: 0)''.&lt;br /&gt;
&lt;br /&gt;
'''_courses_folder_actions.html.erb''' changes:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;ul&amp;gt; &lt;br /&gt;
   &amp;lt;div&amp;gt; &lt;br /&gt;
   &amp;lt;%= link_to image_tag('/assets/tree_view/add-public-24.png'), &lt;br /&gt;
  - { :controller=&amp;gt;'course', :action=&amp;gt;'new', :private =&amp;gt; 0 }, &lt;br /&gt;
  - { :title =&amp;gt; 'Create Public Course', id: 'create-public-course' } %&amp;gt; &lt;br /&gt;
  + new_course_path(private: 0), &lt;br /&gt;
  + { title: 'Create Public Course', id: 'create-public-course' } %&amp;gt; &lt;br /&gt;
   &amp;lt;%= link_to image_tag('/assets/tree_view/add-private-24.png'), &lt;br /&gt;
  - { :controller=&amp;gt;'course', :action=&amp;gt;'new', :private =&amp;gt; 1 }, &lt;br /&gt;
  - { :title =&amp;gt; 'Create Private Course', id: 'create-private-course' } %&amp;gt; &lt;br /&gt;
  + new_course_path(private: 1), &lt;br /&gt;
  + { title: 'Create Private Course', id: 'create-private-course' } %&amp;gt; &lt;br /&gt;
   &amp;lt;/div&amp;gt; &lt;br /&gt;
   &amp;lt;/ul&amp;gt; &lt;br /&gt;
   &amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt; &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Another example of routing helpers in '''_bread_crumbs.html.erb'''. &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Before:'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;%= link_to curr_node.get_name, :controller =&amp;gt; 'tree_display', :action =&amp;gt; 'drill', :root =&amp;gt; curr_node.id %&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''After''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;%= link_to curr_node.get_name, tree_display_index_path(root: curr_node.id)%&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==4) Minimizing the count of Instance Variables==&lt;br /&gt;
=== Instance Variables in Ruby ===&lt;br /&gt;
An instance variable has a name beginning with @, and its scope is confined to whatever object self refers to. Two different objects, even if they belong to the same class, are allowed to have different values for their instance variables. From outside the object, instance variables cannot be altered or even observed (i.e., ruby's instance variables are never public) except by whatever methods are explicitly provided by the programmer. As with globals, instance variables have the nil value until they are initialized.&lt;br /&gt;
&lt;br /&gt;
Instance variables do not need to be declared. This indicates a flexible object structure; in fact, each instance variable is dynamically appended to an object when it is first assigned.&lt;br /&gt;
&lt;br /&gt;
We have observed that in Expertiza, there were several code files related to the Tree Display controller which were observed to be using multiple instance variables which could be reduced. Our team aimed to limit the instantiation of such variables to only necessary places in our code.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The following was added to the ''index'' function of '''tree_display_controller.rb''' in order to replace the use of instance variables with local variables:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
locals  search:       @search,&lt;br /&gt;
        sortvar:      @sortvar,&lt;br /&gt;
        sortorder:    @sortorder,&lt;br /&gt;
        root_node:    @root_node,&lt;br /&gt;
        child_nodes:  @child_nodes,&lt;br /&gt;
        filternode:   params[:filternode],&lt;br /&gt;
        searchnode:   params[:searchnode]&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Many of the view files were changed to make use of the local variables. &lt;br /&gt;
&lt;br /&gt;
Here is an example of how _bread_crumbs.html.erb was changed. Note the removal of the &amp;quot;@&amp;quot; characters.&lt;br /&gt;
&lt;br /&gt;
'''Before:'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;% if @root_node %&amp;gt;&lt;br /&gt;
   &amp;lt;%= link_to &amp;quot;Return to top&amp;quot;, tree_display_index_path %&amp;gt;&lt;br /&gt;
   &amp;lt;%&lt;br /&gt;
      curr_node = @root_node&lt;br /&gt;
   while curr_node.parent_id&lt;br /&gt;
     curr_node = Node.find(curr_node.parent_id) %&amp;gt;&lt;br /&gt;
   &amp;amp;nbsp;&amp;amp;nbsp;&lt;br /&gt;
   &amp;lt;%= link_to curr_node.get_name, tree_display_index_path(root: curr_node.id)%&amp;gt;&lt;br /&gt;
 &amp;lt;% end %&amp;gt;&lt;br /&gt;
&amp;amp;nbsp;&amp;amp;nbsp;&amp;lt;%= @root_node.get_name %&amp;gt;&amp;lt;%&lt;br /&gt;
end %&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''After:'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;% if root_node %&amp;gt;&lt;br /&gt;
   &amp;lt;%= link_to &amp;quot;Return to top&amp;quot;, tree_display_index_path %&amp;gt;&lt;br /&gt;
   &amp;lt;%&lt;br /&gt;
      curr_node = root_node&lt;br /&gt;
   while curr_node.parent_id&lt;br /&gt;
     curr_node = Node.find(curr_node.parent_id) %&amp;gt;&lt;br /&gt;
   &amp;amp;nbsp;&amp;amp;nbsp;&lt;br /&gt;
   &amp;lt;%= link_to curr_node.get_name, tree_display_index_path(root: curr_node.id)%&amp;gt;&lt;br /&gt;
 &amp;lt;% end %&amp;gt;&lt;br /&gt;
&amp;amp;nbsp;&amp;amp;nbsp;&amp;lt;%= root_node.get_name %&amp;gt;&amp;lt;%&lt;br /&gt;
 end %&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Conclusion=&lt;br /&gt;
In conclusion, we were able to successfully refactor the tree_display_controller and related controllers and views. We improved and expanded the use of RESTful and DRY design choices, implemented the use of routing helpers, ensured that instantiation of instance variables is minimized, and overall improved the quality and efficiency of the Expertiza codebase.&lt;/div&gt;</summary>
		<author><name>Jjbeaver</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/oss_E1463_vpd&amp;diff=91512</id>
		<title>CSC/ECE 517 Fall 2014/oss E1463 vpd</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/oss_E1463_vpd&amp;diff=91512"/>
		<updated>2014-11-06T04:46:05Z</updated>

		<summary type="html">&lt;p&gt;Jjbeaver: /* Refactoring TreeDisplayController Tasks */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= '''E1463: Refactoring TreeDisplayController''' =&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
=Project Links=&lt;br /&gt;
[http://ec2-54-186-80-176.us-west-2.compute.amazonaws.com:3000/ Our Expertiza Fork on AWS]&amp;lt;br&amp;gt;&lt;br /&gt;
[https://github.com/Druotic/expertiza Github Repo]&amp;lt;br&amp;gt;&lt;br /&gt;
[https://github.com/expertiza/expertiza/pull/449 Expertize Pull Request] &amp;lt;br&amp;gt;&lt;br /&gt;
[http://ec2-54-186-80-176.us-west-2.compute.amazonaws.com:3000/ Project Running on AWS]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Setup - How To View Our Expertiza Fork Running on AWS=&lt;br /&gt;
NOTE: The scope of our project was only to refactor select code. There are no feature additions or changes, so it should work just like production Expertiza.&lt;br /&gt;
&lt;br /&gt;
1) Go to [http://ec2-54-186-80-176.us-west-2.compute.amazonaws.com:3000/ our Expertiza project running on AWS]&lt;br /&gt;
&lt;br /&gt;
2) Login as Admin&amp;lt;br&amp;gt;&lt;br /&gt;
'''User:''' user2&amp;lt;br&amp;gt;&lt;br /&gt;
'''Password:''' password&lt;br /&gt;
&lt;br /&gt;
3) Click on &amp;quot;Manage...&amp;quot; if you are not automatically directed to the tree display.&lt;br /&gt;
&lt;br /&gt;
=Project Description=&lt;br /&gt;
&lt;br /&gt;
For this project, our team refactored the TreeDisplayController class in the [http://expertiza.ncsu.edu/ Expertiza] OSS project. This class provides access to questionnaires, review rubrics, author feedback, courses, assignments, and course evaluations. The tree display lists all of these categories with the ability for the user to &amp;quot;drill down&amp;quot; into the subcategories or just expand/collapse as needed.&lt;br /&gt;
&lt;br /&gt;
'''Example Image Of Tree Display:&lt;br /&gt;
'''&lt;br /&gt;
[[File:Expertiza.PNG ]]&lt;br /&gt;
&lt;br /&gt;
=Refactoring TreeDisplayController Tasks=&lt;br /&gt;
&lt;br /&gt;
As part of the refactoring task, we had to address the following issues for enhancing code readability and maintainability. The tasks included:&lt;br /&gt;
#Changing List to Index using a [http://www.restapitutorial.com/lessons/whatisrest.html RESTful] approach.&lt;br /&gt;
#Combined all of the goto methods&lt;br /&gt;
#Use of [http://guides.rubyonrails.org/routing.html#path-and-url-helpers routing helpers]&lt;br /&gt;
#Ensuring that instantiation of instance variables is minimized.&lt;br /&gt;
&lt;br /&gt;
In the end, we enhanced this list a bit and resulted in doing the following: 		&lt;br /&gt;
#Changed `list` method to `index`&lt;br /&gt;
#Removed `drill` - combined with `index`	&lt;br /&gt;
#Removed all of the `goto` methods and had them go through `index` instead because they are essentially just filtered versions of a listing (and the previous implementation just redirected each `goto` back to `list` anyway)	&lt;br /&gt;
#Used path helpers where possible	&lt;br /&gt;
#Removed instance variables and used local variables instead.  This should be better for scope reasons.  Note that there are still 1-2 instance variables used in the view, `@show` and `@assignment` which don't appear to be used anywhere.  (`@show` doesn't seem to ever be set, `@assignment` seems to only be used locally)  However, we didn't touch this because it didn't deal directly with our changes to the controller.	&lt;br /&gt;
#Introduced some local variables as params to the view which allow dropdowns to keep their selected option after the page reloads (the logic was there before, but it was using instance variables which were never set!) - this is for the search/filtering options&lt;br /&gt;
&lt;br /&gt;
==1) Changing List to Index==&lt;br /&gt;
&lt;br /&gt;
In order to make the codebase more [http://www.restapitutorial.com/lessons/whatisrest.html RESTful], we have replaced all the controller action redirections with a tree_display_index_path which enormously reduces the code content and as well as provides an organized approach to action redirections. &lt;br /&gt;
&lt;br /&gt;
[[File:List_to_Index.png]]&lt;br /&gt;
&lt;br /&gt;
As seen below, we were able to '''remove''' list from Routes.rb:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
resources :tree_display do &lt;br /&gt;
collection do &lt;br /&gt;
  get ':action' &lt;br /&gt;
    - post 'list' &lt;br /&gt;
  end &lt;br /&gt;
end &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==2) Combined All of the Goto Methods==&lt;br /&gt;
We also combined all of the goto methods into one, in accordance with the [http://en.wikipedia.org/wiki/Don't_repeat_yourself DRY] principle. This removed a significant amount of duplicate code.&lt;br /&gt;
&lt;br /&gt;
Shown below are 3 of the 10 very similar methods we removed from '''tree_display_controller.rb''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
- # direct access to questionnaires &lt;br /&gt;
- def goto_questionnaires &lt;br /&gt;
- node_object = TreeFolder.find_by_name('Questionnaires') &lt;br /&gt;
- session[:root] = FolderNode.find_by_node_object_id(node_object.id).id &lt;br /&gt;
- redirect_to :controller =&amp;gt; 'tree_display', :action =&amp;gt; 'list' &lt;br /&gt;
- end &lt;br /&gt;
- &lt;br /&gt;
- # direct access to review rubrics &lt;br /&gt;
- def goto_review_rubrics &lt;br /&gt;
- node_object = TreeFolder.find_by_name('Review') &lt;br /&gt;
- session[:root] = FolderNode.find_by_node_object_id(node_object.id).id &lt;br /&gt;
- redirect_to :controller =&amp;gt; 'tree_display', :action =&amp;gt; 'list' &lt;br /&gt;
- end &lt;br /&gt;
- &lt;br /&gt;
- # direct access to metareview rubrics &lt;br /&gt;
- def goto_metareview_rubrics &lt;br /&gt;
- node_object = TreeFolder.find_by_name('Metareview') &lt;br /&gt;
- session[:root] = FolderNode.find_by_node_object_id(node_object.id).id &lt;br /&gt;
- redirect_to :controller =&amp;gt; 'tree_display', :action =&amp;gt; 'list' &lt;br /&gt;
- end &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
These methods were replaced by a variable containing a list mapping all the session variable strings to database labels. The goto_assignments method was replaced with an index method to accept this variable, rather then calling each goto method individually.&lt;br /&gt;
&lt;br /&gt;
'''Added''' variable:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
+ @@Groups = { &lt;br /&gt;
+   'Questionnaires' =&amp;gt; 'Questionnaires', &lt;br /&gt;
+   'Review rubrics' =&amp;gt; 'Review', &lt;br /&gt;
+   'Metareview rubrics' =&amp;gt; 'Metareview', &lt;br /&gt;
+   'Teammate review rubrics' =&amp;gt; 'Teammate Review', &lt;br /&gt;
+   'Author feedbacks' =&amp;gt; 'Author Feedback', &lt;br /&gt;
+   'Global survey' =&amp;gt; 'Global Survey', &lt;br /&gt;
+   'Surveys' =&amp;gt; 'Survey', &lt;br /&gt;
+   'Course evaluations' =&amp;gt; 'Course Evaluation', &lt;br /&gt;
+   'Courses' =&amp;gt; 'Courses', &lt;br /&gt;
+   'Bookmarkrating' =&amp;gt; 'Bookmarkrating', &lt;br /&gt;
+   'Assignments' =&amp;gt; 'Assignments' &lt;br /&gt;
+ } &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Removed''' goto_assignments method:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
- # direct access to assignments &lt;br /&gt;
- def goto_assignments &lt;br /&gt;
-   node_object = TreeFolder.find_by_name('Assignments') &lt;br /&gt;
-   session[:root] = FolderNode.find_by_node_object_id(node_object.id).id &lt;br /&gt;
-   redirect_to :controller =&amp;gt; 'tree_display', :action =&amp;gt; 'list' &lt;br /&gt;
- end &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Added''' index method:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
+ def index &lt;br /&gt;
+   session[:root] = params[:root] &lt;br /&gt;
+   group = getGroup session[:menu] &lt;br /&gt;
+   node_object = TreeFolder.find_by_name(group) &lt;br /&gt;
+   if not group.blank? and not node_object.blank? &lt;br /&gt;
+     session[:root] = FolderNode.find_by_node_object_id(node_object.id).id &lt;br /&gt;
+ end &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==3) Use Routing Helpers==&lt;br /&gt;
We refactored the tree display controller class to use route helpers rather than calling &amp;quot;:action =&amp;gt; 'list', :controller =&amp;gt; 'tree_display'&amp;quot;, or something similar. This involved many edits in the tree_display_controller.rb file and related controller and view files. As seen below, we utilized routing helpers and replaced '' ':controller=&amp;gt;'course', :action=&amp;gt;'new', :private =&amp;gt; 0'' with ''new_course_path(private: 0)''.&lt;br /&gt;
&lt;br /&gt;
'''_courses_folder_actions.html.erb''' changes:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;ul&amp;gt; &lt;br /&gt;
   &amp;lt;div&amp;gt; &lt;br /&gt;
   &amp;lt;%= link_to image_tag('/assets/tree_view/add-public-24.png'), &lt;br /&gt;
  - { :controller=&amp;gt;'course', :action=&amp;gt;'new', :private =&amp;gt; 0 }, &lt;br /&gt;
  - { :title =&amp;gt; 'Create Public Course', id: 'create-public-course' } %&amp;gt; &lt;br /&gt;
  + new_course_path(private: 0), &lt;br /&gt;
  + { title: 'Create Public Course', id: 'create-public-course' } %&amp;gt; &lt;br /&gt;
   &amp;lt;%= link_to image_tag('/assets/tree_view/add-private-24.png'), &lt;br /&gt;
  - { :controller=&amp;gt;'course', :action=&amp;gt;'new', :private =&amp;gt; 1 }, &lt;br /&gt;
  - { :title =&amp;gt; 'Create Private Course', id: 'create-private-course' } %&amp;gt; &lt;br /&gt;
  + new_course_path(private: 1), &lt;br /&gt;
  + { title: 'Create Private Course', id: 'create-private-course' } %&amp;gt; &lt;br /&gt;
   &amp;lt;/div&amp;gt; &lt;br /&gt;
   &amp;lt;/ul&amp;gt; &lt;br /&gt;
   &amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt; &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Another example of routing helpers in '''_bread_crumbs.html.erb'''. &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Before:'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;%= link_to curr_node.get_name, :controller =&amp;gt; 'tree_display', :action =&amp;gt; 'drill', :root =&amp;gt; curr_node.id %&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''After''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;%= link_to curr_node.get_name, tree_display_index_path(root: curr_node.id)%&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==4) Minimizing the count of Instance Variables==&lt;br /&gt;
=== Instance Variables in Ruby ===&lt;br /&gt;
An instance variable has a name beginning with @, and its scope is confined to whatever object self refers to. Two different objects, even if they belong to the same class, are allowed to have different values for their instance variables. From outside the object, instance variables cannot be altered or even observed (i.e., ruby's instance variables are never public) except by whatever methods are explicitly provided by the programmer. As with globals, instance variables have the nil value until they are initialized.&lt;br /&gt;
&lt;br /&gt;
Instance variables do not need to be declared. This indicates a flexible object structure; in fact, each instance variable is dynamically appended to an object when it is first assigned.&lt;br /&gt;
&lt;br /&gt;
We have observed that in Expertiza, there were several code files related to the Tree Display controller which were observed to be using multiple instance variables which could be reduced. Our team aimed to limit the instantiation of such variables to only necessary places in our code.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The following was added to the ''index'' function of '''tree_display_controller.rb''' in order to replace the use of instance variables with local variables:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
locals  search:       @search,&lt;br /&gt;
        sortvar:      @sortvar,&lt;br /&gt;
        sortorder:    @sortorder,&lt;br /&gt;
        root_node:    @root_node,&lt;br /&gt;
        child_nodes:  @child_nodes,&lt;br /&gt;
        filternode:   params[:filternode],&lt;br /&gt;
        searchnode:   params[:searchnode]&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Many of the view files were changed to make use of the local variables. &lt;br /&gt;
&lt;br /&gt;
Here is an example of how _bread_crumbs.html.erb was changed. Note the removal of the &amp;quot;@&amp;quot; characters.&lt;br /&gt;
&lt;br /&gt;
'''Before:'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;% if @root_node %&amp;gt;&lt;br /&gt;
   &amp;lt;%= link_to &amp;quot;Return to top&amp;quot;, tree_display_index_path %&amp;gt;&lt;br /&gt;
   &amp;lt;%&lt;br /&gt;
      curr_node = @root_node&lt;br /&gt;
   while curr_node.parent_id&lt;br /&gt;
     curr_node = Node.find(curr_node.parent_id) %&amp;gt;&lt;br /&gt;
   &amp;amp;nbsp;&amp;amp;nbsp;&lt;br /&gt;
   &amp;lt;%= link_to curr_node.get_name, tree_display_index_path(root: curr_node.id)%&amp;gt;&lt;br /&gt;
 &amp;lt;% end %&amp;gt;&lt;br /&gt;
&amp;amp;nbsp;&amp;amp;nbsp;&amp;lt;%= @root_node.get_name %&amp;gt;&amp;lt;%&lt;br /&gt;
end %&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''After:'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;% if root_node %&amp;gt;&lt;br /&gt;
   &amp;lt;%= link_to &amp;quot;Return to top&amp;quot;, tree_display_index_path %&amp;gt;&lt;br /&gt;
   &amp;lt;%&lt;br /&gt;
      curr_node = root_node&lt;br /&gt;
   while curr_node.parent_id&lt;br /&gt;
     curr_node = Node.find(curr_node.parent_id) %&amp;gt;&lt;br /&gt;
   &amp;amp;nbsp;&amp;amp;nbsp;&lt;br /&gt;
   &amp;lt;%= link_to curr_node.get_name, tree_display_index_path(root: curr_node.id)%&amp;gt;&lt;br /&gt;
 &amp;lt;% end %&amp;gt;&lt;br /&gt;
&amp;amp;nbsp;&amp;amp;nbsp;&amp;lt;%= root_node.get_name %&amp;gt;&amp;lt;%&lt;br /&gt;
 end %&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Conclusion=&lt;br /&gt;
In conclusion, we were able to successfully refactor the tree_display_controller and related controllers and views. We improved and expanded the use of RESTful and DRY design choices, implemented the use of routing helpers, ensured that instantiation of instance variables is minimized, and overall improved the quality and efficiency of the Expertiza codebase.&lt;/div&gt;</summary>
		<author><name>Jjbeaver</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/ch1b_27_js&amp;diff=89582</id>
		<title>CSC/ECE 517 Fall 2014/ch1b 27 js</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/ch1b_27_js&amp;diff=89582"/>
		<updated>2014-10-14T02:34:25Z</updated>

		<summary type="html">&lt;p&gt;Jjbeaver: /* Install/Configure (Ruby) */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;='''Selenium vs. Watir'''=&lt;br /&gt;
&lt;br /&gt;
Developing web applications is proving to be a challenging task with each passing day given the complex requirements and the demanding nature of the these applications. For the web applications to be robust we need to put in place some good testing strategies.&lt;br /&gt;
&lt;br /&gt;
'''''Selenium''''' is one of the most popularly used open source automation tools for web based applications. It is a JavaScript framework that runs in your web browser to interact with various elements in your browser. All in all, Selenium is a set of different software tools each with a different approach to supporting test automation. Selenium provides a rich set of testing functions that can be customized to suit the testing requirements.&lt;br /&gt;
 &lt;br /&gt;
'''''Watir''''', is another lightweight automation testing tool that is widely used for web app testing. It is an open-source ([http://en.wikipedia.org/wiki/BSD_licenses BSD])  family of Ruby libraries for automating web browsers. It allows you to write tests that are easy to read and maintain&amp;lt;ref&amp;gt;[http://watir.com/ Web Application Testing in Ruby]&amp;lt;/ref&amp;gt;. Despite the fact that it is a set of Ruby libraries, it works perfectly, independent of the language that the web application is developed in. Watir as a tool is extremely simple and flexible.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=='''Motivation'''==&lt;br /&gt;
===Need for test automation===&lt;br /&gt;
With the majority of software applications today being implemented as [http://en.wikipedia.org/wiki/Web_application web applications] to be used over the internet, testing is becoming an indispensable part of the software development lifecycle ([http://en.wikipedia.org/wiki/Software_development_process SDLC]) of these applications. [http://en.wikipedia.org/wiki/Test_automation Test automation] is used where manual testing needs to be carried out repeatedly making it a cumbersome task. Test automation uses a software tool for this purpose on the application to be tested. It has proven to be highly efficient and critical in larger software development companies. Additionally, automation can be a valuable way to make Test Driven Development ([http://en.wikipedia.org/wiki/Test-driven_development TDD]) tasks an important part of the software development workflow.&lt;br /&gt;
 &lt;br /&gt;
Test Automation has a number of advantages mostly dealing with repetitiveness of the tests and the time taken.&lt;br /&gt;
* '''Covers cases that manual testing probably cannot'''&lt;br /&gt;
# Finds defects missed out my manual testing&lt;br /&gt;
# Automated testing can simulate numerous virtual users interacting with the web software/application&lt;br /&gt;
* '''Helps save time and money'''&lt;br /&gt;
# Once created, automated tests can be executed repeatedly at no additional   costs and at a much faster pace. Saving time directly translates into saving cost.&lt;br /&gt;
# Supports virtually unlimited iterations of test case execution&lt;br /&gt;
* '''Increase test coverage and accuracy'''&lt;br /&gt;
# Automated tests perform the exact same steps and records all details precisely&lt;br /&gt;
# They also increase the depth and scope of tests to improve the quality of the software&lt;br /&gt;
&lt;br /&gt;
=='''Brief History'''==&lt;br /&gt;
====Selenium====&lt;br /&gt;
&lt;br /&gt;
[[File: SE-logo.png|right|Selenium Logo|link=http://www.seleniumhq.org/images/big-logo.png]]&lt;br /&gt;
&lt;br /&gt;
''Selenium'' was developed in the year 2004 by Jason Huggins and has been continuously evolving ever since. Jason Huggins developed this as an internal tool for [http://en.wikipedia.org/wiki/ThoughtWorks ThoughtWorks] as a javascript library which came to be known as the Selenium core. Selenium core is now the basis of the Selenium Remote Control (the server) and Selenium IDE.&lt;br /&gt;
The year 2006 marked the beginning of the development of the 'WebDriver project' which was what they believed ‘a tool of the future’. The WebDriver was initiated to solve the problems that were faced due to the fact that Selenium was a based on JavaScript and a lot of security limitations browsers apply to Javascript.&lt;br /&gt;
In 2008, both Selenium and WebDriver merged to provide a common set of features to all users which is called Selenium 2.&lt;br /&gt;
Simon Stewart, the creator of the WebDriver Project, in a joint email to the WebDriver and Selenium community on August 6, 2009 said the following.&lt;br /&gt;
&lt;br /&gt;
:“Why are the projects merging? Partly because webdriver addresses some shortcomings in selenium (by being able to bypass the JS sandbox, for example. And we’ve got a gorgeous API), partly because selenium addresses some shortcomings  in webdriver (such as supporting a broader range of browsers) and partly because the main selenium contributors and I felt that it was the best way to offer users the best possible framework.”&amp;lt;ref name =&amp;quot;Introduction to Selenium&amp;quot;&amp;gt; [http://docs.seleniumhq.org/docs/01_introducing_selenium.jsp#selenium-history Introducing Selenium]. ''SeleniumHQ: Browser Automation''. Selenium Project, 4 Oct. 2014. Web. 06 Oct. 2014.&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Watir====&lt;br /&gt;
&lt;br /&gt;
''Watir'' started as a library to teach testers to write ruby code and grew to be an IE implementation which now supports IE, Firefox, Safari, Google Chrome and Opera.&lt;br /&gt;
Watir was primarily developed by Bret Pettichord and Paul Rogers. Watir has since then has a couple of stable releases for Watir classic as well as Watir WebDriver. The most recent releases being&amp;lt;ref&amp;gt;[http://watir.com/category/releases/ Watir Releases]. Watir: Web Application Testing in Ruby. 28 April, 2013&amp;lt;/ref&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
[[File: Watir.gif|right|Watir logo|link=http://upload.wikimedia.org/wikipedia/commons/7/7e/Watir.gif]]&lt;br /&gt;
&lt;br /&gt;
* Watir-Classic	    &lt;br /&gt;
# 0.6.3 April 10, 2013 ([https://github.com/watir/watir-webdriver/blob/master/CHANGES.md#063 Release Notes]) &amp;lt;br /&amp;gt;&lt;br /&gt;
* Watir-WebDriver	    &lt;br /&gt;
# 3.6.0 March 16, 2013 ([https://groups.google.com/forum/#!msg/watir-general/MOOun5g3Hvg/JBVNy957lDYJ Release Notes]) &amp;lt;br /&amp;gt;&lt;br /&gt;
# 3.5.0 March 10, 2013 ([https://groups.google.com/forum/#!msg/watir-general/aeUqsglvK6k/Kq7FCBiERjYJ Release Notes]) &amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Watir has a google group ([https://groups.google.com/forum/#!forum/watir-general Watir General]) for its support and contribution while Selenium also has a [http://seleniumforum.forumotion.net/ Selenium forum] apart from its google group called [https://groups.google.com/forum/#!forum/selenium-users Selenium Users].&lt;br /&gt;
&lt;br /&gt;
=='''Pros/Cons'''==&lt;br /&gt;
===Selenium===&lt;br /&gt;
*Pros&lt;br /&gt;
# Open Source, free Software&lt;br /&gt;
# Easy Installation&lt;br /&gt;
# Scripting Techniques&lt;br /&gt;
##Easy recording and playback of scripts&lt;br /&gt;
##Scripts are modular, can be reused&lt;br /&gt;
# Selenium was first written in Java but it also supports .Net, Ruby, Perl, PHP and Python. This is a big plus when you want to build your framework in a language that has the highest adoption in the organization it is being built within. Unlike tools like [http://en.wikipedia.org/wiki/HP_QuickTest_Professional QTP] which force you to use [http://en.wikipedia.org/wiki/VBScript VBScript]&lt;br /&gt;
# Integration with third party tools is possible &lt;br /&gt;
# You can instantiate several concurrent tests with Selenium since no dedicated machine is required&lt;br /&gt;
&lt;br /&gt;
*Cons&lt;br /&gt;
#  Selenium has concept of locators that support common attributes like id, names etc as well as [http://en.wikipedia.org/wiki/XPath XPATH], [http://en.wikipedia.org/wiki/JavaScript javascript] DOM and others. However, this is still not as smart as say the [http://www.tutorialspoint.com/qtp/qtp_object_repository.htm Object Repository] (OR) in QTP. That being said, QTP’s OR comes with it´s baggage as well.&amp;lt;ref&amp;gt;[http://www.qualitytesting.info/forum/topics/selenium-automation-tool Selenium Automation Tool]&amp;lt;/ref&amp;gt;&lt;br /&gt;
# It does not generate detailed results like the result viewer&lt;br /&gt;
# No option to verify images&lt;br /&gt;
&lt;br /&gt;
===Watir===&lt;br /&gt;
*Pros&lt;br /&gt;
# Open Source&lt;br /&gt;
# Opens browser as a normal way how the user opens it unlike Selenium which needs to create an object to work with&lt;br /&gt;
# Changing registry details(Proxy-http,socks) is very easy &amp;lt;ref&amp;gt;Raveendran, 28 Oct., 2009 [http://raveendran.wordpress.com/2009/10/28/watir-vs-selenium/ Selenium Vs Watir ]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*Cons&lt;br /&gt;
# Knowledge in the Ruby programming language is required &lt;br /&gt;
# Does not support certain HTML elements&lt;br /&gt;
# Limited reporting capabilities&lt;br /&gt;
# There is no recorder for Watir unlike Selenium for playback&lt;br /&gt;
&lt;br /&gt;
=='''Comparison of Features, Functionality, and More'''==&lt;br /&gt;
Some features or functionality may be repeated here.  However, we will go into a bit more detail than previously mentioned.&lt;br /&gt;
===='''Open Source'''====&lt;br /&gt;
Both Selenium and Watir are [http://en.wikipedia.org/wiki/Open-source_software open source]!  This allows for greater extensibility and a deeper understanding of the inner workings of both of the frameworks, if the developer/tester chooses to delve into such details.  Additionally, the open source community allows for a more transparent, user-driven development and support cycle.  Users (the tester/developer) can choose to submit bug fixes or enhancements as patches, or they can choose to just use it “straight out of the box.”&lt;br /&gt;
&lt;br /&gt;
====Application Language Agnostic====&lt;br /&gt;
&lt;br /&gt;
Both Selenium and Watir are application language agnostic.  Because both Selenium and Watir test UI functionality in the browser, they can be used to test any web application.    &lt;br /&gt;
&lt;br /&gt;
====Language-specific Test Cases====&lt;br /&gt;
&lt;br /&gt;
Both Selenium and Watir require test cases to be written in some programming language.  Traditionally, both frameworks had limited choices in terms of language bindings.  However, with the advent of WebDriver, both became much more flexible.  WebDriver provided the bindings needed for many languages.  Today, the following are supported:&lt;br /&gt;
&lt;br /&gt;
'''Selenium*'''&lt;br /&gt;
&lt;br /&gt;
* Officially-supported: [http://en.wikipedia.org/wiki/Java_(programming_language) Java], [http://en.wikipedia.org/wiki/C_Sharp_(programming_language) C#], [http://en.wikipedia.org/wiki/Ruby_(programming_language) Ruby], [http://en.wikipedia.org/wiki/Python_(programming_language) Python], [http://en.wikipedia.org/wiki/Node.js Javascript/Node.js]&lt;br /&gt;
&lt;br /&gt;
* Unofficial/community-supported: [http://en.wikipedia.org/wiki/Perl Perl], [http://en.wikipedia.org/wiki/PHP PHP], [http://en.wikipedia.org/wiki/Haskell_(programming_language) Haskell], [http://en.wikipedia.org/wiki/Objective-C Objective-C], [http://en.wikipedia.org/wiki/R_(programming_language) R], [http://en.wikipedia.org/wiki/Dart_(programming_language) Dart], [http://en.wikipedia.org/wiki/Tcl Tcl]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;According to SeleniumHQ’s download page.&lt;br /&gt;
&lt;br /&gt;
'''Watir'''&lt;br /&gt;
&lt;br /&gt;
Unfortunately (or fortunately), Ruby is the only supported language for Watir.  After all, Watir does stand for “Web Application Testing in Ruby.” However, there are other frameworks which were inspired by Watir (but entirely separate) available in Java and C# - [http://watij.com/ Watij] and [http://watin.org/ Watin],  respectively &amp;lt;ref&amp;gt;Djorgjievski, Darko. [http://www.sitepoint.com/watir-webdriver-control-browser/ Watir-WebDriver: Control the Browser]. ''SitePoint''. SitePoint Pty Ltd, 18 Apr. 2014. Web. 05 Oct. 2014.&amp;lt;/ref&amp;gt;.  There may be other similarly inspired frameworks available in other languages, but these are the most notable.&lt;br /&gt;
&lt;br /&gt;
====Cross-Browser and Headless Browser Support====&lt;br /&gt;
&lt;br /&gt;
[[File: watir_meet_webdriver.png | Watir Meets WebDriver &amp;lt;ref&amp;gt;[http://watirmelon.com/2010/04/10/watir-selenium-webdriver/ Watir Meets WebDriver Image]&amp;lt;/ref&amp;gt; |right|frame| link=http://yuml.me/diagram/scruffy/usecase/%5BTester%5D-%28Watir%20API%29,%20%28Watir%20API%29%3C%28FireWatir%29,%20%28Watir%20API%29%3C%28Watir%29,%20%28Watir%20API%29%3C%28SafariWatir%29,%20%28Watir%20API%29%3C%28Webdriver%29,%20%28Watir%20API%29%3C%28Celerity%29,%20%28Celerity%29-%28note:%20Celerity%20requires%20JRuby%29,%20%28Celerity%29-%28headless%29,%20%28Webdriver%29-%28Firefox%29,%20%28Webdriver%29-%28Chrome%29,%20%28Webdriver%29-%28IE%29,%20%28Webdriver%29-%28headless%29,%20%28FireWatir%29-%28Firefox%29,%20%28Watir%29-%28IE%29,%20%28SafariWatir%29-%28Safari%29.]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Traditionally, both Selenium and Watir were limited in the number of browsers they supported. Watir originally supported Internet Explorer and headless browsers exclusively.  Headless browsers were supported via the use of [https://github.com/jarib/celerity Celerity] &amp;lt;ref&amp;gt;Scott, Alister. [http://watirmelon.com/2010/04/10/watir-selenium-webdriver/ Watir, Selenium &amp;amp; WebDriver]. ''Watirmelon''. Watirmelon, 10 Apr. 2010. Web. 05 Oct. 2014.&amp;lt;/ref&amp;gt;.  Selenium started out as a Javascript library, so naturally it supported more browsers such as IE, Firefox, Safari, etc &amp;lt;ref name = &amp;quot;Introduction to Selenium&amp;quot; /&amp;gt;.  However, it did not support headless browsers.&lt;br /&gt;
Today, browser support looks much better for both Selenium and Watir, largely due to the introduction of WebDriver.  With WebDriver in existence, support for most browsers was added to Watir via the gem &amp;quot;watir-webdriver,&amp;quot; and Celerity became [https://github.com/jarib/celerity obsolete] because headless browser support was included in WebDriver.  Similarly for Selenium, support for headless browsers was added, as well as making the API much simpler and more concise &amp;lt;ref&amp;gt;[http://docs.seleniumhq.org/projects/webdriver/ Selenium WebDriver]. ''SeleniumHQ: Browser Automation''. Selenium Project, n.d. Web. 06 Oct. 2014.&amp;lt;/ref&amp;gt;.  Both Selenium &amp;lt;ref&amp;gt;Semerau, Luke. [https://code.google.com/p/selenium/wiki/WebDriverForMobileBrowsers WebDriverForMobileBrowsers]. ''Selenium''. Google Project Hosting, 14 Jan. 2013. Web. 06 Oct. 2014 &amp;lt;/ref&amp;gt; and Watir &amp;lt;ref&amp;gt;Scott, Alister. [http://watirwebdriver.com/mobile-devices/ Mobile Devices]. ''Watir WebDriver''. n.d. Web. 06 Oct. 2014. &amp;lt;/ref&amp;gt; have also gained support of Mobile browsers in recent years through WebDriver.  However, there is the obvious limitation that one can only test a browser which is supported on the running platform.  In other words, Safari and Internet explorer can only be tested on  OS X and Windows environments, respectively**.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;**&amp;lt;/nowiki&amp;gt; &amp;lt;span style=&amp;quot;font-size:88%&amp;quot;&amp;gt;Some work-arounds or programs may exist to allow these browsers to be tested on other platforms. Here, we are assuming no special additional configuration - just the base operating system and browsers.  With virtualization technologies such as [http://www.linux-kvm.org/page/Main_Page KVM], [https://www.virtualbox.org/ VirtualBox], and [http://en.wikipedia.org/wiki/Comparison_of_platform_virtualization_software others], this isn't a problem anyway.  [http://en.wikipedia.org/wiki/Virtual_machine Virtual machines] can be created with any operating system, as needed.&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Cross-Platform Support====&lt;br /&gt;
Both Watir and Selenium run on most popular distributions of Windows, Mac, and Linux.  Selenium doesn't have a list of officially supported operating system versions.  Instead they generally support any version that is currently popular.  Only a few versions are listed which they run test builds on.  These are versions which are officially known to work, but many more are supported as well.&lt;br /&gt;
&lt;br /&gt;
Because Watir is a collection of Ruby Gems, it runs on any platform that Ruby runs on.  Like Selenium, this includes nearly all popular platforms.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=='''Getting started'''==&lt;br /&gt;
===Selenium WebDriver=== &lt;br /&gt;
----&lt;br /&gt;
====Install/Configure (Java)====&lt;br /&gt;
Download binaries from [http://www.seleniumhq.org/download/ here] to configure Selenium. &lt;br /&gt;
Once you have all your binaries in a directory, you can open any IDE of your choice and add this directory with all the .jar files to the CLASSPATH&lt;br /&gt;
*Example&lt;br /&gt;
This is how a typical Selenium code to find the term say, “Automation” on Google and display the results on the page would look like in Java using the [https://code.google.com/p/selenium/wiki/HtmlUnitDriver HtmlUnitDriver] would look like.&lt;br /&gt;
The HtmlUnitDriver is a pure Java driver that runs entirely in-memory. Because of this, you won't see a new browser window open &amp;lt;ref&amp;gt;[https://code.google.com/p/selenium/wiki/GettingStarted Getting started with Selenium] Selenium: Browser Automation Framework. Google Code. 8 Feb, 2014.&amp;lt;/ref&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
       package org.selenium.example;&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;
       import org.openqa.selenium.By;&lt;br /&gt;
       import org.openqa.selenium.WebDriver;&lt;br /&gt;
       import org.openqa.selenium.WebElement;&lt;br /&gt;
       import org.openqa.selenium.htmlunit.HtmlUnitDriver;&amp;lt;br /&amp;gt;&lt;br /&gt;
       public class Example  {&lt;br /&gt;
       public static void main(String[] args) {&lt;br /&gt;
        // Create a new instance of the html unit driver&lt;br /&gt;
        // Notice that the remainder of the code relies on the interface,&lt;br /&gt;
        // not the implementation.&lt;br /&gt;
        WebDriver driver = new HtmlUnitDriver();&amp;lt;br /&amp;gt;&lt;br /&gt;
        System.out.println(&amp;quot;Beginning test for Google search using Selenium&amp;quot;);&lt;br /&gt;
        // And now use this to visit Google&lt;br /&gt;
        System.out.println(&amp;quot;Visit www.google.com&amp;quot; );&lt;br /&gt;
        driver.get(&amp;quot;http://www.google.com&amp;quot;);&amp;lt;br /&amp;gt;&lt;br /&gt;
        // Find the text input element by its name&lt;br /&gt;
        WebElement element = driver.findElement(By.name(&amp;quot;q&amp;quot;));&amp;lt;br /&amp;gt;&lt;br /&gt;
        // Enter something to search for&lt;br /&gt;
        System.out.println(&amp;quot;Type Automation in the search bar&amp;quot; );&lt;br /&gt;
        element.sendKeys(&amp;quot;Automation!&amp;quot;);&amp;lt;br /&amp;gt;&lt;br /&gt;
        // Now submit the form. WebDriver will find the form for us from the element&lt;br /&gt;
        element.submit();&amp;lt;br /&amp;gt;&lt;br /&gt;
        // Check the title of the page&lt;br /&gt;
        System.out.println(&amp;quot;Expected output&amp;quot; );&lt;br /&gt;
        System.out.println(&amp;quot;Page title is: &amp;quot; + driver.getTitle());&lt;br /&gt;
        driver.quit();&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
If you compile and run it, you should see a line with the title of the Google search results as output.&lt;br /&gt;
       ''Output:''&lt;br /&gt;
        Beginning test for Google search using Selenium &amp;lt;/ br&amp;gt;&lt;br /&gt;
        Visit www.google.com &amp;lt;/ br&amp;gt;&lt;br /&gt;
        Expected output &amp;lt;/ br&amp;gt;&lt;br /&gt;
        Page title is: Google&lt;br /&gt;
&lt;br /&gt;
====Install/Configure for other languages====&lt;br /&gt;
Configuring Selenium for languages other than Java and for other development environments can be looked up [http://docs.seleniumhq.org/docs/03_webdriver.jsp#setting-up-a-selenium-webdriver-project here]. viz(C#, Ruby, Python, PHP, Perl, Javascript)&lt;br /&gt;
&lt;br /&gt;
===Watir===&lt;br /&gt;
----&lt;br /&gt;
====Install/Configure (Ruby)====&lt;br /&gt;
Drivers for Watir are installed as gems which are nothing but Ruby libraries which can be accessed over the internet.&lt;br /&gt;
All the instructions for installing Watir on various operating systems (viz. Windows, Mac OS, Linux) can be found [http://watir.com/installation/ here].&lt;br /&gt;
&lt;br /&gt;
*Example:&lt;br /&gt;
This is how a typical Watir code to find the term say, “Automation” on Google and display the results on the page would look like using Ruby&amp;lt;ref&amp;gt;Chernenko, Iryna. [http://blog.qatestlab.com/2011/02/23/automated-testing-with-watir-tutorial-for-begginers-part-1/ Watir Example]. QATestLab Blog: Automated Testing with Watir, 23 Feb 2011.&lt;br /&gt;
&amp;lt;/ref&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
        # Required in ruby 1.8.7&lt;br /&gt;
        require 'rubygems'&lt;br /&gt;
        # Watir IE driver&lt;br /&gt;
        require 'watir'&amp;lt;br /&amp;gt; &lt;br /&gt;
        ie = Watir::IE.new&amp;lt;br /&amp;gt; &lt;br /&gt;
        # text to show on console&lt;br /&gt;
        puts &amp;quot;Beginning of the test for Google search engine&amp;quot;&lt;br /&gt;
        puts &amp;quot;Step 1:  Go to the Google homepage&amp;quot;&lt;br /&gt;
        ie.goto &amp;quot;http://www.google.com&amp;quot;&amp;lt;br /&amp;gt;&lt;br /&gt;
        #set a variable&lt;br /&gt;
        search_text = &amp;quot;Automation&amp;quot;&lt;br /&gt;
        puts &amp;quot;Step 2: enter &amp;quot;+ search_text +&amp;quot; in the search text field.&amp;quot;&lt;br /&gt;
        ie.text_field(:name, &amp;quot;q&amp;quot;).set search_text   # &amp;quot;q&amp;quot; is the name of the search field&amp;lt;br /&amp;gt;&lt;br /&gt;
        puts &amp;quot; Step 3: click the 'Google Search' button.&amp;quot;&lt;br /&gt;
        ie.button(:name, &amp;quot;btnG&amp;quot;).click # &amp;quot;btnG&amp;quot; is the name of the Search button&amp;lt;br /&amp;gt;&lt;br /&gt;
        puts &amp;quot; Expected Result:&amp;quot;&lt;br /&gt;
        puts &amp;quot;  A Google page with results should be shown. 'Watir, pronounced water' should be high on the list.&amp;quot;&lt;br /&gt;
        puts &amp;quot; Actual Result:&amp;quot;&lt;br /&gt;
        if ie.text.include? &amp;quot;Watir, pronounced water&amp;quot;	&lt;br /&gt;
             puts &amp;quot;  Test Passed. Found the text string: 'Watir, pronounced water'. Actual Results match Expected Results.&amp;quot;&lt;br /&gt;
        else	&lt;br /&gt;
 	     puts &amp;quot;  Test Failed! Could not find text: 'Watir, pronounced water'.&amp;quot;&lt;br /&gt;
        end&lt;br /&gt;
        puts &amp;quot;End of test: Google search.&amp;quot;&lt;br /&gt;
        ie.close&lt;br /&gt;
&lt;br /&gt;
On compiling and running this and passing the test, you will see something like&lt;br /&gt;
&lt;br /&gt;
        ''Output:''&lt;br /&gt;
        Beginning of the test for Google search engine &lt;br /&gt;
        Step 1:  Go to the Google homepage &lt;br /&gt;
        Step 2: enter Automation in the search text field. &lt;br /&gt;
        Step 3: click the 'Google Search' button. &lt;br /&gt;
        Expected Result: &lt;br /&gt;
        A Google page with results should be shown. 'Watir, pronounced water' should be high on the list. 	&lt;br /&gt;
        Test Passed. Found the text string: 'Watir, pronounced water'. Actual Results match Expected Results. &lt;br /&gt;
        End of test: Google search. &amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Similar Tools==&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Sahi_(software) Sahi], uses the Sahi Scripting Language&amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Soatest SOATest], for testing and validating [http://en.wikipedia.org/wiki/Application_programming_interface API] driven applications &amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/TestComplete TestComplete], for Desktops, Web and Mobile&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
* [http://www.hiretheworld.com/blog/tech-blog/migrating-unit-tests-from-selenium-to-watir-webdriver Migrating unit tests from Selenium to Watir Web Driver] &amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://www.hiretheworld.com/blog/tech-blog/migrating-unit-tests-from-selenium-to-watir-webdriver Learning Selenium IDE] &amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/List_of_web_testing_tools List of web testing tools] &amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/List_of_web_testing_tools OWASP List of Acceptance Testing tools]&lt;br /&gt;
* [http://www.ijiet.org/papers/425-T0026.pdf  Study of Browser Based Automated Test Tools WATIR and Selenium] Nisha Gogna, August 2014, International Journal of Information and Education Technology, Vol. 4, No. 4&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
{{reflist}}&lt;br /&gt;
&amp;lt;references /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==External Links==&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Selenium_(software) Selenium Wiki Page] &amp;lt;br /&amp;gt;&lt;br /&gt;
* [https://github.com/SeleniumHQ/selenium Selenium Source Code] &amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Watir Watir Wiki Page] &amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Watir Watir Source Code] &amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Watir SauceLabs HomePage] &amp;lt;br /&amp;gt;&lt;/div&gt;</summary>
		<author><name>Jjbeaver</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/ch1b_27_js&amp;diff=89581</id>
		<title>CSC/ECE 517 Fall 2014/ch1b 27 js</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/ch1b_27_js&amp;diff=89581"/>
		<updated>2014-10-14T02:33:17Z</updated>

		<summary type="html">&lt;p&gt;Jjbeaver: /* Selenium */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;='''Selenium vs. Watir'''=&lt;br /&gt;
&lt;br /&gt;
Developing web applications is proving to be a challenging task with each passing day given the complex requirements and the demanding nature of the these applications. For the web applications to be robust we need to put in place some good testing strategies.&lt;br /&gt;
&lt;br /&gt;
'''''Selenium''''' is one of the most popularly used open source automation tools for web based applications. It is a JavaScript framework that runs in your web browser to interact with various elements in your browser. All in all, Selenium is a set of different software tools each with a different approach to supporting test automation. Selenium provides a rich set of testing functions that can be customized to suit the testing requirements.&lt;br /&gt;
 &lt;br /&gt;
'''''Watir''''', is another lightweight automation testing tool that is widely used for web app testing. It is an open-source ([http://en.wikipedia.org/wiki/BSD_licenses BSD])  family of Ruby libraries for automating web browsers. It allows you to write tests that are easy to read and maintain&amp;lt;ref&amp;gt;[http://watir.com/ Web Application Testing in Ruby]&amp;lt;/ref&amp;gt;. Despite the fact that it is a set of Ruby libraries, it works perfectly, independent of the language that the web application is developed in. Watir as a tool is extremely simple and flexible.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=='''Motivation'''==&lt;br /&gt;
===Need for test automation===&lt;br /&gt;
With the majority of software applications today being implemented as [http://en.wikipedia.org/wiki/Web_application web applications] to be used over the internet, testing is becoming an indispensable part of the software development lifecycle ([http://en.wikipedia.org/wiki/Software_development_process SDLC]) of these applications. [http://en.wikipedia.org/wiki/Test_automation Test automation] is used where manual testing needs to be carried out repeatedly making it a cumbersome task. Test automation uses a software tool for this purpose on the application to be tested. It has proven to be highly efficient and critical in larger software development companies. Additionally, automation can be a valuable way to make Test Driven Development ([http://en.wikipedia.org/wiki/Test-driven_development TDD]) tasks an important part of the software development workflow.&lt;br /&gt;
 &lt;br /&gt;
Test Automation has a number of advantages mostly dealing with repetitiveness of the tests and the time taken.&lt;br /&gt;
* '''Covers cases that manual testing probably cannot'''&lt;br /&gt;
# Finds defects missed out my manual testing&lt;br /&gt;
# Automated testing can simulate numerous virtual users interacting with the web software/application&lt;br /&gt;
* '''Helps save time and money'''&lt;br /&gt;
# Once created, automated tests can be executed repeatedly at no additional   costs and at a much faster pace. Saving time directly translates into saving cost.&lt;br /&gt;
# Supports virtually unlimited iterations of test case execution&lt;br /&gt;
* '''Increase test coverage and accuracy'''&lt;br /&gt;
# Automated tests perform the exact same steps and records all details precisely&lt;br /&gt;
# They also increase the depth and scope of tests to improve the quality of the software&lt;br /&gt;
&lt;br /&gt;
=='''Brief History'''==&lt;br /&gt;
====Selenium====&lt;br /&gt;
&lt;br /&gt;
[[File: SE-logo.png|right|Selenium Logo|link=http://www.seleniumhq.org/images/big-logo.png]]&lt;br /&gt;
&lt;br /&gt;
''Selenium'' was developed in the year 2004 by Jason Huggins and has been continuously evolving ever since. Jason Huggins developed this as an internal tool for [http://en.wikipedia.org/wiki/ThoughtWorks ThoughtWorks] as a javascript library which came to be known as the Selenium core. Selenium core is now the basis of the Selenium Remote Control (the server) and Selenium IDE.&lt;br /&gt;
The year 2006 marked the beginning of the development of the 'WebDriver project' which was what they believed ‘a tool of the future’. The WebDriver was initiated to solve the problems that were faced due to the fact that Selenium was a based on JavaScript and a lot of security limitations browsers apply to Javascript.&lt;br /&gt;
In 2008, both Selenium and WebDriver merged to provide a common set of features to all users which is called Selenium 2.&lt;br /&gt;
Simon Stewart, the creator of the WebDriver Project, in a joint email to the WebDriver and Selenium community on August 6, 2009 said the following.&lt;br /&gt;
&lt;br /&gt;
:“Why are the projects merging? Partly because webdriver addresses some shortcomings in selenium (by being able to bypass the JS sandbox, for example. And we’ve got a gorgeous API), partly because selenium addresses some shortcomings  in webdriver (such as supporting a broader range of browsers) and partly because the main selenium contributors and I felt that it was the best way to offer users the best possible framework.”&amp;lt;ref name =&amp;quot;Introduction to Selenium&amp;quot;&amp;gt; [http://docs.seleniumhq.org/docs/01_introducing_selenium.jsp#selenium-history Introducing Selenium]. ''SeleniumHQ: Browser Automation''. Selenium Project, 4 Oct. 2014. Web. 06 Oct. 2014.&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Watir====&lt;br /&gt;
&lt;br /&gt;
''Watir'' started as a library to teach testers to write ruby code and grew to be an IE implementation which now supports IE, Firefox, Safari, Google Chrome and Opera.&lt;br /&gt;
Watir was primarily developed by Bret Pettichord and Paul Rogers. Watir has since then has a couple of stable releases for Watir classic as well as Watir WebDriver. The most recent releases being&amp;lt;ref&amp;gt;[http://watir.com/category/releases/ Watir Releases]. Watir: Web Application Testing in Ruby. 28 April, 2013&amp;lt;/ref&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
[[File: Watir.gif|right|Watir logo|link=http://upload.wikimedia.org/wikipedia/commons/7/7e/Watir.gif]]&lt;br /&gt;
&lt;br /&gt;
* Watir-Classic	    &lt;br /&gt;
# 0.6.3 April 10, 2013 ([https://github.com/watir/watir-webdriver/blob/master/CHANGES.md#063 Release Notes]) &amp;lt;br /&amp;gt;&lt;br /&gt;
* Watir-WebDriver	    &lt;br /&gt;
# 3.6.0 March 16, 2013 ([https://groups.google.com/forum/#!msg/watir-general/MOOun5g3Hvg/JBVNy957lDYJ Release Notes]) &amp;lt;br /&amp;gt;&lt;br /&gt;
# 3.5.0 March 10, 2013 ([https://groups.google.com/forum/#!msg/watir-general/aeUqsglvK6k/Kq7FCBiERjYJ Release Notes]) &amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Watir has a google group ([https://groups.google.com/forum/#!forum/watir-general Watir General]) for its support and contribution while Selenium also has a [http://seleniumforum.forumotion.net/ Selenium forum] apart from its google group called [https://groups.google.com/forum/#!forum/selenium-users Selenium Users].&lt;br /&gt;
&lt;br /&gt;
=='''Pros/Cons'''==&lt;br /&gt;
===Selenium===&lt;br /&gt;
*Pros&lt;br /&gt;
# Open Source, free Software&lt;br /&gt;
# Easy Installation&lt;br /&gt;
# Scripting Techniques&lt;br /&gt;
##Easy recording and playback of scripts&lt;br /&gt;
##Scripts are modular, can be reused&lt;br /&gt;
# Selenium was first written in Java but it also supports .Net, Ruby, Perl, PHP and Python. This is a big plus when you want to build your framework in a language that has the highest adoption in the organization it is being built within. Unlike tools like [http://en.wikipedia.org/wiki/HP_QuickTest_Professional QTP] which force you to use [http://en.wikipedia.org/wiki/VBScript VBScript]&lt;br /&gt;
# Integration with third party tools is possible &lt;br /&gt;
# You can instantiate several concurrent tests with Selenium since no dedicated machine is required&lt;br /&gt;
&lt;br /&gt;
*Cons&lt;br /&gt;
#  Selenium has concept of locators that support common attributes like id, names etc as well as [http://en.wikipedia.org/wiki/XPath XPATH], [http://en.wikipedia.org/wiki/JavaScript javascript] DOM and others. However, this is still not as smart as say the [http://www.tutorialspoint.com/qtp/qtp_object_repository.htm Object Repository] (OR) in QTP. That being said, QTP’s OR comes with it´s baggage as well.&amp;lt;ref&amp;gt;[http://www.qualitytesting.info/forum/topics/selenium-automation-tool Selenium Automation Tool]&amp;lt;/ref&amp;gt;&lt;br /&gt;
# It does not generate detailed results like the result viewer&lt;br /&gt;
# No option to verify images&lt;br /&gt;
&lt;br /&gt;
===Watir===&lt;br /&gt;
*Pros&lt;br /&gt;
# Open Source&lt;br /&gt;
# Opens browser as a normal way how the user opens it unlike Selenium which needs to create an object to work with&lt;br /&gt;
# Changing registry details(Proxy-http,socks) is very easy &amp;lt;ref&amp;gt;Raveendran, 28 Oct., 2009 [http://raveendran.wordpress.com/2009/10/28/watir-vs-selenium/ Selenium Vs Watir ]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*Cons&lt;br /&gt;
# Knowledge in the Ruby programming language is required &lt;br /&gt;
# Does not support certain HTML elements&lt;br /&gt;
# Limited reporting capabilities&lt;br /&gt;
# There is no recorder for Watir unlike Selenium for playback&lt;br /&gt;
&lt;br /&gt;
=='''Comparison of Features, Functionality, and More'''==&lt;br /&gt;
Some features or functionality may be repeated here.  However, we will go into a bit more detail than previously mentioned.&lt;br /&gt;
===='''Open Source'''====&lt;br /&gt;
Both Selenium and Watir are [http://en.wikipedia.org/wiki/Open-source_software open source]!  This allows for greater extensibility and a deeper understanding of the inner workings of both of the frameworks, if the developer/tester chooses to delve into such details.  Additionally, the open source community allows for a more transparent, user-driven development and support cycle.  Users (the tester/developer) can choose to submit bug fixes or enhancements as patches, or they can choose to just use it “straight out of the box.”&lt;br /&gt;
&lt;br /&gt;
====Application Language Agnostic====&lt;br /&gt;
&lt;br /&gt;
Both Selenium and Watir are application language agnostic.  Because both Selenium and Watir test UI functionality in the browser, they can be used to test any web application.    &lt;br /&gt;
&lt;br /&gt;
====Language-specific Test Cases====&lt;br /&gt;
&lt;br /&gt;
Both Selenium and Watir require test cases to be written in some programming language.  Traditionally, both frameworks had limited choices in terms of language bindings.  However, with the advent of WebDriver, both became much more flexible.  WebDriver provided the bindings needed for many languages.  Today, the following are supported:&lt;br /&gt;
&lt;br /&gt;
'''Selenium*'''&lt;br /&gt;
&lt;br /&gt;
* Officially-supported: [http://en.wikipedia.org/wiki/Java_(programming_language) Java], [http://en.wikipedia.org/wiki/C_Sharp_(programming_language) C#], [http://en.wikipedia.org/wiki/Ruby_(programming_language) Ruby], [http://en.wikipedia.org/wiki/Python_(programming_language) Python], [http://en.wikipedia.org/wiki/Node.js Javascript/Node.js]&lt;br /&gt;
&lt;br /&gt;
* Unofficial/community-supported: [http://en.wikipedia.org/wiki/Perl Perl], [http://en.wikipedia.org/wiki/PHP PHP], [http://en.wikipedia.org/wiki/Haskell_(programming_language) Haskell], [http://en.wikipedia.org/wiki/Objective-C Objective-C], [http://en.wikipedia.org/wiki/R_(programming_language) R], [http://en.wikipedia.org/wiki/Dart_(programming_language) Dart], [http://en.wikipedia.org/wiki/Tcl Tcl]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;According to SeleniumHQ’s download page.&lt;br /&gt;
&lt;br /&gt;
'''Watir'''&lt;br /&gt;
&lt;br /&gt;
Unfortunately (or fortunately), Ruby is the only supported language for Watir.  After all, Watir does stand for “Web Application Testing in Ruby.” However, there are other frameworks which were inspired by Watir (but entirely separate) available in Java and C# - [http://watij.com/ Watij] and [http://watin.org/ Watin],  respectively &amp;lt;ref&amp;gt;Djorgjievski, Darko. [http://www.sitepoint.com/watir-webdriver-control-browser/ Watir-WebDriver: Control the Browser]. ''SitePoint''. SitePoint Pty Ltd, 18 Apr. 2014. Web. 05 Oct. 2014.&amp;lt;/ref&amp;gt;.  There may be other similarly inspired frameworks available in other languages, but these are the most notable.&lt;br /&gt;
&lt;br /&gt;
====Cross-Browser and Headless Browser Support====&lt;br /&gt;
&lt;br /&gt;
[[File: watir_meet_webdriver.png | Watir Meets WebDriver &amp;lt;ref&amp;gt;[http://watirmelon.com/2010/04/10/watir-selenium-webdriver/ Watir Meets WebDriver Image]&amp;lt;/ref&amp;gt; |right|frame| link=http://yuml.me/diagram/scruffy/usecase/%5BTester%5D-%28Watir%20API%29,%20%28Watir%20API%29%3C%28FireWatir%29,%20%28Watir%20API%29%3C%28Watir%29,%20%28Watir%20API%29%3C%28SafariWatir%29,%20%28Watir%20API%29%3C%28Webdriver%29,%20%28Watir%20API%29%3C%28Celerity%29,%20%28Celerity%29-%28note:%20Celerity%20requires%20JRuby%29,%20%28Celerity%29-%28headless%29,%20%28Webdriver%29-%28Firefox%29,%20%28Webdriver%29-%28Chrome%29,%20%28Webdriver%29-%28IE%29,%20%28Webdriver%29-%28headless%29,%20%28FireWatir%29-%28Firefox%29,%20%28Watir%29-%28IE%29,%20%28SafariWatir%29-%28Safari%29.]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Traditionally, both Selenium and Watir were limited in the number of browsers they supported. Watir originally supported Internet Explorer and headless browsers exclusively.  Headless browsers were supported via the use of [https://github.com/jarib/celerity Celerity] &amp;lt;ref&amp;gt;Scott, Alister. [http://watirmelon.com/2010/04/10/watir-selenium-webdriver/ Watir, Selenium &amp;amp; WebDriver]. ''Watirmelon''. Watirmelon, 10 Apr. 2010. Web. 05 Oct. 2014.&amp;lt;/ref&amp;gt;.  Selenium started out as a Javascript library, so naturally it supported more browsers such as IE, Firefox, Safari, etc &amp;lt;ref name = &amp;quot;Introduction to Selenium&amp;quot; /&amp;gt;.  However, it did not support headless browsers.&lt;br /&gt;
Today, browser support looks much better for both Selenium and Watir, largely due to the introduction of WebDriver.  With WebDriver in existence, support for most browsers was added to Watir via the gem &amp;quot;watir-webdriver,&amp;quot; and Celerity became [https://github.com/jarib/celerity obsolete] because headless browser support was included in WebDriver.  Similarly for Selenium, support for headless browsers was added, as well as making the API much simpler and more concise &amp;lt;ref&amp;gt;[http://docs.seleniumhq.org/projects/webdriver/ Selenium WebDriver]. ''SeleniumHQ: Browser Automation''. Selenium Project, n.d. Web. 06 Oct. 2014.&amp;lt;/ref&amp;gt;.  Both Selenium &amp;lt;ref&amp;gt;Semerau, Luke. [https://code.google.com/p/selenium/wiki/WebDriverForMobileBrowsers WebDriverForMobileBrowsers]. ''Selenium''. Google Project Hosting, 14 Jan. 2013. Web. 06 Oct. 2014 &amp;lt;/ref&amp;gt; and Watir &amp;lt;ref&amp;gt;Scott, Alister. [http://watirwebdriver.com/mobile-devices/ Mobile Devices]. ''Watir WebDriver''. n.d. Web. 06 Oct. 2014. &amp;lt;/ref&amp;gt; have also gained support of Mobile browsers in recent years through WebDriver.  However, there is the obvious limitation that one can only test a browser which is supported on the running platform.  In other words, Safari and Internet explorer can only be tested on  OS X and Windows environments, respectively**.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;**&amp;lt;/nowiki&amp;gt; &amp;lt;span style=&amp;quot;font-size:88%&amp;quot;&amp;gt;Some work-arounds or programs may exist to allow these browsers to be tested on other platforms. Here, we are assuming no special additional configuration - just the base operating system and browsers.  With virtualization technologies such as [http://www.linux-kvm.org/page/Main_Page KVM], [https://www.virtualbox.org/ VirtualBox], and [http://en.wikipedia.org/wiki/Comparison_of_platform_virtualization_software others], this isn't a problem anyway.  [http://en.wikipedia.org/wiki/Virtual_machine Virtual machines] can be created with any operating system, as needed.&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Cross-Platform Support====&lt;br /&gt;
Both Watir and Selenium run on most popular distributions of Windows, Mac, and Linux.  Selenium doesn't have a list of officially supported operating system versions.  Instead they generally support any version that is currently popular.  Only a few versions are listed which they run test builds on.  These are versions which are officially known to work, but many more are supported as well.&lt;br /&gt;
&lt;br /&gt;
Because Watir is a collection of Ruby Gems, it runs on any platform that Ruby runs on.  Like Selenium, this includes nearly all popular platforms.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=='''Getting started'''==&lt;br /&gt;
===Selenium WebDriver=== &lt;br /&gt;
----&lt;br /&gt;
====Install/Configure (Java)====&lt;br /&gt;
Download binaries from [http://www.seleniumhq.org/download/ here] to configure Selenium. &lt;br /&gt;
Once you have all your binaries in a directory, you can open any IDE of your choice and add this directory with all the .jar files to the CLASSPATH&lt;br /&gt;
*Example&lt;br /&gt;
This is how a typical Selenium code to find the term say, “Automation” on Google and display the results on the page would look like in Java using the [https://code.google.com/p/selenium/wiki/HtmlUnitDriver HtmlUnitDriver] would look like.&lt;br /&gt;
The HtmlUnitDriver is a pure Java driver that runs entirely in-memory. Because of this, you won't see a new browser window open &amp;lt;ref&amp;gt;[https://code.google.com/p/selenium/wiki/GettingStarted Getting started with Selenium] Selenium: Browser Automation Framework. Google Code. 8 Feb, 2014.&amp;lt;/ref&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
       package org.selenium.example;&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;
       import org.openqa.selenium.By;&lt;br /&gt;
       import org.openqa.selenium.WebDriver;&lt;br /&gt;
       import org.openqa.selenium.WebElement;&lt;br /&gt;
       import org.openqa.selenium.htmlunit.HtmlUnitDriver;&amp;lt;br /&amp;gt;&lt;br /&gt;
       public class Example  {&lt;br /&gt;
       public static void main(String[] args) {&lt;br /&gt;
        // Create a new instance of the html unit driver&lt;br /&gt;
        // Notice that the remainder of the code relies on the interface,&lt;br /&gt;
        // not the implementation.&lt;br /&gt;
        WebDriver driver = new HtmlUnitDriver();&amp;lt;br /&amp;gt;&lt;br /&gt;
        System.out.println(&amp;quot;Beginning test for Google search using Selenium&amp;quot;);&lt;br /&gt;
        // And now use this to visit Google&lt;br /&gt;
        System.out.println(&amp;quot;Visit www.google.com&amp;quot; );&lt;br /&gt;
        driver.get(&amp;quot;http://www.google.com&amp;quot;);&amp;lt;br /&amp;gt;&lt;br /&gt;
        // Find the text input element by its name&lt;br /&gt;
        WebElement element = driver.findElement(By.name(&amp;quot;q&amp;quot;));&amp;lt;br /&amp;gt;&lt;br /&gt;
        // Enter something to search for&lt;br /&gt;
        System.out.println(&amp;quot;Type Automation in the search bar&amp;quot; );&lt;br /&gt;
        element.sendKeys(&amp;quot;Automation!&amp;quot;);&amp;lt;br /&amp;gt;&lt;br /&gt;
        // Now submit the form. WebDriver will find the form for us from the element&lt;br /&gt;
        element.submit();&amp;lt;br /&amp;gt;&lt;br /&gt;
        // Check the title of the page&lt;br /&gt;
        System.out.println(&amp;quot;Expected output&amp;quot; );&lt;br /&gt;
        System.out.println(&amp;quot;Page title is: &amp;quot; + driver.getTitle());&lt;br /&gt;
        driver.quit();&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
If you compile and run it, you should see a line with the title of the Google search results as output.&lt;br /&gt;
       ''Output:''&lt;br /&gt;
        Beginning test for Google search using Selenium &amp;lt;/ br&amp;gt;&lt;br /&gt;
        Visit www.google.com &amp;lt;/ br&amp;gt;&lt;br /&gt;
        Expected output &amp;lt;/ br&amp;gt;&lt;br /&gt;
        Page title is: Google&lt;br /&gt;
&lt;br /&gt;
====Install/Configure for other languages====&lt;br /&gt;
Configuring Selenium for languages other than Java and for other development environments can be looked up [http://docs.seleniumhq.org/docs/03_webdriver.jsp#setting-up-a-selenium-webdriver-project here]. viz(C#, Ruby, Python, PHP, Perl, Javascript)&lt;br /&gt;
&lt;br /&gt;
===Watir===&lt;br /&gt;
----&lt;br /&gt;
====Install/Configure (Ruby)====&lt;br /&gt;
Drivers for Watir are installed as gems which are nothing but Ruby libraries which can be accessed over the internet.&lt;br /&gt;
All the instructions for installing Watir on various operating systems (viz. Windows, Mac OS, Linux) can be found [http://watir.com/installation/ here].&lt;br /&gt;
&lt;br /&gt;
*Example:&lt;br /&gt;
This is how a typical Watir code to find the term say, “Automation” on Google and display the results on the page would look like using Ruby&amp;lt;ref&amp;gt;Chernenko, Iryna. [http://blog.qatestlab.com/2011/02/23/automated-testing-with-watir-tutorial-for-begginers-part-1/ Watir Example]. QATestLab Blog: Automated Testing with Watir, 23 Feb 2011.&lt;br /&gt;
&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
        # Required in ruby 1.8.7&lt;br /&gt;
        require 'rubygems'&lt;br /&gt;
        # Watir IE driver&lt;br /&gt;
        require 'watir'&amp;lt;br /&amp;gt; &lt;br /&gt;
        ie = Watir::IE.new&amp;lt;br /&amp;gt; &lt;br /&gt;
        # text to show on console&lt;br /&gt;
        puts &amp;quot;Beginning of the test for Google search engine&amp;quot;&lt;br /&gt;
        puts &amp;quot;Step 1:  Go to the Google homepage&amp;quot;&lt;br /&gt;
        ie.goto &amp;quot;http://www.google.com&amp;quot;&amp;lt;br /&amp;gt;&lt;br /&gt;
        #set a variable&lt;br /&gt;
        search_text = &amp;quot;Automation&amp;quot;&lt;br /&gt;
        puts &amp;quot;Step 2: enter &amp;quot;+ search_text +&amp;quot; in the search text field.&amp;quot;&lt;br /&gt;
        ie.text_field(:name, &amp;quot;q&amp;quot;).set search_text   # &amp;quot;q&amp;quot; is the name of the search field&amp;lt;br /&amp;gt;&lt;br /&gt;
        puts &amp;quot; Step 3: click the 'Google Search' button.&amp;quot;&lt;br /&gt;
        ie.button(:name, &amp;quot;btnG&amp;quot;).click # &amp;quot;btnG&amp;quot; is the name of the Search button&amp;lt;br /&amp;gt;&lt;br /&gt;
        puts &amp;quot; Expected Result:&amp;quot;&lt;br /&gt;
        puts &amp;quot;  A Google page with results should be shown. 'Watir, pronounced water' should be high on the list.&amp;quot;&lt;br /&gt;
        puts &amp;quot; Actual Result:&amp;quot;&lt;br /&gt;
        if ie.text.include? &amp;quot;Watir, pronounced water&amp;quot;	&lt;br /&gt;
             puts &amp;quot;  Test Passed. Found the text string: 'Watir, pronounced water'. Actual Results match Expected Results.&amp;quot;&lt;br /&gt;
        else	&lt;br /&gt;
 	     puts &amp;quot;  Test Failed! Could not find text: 'Watir, pronounced water'.&amp;quot;&lt;br /&gt;
        end&lt;br /&gt;
        puts &amp;quot;End of test: Google search.&amp;quot;&lt;br /&gt;
        ie.close&lt;br /&gt;
&lt;br /&gt;
On compiling and running this and passing the test, you will see something like,&lt;br /&gt;
&lt;br /&gt;
        ''Output:''&lt;br /&gt;
        Beginning of the test for Google search engine &lt;br /&gt;
        Step 1:  Go to the Google homepage &lt;br /&gt;
        Step 2: enter Automation in the search text field. &lt;br /&gt;
        Step 3: click the 'Google Search' button. &lt;br /&gt;
        Expected Result: &lt;br /&gt;
        A Google page with results should be shown. 'Watir, pronounced water' should be high on the list. 	&lt;br /&gt;
        Test Passed. Found the text string: 'Watir, pronounced water'. Actual Results match Expected Results. &lt;br /&gt;
        End of test: Google search. &amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Similar Tools==&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Sahi_(software) Sahi], uses the Sahi Scripting Language&amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Soatest SOATest], for testing and validating [http://en.wikipedia.org/wiki/Application_programming_interface API] driven applications &amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/TestComplete TestComplete], for Desktops, Web and Mobile&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
* [http://www.hiretheworld.com/blog/tech-blog/migrating-unit-tests-from-selenium-to-watir-webdriver Migrating unit tests from Selenium to Watir Web Driver] &amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://www.hiretheworld.com/blog/tech-blog/migrating-unit-tests-from-selenium-to-watir-webdriver Learning Selenium IDE] &amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/List_of_web_testing_tools List of web testing tools] &amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/List_of_web_testing_tools OWASP List of Acceptance Testing tools]&lt;br /&gt;
* [http://www.ijiet.org/papers/425-T0026.pdf  Study of Browser Based Automated Test Tools WATIR and Selenium] Nisha Gogna, August 2014, International Journal of Information and Education Technology, Vol. 4, No. 4&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
{{reflist}}&lt;br /&gt;
&amp;lt;references /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==External Links==&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Selenium_(software) Selenium Wiki Page] &amp;lt;br /&amp;gt;&lt;br /&gt;
* [https://github.com/SeleniumHQ/selenium Selenium Source Code] &amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Watir Watir Wiki Page] &amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Watir Watir Source Code] &amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Watir SauceLabs HomePage] &amp;lt;br /&amp;gt;&lt;/div&gt;</summary>
		<author><name>Jjbeaver</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/ch1b_27_js&amp;diff=89580</id>
		<title>CSC/ECE 517 Fall 2014/ch1b 27 js</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/ch1b_27_js&amp;diff=89580"/>
		<updated>2014-10-14T02:32:53Z</updated>

		<summary type="html">&lt;p&gt;Jjbeaver: /* Need for test automation */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;='''Selenium vs. Watir'''=&lt;br /&gt;
&lt;br /&gt;
Developing web applications is proving to be a challenging task with each passing day given the complex requirements and the demanding nature of the these applications. For the web applications to be robust we need to put in place some good testing strategies.&lt;br /&gt;
&lt;br /&gt;
'''''Selenium''''' is one of the most popularly used open source automation tools for web based applications. It is a JavaScript framework that runs in your web browser to interact with various elements in your browser. All in all, Selenium is a set of different software tools each with a different approach to supporting test automation. Selenium provides a rich set of testing functions that can be customized to suit the testing requirements.&lt;br /&gt;
 &lt;br /&gt;
'''''Watir''''', is another lightweight automation testing tool that is widely used for web app testing. It is an open-source ([http://en.wikipedia.org/wiki/BSD_licenses BSD])  family of Ruby libraries for automating web browsers. It allows you to write tests that are easy to read and maintain&amp;lt;ref&amp;gt;[http://watir.com/ Web Application Testing in Ruby]&amp;lt;/ref&amp;gt;. Despite the fact that it is a set of Ruby libraries, it works perfectly, independent of the language that the web application is developed in. Watir as a tool is extremely simple and flexible.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=='''Motivation'''==&lt;br /&gt;
===Need for test automation===&lt;br /&gt;
With the majority of software applications today being implemented as [http://en.wikipedia.org/wiki/Web_application web applications] to be used over the internet, testing is becoming an indispensable part of the software development lifecycle ([http://en.wikipedia.org/wiki/Software_development_process SDLC]) of these applications. [http://en.wikipedia.org/wiki/Test_automation Test automation] is used where manual testing needs to be carried out repeatedly making it a cumbersome task. Test automation uses a software tool for this purpose on the application to be tested. It has proven to be highly efficient and critical in larger software development companies. Additionally, automation can be a valuable way to make Test Driven Development ([http://en.wikipedia.org/wiki/Test-driven_development TDD]) tasks an important part of the software development workflow.&lt;br /&gt;
 &lt;br /&gt;
Test Automation has a number of advantages mostly dealing with repetitiveness of the tests and the time taken.&lt;br /&gt;
* '''Covers cases that manual testing probably cannot'''&lt;br /&gt;
# Finds defects missed out my manual testing&lt;br /&gt;
# Automated testing can simulate numerous virtual users interacting with the web software/application&lt;br /&gt;
* '''Helps save time and money'''&lt;br /&gt;
# Once created, automated tests can be executed repeatedly at no additional   costs and at a much faster pace. Saving time directly translates into saving cost.&lt;br /&gt;
# Supports virtually unlimited iterations of test case execution&lt;br /&gt;
* '''Increase test coverage and accuracy'''&lt;br /&gt;
# Automated tests perform the exact same steps and records all details precisely&lt;br /&gt;
# They also increase the depth and scope of tests to improve the quality of the software&lt;br /&gt;
&lt;br /&gt;
=='''Brief History'''==&lt;br /&gt;
====Selenium====&lt;br /&gt;
&lt;br /&gt;
[[File: SE-logo.png|right|Selenium Logo|link=http://www.seleniumhq.org/images/big-logo.png]]&lt;br /&gt;
&lt;br /&gt;
''Selenium'' was developed in the year 2004 by Jason Huggins and has been continuously evolving ever since. Jason Huggins developed this as an internal tool for [http://en.wikipedia.org/wiki/ThoughtWorks ThoughtWorks] as a javascript library which came to be known as the Selenium core. Selenium core is now the basis of the Selenium Remote Control (the server) and Selenium IDE.&lt;br /&gt;
The year 2006 marked the beginning of the development of the 'WebDriver project' which was what they believed ‘a tool of the future’. The WebDriver was initiated to solve the problems that were faced due to the fact that Selenium was a based on JavaScript and a lot of security limitations browsers apply to Javascript.&lt;br /&gt;
In 2008, both Selenium and WebDriver merged to provide a common set of features to all users which is called Selenium 2.&lt;br /&gt;
Simon Stewart, the creator of the WebDriver Project, in a joint email to the WebDriver and Selenium community on August 6, 2009 said the following,&lt;br /&gt;
&lt;br /&gt;
:“Why are the projects merging? Partly because webdriver addresses some shortcomings in selenium (by being able to bypass the JS sandbox, for example. And we’ve got a gorgeous API), partly because selenium addresses some shortcomings  in webdriver (such as supporting a broader range of browsers) and partly because the main selenium contributors and I felt that it was the best way to offer users the best possible framework.”&amp;lt;ref name =&amp;quot;Introduction to Selenium&amp;quot;&amp;gt; [http://docs.seleniumhq.org/docs/01_introducing_selenium.jsp#selenium-history Introducing Selenium]. ''SeleniumHQ: Browser Automation''. Selenium Project, 4 Oct. 2014. Web. 06 Oct. 2014.&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Watir====&lt;br /&gt;
&lt;br /&gt;
''Watir'' started as a library to teach testers to write ruby code and grew to be an IE implementation which now supports IE, Firefox, Safari, Google Chrome and Opera.&lt;br /&gt;
Watir was primarily developed by Bret Pettichord and Paul Rogers. Watir has since then has a couple of stable releases for Watir classic as well as Watir WebDriver. The most recent releases being&amp;lt;ref&amp;gt;[http://watir.com/category/releases/ Watir Releases]. Watir: Web Application Testing in Ruby. 28 April, 2013&amp;lt;/ref&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
[[File: Watir.gif|right|Watir logo|link=http://upload.wikimedia.org/wikipedia/commons/7/7e/Watir.gif]]&lt;br /&gt;
&lt;br /&gt;
* Watir-Classic	    &lt;br /&gt;
# 0.6.3 April 10, 2013 ([https://github.com/watir/watir-webdriver/blob/master/CHANGES.md#063 Release Notes]) &amp;lt;br /&amp;gt;&lt;br /&gt;
* Watir-WebDriver	    &lt;br /&gt;
# 3.6.0 March 16, 2013 ([https://groups.google.com/forum/#!msg/watir-general/MOOun5g3Hvg/JBVNy957lDYJ Release Notes]) &amp;lt;br /&amp;gt;&lt;br /&gt;
# 3.5.0 March 10, 2013 ([https://groups.google.com/forum/#!msg/watir-general/aeUqsglvK6k/Kq7FCBiERjYJ Release Notes]) &amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Watir has a google group ([https://groups.google.com/forum/#!forum/watir-general Watir General]) for its support and contribution while Selenium also has a [http://seleniumforum.forumotion.net/ Selenium forum] apart from its google group called [https://groups.google.com/forum/#!forum/selenium-users Selenium Users].&lt;br /&gt;
&lt;br /&gt;
=='''Pros/Cons'''==&lt;br /&gt;
===Selenium===&lt;br /&gt;
*Pros&lt;br /&gt;
# Open Source, free Software&lt;br /&gt;
# Easy Installation&lt;br /&gt;
# Scripting Techniques&lt;br /&gt;
##Easy recording and playback of scripts&lt;br /&gt;
##Scripts are modular, can be reused&lt;br /&gt;
# Selenium was first written in Java but it also supports .Net, Ruby, Perl, PHP and Python. This is a big plus when you want to build your framework in a language that has the highest adoption in the organization it is being built within. Unlike tools like [http://en.wikipedia.org/wiki/HP_QuickTest_Professional QTP] which force you to use [http://en.wikipedia.org/wiki/VBScript VBScript]&lt;br /&gt;
# Integration with third party tools is possible &lt;br /&gt;
# You can instantiate several concurrent tests with Selenium since no dedicated machine is required&lt;br /&gt;
&lt;br /&gt;
*Cons&lt;br /&gt;
#  Selenium has concept of locators that support common attributes like id, names etc as well as [http://en.wikipedia.org/wiki/XPath XPATH], [http://en.wikipedia.org/wiki/JavaScript javascript] DOM and others. However, this is still not as smart as say the [http://www.tutorialspoint.com/qtp/qtp_object_repository.htm Object Repository] (OR) in QTP. That being said, QTP’s OR comes with it´s baggage as well.&amp;lt;ref&amp;gt;[http://www.qualitytesting.info/forum/topics/selenium-automation-tool Selenium Automation Tool]&amp;lt;/ref&amp;gt;&lt;br /&gt;
# It does not generate detailed results like the result viewer&lt;br /&gt;
# No option to verify images&lt;br /&gt;
&lt;br /&gt;
===Watir===&lt;br /&gt;
*Pros&lt;br /&gt;
# Open Source&lt;br /&gt;
# Opens browser as a normal way how the user opens it unlike Selenium which needs to create an object to work with&lt;br /&gt;
# Changing registry details(Proxy-http,socks) is very easy &amp;lt;ref&amp;gt;Raveendran, 28 Oct., 2009 [http://raveendran.wordpress.com/2009/10/28/watir-vs-selenium/ Selenium Vs Watir ]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*Cons&lt;br /&gt;
# Knowledge in the Ruby programming language is required &lt;br /&gt;
# Does not support certain HTML elements&lt;br /&gt;
# Limited reporting capabilities&lt;br /&gt;
# There is no recorder for Watir unlike Selenium for playback&lt;br /&gt;
&lt;br /&gt;
=='''Comparison of Features, Functionality, and More'''==&lt;br /&gt;
Some features or functionality may be repeated here.  However, we will go into a bit more detail than previously mentioned.&lt;br /&gt;
===='''Open Source'''====&lt;br /&gt;
Both Selenium and Watir are [http://en.wikipedia.org/wiki/Open-source_software open source]!  This allows for greater extensibility and a deeper understanding of the inner workings of both of the frameworks, if the developer/tester chooses to delve into such details.  Additionally, the open source community allows for a more transparent, user-driven development and support cycle.  Users (the tester/developer) can choose to submit bug fixes or enhancements as patches, or they can choose to just use it “straight out of the box.”&lt;br /&gt;
&lt;br /&gt;
====Application Language Agnostic====&lt;br /&gt;
&lt;br /&gt;
Both Selenium and Watir are application language agnostic.  Because both Selenium and Watir test UI functionality in the browser, they can be used to test any web application.    &lt;br /&gt;
&lt;br /&gt;
====Language-specific Test Cases====&lt;br /&gt;
&lt;br /&gt;
Both Selenium and Watir require test cases to be written in some programming language.  Traditionally, both frameworks had limited choices in terms of language bindings.  However, with the advent of WebDriver, both became much more flexible.  WebDriver provided the bindings needed for many languages.  Today, the following are supported:&lt;br /&gt;
&lt;br /&gt;
'''Selenium*'''&lt;br /&gt;
&lt;br /&gt;
* Officially-supported: [http://en.wikipedia.org/wiki/Java_(programming_language) Java], [http://en.wikipedia.org/wiki/C_Sharp_(programming_language) C#], [http://en.wikipedia.org/wiki/Ruby_(programming_language) Ruby], [http://en.wikipedia.org/wiki/Python_(programming_language) Python], [http://en.wikipedia.org/wiki/Node.js Javascript/Node.js]&lt;br /&gt;
&lt;br /&gt;
* Unofficial/community-supported: [http://en.wikipedia.org/wiki/Perl Perl], [http://en.wikipedia.org/wiki/PHP PHP], [http://en.wikipedia.org/wiki/Haskell_(programming_language) Haskell], [http://en.wikipedia.org/wiki/Objective-C Objective-C], [http://en.wikipedia.org/wiki/R_(programming_language) R], [http://en.wikipedia.org/wiki/Dart_(programming_language) Dart], [http://en.wikipedia.org/wiki/Tcl Tcl]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;According to SeleniumHQ’s download page.&lt;br /&gt;
&lt;br /&gt;
'''Watir'''&lt;br /&gt;
&lt;br /&gt;
Unfortunately (or fortunately), Ruby is the only supported language for Watir.  After all, Watir does stand for “Web Application Testing in Ruby.” However, there are other frameworks which were inspired by Watir (but entirely separate) available in Java and C# - [http://watij.com/ Watij] and [http://watin.org/ Watin],  respectively &amp;lt;ref&amp;gt;Djorgjievski, Darko. [http://www.sitepoint.com/watir-webdriver-control-browser/ Watir-WebDriver: Control the Browser]. ''SitePoint''. SitePoint Pty Ltd, 18 Apr. 2014. Web. 05 Oct. 2014.&amp;lt;/ref&amp;gt;.  There may be other similarly inspired frameworks available in other languages, but these are the most notable.&lt;br /&gt;
&lt;br /&gt;
====Cross-Browser and Headless Browser Support====&lt;br /&gt;
&lt;br /&gt;
[[File: watir_meet_webdriver.png | Watir Meets WebDriver &amp;lt;ref&amp;gt;[http://watirmelon.com/2010/04/10/watir-selenium-webdriver/ Watir Meets WebDriver Image]&amp;lt;/ref&amp;gt; |right|frame| link=http://yuml.me/diagram/scruffy/usecase/%5BTester%5D-%28Watir%20API%29,%20%28Watir%20API%29%3C%28FireWatir%29,%20%28Watir%20API%29%3C%28Watir%29,%20%28Watir%20API%29%3C%28SafariWatir%29,%20%28Watir%20API%29%3C%28Webdriver%29,%20%28Watir%20API%29%3C%28Celerity%29,%20%28Celerity%29-%28note:%20Celerity%20requires%20JRuby%29,%20%28Celerity%29-%28headless%29,%20%28Webdriver%29-%28Firefox%29,%20%28Webdriver%29-%28Chrome%29,%20%28Webdriver%29-%28IE%29,%20%28Webdriver%29-%28headless%29,%20%28FireWatir%29-%28Firefox%29,%20%28Watir%29-%28IE%29,%20%28SafariWatir%29-%28Safari%29.]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Traditionally, both Selenium and Watir were limited in the number of browsers they supported. Watir originally supported Internet Explorer and headless browsers exclusively.  Headless browsers were supported via the use of [https://github.com/jarib/celerity Celerity] &amp;lt;ref&amp;gt;Scott, Alister. [http://watirmelon.com/2010/04/10/watir-selenium-webdriver/ Watir, Selenium &amp;amp; WebDriver]. ''Watirmelon''. Watirmelon, 10 Apr. 2010. Web. 05 Oct. 2014.&amp;lt;/ref&amp;gt;.  Selenium started out as a Javascript library, so naturally it supported more browsers such as IE, Firefox, Safari, etc &amp;lt;ref name = &amp;quot;Introduction to Selenium&amp;quot; /&amp;gt;.  However, it did not support headless browsers.&lt;br /&gt;
Today, browser support looks much better for both Selenium and Watir, largely due to the introduction of WebDriver.  With WebDriver in existence, support for most browsers was added to Watir via the gem &amp;quot;watir-webdriver,&amp;quot; and Celerity became [https://github.com/jarib/celerity obsolete] because headless browser support was included in WebDriver.  Similarly for Selenium, support for headless browsers was added, as well as making the API much simpler and more concise &amp;lt;ref&amp;gt;[http://docs.seleniumhq.org/projects/webdriver/ Selenium WebDriver]. ''SeleniumHQ: Browser Automation''. Selenium Project, n.d. Web. 06 Oct. 2014.&amp;lt;/ref&amp;gt;.  Both Selenium &amp;lt;ref&amp;gt;Semerau, Luke. [https://code.google.com/p/selenium/wiki/WebDriverForMobileBrowsers WebDriverForMobileBrowsers]. ''Selenium''. Google Project Hosting, 14 Jan. 2013. Web. 06 Oct. 2014 &amp;lt;/ref&amp;gt; and Watir &amp;lt;ref&amp;gt;Scott, Alister. [http://watirwebdriver.com/mobile-devices/ Mobile Devices]. ''Watir WebDriver''. n.d. Web. 06 Oct. 2014. &amp;lt;/ref&amp;gt; have also gained support of Mobile browsers in recent years through WebDriver.  However, there is the obvious limitation that one can only test a browser which is supported on the running platform.  In other words, Safari and Internet explorer can only be tested on  OS X and Windows environments, respectively**.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;**&amp;lt;/nowiki&amp;gt; &amp;lt;span style=&amp;quot;font-size:88%&amp;quot;&amp;gt;Some work-arounds or programs may exist to allow these browsers to be tested on other platforms. Here, we are assuming no special additional configuration - just the base operating system and browsers.  With virtualization technologies such as [http://www.linux-kvm.org/page/Main_Page KVM], [https://www.virtualbox.org/ VirtualBox], and [http://en.wikipedia.org/wiki/Comparison_of_platform_virtualization_software others], this isn't a problem anyway.  [http://en.wikipedia.org/wiki/Virtual_machine Virtual machines] can be created with any operating system, as needed.&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Cross-Platform Support====&lt;br /&gt;
Both Watir and Selenium run on most popular distributions of Windows, Mac, and Linux.  Selenium doesn't have a list of officially supported operating system versions.  Instead they generally support any version that is currently popular.  Only a few versions are listed which they run test builds on.  These are versions which are officially known to work, but many more are supported as well.&lt;br /&gt;
&lt;br /&gt;
Because Watir is a collection of Ruby Gems, it runs on any platform that Ruby runs on.  Like Selenium, this includes nearly all popular platforms.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=='''Getting started'''==&lt;br /&gt;
===Selenium WebDriver=== &lt;br /&gt;
----&lt;br /&gt;
====Install/Configure (Java)====&lt;br /&gt;
Download binaries from [http://www.seleniumhq.org/download/ here] to configure Selenium. &lt;br /&gt;
Once you have all your binaries in a directory, you can open any IDE of your choice and add this directory with all the .jar files to the CLASSPATH&lt;br /&gt;
*Example&lt;br /&gt;
This is how a typical Selenium code to find the term say, “Automation” on Google and display the results on the page would look like in Java using the [https://code.google.com/p/selenium/wiki/HtmlUnitDriver HtmlUnitDriver] would look like.&lt;br /&gt;
The HtmlUnitDriver is a pure Java driver that runs entirely in-memory. Because of this, you won't see a new browser window open &amp;lt;ref&amp;gt;[https://code.google.com/p/selenium/wiki/GettingStarted Getting started with Selenium] Selenium: Browser Automation Framework. Google Code. 8 Feb, 2014.&amp;lt;/ref&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
       package org.selenium.example;&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;
       import org.openqa.selenium.By;&lt;br /&gt;
       import org.openqa.selenium.WebDriver;&lt;br /&gt;
       import org.openqa.selenium.WebElement;&lt;br /&gt;
       import org.openqa.selenium.htmlunit.HtmlUnitDriver;&amp;lt;br /&amp;gt;&lt;br /&gt;
       public class Example  {&lt;br /&gt;
       public static void main(String[] args) {&lt;br /&gt;
        // Create a new instance of the html unit driver&lt;br /&gt;
        // Notice that the remainder of the code relies on the interface,&lt;br /&gt;
        // not the implementation.&lt;br /&gt;
        WebDriver driver = new HtmlUnitDriver();&amp;lt;br /&amp;gt;&lt;br /&gt;
        System.out.println(&amp;quot;Beginning test for Google search using Selenium&amp;quot;);&lt;br /&gt;
        // And now use this to visit Google&lt;br /&gt;
        System.out.println(&amp;quot;Visit www.google.com&amp;quot; );&lt;br /&gt;
        driver.get(&amp;quot;http://www.google.com&amp;quot;);&amp;lt;br /&amp;gt;&lt;br /&gt;
        // Find the text input element by its name&lt;br /&gt;
        WebElement element = driver.findElement(By.name(&amp;quot;q&amp;quot;));&amp;lt;br /&amp;gt;&lt;br /&gt;
        // Enter something to search for&lt;br /&gt;
        System.out.println(&amp;quot;Type Automation in the search bar&amp;quot; );&lt;br /&gt;
        element.sendKeys(&amp;quot;Automation!&amp;quot;);&amp;lt;br /&amp;gt;&lt;br /&gt;
        // Now submit the form. WebDriver will find the form for us from the element&lt;br /&gt;
        element.submit();&amp;lt;br /&amp;gt;&lt;br /&gt;
        // Check the title of the page&lt;br /&gt;
        System.out.println(&amp;quot;Expected output&amp;quot; );&lt;br /&gt;
        System.out.println(&amp;quot;Page title is: &amp;quot; + driver.getTitle());&lt;br /&gt;
        driver.quit();&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
If you compile and run it, you should see a line with the title of the Google search results as output.&lt;br /&gt;
       ''Output:''&lt;br /&gt;
        Beginning test for Google search using Selenium &amp;lt;/ br&amp;gt;&lt;br /&gt;
        Visit www.google.com &amp;lt;/ br&amp;gt;&lt;br /&gt;
        Expected output &amp;lt;/ br&amp;gt;&lt;br /&gt;
        Page title is: Google&lt;br /&gt;
&lt;br /&gt;
====Install/Configure for other languages====&lt;br /&gt;
Configuring Selenium for languages other than Java and for other development environments can be looked up [http://docs.seleniumhq.org/docs/03_webdriver.jsp#setting-up-a-selenium-webdriver-project here]. viz(C#, Ruby, Python, PHP, Perl, Javascript)&lt;br /&gt;
&lt;br /&gt;
===Watir===&lt;br /&gt;
----&lt;br /&gt;
====Install/Configure (Ruby)====&lt;br /&gt;
Drivers for Watir are installed as gems which are nothing but Ruby libraries which can be accessed over the internet.&lt;br /&gt;
All the instructions for installing Watir on various operating systems (viz. Windows, Mac OS, Linux) can be found [http://watir.com/installation/ here].&lt;br /&gt;
&lt;br /&gt;
*Example:&lt;br /&gt;
This is how a typical Watir code to find the term say, “Automation” on Google and display the results on the page would look like using Ruby&amp;lt;ref&amp;gt;Chernenko, Iryna. [http://blog.qatestlab.com/2011/02/23/automated-testing-with-watir-tutorial-for-begginers-part-1/ Watir Example]. QATestLab Blog: Automated Testing with Watir, 23 Feb 2011.&lt;br /&gt;
&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
        # Required in ruby 1.8.7&lt;br /&gt;
        require 'rubygems'&lt;br /&gt;
        # Watir IE driver&lt;br /&gt;
        require 'watir'&amp;lt;br /&amp;gt; &lt;br /&gt;
        ie = Watir::IE.new&amp;lt;br /&amp;gt; &lt;br /&gt;
        # text to show on console&lt;br /&gt;
        puts &amp;quot;Beginning of the test for Google search engine&amp;quot;&lt;br /&gt;
        puts &amp;quot;Step 1:  Go to the Google homepage&amp;quot;&lt;br /&gt;
        ie.goto &amp;quot;http://www.google.com&amp;quot;&amp;lt;br /&amp;gt;&lt;br /&gt;
        #set a variable&lt;br /&gt;
        search_text = &amp;quot;Automation&amp;quot;&lt;br /&gt;
        puts &amp;quot;Step 2: enter &amp;quot;+ search_text +&amp;quot; in the search text field.&amp;quot;&lt;br /&gt;
        ie.text_field(:name, &amp;quot;q&amp;quot;).set search_text   # &amp;quot;q&amp;quot; is the name of the search field&amp;lt;br /&amp;gt;&lt;br /&gt;
        puts &amp;quot; Step 3: click the 'Google Search' button.&amp;quot;&lt;br /&gt;
        ie.button(:name, &amp;quot;btnG&amp;quot;).click # &amp;quot;btnG&amp;quot; is the name of the Search button&amp;lt;br /&amp;gt;&lt;br /&gt;
        puts &amp;quot; Expected Result:&amp;quot;&lt;br /&gt;
        puts &amp;quot;  A Google page with results should be shown. 'Watir, pronounced water' should be high on the list.&amp;quot;&lt;br /&gt;
        puts &amp;quot; Actual Result:&amp;quot;&lt;br /&gt;
        if ie.text.include? &amp;quot;Watir, pronounced water&amp;quot;	&lt;br /&gt;
             puts &amp;quot;  Test Passed. Found the text string: 'Watir, pronounced water'. Actual Results match Expected Results.&amp;quot;&lt;br /&gt;
        else	&lt;br /&gt;
 	     puts &amp;quot;  Test Failed! Could not find text: 'Watir, pronounced water'.&amp;quot;&lt;br /&gt;
        end&lt;br /&gt;
        puts &amp;quot;End of test: Google search.&amp;quot;&lt;br /&gt;
        ie.close&lt;br /&gt;
&lt;br /&gt;
On compiling and running this and passing the test, you will see something like,&lt;br /&gt;
&lt;br /&gt;
        ''Output:''&lt;br /&gt;
        Beginning of the test for Google search engine &lt;br /&gt;
        Step 1:  Go to the Google homepage &lt;br /&gt;
        Step 2: enter Automation in the search text field. &lt;br /&gt;
        Step 3: click the 'Google Search' button. &lt;br /&gt;
        Expected Result: &lt;br /&gt;
        A Google page with results should be shown. 'Watir, pronounced water' should be high on the list. 	&lt;br /&gt;
        Test Passed. Found the text string: 'Watir, pronounced water'. Actual Results match Expected Results. &lt;br /&gt;
        End of test: Google search. &amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Similar Tools==&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Sahi_(software) Sahi], uses the Sahi Scripting Language&amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Soatest SOATest], for testing and validating [http://en.wikipedia.org/wiki/Application_programming_interface API] driven applications &amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/TestComplete TestComplete], for Desktops, Web and Mobile&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
* [http://www.hiretheworld.com/blog/tech-blog/migrating-unit-tests-from-selenium-to-watir-webdriver Migrating unit tests from Selenium to Watir Web Driver] &amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://www.hiretheworld.com/blog/tech-blog/migrating-unit-tests-from-selenium-to-watir-webdriver Learning Selenium IDE] &amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/List_of_web_testing_tools List of web testing tools] &amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/List_of_web_testing_tools OWASP List of Acceptance Testing tools]&lt;br /&gt;
* [http://www.ijiet.org/papers/425-T0026.pdf  Study of Browser Based Automated Test Tools WATIR and Selenium] Nisha Gogna, August 2014, International Journal of Information and Education Technology, Vol. 4, No. 4&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
{{reflist}}&lt;br /&gt;
&amp;lt;references /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==External Links==&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Selenium_(software) Selenium Wiki Page] &amp;lt;br /&amp;gt;&lt;br /&gt;
* [https://github.com/SeleniumHQ/selenium Selenium Source Code] &amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Watir Watir Wiki Page] &amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Watir Watir Source Code] &amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Watir SauceLabs HomePage] &amp;lt;br /&amp;gt;&lt;/div&gt;</summary>
		<author><name>Jjbeaver</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/ch1b_27_js&amp;diff=89579</id>
		<title>CSC/ECE 517 Fall 2014/ch1b 27 js</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/ch1b_27_js&amp;diff=89579"/>
		<updated>2014-10-14T02:32:04Z</updated>

		<summary type="html">&lt;p&gt;Jjbeaver: /* Watir */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;='''Selenium vs. Watir'''=&lt;br /&gt;
&lt;br /&gt;
Developing web applications is proving to be a challenging task with each passing day given the complex requirements and the demanding nature of the these applications. For the web applications to be robust we need to put in place some good testing strategies.&lt;br /&gt;
&lt;br /&gt;
'''''Selenium''''' is one of the most popularly used open source automation tools for web based applications. It is a JavaScript framework that runs in your web browser to interact with various elements in your browser. All in all, Selenium is a set of different software tools each with a different approach to supporting test automation. Selenium provides a rich set of testing functions that can be customized to suit the testing requirements.&lt;br /&gt;
 &lt;br /&gt;
'''''Watir''''', is another lightweight automation testing tool that is widely used for web app testing. It is an open-source ([http://en.wikipedia.org/wiki/BSD_licenses BSD])  family of Ruby libraries for automating web browsers. It allows you to write tests that are easy to read and maintain&amp;lt;ref&amp;gt;[http://watir.com/ Web Application Testing in Ruby]&amp;lt;/ref&amp;gt;. Despite the fact that it is a set of Ruby libraries, it works perfectly, independent of the language that the web application is developed in. Watir as a tool is extremely simple and flexible.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=='''Motivation'''==&lt;br /&gt;
===Need for test automation===&lt;br /&gt;
With the majority of software applications today being implemented as [http://en.wikipedia.org/wiki/Web_application web applications] to be used over the internet, testing is becoming an indispensable part of the software development lifecycle ([http://en.wikipedia.org/wiki/Software_development_process SDLC]) of these applications. [http://en.wikipedia.org/wiki/Test_automation Test automation] is used where manual testing needs to be carried out repeatedly making it a cumbersome task. Test automation uses a software tool for this purpose on the application to be tested. It has proven to be highly efficient and critical in larger software development companies. Additionally, automation can be a valuable way to make Test Driven Development ([http://en.wikipedia.org/wiki/Test-driven_development TDD]) tasks an important part of the software development workflow.&lt;br /&gt;
 &lt;br /&gt;
Test Automation has a number of advantages mostly dealing with repetitiveness of the tests and the time taken,&lt;br /&gt;
* '''Covers cases that manual testing probably cannot'''&lt;br /&gt;
# Finds defects missed out my manual testing&lt;br /&gt;
# Automated testing can simulate numerous virtual users interacting with the web software/application&lt;br /&gt;
* '''Helps save time and money'''&lt;br /&gt;
# Once created, automated tests can be executed repeatedly at no additional   costs and at a much faster pace. Saving time directly translates into saving cost.&lt;br /&gt;
# Supports virtually unlimited iterations of test case execution&lt;br /&gt;
* '''Increase test coverage and accuracy'''&lt;br /&gt;
# Automated tests perform the exact same steps and records all details precisely&lt;br /&gt;
# They also increase the depth and scope of tests to improve the quality of the software&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=='''Brief History'''==&lt;br /&gt;
====Selenium====&lt;br /&gt;
&lt;br /&gt;
[[File: SE-logo.png|right|Selenium Logo|link=http://www.seleniumhq.org/images/big-logo.png]]&lt;br /&gt;
&lt;br /&gt;
''Selenium'' was developed in the year 2004 by Jason Huggins and has been continuously evolving ever since. Jason Huggins developed this as an internal tool for [http://en.wikipedia.org/wiki/ThoughtWorks ThoughtWorks] as a javascript library which came to be known as the Selenium core. Selenium core is now the basis of the Selenium Remote Control (the server) and Selenium IDE.&lt;br /&gt;
The year 2006 marked the beginning of the development of the 'WebDriver project' which was what they believed ‘a tool of the future’. The WebDriver was initiated to solve the problems that were faced due to the fact that Selenium was a based on JavaScript and a lot of security limitations browsers apply to Javascript.&lt;br /&gt;
In 2008, both Selenium and WebDriver merged to provide a common set of features to all users which is called Selenium 2.&lt;br /&gt;
Simon Stewart, the creator of the WebDriver Project, in a joint email to the WebDriver and Selenium community on August 6, 2009 said the following,&lt;br /&gt;
&lt;br /&gt;
:“Why are the projects merging? Partly because webdriver addresses some shortcomings in selenium (by being able to bypass the JS sandbox, for example. And we’ve got a gorgeous API), partly because selenium addresses some shortcomings  in webdriver (such as supporting a broader range of browsers) and partly because the main selenium contributors and I felt that it was the best way to offer users the best possible framework.”&amp;lt;ref name =&amp;quot;Introduction to Selenium&amp;quot;&amp;gt; [http://docs.seleniumhq.org/docs/01_introducing_selenium.jsp#selenium-history Introducing Selenium]. ''SeleniumHQ: Browser Automation''. Selenium Project, 4 Oct. 2014. Web. 06 Oct. 2014.&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Watir====&lt;br /&gt;
&lt;br /&gt;
''Watir'' started as a library to teach testers to write ruby code and grew to be an IE implementation which now supports IE, Firefox, Safari, Google Chrome and Opera.&lt;br /&gt;
Watir was primarily developed by Bret Pettichord and Paul Rogers. Watir has since then has a couple of stable releases for Watir classic as well as Watir WebDriver. The most recent releases being&amp;lt;ref&amp;gt;[http://watir.com/category/releases/ Watir Releases]. Watir: Web Application Testing in Ruby. 28 April, 2013&amp;lt;/ref&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
[[File: Watir.gif|right|Watir logo|link=http://upload.wikimedia.org/wikipedia/commons/7/7e/Watir.gif]]&lt;br /&gt;
&lt;br /&gt;
* Watir-Classic	    &lt;br /&gt;
# 0.6.3 April 10, 2013 ([https://github.com/watir/watir-webdriver/blob/master/CHANGES.md#063 Release Notes]) &amp;lt;br /&amp;gt;&lt;br /&gt;
* Watir-WebDriver	    &lt;br /&gt;
# 3.6.0 March 16, 2013 ([https://groups.google.com/forum/#!msg/watir-general/MOOun5g3Hvg/JBVNy957lDYJ Release Notes]) &amp;lt;br /&amp;gt;&lt;br /&gt;
# 3.5.0 March 10, 2013 ([https://groups.google.com/forum/#!msg/watir-general/aeUqsglvK6k/Kq7FCBiERjYJ Release Notes]) &amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Watir has a google group ([https://groups.google.com/forum/#!forum/watir-general Watir General]) for its support and contribution while Selenium also has a [http://seleniumforum.forumotion.net/ Selenium forum] apart from its google group called [https://groups.google.com/forum/#!forum/selenium-users Selenium Users].&lt;br /&gt;
&lt;br /&gt;
=='''Pros/Cons'''==&lt;br /&gt;
===Selenium===&lt;br /&gt;
*Pros&lt;br /&gt;
# Open Source, free Software&lt;br /&gt;
# Easy Installation&lt;br /&gt;
# Scripting Techniques&lt;br /&gt;
##Easy recording and playback of scripts&lt;br /&gt;
##Scripts are modular, can be reused&lt;br /&gt;
# Selenium was first written in Java but it also supports .Net, Ruby, Perl, PHP and Python. This is a big plus when you want to build your framework in a language that has the highest adoption in the organization it is being built within. Unlike tools like [http://en.wikipedia.org/wiki/HP_QuickTest_Professional QTP] which force you to use [http://en.wikipedia.org/wiki/VBScript VBScript]&lt;br /&gt;
# Integration with third party tools is possible &lt;br /&gt;
# You can instantiate several concurrent tests with Selenium since no dedicated machine is required&lt;br /&gt;
&lt;br /&gt;
*Cons&lt;br /&gt;
#  Selenium has concept of locators that support common attributes like id, names etc as well as [http://en.wikipedia.org/wiki/XPath XPATH], [http://en.wikipedia.org/wiki/JavaScript javascript] DOM and others. However, this is still not as smart as say the [http://www.tutorialspoint.com/qtp/qtp_object_repository.htm Object Repository] (OR) in QTP. That being said, QTP’s OR comes with it´s baggage as well.&amp;lt;ref&amp;gt;[http://www.qualitytesting.info/forum/topics/selenium-automation-tool Selenium Automation Tool]&amp;lt;/ref&amp;gt;&lt;br /&gt;
# It does not generate detailed results like the result viewer&lt;br /&gt;
# No option to verify images&lt;br /&gt;
&lt;br /&gt;
===Watir===&lt;br /&gt;
*Pros&lt;br /&gt;
# Open Source&lt;br /&gt;
# Opens browser as a normal way how the user opens it unlike Selenium which needs to create an object to work with&lt;br /&gt;
# Changing registry details(Proxy-http,socks) is very easy &amp;lt;ref&amp;gt;Raveendran, 28 Oct., 2009 [http://raveendran.wordpress.com/2009/10/28/watir-vs-selenium/ Selenium Vs Watir ]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*Cons&lt;br /&gt;
# Knowledge in the Ruby programming language is required &lt;br /&gt;
# Does not support certain HTML elements&lt;br /&gt;
# Limited reporting capabilities&lt;br /&gt;
# There is no recorder for Watir unlike Selenium for playback&lt;br /&gt;
&lt;br /&gt;
=='''Comparison of Features, Functionality, and More'''==&lt;br /&gt;
Some features or functionality may be repeated here.  However, we will go into a bit more detail than previously mentioned.&lt;br /&gt;
===='''Open Source'''====&lt;br /&gt;
Both Selenium and Watir are [http://en.wikipedia.org/wiki/Open-source_software open source]!  This allows for greater extensibility and a deeper understanding of the inner workings of both of the frameworks, if the developer/tester chooses to delve into such details.  Additionally, the open source community allows for a more transparent, user-driven development and support cycle.  Users (the tester/developer) can choose to submit bug fixes or enhancements as patches, or they can choose to just use it “straight out of the box.”&lt;br /&gt;
&lt;br /&gt;
====Application Language Agnostic====&lt;br /&gt;
&lt;br /&gt;
Both Selenium and Watir are application language agnostic.  Because both Selenium and Watir test UI functionality in the browser, they can be used to test any web application.    &lt;br /&gt;
&lt;br /&gt;
====Language-specific Test Cases====&lt;br /&gt;
&lt;br /&gt;
Both Selenium and Watir require test cases to be written in some programming language.  Traditionally, both frameworks had limited choices in terms of language bindings.  However, with the advent of WebDriver, both became much more flexible.  WebDriver provided the bindings needed for many languages.  Today, the following are supported:&lt;br /&gt;
&lt;br /&gt;
'''Selenium*'''&lt;br /&gt;
&lt;br /&gt;
* Officially-supported: [http://en.wikipedia.org/wiki/Java_(programming_language) Java], [http://en.wikipedia.org/wiki/C_Sharp_(programming_language) C#], [http://en.wikipedia.org/wiki/Ruby_(programming_language) Ruby], [http://en.wikipedia.org/wiki/Python_(programming_language) Python], [http://en.wikipedia.org/wiki/Node.js Javascript/Node.js]&lt;br /&gt;
&lt;br /&gt;
* Unofficial/community-supported: [http://en.wikipedia.org/wiki/Perl Perl], [http://en.wikipedia.org/wiki/PHP PHP], [http://en.wikipedia.org/wiki/Haskell_(programming_language) Haskell], [http://en.wikipedia.org/wiki/Objective-C Objective-C], [http://en.wikipedia.org/wiki/R_(programming_language) R], [http://en.wikipedia.org/wiki/Dart_(programming_language) Dart], [http://en.wikipedia.org/wiki/Tcl Tcl]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;According to SeleniumHQ’s download page.&lt;br /&gt;
&lt;br /&gt;
'''Watir'''&lt;br /&gt;
&lt;br /&gt;
Unfortunately (or fortunately), Ruby is the only supported language for Watir.  After all, Watir does stand for “Web Application Testing in Ruby.” However, there are other frameworks which were inspired by Watir (but entirely separate) available in Java and C# - [http://watij.com/ Watij] and [http://watin.org/ Watin],  respectively &amp;lt;ref&amp;gt;Djorgjievski, Darko. [http://www.sitepoint.com/watir-webdriver-control-browser/ Watir-WebDriver: Control the Browser]. ''SitePoint''. SitePoint Pty Ltd, 18 Apr. 2014. Web. 05 Oct. 2014.&amp;lt;/ref&amp;gt;.  There may be other similarly inspired frameworks available in other languages, but these are the most notable.&lt;br /&gt;
&lt;br /&gt;
====Cross-Browser and Headless Browser Support====&lt;br /&gt;
&lt;br /&gt;
[[File: watir_meet_webdriver.png | Watir Meets WebDriver &amp;lt;ref&amp;gt;[http://watirmelon.com/2010/04/10/watir-selenium-webdriver/ Watir Meets WebDriver Image]&amp;lt;/ref&amp;gt; |right|frame| link=http://yuml.me/diagram/scruffy/usecase/%5BTester%5D-%28Watir%20API%29,%20%28Watir%20API%29%3C%28FireWatir%29,%20%28Watir%20API%29%3C%28Watir%29,%20%28Watir%20API%29%3C%28SafariWatir%29,%20%28Watir%20API%29%3C%28Webdriver%29,%20%28Watir%20API%29%3C%28Celerity%29,%20%28Celerity%29-%28note:%20Celerity%20requires%20JRuby%29,%20%28Celerity%29-%28headless%29,%20%28Webdriver%29-%28Firefox%29,%20%28Webdriver%29-%28Chrome%29,%20%28Webdriver%29-%28IE%29,%20%28Webdriver%29-%28headless%29,%20%28FireWatir%29-%28Firefox%29,%20%28Watir%29-%28IE%29,%20%28SafariWatir%29-%28Safari%29.]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Traditionally, both Selenium and Watir were limited in the number of browsers they supported. Watir originally supported Internet Explorer and headless browsers exclusively.  Headless browsers were supported via the use of [https://github.com/jarib/celerity Celerity] &amp;lt;ref&amp;gt;Scott, Alister. [http://watirmelon.com/2010/04/10/watir-selenium-webdriver/ Watir, Selenium &amp;amp; WebDriver]. ''Watirmelon''. Watirmelon, 10 Apr. 2010. Web. 05 Oct. 2014.&amp;lt;/ref&amp;gt;.  Selenium started out as a Javascript library, so naturally it supported more browsers such as IE, Firefox, Safari, etc &amp;lt;ref name = &amp;quot;Introduction to Selenium&amp;quot; /&amp;gt;.  However, it did not support headless browsers.&lt;br /&gt;
Today, browser support looks much better for both Selenium and Watir, largely due to the introduction of WebDriver.  With WebDriver in existence, support for most browsers was added to Watir via the gem &amp;quot;watir-webdriver,&amp;quot; and Celerity became [https://github.com/jarib/celerity obsolete] because headless browser support was included in WebDriver.  Similarly for Selenium, support for headless browsers was added, as well as making the API much simpler and more concise &amp;lt;ref&amp;gt;[http://docs.seleniumhq.org/projects/webdriver/ Selenium WebDriver]. ''SeleniumHQ: Browser Automation''. Selenium Project, n.d. Web. 06 Oct. 2014.&amp;lt;/ref&amp;gt;.  Both Selenium &amp;lt;ref&amp;gt;Semerau, Luke. [https://code.google.com/p/selenium/wiki/WebDriverForMobileBrowsers WebDriverForMobileBrowsers]. ''Selenium''. Google Project Hosting, 14 Jan. 2013. Web. 06 Oct. 2014 &amp;lt;/ref&amp;gt; and Watir &amp;lt;ref&amp;gt;Scott, Alister. [http://watirwebdriver.com/mobile-devices/ Mobile Devices]. ''Watir WebDriver''. n.d. Web. 06 Oct. 2014. &amp;lt;/ref&amp;gt; have also gained support of Mobile browsers in recent years through WebDriver.  However, there is the obvious limitation that one can only test a browser which is supported on the running platform.  In other words, Safari and Internet explorer can only be tested on  OS X and Windows environments, respectively**.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;**&amp;lt;/nowiki&amp;gt; &amp;lt;span style=&amp;quot;font-size:88%&amp;quot;&amp;gt;Some work-arounds or programs may exist to allow these browsers to be tested on other platforms. Here, we are assuming no special additional configuration - just the base operating system and browsers.  With virtualization technologies such as [http://www.linux-kvm.org/page/Main_Page KVM], [https://www.virtualbox.org/ VirtualBox], and [http://en.wikipedia.org/wiki/Comparison_of_platform_virtualization_software others], this isn't a problem anyway.  [http://en.wikipedia.org/wiki/Virtual_machine Virtual machines] can be created with any operating system, as needed.&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Cross-Platform Support====&lt;br /&gt;
Both Watir and Selenium run on most popular distributions of Windows, Mac, and Linux.  Selenium doesn't have a list of officially supported operating system versions.  Instead they generally support any version that is currently popular.  Only a few versions are listed which they run test builds on.  These are versions which are officially known to work, but many more are supported as well.&lt;br /&gt;
&lt;br /&gt;
Because Watir is a collection of Ruby Gems, it runs on any platform that Ruby runs on.  Like Selenium, this includes nearly all popular platforms.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=='''Getting started'''==&lt;br /&gt;
===Selenium WebDriver=== &lt;br /&gt;
----&lt;br /&gt;
====Install/Configure (Java)====&lt;br /&gt;
Download binaries from [http://www.seleniumhq.org/download/ here] to configure Selenium. &lt;br /&gt;
Once you have all your binaries in a directory, you can open any IDE of your choice and add this directory with all the .jar files to the CLASSPATH&lt;br /&gt;
*Example&lt;br /&gt;
This is how a typical Selenium code to find the term say, “Automation” on Google and display the results on the page would look like in Java using the [https://code.google.com/p/selenium/wiki/HtmlUnitDriver HtmlUnitDriver] would look like.&lt;br /&gt;
The HtmlUnitDriver is a pure Java driver that runs entirely in-memory. Because of this, you won't see a new browser window open &amp;lt;ref&amp;gt;[https://code.google.com/p/selenium/wiki/GettingStarted Getting started with Selenium] Selenium: Browser Automation Framework. Google Code. 8 Feb, 2014.&amp;lt;/ref&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
       package org.selenium.example;&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;
       import org.openqa.selenium.By;&lt;br /&gt;
       import org.openqa.selenium.WebDriver;&lt;br /&gt;
       import org.openqa.selenium.WebElement;&lt;br /&gt;
       import org.openqa.selenium.htmlunit.HtmlUnitDriver;&amp;lt;br /&amp;gt;&lt;br /&gt;
       public class Example  {&lt;br /&gt;
       public static void main(String[] args) {&lt;br /&gt;
        // Create a new instance of the html unit driver&lt;br /&gt;
        // Notice that the remainder of the code relies on the interface,&lt;br /&gt;
        // not the implementation.&lt;br /&gt;
        WebDriver driver = new HtmlUnitDriver();&amp;lt;br /&amp;gt;&lt;br /&gt;
        System.out.println(&amp;quot;Beginning test for Google search using Selenium&amp;quot;);&lt;br /&gt;
        // And now use this to visit Google&lt;br /&gt;
        System.out.println(&amp;quot;Visit www.google.com&amp;quot; );&lt;br /&gt;
        driver.get(&amp;quot;http://www.google.com&amp;quot;);&amp;lt;br /&amp;gt;&lt;br /&gt;
        // Find the text input element by its name&lt;br /&gt;
        WebElement element = driver.findElement(By.name(&amp;quot;q&amp;quot;));&amp;lt;br /&amp;gt;&lt;br /&gt;
        // Enter something to search for&lt;br /&gt;
        System.out.println(&amp;quot;Type Automation in the search bar&amp;quot; );&lt;br /&gt;
        element.sendKeys(&amp;quot;Automation!&amp;quot;);&amp;lt;br /&amp;gt;&lt;br /&gt;
        // Now submit the form. WebDriver will find the form for us from the element&lt;br /&gt;
        element.submit();&amp;lt;br /&amp;gt;&lt;br /&gt;
        // Check the title of the page&lt;br /&gt;
        System.out.println(&amp;quot;Expected output&amp;quot; );&lt;br /&gt;
        System.out.println(&amp;quot;Page title is: &amp;quot; + driver.getTitle());&lt;br /&gt;
        driver.quit();&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
If you compile and run it, you should see a line with the title of the Google search results as output.&lt;br /&gt;
       ''Output:''&lt;br /&gt;
        Beginning test for Google search using Selenium &amp;lt;/ br&amp;gt;&lt;br /&gt;
        Visit www.google.com &amp;lt;/ br&amp;gt;&lt;br /&gt;
        Expected output &amp;lt;/ br&amp;gt;&lt;br /&gt;
        Page title is: Google&lt;br /&gt;
&lt;br /&gt;
====Install/Configure for other languages====&lt;br /&gt;
Configuring Selenium for languages other than Java and for other development environments can be looked up [http://docs.seleniumhq.org/docs/03_webdriver.jsp#setting-up-a-selenium-webdriver-project here]. viz(C#, Ruby, Python, PHP, Perl, Javascript)&lt;br /&gt;
&lt;br /&gt;
===Watir===&lt;br /&gt;
----&lt;br /&gt;
====Install/Configure (Ruby)====&lt;br /&gt;
Drivers for Watir are installed as gems which are nothing but Ruby libraries which can be accessed over the internet.&lt;br /&gt;
All the instructions for installing Watir on various operating systems (viz. Windows, Mac OS, Linux) can be found [http://watir.com/installation/ here].&lt;br /&gt;
&lt;br /&gt;
*Example:&lt;br /&gt;
This is how a typical Watir code to find the term say, “Automation” on Google and display the results on the page would look like using Ruby&amp;lt;ref&amp;gt;Chernenko, Iryna. [http://blog.qatestlab.com/2011/02/23/automated-testing-with-watir-tutorial-for-begginers-part-1/ Watir Example]. QATestLab Blog: Automated Testing with Watir, 23 Feb 2011.&lt;br /&gt;
&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
        # Required in ruby 1.8.7&lt;br /&gt;
        require 'rubygems'&lt;br /&gt;
        # Watir IE driver&lt;br /&gt;
        require 'watir'&amp;lt;br /&amp;gt; &lt;br /&gt;
        ie = Watir::IE.new&amp;lt;br /&amp;gt; &lt;br /&gt;
        # text to show on console&lt;br /&gt;
        puts &amp;quot;Beginning of the test for Google search engine&amp;quot;&lt;br /&gt;
        puts &amp;quot;Step 1:  Go to the Google homepage&amp;quot;&lt;br /&gt;
        ie.goto &amp;quot;http://www.google.com&amp;quot;&amp;lt;br /&amp;gt;&lt;br /&gt;
        #set a variable&lt;br /&gt;
        search_text = &amp;quot;Automation&amp;quot;&lt;br /&gt;
        puts &amp;quot;Step 2: enter &amp;quot;+ search_text +&amp;quot; in the search text field.&amp;quot;&lt;br /&gt;
        ie.text_field(:name, &amp;quot;q&amp;quot;).set search_text   # &amp;quot;q&amp;quot; is the name of the search field&amp;lt;br /&amp;gt;&lt;br /&gt;
        puts &amp;quot; Step 3: click the 'Google Search' button.&amp;quot;&lt;br /&gt;
        ie.button(:name, &amp;quot;btnG&amp;quot;).click # &amp;quot;btnG&amp;quot; is the name of the Search button&amp;lt;br /&amp;gt;&lt;br /&gt;
        puts &amp;quot; Expected Result:&amp;quot;&lt;br /&gt;
        puts &amp;quot;  A Google page with results should be shown. 'Watir, pronounced water' should be high on the list.&amp;quot;&lt;br /&gt;
        puts &amp;quot; Actual Result:&amp;quot;&lt;br /&gt;
        if ie.text.include? &amp;quot;Watir, pronounced water&amp;quot;	&lt;br /&gt;
             puts &amp;quot;  Test Passed. Found the text string: 'Watir, pronounced water'. Actual Results match Expected Results.&amp;quot;&lt;br /&gt;
        else	&lt;br /&gt;
 	     puts &amp;quot;  Test Failed! Could not find text: 'Watir, pronounced water'.&amp;quot;&lt;br /&gt;
        end&lt;br /&gt;
        puts &amp;quot;End of test: Google search.&amp;quot;&lt;br /&gt;
        ie.close&lt;br /&gt;
&lt;br /&gt;
On compiling and running this and passing the test, you will see something like,&lt;br /&gt;
&lt;br /&gt;
        ''Output:''&lt;br /&gt;
        Beginning of the test for Google search engine &lt;br /&gt;
        Step 1:  Go to the Google homepage &lt;br /&gt;
        Step 2: enter Automation in the search text field. &lt;br /&gt;
        Step 3: click the 'Google Search' button. &lt;br /&gt;
        Expected Result: &lt;br /&gt;
        A Google page with results should be shown. 'Watir, pronounced water' should be high on the list. 	&lt;br /&gt;
        Test Passed. Found the text string: 'Watir, pronounced water'. Actual Results match Expected Results. &lt;br /&gt;
        End of test: Google search. &amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Similar Tools==&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Sahi_(software) Sahi], uses the Sahi Scripting Language&amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Soatest SOATest], for testing and validating [http://en.wikipedia.org/wiki/Application_programming_interface API] driven applications &amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/TestComplete TestComplete], for Desktops, Web and Mobile&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
* [http://www.hiretheworld.com/blog/tech-blog/migrating-unit-tests-from-selenium-to-watir-webdriver Migrating unit tests from Selenium to Watir Web Driver] &amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://www.hiretheworld.com/blog/tech-blog/migrating-unit-tests-from-selenium-to-watir-webdriver Learning Selenium IDE] &amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/List_of_web_testing_tools List of web testing tools] &amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/List_of_web_testing_tools OWASP List of Acceptance Testing tools]&lt;br /&gt;
* [http://www.ijiet.org/papers/425-T0026.pdf  Study of Browser Based Automated Test Tools WATIR and Selenium] Nisha Gogna, August 2014, International Journal of Information and Education Technology, Vol. 4, No. 4&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
{{reflist}}&lt;br /&gt;
&amp;lt;references /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==External Links==&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Selenium_(software) Selenium Wiki Page] &amp;lt;br /&amp;gt;&lt;br /&gt;
* [https://github.com/SeleniumHQ/selenium Selenium Source Code] &amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Watir Watir Wiki Page] &amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Watir Watir Source Code] &amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Watir SauceLabs HomePage] &amp;lt;br /&amp;gt;&lt;/div&gt;</summary>
		<author><name>Jjbeaver</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/ch1b_27_js&amp;diff=89578</id>
		<title>CSC/ECE 517 Fall 2014/ch1b 27 js</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/ch1b_27_js&amp;diff=89578"/>
		<updated>2014-10-14T02:31:24Z</updated>

		<summary type="html">&lt;p&gt;Jjbeaver: /* Selenium */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;='''Selenium vs. Watir'''=&lt;br /&gt;
&lt;br /&gt;
Developing web applications is proving to be a challenging task with each passing day given the complex requirements and the demanding nature of the these applications. For the web applications to be robust we need to put in place some good testing strategies.&lt;br /&gt;
&lt;br /&gt;
'''''Selenium''''' is one of the most popularly used open source automation tools for web based applications. It is a JavaScript framework that runs in your web browser to interact with various elements in your browser. All in all, Selenium is a set of different software tools each with a different approach to supporting test automation. Selenium provides a rich set of testing functions that can be customized to suit the testing requirements.&lt;br /&gt;
 &lt;br /&gt;
'''''Watir''''', is another lightweight automation testing tool that is widely used for web app testing. It is an open-source ([http://en.wikipedia.org/wiki/BSD_licenses BSD])  family of Ruby libraries for automating web browsers. It allows you to write tests that are easy to read and maintain&amp;lt;ref&amp;gt;[http://watir.com/ Web Application Testing in Ruby]&amp;lt;/ref&amp;gt;. Despite the fact that it is a set of Ruby libraries, it works perfectly, independent of the language that the web application is developed in. Watir as a tool is extremely simple and flexible.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=='''Motivation'''==&lt;br /&gt;
===Need for test automation===&lt;br /&gt;
With the majority of software applications today being implemented as [http://en.wikipedia.org/wiki/Web_application web applications] to be used over the internet, testing is becoming an indispensable part of the software development lifecycle ([http://en.wikipedia.org/wiki/Software_development_process SDLC]) of these applications. [http://en.wikipedia.org/wiki/Test_automation Test automation] is used where manual testing needs to be carried out repeatedly making it a cumbersome task. Test automation uses a software tool for this purpose on the application to be tested. It has proven to be highly efficient and critical in larger software development companies. Additionally, automation can be a valuable way to make Test Driven Development ([http://en.wikipedia.org/wiki/Test-driven_development TDD]) tasks an important part of the software development workflow.&lt;br /&gt;
 &lt;br /&gt;
Test Automation has a number of advantages mostly dealing with repetitiveness of the tests and the time taken,&lt;br /&gt;
* '''Covers cases that manual testing probably cannot'''&lt;br /&gt;
# Finds defects missed out my manual testing&lt;br /&gt;
# Automated testing can simulate numerous virtual users interacting with the web software/application&lt;br /&gt;
* '''Helps save time and money'''&lt;br /&gt;
# Once created, automated tests can be executed repeatedly at no additional   costs and at a much faster pace. Saving time directly translates into saving cost.&lt;br /&gt;
# Supports virtually unlimited iterations of test case execution&lt;br /&gt;
* '''Increase test coverage and accuracy'''&lt;br /&gt;
# Automated tests perform the exact same steps and records all details precisely&lt;br /&gt;
# They also increase the depth and scope of tests to improve the quality of the software&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=='''Brief History'''==&lt;br /&gt;
====Selenium====&lt;br /&gt;
&lt;br /&gt;
[[File: SE-logo.png|right|Selenium Logo|link=http://www.seleniumhq.org/images/big-logo.png]]&lt;br /&gt;
&lt;br /&gt;
''Selenium'' was developed in the year 2004 by Jason Huggins and has been continuously evolving ever since. Jason Huggins developed this as an internal tool for [http://en.wikipedia.org/wiki/ThoughtWorks ThoughtWorks] as a javascript library which came to be known as the Selenium core. Selenium core is now the basis of the Selenium Remote Control (the server) and Selenium IDE.&lt;br /&gt;
The year 2006 marked the beginning of the development of the 'WebDriver project' which was what they believed ‘a tool of the future’. The WebDriver was initiated to solve the problems that were faced due to the fact that Selenium was a based on JavaScript and a lot of security limitations browsers apply to Javascript.&lt;br /&gt;
In 2008, both Selenium and WebDriver merged to provide a common set of features to all users which is called Selenium 2.&lt;br /&gt;
Simon Stewart, the creator of the WebDriver Project, in a joint email to the WebDriver and Selenium community on August 6, 2009 said the following,&lt;br /&gt;
&lt;br /&gt;
:“Why are the projects merging? Partly because webdriver addresses some shortcomings in selenium (by being able to bypass the JS sandbox, for example. And we’ve got a gorgeous API), partly because selenium addresses some shortcomings  in webdriver (such as supporting a broader range of browsers) and partly because the main selenium contributors and I felt that it was the best way to offer users the best possible framework.”&amp;lt;ref name =&amp;quot;Introduction to Selenium&amp;quot;&amp;gt; [http://docs.seleniumhq.org/docs/01_introducing_selenium.jsp#selenium-history Introducing Selenium]. ''SeleniumHQ: Browser Automation''. Selenium Project, 4 Oct. 2014. Web. 06 Oct. 2014.&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Watir====&lt;br /&gt;
&lt;br /&gt;
''Watir'' started as a library to teach testers to write ruby code and grew to be an IE implementation which now supports IE, Firefox, Safari, Google Chrome and Opera.&lt;br /&gt;
Watir was primarily developed by Bret Pettichord and Paul Rogers. Watir has since then has a couple of stable releases for Watir classic as well as Watir WebDriver. The most recent releases being&amp;lt;ref&amp;gt;[http://watir.com/category/releases/ Watir Releases]. Watir: Web Application Testing in Ruby. 28 April, 2013&amp;lt;/ref&amp;gt;, &lt;br /&gt;
&lt;br /&gt;
[[File: Watir.gif|right|Watir logo|link=http://upload.wikimedia.org/wikipedia/commons/7/7e/Watir.gif]]&lt;br /&gt;
&lt;br /&gt;
* Watir-Classic	    &lt;br /&gt;
# 0.6.3 April 10, 2013 ([https://github.com/watir/watir-webdriver/blob/master/CHANGES.md#063 Release Notes]) &amp;lt;br /&amp;gt;&lt;br /&gt;
* Watir-WebDriver	    &lt;br /&gt;
# 3.6.0 March 16, 2013 ([https://groups.google.com/forum/#!msg/watir-general/MOOun5g3Hvg/JBVNy957lDYJ Release Notes]) &amp;lt;br /&amp;gt;&lt;br /&gt;
# 3.5.0 March 10, 2013 ([https://groups.google.com/forum/#!msg/watir-general/aeUqsglvK6k/Kq7FCBiERjYJ Release Notes]) &amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Watir has a google group ([https://groups.google.com/forum/#!forum/watir-general Watir General]) for its support and contribution while Selenium also has a [http://seleniumforum.forumotion.net/ Selenium forum] apart from its google group called [https://groups.google.com/forum/#!forum/selenium-users Selenium Users].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=='''Pros/Cons'''==&lt;br /&gt;
===Selenium===&lt;br /&gt;
*Pros&lt;br /&gt;
# Open Source, free Software&lt;br /&gt;
# Easy Installation&lt;br /&gt;
# Scripting Techniques&lt;br /&gt;
##Easy recording and playback of scripts&lt;br /&gt;
##Scripts are modular, can be reused&lt;br /&gt;
# Selenium was first written in Java but it also supports .Net, Ruby, Perl, PHP and Python. This is a big plus when you want to build your framework in a language that has the highest adoption in the organization it is being built within. Unlike tools like [http://en.wikipedia.org/wiki/HP_QuickTest_Professional QTP] which force you to use [http://en.wikipedia.org/wiki/VBScript VBScript]&lt;br /&gt;
# Integration with third party tools is possible &lt;br /&gt;
# You can instantiate several concurrent tests with Selenium since no dedicated machine is required&lt;br /&gt;
&lt;br /&gt;
*Cons&lt;br /&gt;
#  Selenium has concept of locators that support common attributes like id, names etc as well as [http://en.wikipedia.org/wiki/XPath XPATH], [http://en.wikipedia.org/wiki/JavaScript javascript] DOM and others. However, this is still not as smart as say the [http://www.tutorialspoint.com/qtp/qtp_object_repository.htm Object Repository] (OR) in QTP. That being said, QTP’s OR comes with it´s baggage as well.&amp;lt;ref&amp;gt;[http://www.qualitytesting.info/forum/topics/selenium-automation-tool Selenium Automation Tool]&amp;lt;/ref&amp;gt;&lt;br /&gt;
# It does not generate detailed results like the result viewer&lt;br /&gt;
# No option to verify images&lt;br /&gt;
&lt;br /&gt;
===Watir===&lt;br /&gt;
*Pros&lt;br /&gt;
# Open Source&lt;br /&gt;
# Opens browser as a normal way how the user opens it unlike Selenium which needs to create an object to work with&lt;br /&gt;
# Changing registry details(Proxy-http,socks) is very easy &amp;lt;ref&amp;gt;Raveendran, 28 Oct., 2009 [http://raveendran.wordpress.com/2009/10/28/watir-vs-selenium/ Selenium Vs Watir ]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*Cons&lt;br /&gt;
# Knowledge in the Ruby programming language is required &lt;br /&gt;
# Does not support certain HTML elements&lt;br /&gt;
# Limited reporting capabilities&lt;br /&gt;
# There is no recorder for Watir unlike Selenium for playback&lt;br /&gt;
&lt;br /&gt;
=='''Comparison of Features, Functionality, and More'''==&lt;br /&gt;
Some features or functionality may be repeated here.  However, we will go into a bit more detail than previously mentioned.&lt;br /&gt;
===='''Open Source'''====&lt;br /&gt;
Both Selenium and Watir are [http://en.wikipedia.org/wiki/Open-source_software open source]!  This allows for greater extensibility and a deeper understanding of the inner workings of both of the frameworks, if the developer/tester chooses to delve into such details.  Additionally, the open source community allows for a more transparent, user-driven development and support cycle.  Users (the tester/developer) can choose to submit bug fixes or enhancements as patches, or they can choose to just use it “straight out of the box.”&lt;br /&gt;
&lt;br /&gt;
====Application Language Agnostic====&lt;br /&gt;
&lt;br /&gt;
Both Selenium and Watir are application language agnostic.  Because both Selenium and Watir test UI functionality in the browser, they can be used to test any web application.    &lt;br /&gt;
&lt;br /&gt;
====Language-specific Test Cases====&lt;br /&gt;
&lt;br /&gt;
Both Selenium and Watir require test cases to be written in some programming language.  Traditionally, both frameworks had limited choices in terms of language bindings.  However, with the advent of WebDriver, both became much more flexible.  WebDriver provided the bindings needed for many languages.  Today, the following are supported:&lt;br /&gt;
&lt;br /&gt;
'''Selenium*'''&lt;br /&gt;
&lt;br /&gt;
* Officially-supported: [http://en.wikipedia.org/wiki/Java_(programming_language) Java], [http://en.wikipedia.org/wiki/C_Sharp_(programming_language) C#], [http://en.wikipedia.org/wiki/Ruby_(programming_language) Ruby], [http://en.wikipedia.org/wiki/Python_(programming_language) Python], [http://en.wikipedia.org/wiki/Node.js Javascript/Node.js]&lt;br /&gt;
&lt;br /&gt;
* Unofficial/community-supported: [http://en.wikipedia.org/wiki/Perl Perl], [http://en.wikipedia.org/wiki/PHP PHP], [http://en.wikipedia.org/wiki/Haskell_(programming_language) Haskell], [http://en.wikipedia.org/wiki/Objective-C Objective-C], [http://en.wikipedia.org/wiki/R_(programming_language) R], [http://en.wikipedia.org/wiki/Dart_(programming_language) Dart], [http://en.wikipedia.org/wiki/Tcl Tcl]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;According to SeleniumHQ’s download page.&lt;br /&gt;
&lt;br /&gt;
'''Watir'''&lt;br /&gt;
&lt;br /&gt;
Unfortunately (or fortunately), Ruby is the only supported language for Watir.  After all, Watir does stand for “Web Application Testing in Ruby.” However, there are other frameworks which were inspired by Watir (but entirely separate) available in Java and C# - [http://watij.com/ Watij] and [http://watin.org/ Watin],  respectively &amp;lt;ref&amp;gt;Djorgjievski, Darko. [http://www.sitepoint.com/watir-webdriver-control-browser/ Watir-WebDriver: Control the Browser]. ''SitePoint''. SitePoint Pty Ltd, 18 Apr. 2014. Web. 05 Oct. 2014.&amp;lt;/ref&amp;gt;.  There may be other similarly inspired frameworks available in other languages, but these are the most notable.&lt;br /&gt;
&lt;br /&gt;
====Cross-Browser and Headless Browser Support====&lt;br /&gt;
&lt;br /&gt;
[[File: watir_meet_webdriver.png | Watir Meets WebDriver &amp;lt;ref&amp;gt;[http://watirmelon.com/2010/04/10/watir-selenium-webdriver/ Watir Meets WebDriver Image]&amp;lt;/ref&amp;gt; |right|frame| link=http://yuml.me/diagram/scruffy/usecase/%5BTester%5D-%28Watir%20API%29,%20%28Watir%20API%29%3C%28FireWatir%29,%20%28Watir%20API%29%3C%28Watir%29,%20%28Watir%20API%29%3C%28SafariWatir%29,%20%28Watir%20API%29%3C%28Webdriver%29,%20%28Watir%20API%29%3C%28Celerity%29,%20%28Celerity%29-%28note:%20Celerity%20requires%20JRuby%29,%20%28Celerity%29-%28headless%29,%20%28Webdriver%29-%28Firefox%29,%20%28Webdriver%29-%28Chrome%29,%20%28Webdriver%29-%28IE%29,%20%28Webdriver%29-%28headless%29,%20%28FireWatir%29-%28Firefox%29,%20%28Watir%29-%28IE%29,%20%28SafariWatir%29-%28Safari%29.]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Traditionally, both Selenium and Watir were limited in the number of browsers they supported. Watir originally supported Internet Explorer and headless browsers exclusively.  Headless browsers were supported via the use of [https://github.com/jarib/celerity Celerity] &amp;lt;ref&amp;gt;Scott, Alister. [http://watirmelon.com/2010/04/10/watir-selenium-webdriver/ Watir, Selenium &amp;amp; WebDriver]. ''Watirmelon''. Watirmelon, 10 Apr. 2010. Web. 05 Oct. 2014.&amp;lt;/ref&amp;gt;.  Selenium started out as a Javascript library, so naturally it supported more browsers such as IE, Firefox, Safari, etc &amp;lt;ref name = &amp;quot;Introduction to Selenium&amp;quot; /&amp;gt;.  However, it did not support headless browsers.&lt;br /&gt;
Today, browser support looks much better for both Selenium and Watir, largely due to the introduction of WebDriver.  With WebDriver in existence, support for most browsers was added to Watir via the gem &amp;quot;watir-webdriver,&amp;quot; and Celerity became [https://github.com/jarib/celerity obsolete] because headless browser support was included in WebDriver.  Similarly for Selenium, support for headless browsers was added, as well as making the API much simpler and more concise &amp;lt;ref&amp;gt;[http://docs.seleniumhq.org/projects/webdriver/ Selenium WebDriver]. ''SeleniumHQ: Browser Automation''. Selenium Project, n.d. Web. 06 Oct. 2014.&amp;lt;/ref&amp;gt;.  Both Selenium &amp;lt;ref&amp;gt;Semerau, Luke. [https://code.google.com/p/selenium/wiki/WebDriverForMobileBrowsers WebDriverForMobileBrowsers]. ''Selenium''. Google Project Hosting, 14 Jan. 2013. Web. 06 Oct. 2014 &amp;lt;/ref&amp;gt; and Watir &amp;lt;ref&amp;gt;Scott, Alister. [http://watirwebdriver.com/mobile-devices/ Mobile Devices]. ''Watir WebDriver''. n.d. Web. 06 Oct. 2014. &amp;lt;/ref&amp;gt; have also gained support of Mobile browsers in recent years through WebDriver.  However, there is the obvious limitation that one can only test a browser which is supported on the running platform.  In other words, Safari and Internet explorer can only be tested on  OS X and Windows environments, respectively**.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;**&amp;lt;/nowiki&amp;gt; &amp;lt;span style=&amp;quot;font-size:88%&amp;quot;&amp;gt;Some work-arounds or programs may exist to allow these browsers to be tested on other platforms. Here, we are assuming no special additional configuration - just the base operating system and browsers.  With virtualization technologies such as [http://www.linux-kvm.org/page/Main_Page KVM], [https://www.virtualbox.org/ VirtualBox], and [http://en.wikipedia.org/wiki/Comparison_of_platform_virtualization_software others], this isn't a problem anyway.  [http://en.wikipedia.org/wiki/Virtual_machine Virtual machines] can be created with any operating system, as needed.&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Cross-Platform Support====&lt;br /&gt;
Both Watir and Selenium run on most popular distributions of Windows, Mac, and Linux.  Selenium doesn't have a list of officially supported operating system versions.  Instead they generally support any version that is currently popular.  Only a few versions are listed which they run test builds on.  These are versions which are officially known to work, but many more are supported as well.&lt;br /&gt;
&lt;br /&gt;
Because Watir is a collection of Ruby Gems, it runs on any platform that Ruby runs on.  Like Selenium, this includes nearly all popular platforms.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=='''Getting started'''==&lt;br /&gt;
===Selenium WebDriver=== &lt;br /&gt;
----&lt;br /&gt;
====Install/Configure (Java)====&lt;br /&gt;
Download binaries from [http://www.seleniumhq.org/download/ here] to configure Selenium. &lt;br /&gt;
Once you have all your binaries in a directory, you can open any IDE of your choice and add this directory with all the .jar files to the CLASSPATH&lt;br /&gt;
*Example&lt;br /&gt;
This is how a typical Selenium code to find the term say, “Automation” on Google and display the results on the page would look like in Java using the [https://code.google.com/p/selenium/wiki/HtmlUnitDriver HtmlUnitDriver] would look like.&lt;br /&gt;
The HtmlUnitDriver is a pure Java driver that runs entirely in-memory. Because of this, you won't see a new browser window open &amp;lt;ref&amp;gt;[https://code.google.com/p/selenium/wiki/GettingStarted Getting started with Selenium] Selenium: Browser Automation Framework. Google Code. 8 Feb, 2014.&amp;lt;/ref&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
       package org.selenium.example;&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;
       import org.openqa.selenium.By;&lt;br /&gt;
       import org.openqa.selenium.WebDriver;&lt;br /&gt;
       import org.openqa.selenium.WebElement;&lt;br /&gt;
       import org.openqa.selenium.htmlunit.HtmlUnitDriver;&amp;lt;br /&amp;gt;&lt;br /&gt;
       public class Example  {&lt;br /&gt;
       public static void main(String[] args) {&lt;br /&gt;
        // Create a new instance of the html unit driver&lt;br /&gt;
        // Notice that the remainder of the code relies on the interface,&lt;br /&gt;
        // not the implementation.&lt;br /&gt;
        WebDriver driver = new HtmlUnitDriver();&amp;lt;br /&amp;gt;&lt;br /&gt;
        System.out.println(&amp;quot;Beginning test for Google search using Selenium&amp;quot;);&lt;br /&gt;
        // And now use this to visit Google&lt;br /&gt;
        System.out.println(&amp;quot;Visit www.google.com&amp;quot; );&lt;br /&gt;
        driver.get(&amp;quot;http://www.google.com&amp;quot;);&amp;lt;br /&amp;gt;&lt;br /&gt;
        // Find the text input element by its name&lt;br /&gt;
        WebElement element = driver.findElement(By.name(&amp;quot;q&amp;quot;));&amp;lt;br /&amp;gt;&lt;br /&gt;
        // Enter something to search for&lt;br /&gt;
        System.out.println(&amp;quot;Type Automation in the search bar&amp;quot; );&lt;br /&gt;
        element.sendKeys(&amp;quot;Automation!&amp;quot;);&amp;lt;br /&amp;gt;&lt;br /&gt;
        // Now submit the form. WebDriver will find the form for us from the element&lt;br /&gt;
        element.submit();&amp;lt;br /&amp;gt;&lt;br /&gt;
        // Check the title of the page&lt;br /&gt;
        System.out.println(&amp;quot;Expected output&amp;quot; );&lt;br /&gt;
        System.out.println(&amp;quot;Page title is: &amp;quot; + driver.getTitle());&lt;br /&gt;
        driver.quit();&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
If you compile and run it, you should see a line with the title of the Google search results as output.&lt;br /&gt;
       ''Output:''&lt;br /&gt;
        Beginning test for Google search using Selenium &amp;lt;/ br&amp;gt;&lt;br /&gt;
        Visit www.google.com &amp;lt;/ br&amp;gt;&lt;br /&gt;
        Expected output &amp;lt;/ br&amp;gt;&lt;br /&gt;
        Page title is: Google&lt;br /&gt;
&lt;br /&gt;
====Install/Configure for other languages====&lt;br /&gt;
Configuring Selenium for languages other than Java and for other development environments can be looked up [http://docs.seleniumhq.org/docs/03_webdriver.jsp#setting-up-a-selenium-webdriver-project here]. viz(C#, Ruby, Python, PHP, Perl, Javascript)&lt;br /&gt;
&lt;br /&gt;
===Watir===&lt;br /&gt;
----&lt;br /&gt;
====Install/Configure (Ruby)====&lt;br /&gt;
Drivers for Watir are installed as gems which are nothing but Ruby libraries which can be accessed over the internet.&lt;br /&gt;
All the instructions for installing Watir on various operating systems (viz. Windows, Mac OS, Linux) can be found [http://watir.com/installation/ here].&lt;br /&gt;
&lt;br /&gt;
*Example:&lt;br /&gt;
This is how a typical Watir code to find the term say, “Automation” on Google and display the results on the page would look like using Ruby&amp;lt;ref&amp;gt;Chernenko, Iryna. [http://blog.qatestlab.com/2011/02/23/automated-testing-with-watir-tutorial-for-begginers-part-1/ Watir Example]. QATestLab Blog: Automated Testing with Watir, 23 Feb 2011.&lt;br /&gt;
&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
        # Required in ruby 1.8.7&lt;br /&gt;
        require 'rubygems'&lt;br /&gt;
        # Watir IE driver&lt;br /&gt;
        require 'watir'&amp;lt;br /&amp;gt; &lt;br /&gt;
        ie = Watir::IE.new&amp;lt;br /&amp;gt; &lt;br /&gt;
        # text to show on console&lt;br /&gt;
        puts &amp;quot;Beginning of the test for Google search engine&amp;quot;&lt;br /&gt;
        puts &amp;quot;Step 1:  Go to the Google homepage&amp;quot;&lt;br /&gt;
        ie.goto &amp;quot;http://www.google.com&amp;quot;&amp;lt;br /&amp;gt;&lt;br /&gt;
        #set a variable&lt;br /&gt;
        search_text = &amp;quot;Automation&amp;quot;&lt;br /&gt;
        puts &amp;quot;Step 2: enter &amp;quot;+ search_text +&amp;quot; in the search text field.&amp;quot;&lt;br /&gt;
        ie.text_field(:name, &amp;quot;q&amp;quot;).set search_text   # &amp;quot;q&amp;quot; is the name of the search field&amp;lt;br /&amp;gt;&lt;br /&gt;
        puts &amp;quot; Step 3: click the 'Google Search' button.&amp;quot;&lt;br /&gt;
        ie.button(:name, &amp;quot;btnG&amp;quot;).click # &amp;quot;btnG&amp;quot; is the name of the Search button&amp;lt;br /&amp;gt;&lt;br /&gt;
        puts &amp;quot; Expected Result:&amp;quot;&lt;br /&gt;
        puts &amp;quot;  A Google page with results should be shown. 'Watir, pronounced water' should be high on the list.&amp;quot;&lt;br /&gt;
        puts &amp;quot; Actual Result:&amp;quot;&lt;br /&gt;
        if ie.text.include? &amp;quot;Watir, pronounced water&amp;quot;	&lt;br /&gt;
             puts &amp;quot;  Test Passed. Found the text string: 'Watir, pronounced water'. Actual Results match Expected Results.&amp;quot;&lt;br /&gt;
        else	&lt;br /&gt;
 	     puts &amp;quot;  Test Failed! Could not find text: 'Watir, pronounced water'.&amp;quot;&lt;br /&gt;
        end&lt;br /&gt;
        puts &amp;quot;End of test: Google search.&amp;quot;&lt;br /&gt;
        ie.close&lt;br /&gt;
&lt;br /&gt;
On compiling and running this and passing the test, you will see something like,&lt;br /&gt;
&lt;br /&gt;
        ''Output:''&lt;br /&gt;
        Beginning of the test for Google search engine &lt;br /&gt;
        Step 1:  Go to the Google homepage &lt;br /&gt;
        Step 2: enter Automation in the search text field. &lt;br /&gt;
        Step 3: click the 'Google Search' button. &lt;br /&gt;
        Expected Result: &lt;br /&gt;
        A Google page with results should be shown. 'Watir, pronounced water' should be high on the list. 	&lt;br /&gt;
        Test Passed. Found the text string: 'Watir, pronounced water'. Actual Results match Expected Results. &lt;br /&gt;
        End of test: Google search. &amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Similar Tools==&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Sahi_(software) Sahi], uses the Sahi Scripting Language&amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Soatest SOATest], for testing and validating [http://en.wikipedia.org/wiki/Application_programming_interface API] driven applications &amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/TestComplete TestComplete], for Desktops, Web and Mobile&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
* [http://www.hiretheworld.com/blog/tech-blog/migrating-unit-tests-from-selenium-to-watir-webdriver Migrating unit tests from Selenium to Watir Web Driver] &amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://www.hiretheworld.com/blog/tech-blog/migrating-unit-tests-from-selenium-to-watir-webdriver Learning Selenium IDE] &amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/List_of_web_testing_tools List of web testing tools] &amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/List_of_web_testing_tools OWASP List of Acceptance Testing tools]&lt;br /&gt;
* [http://www.ijiet.org/papers/425-T0026.pdf  Study of Browser Based Automated Test Tools WATIR and Selenium] Nisha Gogna, August 2014, International Journal of Information and Education Technology, Vol. 4, No. 4&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
{{reflist}}&lt;br /&gt;
&amp;lt;references /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==External Links==&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Selenium_(software) Selenium Wiki Page] &amp;lt;br /&amp;gt;&lt;br /&gt;
* [https://github.com/SeleniumHQ/selenium Selenium Source Code] &amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Watir Watir Wiki Page] &amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Watir Watir Source Code] &amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Watir SauceLabs HomePage] &amp;lt;br /&amp;gt;&lt;/div&gt;</summary>
		<author><name>Jjbeaver</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/ch1b_27_js&amp;diff=89577</id>
		<title>CSC/ECE 517 Fall 2014/ch1b 27 js</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/ch1b_27_js&amp;diff=89577"/>
		<updated>2014-10-14T02:26:09Z</updated>

		<summary type="html">&lt;p&gt;Jjbeaver: /* Install/Configure (Java) */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;='''Selenium vs. Watir'''=&lt;br /&gt;
&lt;br /&gt;
Developing web applications is proving to be a challenging task with each passing day given the complex requirements and the demanding nature of the these applications. For the web applications to be robust we need to put in place some good testing strategies.&lt;br /&gt;
&lt;br /&gt;
'''''Selenium''''' is one of the most popularly used open source automation tools for web based applications. It is a JavaScript framework that runs in your web browser to interact with various elements in your browser. All in all, Selenium is a set of different software tools each with a different approach to supporting test automation. Selenium provides a rich set of testing functions that can be customized to suit the testing requirements.&lt;br /&gt;
 &lt;br /&gt;
'''''Watir''''', is another lightweight automation testing tool that is widely used for web app testing. It is an open-source ([http://en.wikipedia.org/wiki/BSD_licenses BSD])  family of Ruby libraries for automating web browsers. It allows you to write tests that are easy to read and maintain&amp;lt;ref&amp;gt;[http://watir.com/ Web Application Testing in Ruby]&amp;lt;/ref&amp;gt;. Despite the fact that it is a set of Ruby libraries, it works perfectly, independent of the language that the web application is developed in. Watir as a tool is extremely simple and flexible.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=='''Motivation'''==&lt;br /&gt;
===Need for test automation===&lt;br /&gt;
With the majority of software applications today being implemented as [http://en.wikipedia.org/wiki/Web_application web applications] to be used over the internet, testing is becoming an indispensable part of the software development lifecycle ([http://en.wikipedia.org/wiki/Software_development_process SDLC]) of these applications. [http://en.wikipedia.org/wiki/Test_automation Test automation] is used where manual testing needs to be carried out repeatedly making it a cumbersome task. Test automation uses a software tool for this purpose on the application to be tested. It has proven to be highly efficient and critical in larger software development companies. Additionally, automation can be a valuable way to make Test Driven Development ([http://en.wikipedia.org/wiki/Test-driven_development TDD]) tasks an important part of the software development workflow.&lt;br /&gt;
 &lt;br /&gt;
Test Automation has a number of advantages mostly dealing with repetitiveness of the tests and the time taken,&lt;br /&gt;
* '''Covers cases that manual testing probably cannot'''&lt;br /&gt;
# Finds defects missed out my manual testing&lt;br /&gt;
# Automated testing can simulate numerous virtual users interacting with the web software/application&lt;br /&gt;
* '''Helps save time and money'''&lt;br /&gt;
# Once created, automated tests can be executed repeatedly at no additional   costs and at a much faster pace. Saving time directly translates into saving cost.&lt;br /&gt;
# Supports virtually unlimited iterations of test case execution&lt;br /&gt;
* '''Increase test coverage and accuracy'''&lt;br /&gt;
# Automated tests perform the exact same steps and records all details precisely&lt;br /&gt;
# They also increase the depth and scope of tests to improve the quality of the software&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=='''Brief History'''==&lt;br /&gt;
====Selenium====&lt;br /&gt;
&lt;br /&gt;
[[File: SE-logo.png|right|Selenium Logo|link=http://www.seleniumhq.org/images/big-logo.png]]&lt;br /&gt;
&lt;br /&gt;
''Selenium'' was developed in the year 2004 by Jason Huggins and has been continuously evolving ever since. Jason Huggins developed this as an internal tool for [http://en.wikipedia.org/wiki/ThoughtWorks ThoughtWorks] as a javascript library which came to be known as the Selenium core. Selenium core is now the basis of the Selenium Remote Control (the server) and Selenium IDE.&lt;br /&gt;
The year 2006 marked the beginning of the development of the 'WebDriver project' which was what they believed ‘a tool of the future’. The WebDriver was initiated to solve the problems that were faced due to the fact that Selenium was a based on JavaScript and a lot of security limitations browsers apply to Javascript.&lt;br /&gt;
In 2008, both Selenium and WebDriver merged to provide a common set of features to all users which is called Selenium 2.&lt;br /&gt;
Simon Stewart, the creator of the WebDriver Project, in a joint email to the WebDriver and Selenium community on August 6, 2009 said the following,&lt;br /&gt;
&lt;br /&gt;
“Why are the projects merging? Partly because webdriver addresses some shortcomings in selenium (by being able to bypass the JS sandbox, for example. And we’ve got a gorgeous API), partly because selenium addresses some shortcomings in webdriver (such as supporting a broader range of browsers) and partly because the main selenium contributors and I felt that it was the best way to offer users the best possible framework.”&amp;lt;ref name =&amp;quot;Introduction to Selenium&amp;quot;&amp;gt;[http://docs.seleniumhq.org/docs/01_introducing_selenium.jsp#selenium-history Introducing Selenium]. ''SeleniumHQ: Browser Automation''. Selenium Project, 4 Oct. 2014. Web. 06 Oct. 2014.&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Watir====&lt;br /&gt;
&lt;br /&gt;
''Watir'' started as a library to teach testers to write ruby code and grew to be an IE implementation which now supports IE, Firefox, Safari, Google Chrome and Opera.&lt;br /&gt;
Watir was primarily developed by Bret Pettichord and Paul Rogers. Watir has since then has a couple of stable releases for Watir classic as well as Watir WebDriver. The most recent releases being&amp;lt;ref&amp;gt;[http://watir.com/category/releases/ Watir Releases]. Watir: Web Application Testing in Ruby. 28 April, 2013&amp;lt;/ref&amp;gt;, &lt;br /&gt;
&lt;br /&gt;
[[File: Watir.gif|right|Watir logo|link=http://upload.wikimedia.org/wikipedia/commons/7/7e/Watir.gif]]&lt;br /&gt;
&lt;br /&gt;
* Watir-Classic	    &lt;br /&gt;
# 0.6.3 April 10, 2013 ([https://github.com/watir/watir-webdriver/blob/master/CHANGES.md#063 Release Notes]) &amp;lt;br /&amp;gt;&lt;br /&gt;
* Watir-WebDriver	    &lt;br /&gt;
# 3.6.0 March 16, 2013 ([https://groups.google.com/forum/#!msg/watir-general/MOOun5g3Hvg/JBVNy957lDYJ Release Notes]) &amp;lt;br /&amp;gt;&lt;br /&gt;
# 3.5.0 March 10, 2013 ([https://groups.google.com/forum/#!msg/watir-general/aeUqsglvK6k/Kq7FCBiERjYJ Release Notes]) &amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Watir has a google group ([https://groups.google.com/forum/#!forum/watir-general Watir General]) for its support and contribution while Selenium also has a [http://seleniumforum.forumotion.net/ Selenium forum] apart from its google group called [https://groups.google.com/forum/#!forum/selenium-users Selenium Users].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=='''Pros/Cons'''==&lt;br /&gt;
===Selenium===&lt;br /&gt;
*Pros&lt;br /&gt;
# Open Source, free Software&lt;br /&gt;
# Easy Installation&lt;br /&gt;
# Scripting Techniques&lt;br /&gt;
##Easy recording and playback of scripts&lt;br /&gt;
##Scripts are modular, can be reused&lt;br /&gt;
# Selenium was first written in Java but it also supports .Net, Ruby, Perl, PHP and Python. This is a big plus when you want to build your framework in a language that has the highest adoption in the organization it is being built within. Unlike tools like [http://en.wikipedia.org/wiki/HP_QuickTest_Professional QTP] which force you to use [http://en.wikipedia.org/wiki/VBScript VBScript]&lt;br /&gt;
# Integration with third party tools is possible &lt;br /&gt;
# You can instantiate several concurrent tests with Selenium since no dedicated machine is required&lt;br /&gt;
&lt;br /&gt;
*Cons&lt;br /&gt;
#  Selenium has concept of locators that support common attributes like id, names etc as well as [http://en.wikipedia.org/wiki/XPath XPATH], [http://en.wikipedia.org/wiki/JavaScript javascript] DOM and others. However, this is still not as smart as say the [http://www.tutorialspoint.com/qtp/qtp_object_repository.htm Object Repository] (OR) in QTP. That being said, QTP’s OR comes with it´s baggage as well.&amp;lt;ref&amp;gt;[http://www.qualitytesting.info/forum/topics/selenium-automation-tool Selenium Automation Tool]&amp;lt;/ref&amp;gt;&lt;br /&gt;
# It does not generate detailed results like the result viewer&lt;br /&gt;
# No option to verify images&lt;br /&gt;
&lt;br /&gt;
===Watir===&lt;br /&gt;
*Pros&lt;br /&gt;
# Open Source&lt;br /&gt;
# Opens browser as a normal way how the user opens it unlike Selenium which needs to create an object to work with&lt;br /&gt;
# Changing registry details(Proxy-http,socks) is very easy &amp;lt;ref&amp;gt;Raveendran, 28 Oct., 2009 [http://raveendran.wordpress.com/2009/10/28/watir-vs-selenium/ Selenium Vs Watir ]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*Cons&lt;br /&gt;
# Knowledge in the Ruby programming language is required &lt;br /&gt;
# Does not support certain HTML elements&lt;br /&gt;
# Limited reporting capabilities&lt;br /&gt;
# There is no recorder for Watir unlike Selenium for playback&lt;br /&gt;
&lt;br /&gt;
=='''Comparison of Features, Functionality, and More'''==&lt;br /&gt;
Some features or functionality may be repeated here.  However, we will go into a bit more detail than previously mentioned.&lt;br /&gt;
===='''Open Source'''====&lt;br /&gt;
Both Selenium and Watir are [http://en.wikipedia.org/wiki/Open-source_software open source]!  This allows for greater extensibility and a deeper understanding of the inner workings of both of the frameworks, if the developer/tester chooses to delve into such details.  Additionally, the open source community allows for a more transparent, user-driven development and support cycle.  Users (the tester/developer) can choose to submit bug fixes or enhancements as patches, or they can choose to just use it “straight out of the box.”&lt;br /&gt;
&lt;br /&gt;
====Application Language Agnostic====&lt;br /&gt;
&lt;br /&gt;
Both Selenium and Watir are application language agnostic.  Because both Selenium and Watir test UI functionality in the browser, they can be used to test any web application.    &lt;br /&gt;
&lt;br /&gt;
====Language-specific Test Cases====&lt;br /&gt;
&lt;br /&gt;
Both Selenium and Watir require test cases to be written in some programming language.  Traditionally, both frameworks had limited choices in terms of language bindings.  However, with the advent of WebDriver, both became much more flexible.  WebDriver provided the bindings needed for many languages.  Today, the following are supported:&lt;br /&gt;
&lt;br /&gt;
'''Selenium*'''&lt;br /&gt;
&lt;br /&gt;
* Officially-supported: [http://en.wikipedia.org/wiki/Java_(programming_language) Java], [http://en.wikipedia.org/wiki/C_Sharp_(programming_language) C#], [http://en.wikipedia.org/wiki/Ruby_(programming_language) Ruby], [http://en.wikipedia.org/wiki/Python_(programming_language) Python], [http://en.wikipedia.org/wiki/Node.js Javascript/Node.js]&lt;br /&gt;
&lt;br /&gt;
* Unofficial/community-supported: [http://en.wikipedia.org/wiki/Perl Perl], [http://en.wikipedia.org/wiki/PHP PHP], [http://en.wikipedia.org/wiki/Haskell_(programming_language) Haskell], [http://en.wikipedia.org/wiki/Objective-C Objective-C], [http://en.wikipedia.org/wiki/R_(programming_language) R], [http://en.wikipedia.org/wiki/Dart_(programming_language) Dart], [http://en.wikipedia.org/wiki/Tcl Tcl]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;According to SeleniumHQ’s download page.&lt;br /&gt;
&lt;br /&gt;
'''Watir'''&lt;br /&gt;
&lt;br /&gt;
Unfortunately (or fortunately), Ruby is the only supported language for Watir.  After all, Watir does stand for “Web Application Testing in Ruby.” However, there are other frameworks which were inspired by Watir (but entirely separate) available in Java and C# - [http://watij.com/ Watij] and [http://watin.org/ Watin],  respectively &amp;lt;ref&amp;gt;Djorgjievski, Darko. [http://www.sitepoint.com/watir-webdriver-control-browser/ Watir-WebDriver: Control the Browser]. ''SitePoint''. SitePoint Pty Ltd, 18 Apr. 2014. Web. 05 Oct. 2014.&amp;lt;/ref&amp;gt;.  There may be other similarly inspired frameworks available in other languages, but these are the most notable.&lt;br /&gt;
&lt;br /&gt;
====Cross-Browser and Headless Browser Support====&lt;br /&gt;
&lt;br /&gt;
[[File: watir_meet_webdriver.png | Watir Meets WebDriver &amp;lt;ref&amp;gt;[http://watirmelon.com/2010/04/10/watir-selenium-webdriver/ Watir Meets WebDriver Image]&amp;lt;/ref&amp;gt; |right|frame| link=http://yuml.me/diagram/scruffy/usecase/%5BTester%5D-%28Watir%20API%29,%20%28Watir%20API%29%3C%28FireWatir%29,%20%28Watir%20API%29%3C%28Watir%29,%20%28Watir%20API%29%3C%28SafariWatir%29,%20%28Watir%20API%29%3C%28Webdriver%29,%20%28Watir%20API%29%3C%28Celerity%29,%20%28Celerity%29-%28note:%20Celerity%20requires%20JRuby%29,%20%28Celerity%29-%28headless%29,%20%28Webdriver%29-%28Firefox%29,%20%28Webdriver%29-%28Chrome%29,%20%28Webdriver%29-%28IE%29,%20%28Webdriver%29-%28headless%29,%20%28FireWatir%29-%28Firefox%29,%20%28Watir%29-%28IE%29,%20%28SafariWatir%29-%28Safari%29.]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Traditionally, both Selenium and Watir were limited in the number of browsers they supported. Watir originally supported Internet Explorer and headless browsers exclusively.  Headless browsers were supported via the use of [https://github.com/jarib/celerity Celerity] &amp;lt;ref&amp;gt;Scott, Alister. [http://watirmelon.com/2010/04/10/watir-selenium-webdriver/ Watir, Selenium &amp;amp; WebDriver]. ''Watirmelon''. Watirmelon, 10 Apr. 2010. Web. 05 Oct. 2014.&amp;lt;/ref&amp;gt;.  Selenium started out as a Javascript library, so naturally it supported more browsers such as IE, Firefox, Safari, etc &amp;lt;ref name = &amp;quot;Introduction to Selenium&amp;quot; /&amp;gt;.  However, it did not support headless browsers.&lt;br /&gt;
Today, browser support looks much better for both Selenium and Watir, largely due to the introduction of WebDriver.  With WebDriver in existence, support for most browsers was added to Watir via the gem &amp;quot;watir-webdriver,&amp;quot; and Celerity became [https://github.com/jarib/celerity obsolete] because headless browser support was included in WebDriver.  Similarly for Selenium, support for headless browsers was added, as well as making the API much simpler and more concise &amp;lt;ref&amp;gt;[http://docs.seleniumhq.org/projects/webdriver/ Selenium WebDriver]. ''SeleniumHQ: Browser Automation''. Selenium Project, n.d. Web. 06 Oct. 2014.&amp;lt;/ref&amp;gt;.  Both Selenium &amp;lt;ref&amp;gt;Semerau, Luke. [https://code.google.com/p/selenium/wiki/WebDriverForMobileBrowsers WebDriverForMobileBrowsers]. ''Selenium''. Google Project Hosting, 14 Jan. 2013. Web. 06 Oct. 2014 &amp;lt;/ref&amp;gt; and Watir &amp;lt;ref&amp;gt;Scott, Alister. [http://watirwebdriver.com/mobile-devices/ Mobile Devices]. ''Watir WebDriver''. n.d. Web. 06 Oct. 2014. &amp;lt;/ref&amp;gt; have also gained support of Mobile browsers in recent years through WebDriver.  However, there is the obvious limitation that one can only test a browser which is supported on the running platform.  In other words, Safari and Internet explorer can only be tested on  OS X and Windows environments, respectively**.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;**&amp;lt;/nowiki&amp;gt; &amp;lt;span style=&amp;quot;font-size:88%&amp;quot;&amp;gt;Some work-arounds or programs may exist to allow these browsers to be tested on other platforms. Here, we are assuming no special additional configuration - just the base operating system and browsers.  With virtualization technologies such as [http://www.linux-kvm.org/page/Main_Page KVM], [https://www.virtualbox.org/ VirtualBox], and [http://en.wikipedia.org/wiki/Comparison_of_platform_virtualization_software others], this isn't a problem anyway.  [http://en.wikipedia.org/wiki/Virtual_machine Virtual machines] can be created with any operating system, as needed.&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Cross-Platform Support====&lt;br /&gt;
Both Watir and Selenium run on most popular distributions of Windows, Mac, and Linux.  Selenium doesn't have a list of officially supported operating system versions.  Instead they generally support any version that is currently popular.  Only a few versions are listed which they run test builds on.  These are versions which are officially known to work, but many more are supported as well.&lt;br /&gt;
&lt;br /&gt;
Because Watir is a collection of Ruby Gems, it runs on any platform that Ruby runs on.  Like Selenium, this includes nearly all popular platforms.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=='''Getting started'''==&lt;br /&gt;
===Selenium WebDriver=== &lt;br /&gt;
----&lt;br /&gt;
====Install/Configure (Java)====&lt;br /&gt;
Download binaries from [http://www.seleniumhq.org/download/ here] to configure Selenium. &lt;br /&gt;
Once you have all your binaries in a directory, you can open any IDE of your choice and add this directory with all the .jar files to the CLASSPATH&lt;br /&gt;
*Example&lt;br /&gt;
This is how a typical Selenium code to find the term say, “Automation” on Google and display the results on the page would look like in Java using the [https://code.google.com/p/selenium/wiki/HtmlUnitDriver HtmlUnitDriver] would look like.&lt;br /&gt;
The HtmlUnitDriver is a pure Java driver that runs entirely in-memory. Because of this, you won't see a new browser window open &amp;lt;ref&amp;gt;[https://code.google.com/p/selenium/wiki/GettingStarted Getting started with Selenium] Selenium: Browser Automation Framework. Google Code. 8 Feb, 2014.&amp;lt;/ref&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
       package org.selenium.example;&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;
       import org.openqa.selenium.By;&lt;br /&gt;
       import org.openqa.selenium.WebDriver;&lt;br /&gt;
       import org.openqa.selenium.WebElement;&lt;br /&gt;
       import org.openqa.selenium.htmlunit.HtmlUnitDriver;&amp;lt;br /&amp;gt;&lt;br /&gt;
       public class Example  {&lt;br /&gt;
       public static void main(String[] args) {&lt;br /&gt;
        // Create a new instance of the html unit driver&lt;br /&gt;
        // Notice that the remainder of the code relies on the interface,&lt;br /&gt;
        // not the implementation.&lt;br /&gt;
        WebDriver driver = new HtmlUnitDriver();&amp;lt;br /&amp;gt;&lt;br /&gt;
        System.out.println(&amp;quot;Beginning test for Google search using Selenium&amp;quot;);&lt;br /&gt;
        // And now use this to visit Google&lt;br /&gt;
        System.out.println(&amp;quot;Visit www.google.com&amp;quot; );&lt;br /&gt;
        driver.get(&amp;quot;http://www.google.com&amp;quot;);&amp;lt;br /&amp;gt;&lt;br /&gt;
        // Find the text input element by its name&lt;br /&gt;
        WebElement element = driver.findElement(By.name(&amp;quot;q&amp;quot;));&amp;lt;br /&amp;gt;&lt;br /&gt;
        // Enter something to search for&lt;br /&gt;
        System.out.println(&amp;quot;Type Automation in the search bar&amp;quot; );&lt;br /&gt;
        element.sendKeys(&amp;quot;Automation!&amp;quot;);&amp;lt;br /&amp;gt;&lt;br /&gt;
        // Now submit the form. WebDriver will find the form for us from the element&lt;br /&gt;
        element.submit();&amp;lt;br /&amp;gt;&lt;br /&gt;
        // Check the title of the page&lt;br /&gt;
        System.out.println(&amp;quot;Expected output&amp;quot; );&lt;br /&gt;
        System.out.println(&amp;quot;Page title is: &amp;quot; + driver.getTitle());&lt;br /&gt;
        driver.quit();&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
If you compile and run it, you should see a line with the title of the Google search results as output.&lt;br /&gt;
       ''Output:''&lt;br /&gt;
        Beginning test for Google search using Selenium &amp;lt;/ br&amp;gt;&lt;br /&gt;
        Visit www.google.com &amp;lt;/ br&amp;gt;&lt;br /&gt;
        Expected output &amp;lt;/ br&amp;gt;&lt;br /&gt;
        Page title is: Google&lt;br /&gt;
&lt;br /&gt;
====Install/Configure for other languages====&lt;br /&gt;
Configuring Selenium for languages other than Java and for other development environments can be looked up [http://docs.seleniumhq.org/docs/03_webdriver.jsp#setting-up-a-selenium-webdriver-project here]. viz(C#, Ruby, Python, PHP, Perl, Javascript)&lt;br /&gt;
&lt;br /&gt;
===Watir===&lt;br /&gt;
----&lt;br /&gt;
====Install/Configure (Ruby)====&lt;br /&gt;
Drivers for Watir are installed as gems which are nothing but Ruby libraries which can be accessed over the internet.&lt;br /&gt;
All the instructions for installing Watir on various operating systems (viz. Windows, Mac OS, Linux) can be found [http://watir.com/installation/ here].&lt;br /&gt;
&lt;br /&gt;
*Example:&lt;br /&gt;
This is how a typical Watir code to find the term say, “Automation” on Google and display the results on the page would look like using Ruby&amp;lt;ref&amp;gt;Chernenko, Iryna. [http://blog.qatestlab.com/2011/02/23/automated-testing-with-watir-tutorial-for-begginers-part-1/ Watir Example]. QATestLab Blog: Automated Testing with Watir, 23 Feb 2011.&lt;br /&gt;
&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
        # Required in ruby 1.8.7&lt;br /&gt;
        require 'rubygems'&lt;br /&gt;
        # Watir IE driver&lt;br /&gt;
        require 'watir'&amp;lt;br /&amp;gt; &lt;br /&gt;
        ie = Watir::IE.new&amp;lt;br /&amp;gt; &lt;br /&gt;
        # text to show on console&lt;br /&gt;
        puts &amp;quot;Beginning of the test for Google search engine&amp;quot;&lt;br /&gt;
        puts &amp;quot;Step 1:  Go to the Google homepage&amp;quot;&lt;br /&gt;
        ie.goto &amp;quot;http://www.google.com&amp;quot;&amp;lt;br /&amp;gt;&lt;br /&gt;
        #set a variable&lt;br /&gt;
        search_text = &amp;quot;Automation&amp;quot;&lt;br /&gt;
        puts &amp;quot;Step 2: enter &amp;quot;+ search_text +&amp;quot; in the search text field.&amp;quot;&lt;br /&gt;
        ie.text_field(:name, &amp;quot;q&amp;quot;).set search_text   # &amp;quot;q&amp;quot; is the name of the search field&amp;lt;br /&amp;gt;&lt;br /&gt;
        puts &amp;quot; Step 3: click the 'Google Search' button.&amp;quot;&lt;br /&gt;
        ie.button(:name, &amp;quot;btnG&amp;quot;).click # &amp;quot;btnG&amp;quot; is the name of the Search button&amp;lt;br /&amp;gt;&lt;br /&gt;
        puts &amp;quot; Expected Result:&amp;quot;&lt;br /&gt;
        puts &amp;quot;  A Google page with results should be shown. 'Watir, pronounced water' should be high on the list.&amp;quot;&lt;br /&gt;
        puts &amp;quot; Actual Result:&amp;quot;&lt;br /&gt;
        if ie.text.include? &amp;quot;Watir, pronounced water&amp;quot;	&lt;br /&gt;
             puts &amp;quot;  Test Passed. Found the text string: 'Watir, pronounced water'. Actual Results match Expected Results.&amp;quot;&lt;br /&gt;
        else	&lt;br /&gt;
 	     puts &amp;quot;  Test Failed! Could not find text: 'Watir, pronounced water'.&amp;quot;&lt;br /&gt;
        end&lt;br /&gt;
        puts &amp;quot;End of test: Google search.&amp;quot;&lt;br /&gt;
        ie.close&lt;br /&gt;
&lt;br /&gt;
On compiling and running this and passing the test, you will see something like,&lt;br /&gt;
&lt;br /&gt;
        ''Output:''&lt;br /&gt;
        Beginning of the test for Google search engine &lt;br /&gt;
        Step 1:  Go to the Google homepage &lt;br /&gt;
        Step 2: enter Automation in the search text field. &lt;br /&gt;
        Step 3: click the 'Google Search' button. &lt;br /&gt;
        Expected Result: &lt;br /&gt;
        A Google page with results should be shown. 'Watir, pronounced water' should be high on the list. 	&lt;br /&gt;
        Test Passed. Found the text string: 'Watir, pronounced water'. Actual Results match Expected Results. &lt;br /&gt;
        End of test: Google search. &amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Similar Tools==&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Sahi_(software) Sahi], uses the Sahi Scripting Language&amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Soatest SOATest], for testing and validating [http://en.wikipedia.org/wiki/Application_programming_interface API] driven applications &amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/TestComplete TestComplete], for Desktops, Web and Mobile&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
* [http://www.hiretheworld.com/blog/tech-blog/migrating-unit-tests-from-selenium-to-watir-webdriver Migrating unit tests from Selenium to Watir Web Driver] &amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://www.hiretheworld.com/blog/tech-blog/migrating-unit-tests-from-selenium-to-watir-webdriver Learning Selenium IDE] &amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/List_of_web_testing_tools List of web testing tools] &amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/List_of_web_testing_tools OWASP List of Acceptance Testing tools]&lt;br /&gt;
* [http://www.ijiet.org/papers/425-T0026.pdf  Study of Browser Based Automated Test Tools WATIR and Selenium] Nisha Gogna, August 2014, International Journal of Information and Education Technology, Vol. 4, No. 4&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
{{reflist}}&lt;br /&gt;
&amp;lt;references /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==External Links==&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Selenium_(software) Selenium Wiki Page] &amp;lt;br /&amp;gt;&lt;br /&gt;
* [https://github.com/SeleniumHQ/selenium Selenium Source Code] &amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Watir Watir Wiki Page] &amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Watir Watir Source Code] &amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Watir SauceLabs HomePage] &amp;lt;br /&amp;gt;&lt;/div&gt;</summary>
		<author><name>Jjbeaver</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/ch1b_27_js&amp;diff=89576</id>
		<title>CSC/ECE 517 Fall 2014/ch1b 27 js</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/ch1b_27_js&amp;diff=89576"/>
		<updated>2014-10-14T02:25:13Z</updated>

		<summary type="html">&lt;p&gt;Jjbeaver: /* Install/Configure (Java) */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;='''Selenium vs. Watir'''=&lt;br /&gt;
&lt;br /&gt;
Developing web applications is proving to be a challenging task with each passing day given the complex requirements and the demanding nature of the these applications. For the web applications to be robust we need to put in place some good testing strategies.&lt;br /&gt;
&lt;br /&gt;
'''''Selenium''''' is one of the most popularly used open source automation tools for web based applications. It is a JavaScript framework that runs in your web browser to interact with various elements in your browser. All in all, Selenium is a set of different software tools each with a different approach to supporting test automation. Selenium provides a rich set of testing functions that can be customized to suit the testing requirements.&lt;br /&gt;
 &lt;br /&gt;
'''''Watir''''', is another lightweight automation testing tool that is widely used for web app testing. It is an open-source ([http://en.wikipedia.org/wiki/BSD_licenses BSD])  family of Ruby libraries for automating web browsers. It allows you to write tests that are easy to read and maintain&amp;lt;ref&amp;gt;[http://watir.com/ Web Application Testing in Ruby]&amp;lt;/ref&amp;gt;. Despite the fact that it is a set of Ruby libraries, it works perfectly, independent of the language that the web application is developed in. Watir as a tool is extremely simple and flexible.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=='''Motivation'''==&lt;br /&gt;
===Need for test automation===&lt;br /&gt;
With the majority of software applications today being implemented as [http://en.wikipedia.org/wiki/Web_application web applications] to be used over the internet, testing is becoming an indispensable part of the software development lifecycle ([http://en.wikipedia.org/wiki/Software_development_process SDLC]) of these applications. [http://en.wikipedia.org/wiki/Test_automation Test automation] is used where manual testing needs to be carried out repeatedly making it a cumbersome task. Test automation uses a software tool for this purpose on the application to be tested. It has proven to be highly efficient and critical in larger software development companies. Additionally, automation can be a valuable way to make Test Driven Development ([http://en.wikipedia.org/wiki/Test-driven_development TDD]) tasks an important part of the software development workflow.&lt;br /&gt;
 &lt;br /&gt;
Test Automation has a number of advantages mostly dealing with repetitiveness of the tests and the time taken,&lt;br /&gt;
* '''Covers cases that manual testing probably cannot'''&lt;br /&gt;
# Finds defects missed out my manual testing&lt;br /&gt;
# Automated testing can simulate numerous virtual users interacting with the web software/application&lt;br /&gt;
* '''Helps save time and money'''&lt;br /&gt;
# Once created, automated tests can be executed repeatedly at no additional   costs and at a much faster pace. Saving time directly translates into saving cost.&lt;br /&gt;
# Supports virtually unlimited iterations of test case execution&lt;br /&gt;
* '''Increase test coverage and accuracy'''&lt;br /&gt;
# Automated tests perform the exact same steps and records all details precisely&lt;br /&gt;
# They also increase the depth and scope of tests to improve the quality of the software&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=='''Brief History'''==&lt;br /&gt;
====Selenium====&lt;br /&gt;
&lt;br /&gt;
[[File: SE-logo.png|right|Selenium Logo|link=http://www.seleniumhq.org/images/big-logo.png]]&lt;br /&gt;
&lt;br /&gt;
''Selenium'' was developed in the year 2004 by Jason Huggins and has been continuously evolving ever since. Jason Huggins developed this as an internal tool for [http://en.wikipedia.org/wiki/ThoughtWorks ThoughtWorks] as a javascript library which came to be known as the Selenium core. Selenium core is now the basis of the Selenium Remote Control (the server) and Selenium IDE.&lt;br /&gt;
The year 2006 marked the beginning of the development of the 'WebDriver project' which was what they believed ‘a tool of the future’. The WebDriver was initiated to solve the problems that were faced due to the fact that Selenium was a based on JavaScript and a lot of security limitations browsers apply to Javascript.&lt;br /&gt;
In 2008, both Selenium and WebDriver merged to provide a common set of features to all users which is called Selenium 2.&lt;br /&gt;
Simon Stewart, the creator of the WebDriver Project, in a joint email to the WebDriver and Selenium community on August 6, 2009 said the following,&lt;br /&gt;
&lt;br /&gt;
“Why are the projects merging? Partly because webdriver addresses some shortcomings in selenium (by being able to bypass the JS sandbox, for example. And we’ve got a gorgeous API), partly because selenium addresses some shortcomings in webdriver (such as supporting a broader range of browsers) and partly because the main selenium contributors and I felt that it was the best way to offer users the best possible framework.”&amp;lt;ref name =&amp;quot;Introduction to Selenium&amp;quot;&amp;gt;[http://docs.seleniumhq.org/docs/01_introducing_selenium.jsp#selenium-history Introducing Selenium]. ''SeleniumHQ: Browser Automation''. Selenium Project, 4 Oct. 2014. Web. 06 Oct. 2014.&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Watir====&lt;br /&gt;
&lt;br /&gt;
''Watir'' started as a library to teach testers to write ruby code and grew to be an IE implementation which now supports IE, Firefox, Safari, Google Chrome and Opera.&lt;br /&gt;
Watir was primarily developed by Bret Pettichord and Paul Rogers. Watir has since then has a couple of stable releases for Watir classic as well as Watir WebDriver. The most recent releases being&amp;lt;ref&amp;gt;[http://watir.com/category/releases/ Watir Releases]. Watir: Web Application Testing in Ruby. 28 April, 2013&amp;lt;/ref&amp;gt;, &lt;br /&gt;
&lt;br /&gt;
[[File: Watir.gif|right|Watir logo|link=http://upload.wikimedia.org/wikipedia/commons/7/7e/Watir.gif]]&lt;br /&gt;
&lt;br /&gt;
* Watir-Classic	    &lt;br /&gt;
# 0.6.3 April 10, 2013 ([https://github.com/watir/watir-webdriver/blob/master/CHANGES.md#063 Release Notes]) &amp;lt;br /&amp;gt;&lt;br /&gt;
* Watir-WebDriver	    &lt;br /&gt;
# 3.6.0 March 16, 2013 ([https://groups.google.com/forum/#!msg/watir-general/MOOun5g3Hvg/JBVNy957lDYJ Release Notes]) &amp;lt;br /&amp;gt;&lt;br /&gt;
# 3.5.0 March 10, 2013 ([https://groups.google.com/forum/#!msg/watir-general/aeUqsglvK6k/Kq7FCBiERjYJ Release Notes]) &amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Watir has a google group ([https://groups.google.com/forum/#!forum/watir-general Watir General]) for its support and contribution while Selenium also has a [http://seleniumforum.forumotion.net/ Selenium forum] apart from its google group called [https://groups.google.com/forum/#!forum/selenium-users Selenium Users].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=='''Pros/Cons'''==&lt;br /&gt;
===Selenium===&lt;br /&gt;
*Pros&lt;br /&gt;
# Open Source, free Software&lt;br /&gt;
# Easy Installation&lt;br /&gt;
# Scripting Techniques&lt;br /&gt;
##Easy recording and playback of scripts&lt;br /&gt;
##Scripts are modular, can be reused&lt;br /&gt;
# Selenium was first written in Java but it also supports .Net, Ruby, Perl, PHP and Python. This is a big plus when you want to build your framework in a language that has the highest adoption in the organization it is being built within. Unlike tools like [http://en.wikipedia.org/wiki/HP_QuickTest_Professional QTP] which force you to use [http://en.wikipedia.org/wiki/VBScript VBScript]&lt;br /&gt;
# Integration with third party tools is possible &lt;br /&gt;
# You can instantiate several concurrent tests with Selenium since no dedicated machine is required&lt;br /&gt;
&lt;br /&gt;
*Cons&lt;br /&gt;
#  Selenium has concept of locators that support common attributes like id, names etc as well as [http://en.wikipedia.org/wiki/XPath XPATH], [http://en.wikipedia.org/wiki/JavaScript javascript] DOM and others. However, this is still not as smart as say the [http://www.tutorialspoint.com/qtp/qtp_object_repository.htm Object Repository] (OR) in QTP. That being said, QTP’s OR comes with it´s baggage as well.&amp;lt;ref&amp;gt;[http://www.qualitytesting.info/forum/topics/selenium-automation-tool Selenium Automation Tool]&amp;lt;/ref&amp;gt;&lt;br /&gt;
# It does not generate detailed results like the result viewer&lt;br /&gt;
# No option to verify images&lt;br /&gt;
&lt;br /&gt;
===Watir===&lt;br /&gt;
*Pros&lt;br /&gt;
# Open Source&lt;br /&gt;
# Opens browser as a normal way how the user opens it unlike Selenium which needs to create an object to work with&lt;br /&gt;
# Changing registry details(Proxy-http,socks) is very easy &amp;lt;ref&amp;gt;Raveendran, 28 Oct., 2009 [http://raveendran.wordpress.com/2009/10/28/watir-vs-selenium/ Selenium Vs Watir ]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*Cons&lt;br /&gt;
# Knowledge in the Ruby programming language is required &lt;br /&gt;
# Does not support certain HTML elements&lt;br /&gt;
# Limited reporting capabilities&lt;br /&gt;
# There is no recorder for Watir unlike Selenium for playback&lt;br /&gt;
&lt;br /&gt;
=='''Comparison of Features, Functionality, and More'''==&lt;br /&gt;
Some features or functionality may be repeated here.  However, we will go into a bit more detail than previously mentioned.&lt;br /&gt;
===='''Open Source'''====&lt;br /&gt;
Both Selenium and Watir are [http://en.wikipedia.org/wiki/Open-source_software open source]!  This allows for greater extensibility and a deeper understanding of the inner workings of both of the frameworks, if the developer/tester chooses to delve into such details.  Additionally, the open source community allows for a more transparent, user-driven development and support cycle.  Users (the tester/developer) can choose to submit bug fixes or enhancements as patches, or they can choose to just use it “straight out of the box.”&lt;br /&gt;
&lt;br /&gt;
====Application Language Agnostic====&lt;br /&gt;
&lt;br /&gt;
Both Selenium and Watir are application language agnostic.  Because both Selenium and Watir test UI functionality in the browser, they can be used to test any web application.    &lt;br /&gt;
&lt;br /&gt;
====Language-specific Test Cases====&lt;br /&gt;
&lt;br /&gt;
Both Selenium and Watir require test cases to be written in some programming language.  Traditionally, both frameworks had limited choices in terms of language bindings.  However, with the advent of WebDriver, both became much more flexible.  WebDriver provided the bindings needed for many languages.  Today, the following are supported:&lt;br /&gt;
&lt;br /&gt;
'''Selenium*'''&lt;br /&gt;
&lt;br /&gt;
* Officially-supported: [http://en.wikipedia.org/wiki/Java_(programming_language) Java], [http://en.wikipedia.org/wiki/C_Sharp_(programming_language) C#], [http://en.wikipedia.org/wiki/Ruby_(programming_language) Ruby], [http://en.wikipedia.org/wiki/Python_(programming_language) Python], [http://en.wikipedia.org/wiki/Node.js Javascript/Node.js]&lt;br /&gt;
&lt;br /&gt;
* Unofficial/community-supported: [http://en.wikipedia.org/wiki/Perl Perl], [http://en.wikipedia.org/wiki/PHP PHP], [http://en.wikipedia.org/wiki/Haskell_(programming_language) Haskell], [http://en.wikipedia.org/wiki/Objective-C Objective-C], [http://en.wikipedia.org/wiki/R_(programming_language) R], [http://en.wikipedia.org/wiki/Dart_(programming_language) Dart], [http://en.wikipedia.org/wiki/Tcl Tcl]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;According to SeleniumHQ’s download page.&lt;br /&gt;
&lt;br /&gt;
'''Watir'''&lt;br /&gt;
&lt;br /&gt;
Unfortunately (or fortunately), Ruby is the only supported language for Watir.  After all, Watir does stand for “Web Application Testing in Ruby.” However, there are other frameworks which were inspired by Watir (but entirely separate) available in Java and C# - [http://watij.com/ Watij] and [http://watin.org/ Watin],  respectively &amp;lt;ref&amp;gt;Djorgjievski, Darko. [http://www.sitepoint.com/watir-webdriver-control-browser/ Watir-WebDriver: Control the Browser]. ''SitePoint''. SitePoint Pty Ltd, 18 Apr. 2014. Web. 05 Oct. 2014.&amp;lt;/ref&amp;gt;.  There may be other similarly inspired frameworks available in other languages, but these are the most notable.&lt;br /&gt;
&lt;br /&gt;
====Cross-Browser and Headless Browser Support====&lt;br /&gt;
&lt;br /&gt;
[[File: watir_meet_webdriver.png | Watir Meets WebDriver &amp;lt;ref&amp;gt;[http://watirmelon.com/2010/04/10/watir-selenium-webdriver/ Watir Meets WebDriver Image]&amp;lt;/ref&amp;gt; |right|frame| link=http://yuml.me/diagram/scruffy/usecase/%5BTester%5D-%28Watir%20API%29,%20%28Watir%20API%29%3C%28FireWatir%29,%20%28Watir%20API%29%3C%28Watir%29,%20%28Watir%20API%29%3C%28SafariWatir%29,%20%28Watir%20API%29%3C%28Webdriver%29,%20%28Watir%20API%29%3C%28Celerity%29,%20%28Celerity%29-%28note:%20Celerity%20requires%20JRuby%29,%20%28Celerity%29-%28headless%29,%20%28Webdriver%29-%28Firefox%29,%20%28Webdriver%29-%28Chrome%29,%20%28Webdriver%29-%28IE%29,%20%28Webdriver%29-%28headless%29,%20%28FireWatir%29-%28Firefox%29,%20%28Watir%29-%28IE%29,%20%28SafariWatir%29-%28Safari%29.]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Traditionally, both Selenium and Watir were limited in the number of browsers they supported. Watir originally supported Internet Explorer and headless browsers exclusively.  Headless browsers were supported via the use of [https://github.com/jarib/celerity Celerity] &amp;lt;ref&amp;gt;Scott, Alister. [http://watirmelon.com/2010/04/10/watir-selenium-webdriver/ Watir, Selenium &amp;amp; WebDriver]. ''Watirmelon''. Watirmelon, 10 Apr. 2010. Web. 05 Oct. 2014.&amp;lt;/ref&amp;gt;.  Selenium started out as a Javascript library, so naturally it supported more browsers such as IE, Firefox, Safari, etc &amp;lt;ref name = &amp;quot;Introduction to Selenium&amp;quot; /&amp;gt;.  However, it did not support headless browsers.&lt;br /&gt;
Today, browser support looks much better for both Selenium and Watir, largely due to the introduction of WebDriver.  With WebDriver in existence, support for most browsers was added to Watir via the gem &amp;quot;watir-webdriver,&amp;quot; and Celerity became [https://github.com/jarib/celerity obsolete] because headless browser support was included in WebDriver.  Similarly for Selenium, support for headless browsers was added, as well as making the API much simpler and more concise &amp;lt;ref&amp;gt;[http://docs.seleniumhq.org/projects/webdriver/ Selenium WebDriver]. ''SeleniumHQ: Browser Automation''. Selenium Project, n.d. Web. 06 Oct. 2014.&amp;lt;/ref&amp;gt;.  Both Selenium &amp;lt;ref&amp;gt;Semerau, Luke. [https://code.google.com/p/selenium/wiki/WebDriverForMobileBrowsers WebDriverForMobileBrowsers]. ''Selenium''. Google Project Hosting, 14 Jan. 2013. Web. 06 Oct. 2014 &amp;lt;/ref&amp;gt; and Watir &amp;lt;ref&amp;gt;Scott, Alister. [http://watirwebdriver.com/mobile-devices/ Mobile Devices]. ''Watir WebDriver''. n.d. Web. 06 Oct. 2014. &amp;lt;/ref&amp;gt; have also gained support of Mobile browsers in recent years through WebDriver.  However, there is the obvious limitation that one can only test a browser which is supported on the running platform.  In other words, Safari and Internet explorer can only be tested on  OS X and Windows environments, respectively**.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;**&amp;lt;/nowiki&amp;gt; &amp;lt;span style=&amp;quot;font-size:88%&amp;quot;&amp;gt;Some work-arounds or programs may exist to allow these browsers to be tested on other platforms. Here, we are assuming no special additional configuration - just the base operating system and browsers.  With virtualization technologies such as [http://www.linux-kvm.org/page/Main_Page KVM], [https://www.virtualbox.org/ VirtualBox], and [http://en.wikipedia.org/wiki/Comparison_of_platform_virtualization_software others], this isn't a problem anyway.  [http://en.wikipedia.org/wiki/Virtual_machine Virtual machines] can be created with any operating system, as needed.&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Cross-Platform Support====&lt;br /&gt;
Both Watir and Selenium run on most popular distributions of Windows, Mac, and Linux.  Selenium doesn't have a list of officially supported operating system versions.  Instead they generally support any version that is currently popular.  Only a few versions are listed which they run test builds on.  These are versions which are officially known to work, but many more are supported as well.&lt;br /&gt;
&lt;br /&gt;
Because Watir is a collection of Ruby Gems, it runs on any platform that Ruby runs on.  Like Selenium, this includes nearly all popular platforms.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=='''Getting started'''==&lt;br /&gt;
===Selenium WebDriver=== &lt;br /&gt;
----&lt;br /&gt;
====Install/Configure (Java)====&lt;br /&gt;
Download binaries from [http://www.seleniumhq.org/download/ here] to configure Selenium. &lt;br /&gt;
Once you have all your binaries in a directory, you can open any IDE of your choice and add this directory with all the .jar files to the CLASSPATH&lt;br /&gt;
*Example&lt;br /&gt;
This is how a typical Selenium code to find the term say, “Automation” on Google and display the results on the page would look like in Java using the [https://code.google.com/p/selenium/wiki/HtmlUnitDriver HtmlUnitDriver] would look like.&lt;br /&gt;
The HtmlUnitDriver is a pure Java driver that runs entirely in-memory. Because of this, you won't see a new browser window open &amp;lt;ref&amp;gt;[https://code.google.com/p/selenium/wiki/GettingStarted Getting started with Selenium]. Selenium: Browser Automation Framework. Google Code. 8 Feb, 2014.&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
       package org.selenium.example;&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;
       import org.openqa.selenium.By;&lt;br /&gt;
       import org.openqa.selenium.WebDriver;&lt;br /&gt;
       import org.openqa.selenium.WebElement;&lt;br /&gt;
       import org.openqa.selenium.htmlunit.HtmlUnitDriver;&amp;lt;br /&amp;gt;&lt;br /&gt;
       public class Example  {&lt;br /&gt;
       public static void main(String[] args) {&lt;br /&gt;
        // Create a new instance of the html unit driver&lt;br /&gt;
        // Notice that the remainder of the code relies on the interface,&lt;br /&gt;
        // not the implementation.&lt;br /&gt;
        WebDriver driver = new HtmlUnitDriver();&amp;lt;br /&amp;gt;&lt;br /&gt;
        System.out.println(&amp;quot;Beginning test for Google search using Selenium&amp;quot;);&lt;br /&gt;
        // And now use this to visit Google&lt;br /&gt;
        System.out.println(&amp;quot;Visit www.google.com&amp;quot; );&lt;br /&gt;
        driver.get(&amp;quot;http://www.google.com&amp;quot;);&amp;lt;br /&amp;gt;&lt;br /&gt;
        // Find the text input element by its name&lt;br /&gt;
        WebElement element = driver.findElement(By.name(&amp;quot;q&amp;quot;));&amp;lt;br /&amp;gt;&lt;br /&gt;
        // Enter something to search for&lt;br /&gt;
        System.out.println(&amp;quot;Type Automation in the search bar&amp;quot; );&lt;br /&gt;
        element.sendKeys(&amp;quot;Automation!&amp;quot;);&amp;lt;br /&amp;gt;&lt;br /&gt;
        // Now submit the form. WebDriver will find the form for us from the element&lt;br /&gt;
        element.submit();&amp;lt;br /&amp;gt;&lt;br /&gt;
        // Check the title of the page&lt;br /&gt;
        System.out.println(&amp;quot;Expected output&amp;quot; );&lt;br /&gt;
        System.out.println(&amp;quot;Page title is: &amp;quot; + driver.getTitle());&lt;br /&gt;
        driver.quit();&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
If you compile and run it, you should see a line with the title of the Google search results as output.&lt;br /&gt;
       ''Output:''&lt;br /&gt;
        Beginning test for Google search using Selenium &amp;lt;/ br&amp;gt;&lt;br /&gt;
        Visit www.google.com &amp;lt;/ br&amp;gt;&lt;br /&gt;
        Expected output &amp;lt;/ br&amp;gt;&lt;br /&gt;
        Page title is: Google&lt;br /&gt;
&lt;br /&gt;
====Install/Configure for other languages====&lt;br /&gt;
Configuring Selenium for languages other than Java and for other development environments can be looked up [http://docs.seleniumhq.org/docs/03_webdriver.jsp#setting-up-a-selenium-webdriver-project here]. viz(C#, Ruby, Python, PHP, Perl, Javascript)&lt;br /&gt;
&lt;br /&gt;
===Watir===&lt;br /&gt;
----&lt;br /&gt;
====Install/Configure (Ruby)====&lt;br /&gt;
Drivers for Watir are installed as gems which are nothing but Ruby libraries which can be accessed over the internet.&lt;br /&gt;
All the instructions for installing Watir on various operating systems (viz. Windows, Mac OS, Linux) can be found [http://watir.com/installation/ here].&lt;br /&gt;
&lt;br /&gt;
*Example:&lt;br /&gt;
This is how a typical Watir code to find the term say, “Automation” on Google and display the results on the page would look like using Ruby&amp;lt;ref&amp;gt;Chernenko, Iryna. [http://blog.qatestlab.com/2011/02/23/automated-testing-with-watir-tutorial-for-begginers-part-1/ Watir Example]. QATestLab Blog: Automated Testing with Watir, 23 Feb 2011.&lt;br /&gt;
&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
        # Required in ruby 1.8.7&lt;br /&gt;
        require 'rubygems'&lt;br /&gt;
        # Watir IE driver&lt;br /&gt;
        require 'watir'&amp;lt;br /&amp;gt; &lt;br /&gt;
        ie = Watir::IE.new&amp;lt;br /&amp;gt; &lt;br /&gt;
        # text to show on console&lt;br /&gt;
        puts &amp;quot;Beginning of the test for Google search engine&amp;quot;&lt;br /&gt;
        puts &amp;quot;Step 1:  Go to the Google homepage&amp;quot;&lt;br /&gt;
        ie.goto &amp;quot;http://www.google.com&amp;quot;&amp;lt;br /&amp;gt;&lt;br /&gt;
        #set a variable&lt;br /&gt;
        search_text = &amp;quot;Automation&amp;quot;&lt;br /&gt;
        puts &amp;quot;Step 2: enter &amp;quot;+ search_text +&amp;quot; in the search text field.&amp;quot;&lt;br /&gt;
        ie.text_field(:name, &amp;quot;q&amp;quot;).set search_text   # &amp;quot;q&amp;quot; is the name of the search field&amp;lt;br /&amp;gt;&lt;br /&gt;
        puts &amp;quot; Step 3: click the 'Google Search' button.&amp;quot;&lt;br /&gt;
        ie.button(:name, &amp;quot;btnG&amp;quot;).click # &amp;quot;btnG&amp;quot; is the name of the Search button&amp;lt;br /&amp;gt;&lt;br /&gt;
        puts &amp;quot; Expected Result:&amp;quot;&lt;br /&gt;
        puts &amp;quot;  A Google page with results should be shown. 'Watir, pronounced water' should be high on the list.&amp;quot;&lt;br /&gt;
        puts &amp;quot; Actual Result:&amp;quot;&lt;br /&gt;
        if ie.text.include? &amp;quot;Watir, pronounced water&amp;quot;	&lt;br /&gt;
             puts &amp;quot;  Test Passed. Found the text string: 'Watir, pronounced water'. Actual Results match Expected Results.&amp;quot;&lt;br /&gt;
        else	&lt;br /&gt;
 	     puts &amp;quot;  Test Failed! Could not find text: 'Watir, pronounced water'.&amp;quot;&lt;br /&gt;
        end&lt;br /&gt;
        puts &amp;quot;End of test: Google search.&amp;quot;&lt;br /&gt;
        ie.close&lt;br /&gt;
&lt;br /&gt;
On compiling and running this and passing the test, you will see something like,&lt;br /&gt;
&lt;br /&gt;
        ''Output:''&lt;br /&gt;
        Beginning of the test for Google search engine &lt;br /&gt;
        Step 1:  Go to the Google homepage &lt;br /&gt;
        Step 2: enter Automation in the search text field. &lt;br /&gt;
        Step 3: click the 'Google Search' button. &lt;br /&gt;
        Expected Result: &lt;br /&gt;
        A Google page with results should be shown. 'Watir, pronounced water' should be high on the list. 	&lt;br /&gt;
        Test Passed. Found the text string: 'Watir, pronounced water'. Actual Results match Expected Results. &lt;br /&gt;
        End of test: Google search. &amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Similar Tools==&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Sahi_(software) Sahi], uses the Sahi Scripting Language&amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Soatest SOATest], for testing and validating [http://en.wikipedia.org/wiki/Application_programming_interface API] driven applications &amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/TestComplete TestComplete], for Desktops, Web and Mobile&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
* [http://www.hiretheworld.com/blog/tech-blog/migrating-unit-tests-from-selenium-to-watir-webdriver Migrating unit tests from Selenium to Watir Web Driver] &amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://www.hiretheworld.com/blog/tech-blog/migrating-unit-tests-from-selenium-to-watir-webdriver Learning Selenium IDE] &amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/List_of_web_testing_tools List of web testing tools] &amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/List_of_web_testing_tools OWASP List of Acceptance Testing tools]&lt;br /&gt;
* [http://www.ijiet.org/papers/425-T0026.pdf  Study of Browser Based Automated Test Tools WATIR and Selenium] Nisha Gogna, August 2014, International Journal of Information and Education Technology, Vol. 4, No. 4&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
{{reflist}}&lt;br /&gt;
&amp;lt;references /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==External Links==&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Selenium_(software) Selenium Wiki Page] &amp;lt;br /&amp;gt;&lt;br /&gt;
* [https://github.com/SeleniumHQ/selenium Selenium Source Code] &amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Watir Watir Wiki Page] &amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Watir Watir Source Code] &amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Watir SauceLabs HomePage] &amp;lt;br /&amp;gt;&lt;/div&gt;</summary>
		<author><name>Jjbeaver</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/ch1b_27_js&amp;diff=89449</id>
		<title>CSC/ECE 517 Fall 2014/ch1b 27 js</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/ch1b_27_js&amp;diff=89449"/>
		<updated>2014-10-07T04:22:14Z</updated>

		<summary type="html">&lt;p&gt;Jjbeaver: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;='''Selenium vs. Watir'''=&lt;br /&gt;
&lt;br /&gt;
Developing web applications is proving to be a challenging task with each passing day given the complex requirements and the demanding nature of the these applications. For the web applications to be robust we need to put in place some good testing strategies.&lt;br /&gt;
&lt;br /&gt;
'''''Selenium''''' is one of the most popularly used open source automation tools for web based applications. It is a JavaScript framework that runs in your web browser to interact with various elements in your browser. All in all, Selenium is a set of different software tools each with a different approach to supporting test automation. Selenium provides a rich set of testing functions that can be customized to suit the testing requirements.&lt;br /&gt;
 &lt;br /&gt;
'''''Watir''''', is another lightweight automation testing tool that is widely used for web app testing. It is an open-source ([http://en.wikipedia.org/wiki/BSD_licenses BSD])  family of Ruby libraries for automating web browsers. It allows you to write tests that are easy to read and maintain. Despite the fact that it is a set of Ruby libraries, it works perfectly, independent of the language that the web application is developed in. Watir as a tool is extremely simple and flexible.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=='''Motivation'''==&lt;br /&gt;
===Need for test automation===&lt;br /&gt;
With the majority of software applications today being implemented as [http://en.wikipedia.org/wiki/Web_application web applications] to be used over the internet, testing is becoming an indispensable part of the software development lifecycle ([http://en.wikipedia.org/wiki/Software_development_process SDLC]) of these applications. [http://en.wikipedia.org/wiki/Test_automation Test automation] is used where manual testing needs to be carried out repeatedly making it a cumbersome task. Test automation uses a software tool for this purpose on the application to be tested. It has proven to be highly efficient and critical in larger software development companies. Additionally, automation can be a valuable way to make Test Driven Development ([http://en.wikipedia.org/wiki/Test-driven_development TDD]) tasks an important part of the software development workflow.&lt;br /&gt;
 &lt;br /&gt;
Test Automation has a number of advantages mostly dealing with repetitiveness of the tests and the time taken,&lt;br /&gt;
* '''Covers cases that manual testing probably cannot'''&lt;br /&gt;
# Finds defects missed out my manual testing&lt;br /&gt;
# Automated testing can simulate numerous virtual users interacting with the web software/application&lt;br /&gt;
* '''Helps save time and money'''&lt;br /&gt;
# Once created, automated tests can be executed repeatedly at no additional   costs and at a much faster pace. Saving time directly translates into saving cost.&lt;br /&gt;
# Supports virtually unlimited iterations of test case execution&lt;br /&gt;
* '''Increase test coverage and accuracy'''&lt;br /&gt;
# Automated tests perform the exact same steps and records all details precisely&lt;br /&gt;
# They also increase the depth and scope of tests to improve the quality of the software&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=='''Brief History'''==&lt;br /&gt;
====Selenium====&lt;br /&gt;
&lt;br /&gt;
[[File: SE-logo.png|right|Selenium Logo|link=http://www.seleniumhq.org/images/big-logo.png]]&lt;br /&gt;
&lt;br /&gt;
''Selenium'' was developed in the year 2004 by Jason Huggins and has been continuously evolving ever since. Jason Huggins developed this as an internal tool for [http://en.wikipedia.org/wiki/ThoughtWorks ThoughtWorks] as a javascript library which came to be known as the Selenium core. Selenium core is now the basis of the Selenium Remote Control (the server) and Selenium IDE.&lt;br /&gt;
The year 2006 marked the beginning of the development of the WebDriver project which was what they believed ‘a tool of the future’. The WebDriver was initiated to solve the problems that were faced due to the fact that Selenium was a based on JavaScript and a lot of security limitations browsers apply to Javascript.&lt;br /&gt;
In 2008, both Selenium and WebDriver merged to provide a common set of features to all users which is called Selenium 2..&lt;br /&gt;
Simon Stewart, the creator of WebDriver, in a joint email to the WebDriver and Selenium community on August 6, 2009 said the following,&lt;br /&gt;
&lt;br /&gt;
“Why are the projects merging? Partly because webdriver addresses some shortcomings in selenium (by being able to bypass the JS sandbox, for example. And we’ve got a gorgeous API), partly because selenium addresses some shortcomings in webdriver (such as supporting a broader range of browsers) and partly because the main selenium contributors and I felt that it was the best way to offer users the best possible framework.”&amp;lt;ref name =&amp;quot;Introduction to Selenium&amp;quot;&amp;gt;[http://docs.seleniumhq.org/docs/01_introducing_selenium.jsp#selenium-history Introducing Selenium]. ''SeleniumHQ: Browser Automation''. Selenium Project, 4 Oct. 2014. Web. 06 Oct. 2014.&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Watir====&lt;br /&gt;
&lt;br /&gt;
''Watir'' started as a library to teach testers to write ruby code and grew to be an IE implementation which now supports IE, Firefox, Safari, Google Chrome and Opera.&lt;br /&gt;
Watir was primarily developed by Bret Pettichord and Paul Rogers. Watir has since then has a couple of stable releases for Watir classic as well as Watir WebDriver. The most recent releases being&amp;lt;ref&amp;gt;[http://watir.com/category/releases/ Watir Releases]. Watir: Web Application Testing in Ruby. 28 April, 2013&amp;lt;/ref&amp;gt;, &lt;br /&gt;
&lt;br /&gt;
[[File: Watir.gif|right|Watir logo|link=http://upload.wikimedia.org/wikipedia/commons/7/7e/Watir.gif]]&lt;br /&gt;
&lt;br /&gt;
* Watir-Classic	    &lt;br /&gt;
# 0.6.3 April 10, 2013 ([https://github.com/watir/watir-webdriver/blob/master/CHANGES.md#063 Release Notes]) &amp;lt;br /&amp;gt;&lt;br /&gt;
* Watir-WebDriver	    &lt;br /&gt;
# 3.6.0 March 16, 2013 ([https://groups.google.com/forum/#!msg/watir-general/MOOun5g3Hvg/JBVNy957lDYJ Release Notes]) &amp;lt;br /&amp;gt;&lt;br /&gt;
# 3.5.0 March 10, 2013 ([https://groups.google.com/forum/#!msg/watir-general/aeUqsglvK6k/Kq7FCBiERjYJ Release Notes]) &amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Watir has a google group ([https://groups.google.com/forum/#!forum/watir-general Watir General]) for its support and contribution while Selenium also has a [http://seleniumforum.forumotion.net/ Selenium forum] apart from its google group called [https://groups.google.com/forum/#!forum/selenium-users Selenium Users].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=='''Comparison of Features, Functionality, and More'''==&lt;br /&gt;
Some features or functionality may be repeated here.  However, we will go into a bit more detail than previously mentioned.&lt;br /&gt;
===='''Open Source'''====&lt;br /&gt;
Both Selenium and Watir are [http://en.wikipedia.org/wiki/Open-source_software open source]!  This allows for greater extensibility and a deeper understanding of the inner workings of both of the frameworks, if the developer/tester chooses to delve into such details.  Additionally, the open source community allows for a more transparent, user-driven development and support cycle.  Users (the tester/developer) can choose to submit bug fixes or enhancements as patches, or they can choose to just use it “straight out of the box.”&lt;br /&gt;
&lt;br /&gt;
====Application Language Agnostic====&lt;br /&gt;
&lt;br /&gt;
Both Selenium and Watir are application language agnostic.  Because both Selenium and Watir test UI functionality in the browser, they can be used to test any web application.    &lt;br /&gt;
&lt;br /&gt;
====Language-specific Test Cases====&lt;br /&gt;
&lt;br /&gt;
Both Selenium and Watir require test cases to be written in some programming language.  Traditionally, both frameworks had limited choices in terms of language bindings.  However, with the advent of WebDriver, both became much more flexible.  WebDriver provided the bindings needed for many languages.  Today, the following are supported:&lt;br /&gt;
&lt;br /&gt;
'''Selenium*'''&lt;br /&gt;
&lt;br /&gt;
* Officially-supported: [http://en.wikipedia.org/wiki/Java_(programming_language) Java], [http://en.wikipedia.org/wiki/C_Sharp_(programming_language) C#], [http://en.wikipedia.org/wiki/Ruby_(programming_language) Ruby], [http://en.wikipedia.org/wiki/Python_(programming_language) Python], [http://en.wikipedia.org/wiki/Node.js Javascript/Node.js]&lt;br /&gt;
&lt;br /&gt;
* Unofficial/community-supported: [http://en.wikipedia.org/wiki/Perl Perl], [http://en.wikipedia.org/wiki/PHP PHP], [http://en.wikipedia.org/wiki/Haskell_(programming_language) Haskell], [http://en.wikipedia.org/wiki/Objective-C Objective-C], [http://en.wikipedia.org/wiki/R_(programming_language) R], [http://en.wikipedia.org/wiki/Dart_(programming_language) Dart], [http://en.wikipedia.org/wiki/Tcl Tcl]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;According to SeleniumHQ’s download page.&lt;br /&gt;
&lt;br /&gt;
'''Watir'''&lt;br /&gt;
&lt;br /&gt;
Unfortunately (or fortunately), Ruby is the only supported language for Watir.  After all, Watir does stand for “Web Application Testing in Ruby.” However, there are other frameworks which were inspired by Watir (but entirely separate) available in Java and C# - [http://watij.com/ Watij] and [http://watin.org/ Watin],  respectively &amp;lt;ref&amp;gt;Djorgjievski, Darko. [http://www.sitepoint.com/watir-webdriver-control-browser/ Watir-WebDriver: Control the Browser]. ''SitePoint''. SitePoint Pty Ltd, 18 Apr. 2014. Web. 05 Oct. 2014.&amp;lt;/ref&amp;gt;.  There may be other similarly inspired frameworks available in other languages, but these are the most notable.&lt;br /&gt;
&lt;br /&gt;
====Cross-Browser and Headless Browser Support====&lt;br /&gt;
&lt;br /&gt;
[[File: watir_meet_webdriver.png | Watir Meets WebDriver |right|frame| link=http://yuml.me/diagram/scruffy/usecase/%5BTester%5D-%28Watir%20API%29,%20%28Watir%20API%29%3C%28FireWatir%29,%20%28Watir%20API%29%3C%28Watir%29,%20%28Watir%20API%29%3C%28SafariWatir%29,%20%28Watir%20API%29%3C%28Webdriver%29,%20%28Watir%20API%29%3C%28Celerity%29,%20%28Celerity%29-%28note:%20Celerity%20requires%20JRuby%29,%20%28Celerity%29-%28headless%29,%20%28Webdriver%29-%28Firefox%29,%20%28Webdriver%29-%28Chrome%29,%20%28Webdriver%29-%28IE%29,%20%28Webdriver%29-%28headless%29,%20%28FireWatir%29-%28Firefox%29,%20%28Watir%29-%28IE%29,%20%28SafariWatir%29-%28Safari%29.]]&lt;br /&gt;
&lt;br /&gt;
Traditionally, both Selenium and Watir were limited in the number of browsers they supported. Watir originally supported Internet Explorer and headless browsers exclusively.  Headless browsers were supported via the use of [https://github.com/jarib/celerity Celerity] &amp;lt;ref&amp;gt;Scott, Alister. [http://watirmelon.com/2010/04/10/watir-selenium-webdriver/ Watir, Selenium &amp;amp; WebDriver]. ''Watirmelon''. Watirmelon, 10 Apr. 2010. Web. 05 Oct. 2014.&amp;lt;/ref&amp;gt;.  Selenium started out as a Javascript library, so naturally it supported more browsers such as IE, Firefox, Safari, etc &amp;lt;ref name = &amp;quot;Introduction to Selenium&amp;quot; /&amp;gt;.  However, it did not support headless browsers.&lt;br /&gt;
Today, browser support looks much better for both Selenium and Watir, largely due to the introduction of WebDriver.  With WebDriver in existence, support for most browsers was added to Watir via the gem &amp;quot;watir-webdriver,&amp;quot; and Celerity became [https://github.com/jarib/celerity obsolete] because headless browser support was included in WebDriver.  Similarly for Selenium, support for headless browsers was added, as well as making the API much simpler and more concise &amp;lt;ref&amp;gt;[http://docs.seleniumhq.org/projects/webdriver/ Selenium WebDriver]. ''SeleniumHQ: Browser Automation''. Selenium Project, n.d. Web. 06 Oct. 2014.&amp;lt;/ref&amp;gt;.  Both Selenium &amp;lt;ref&amp;gt;Semerau, Luke. [https://code.google.com/p/selenium/wiki/WebDriverForMobileBrowsers WebDriverForMobileBrowsers]. ''Selenium''. Google Project Hosting, 14 Jan. 2013. Web. 06 Oct. 2014 &amp;lt;/ref&amp;gt; and Watir &amp;lt;ref&amp;gt;Scott, Alister. [http://watirwebdriver.com/mobile-devices/ Mobile Devices]. ''Watir WebDriver''. n.d. Web. 06 Oct. 2014. &amp;lt;/ref&amp;gt; have also gained support of Mobile browsers in recent years through WebDriver.  However, there is the obvious limitation that one can only test a browser which is supported on the running platform.  In other words, Safari and Internet explorer can only be tested on  OS X and Windows environments, respectively**.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;**&amp;lt;/nowiki&amp;gt; &amp;lt;span style=&amp;quot;font-size:88%&amp;quot;&amp;gt;Some work-arounds or programs may exist to allow these browsers to be tested on other platforms. Here, we are assuming no special additional configuration - just the base operating system and browsers.  With virtualization technologies such as [http://www.linux-kvm.org/page/Main_Page KVM], [https://www.virtualbox.org/ VirtualBox], and [http://en.wikipedia.org/wiki/Comparison_of_platform_virtualization_software others], this isn't a problem anyway.  [http://en.wikipedia.org/wiki/Virtual_machine Virtual machines] can be created with any operating system, as needed.&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Cross-Platform Support====&lt;br /&gt;
Both Watir and Selenium run on most popular distributions of Windows, Mac, and Linux.  Selenium doesn't have a list of officially supported operating system versions.  Instead they generally support any version that is currently popular.  Only a few versions are listed which they run test builds on.  These are versions which are officially known to work, but many more are supported as well.&lt;br /&gt;
&lt;br /&gt;
Because Watir is a collection of Ruby Gems, it runs on any platform that Ruby runs on.  Like Selenium, this includes nearly all popular platforms.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=='''Getting started'''==&lt;br /&gt;
===Selenium WebDriver=== &lt;br /&gt;
----&lt;br /&gt;
====Install/Configure (Java)====&lt;br /&gt;
Configuring Selenium requires you to download the binaries from [http://www.seleniumhq.org/download/ here]. &lt;br /&gt;
Once you have all your binaries in a directory, you can open any IDE of your choice and add this directory with all the .jar files to the CLASSPATH&lt;br /&gt;
*Example&lt;br /&gt;
This is how a typical Selenium code to find the term say, “Automation” on Google and display the results on the page would look like in Java using the [https://code.google.com/p/selenium/wiki/HtmlUnitDriver HtmlUnitDriver] would look like.&lt;br /&gt;
The HtmlUnitDriver is a pure Java driver that runs entirely in-memory. Because of this, you won't see a new browser window open &amp;lt;ref&amp;gt;[https://code.google.com/p/selenium/wiki/GettingStarted Getting started with Selenium]. Selenium: Browser Automation Framework. Google Code. 8 Feb, 2014.&amp;lt;/ref&amp;gt;,&lt;br /&gt;
&lt;br /&gt;
       package org.selenium.example;&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;
       import org.openqa.selenium.By;&lt;br /&gt;
       import org.openqa.selenium.WebDriver;&lt;br /&gt;
       import org.openqa.selenium.WebElement;&lt;br /&gt;
       import org.openqa.selenium.htmlunit.HtmlUnitDriver;&amp;lt;br /&amp;gt;&lt;br /&gt;
       public class Example  {&lt;br /&gt;
       public static void main(String[] args) {&lt;br /&gt;
        // Create a new instance of the html unit driver&lt;br /&gt;
        // Notice that the remainder of the code relies on the interface,&lt;br /&gt;
        // not the implementation.&lt;br /&gt;
        WebDriver driver = new HtmlUnitDriver();&amp;lt;br /&amp;gt;&lt;br /&gt;
        // And now use this to visit Google&lt;br /&gt;
        driver.get(&amp;quot;http://www.google.com&amp;quot;);&amp;lt;br /&amp;gt;&lt;br /&gt;
        // Find the text input element by its name&lt;br /&gt;
        WebElement element = driver.findElement(By.name(&amp;quot;q&amp;quot;));&amp;lt;br /&amp;gt;&lt;br /&gt;
        // Enter something to search for&lt;br /&gt;
        element.sendKeys(&amp;quot;Automation!&amp;quot;);&amp;lt;br /&amp;gt;&lt;br /&gt;
        // Now submit the form. WebDriver will find the form for us from the element&lt;br /&gt;
        element.submit();&amp;lt;br /&amp;gt;&lt;br /&gt;
        // Check the title of the page&lt;br /&gt;
        System.out.println(&amp;quot;Page title is: &amp;quot; + driver.getTitle());&lt;br /&gt;
        driver.quit();&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
If you compile and run it, you should see a line with the title of the Google search results as output.&lt;br /&gt;
&lt;br /&gt;
====Install/Configure for other languages====&lt;br /&gt;
Configuring Selenium for languages other than Java and for other development environments can be looked up [http://docs.seleniumhq.org/docs/03_webdriver.jsp#setting-up-a-selenium-webdriver-project here]. viz(C#, Ruby, Python, PHP, Perl, Javascript)&lt;br /&gt;
&lt;br /&gt;
===Watir===&lt;br /&gt;
----&lt;br /&gt;
====Install/Configure (Ruby)====&lt;br /&gt;
Drivers for Watir are installed as gems which are nothing but Ruby libraries which can be accessed over the internet.&lt;br /&gt;
All the instructions for installing Watir on various operating systems (viz. Windows, Mac OS, Linux) can be found [http://watir.com/installation/ here].&lt;br /&gt;
&lt;br /&gt;
*Example:&lt;br /&gt;
This is how a typical Watir code to find the term say, “Automation” on Google and display the results on the page would look like using Ruby&amp;lt;ref&amp;gt;Chernenko, Iryna. [http://blog.qatestlab.com/2011/02/23/automated-testing-with-watir-tutorial-for-begginers-part-1/ Watir Example]. QATestLab Blog: Automated Testing with Watir, 23 Feb 2011.&lt;br /&gt;
&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
        # Required in ruby 1.8.7&lt;br /&gt;
        require 'rubygems'&lt;br /&gt;
        # Watir IE driver&lt;br /&gt;
        require 'watir'&amp;lt;br /&amp;gt; &lt;br /&gt;
        ie = Watir::IE.new&amp;lt;br /&amp;gt; &lt;br /&gt;
        # text to show on console&lt;br /&gt;
        puts &amp;quot;Beginning of the test for Google search engine&amp;quot;&lt;br /&gt;
        puts &amp;quot;Step 1:  Go to the Google homepage&amp;quot;&lt;br /&gt;
        ie.goto &amp;quot;http://www.google.com&amp;quot;&amp;lt;br /&amp;gt;&lt;br /&gt;
        #set a variable&lt;br /&gt;
        search_text = &amp;quot;Automation&amp;quot;&lt;br /&gt;
        puts &amp;quot;Step 2: enter &amp;quot;+ search_text +&amp;quot; in the search text field.&amp;quot;&lt;br /&gt;
        ie.text_field(:name, &amp;quot;q&amp;quot;).set search_text   # &amp;quot;q&amp;quot; is the name of the search field&amp;lt;br /&amp;gt;&lt;br /&gt;
        puts &amp;quot; Step 3: click the 'Google Search' button.&amp;quot;&lt;br /&gt;
        ie.button(:name, &amp;quot;btnG&amp;quot;).click # &amp;quot;btnG&amp;quot; is the name of the Search button&amp;lt;br /&amp;gt;&lt;br /&gt;
        puts &amp;quot; Expected Result:&amp;quot;&lt;br /&gt;
        puts &amp;quot;  A Google page with results should be shown. 'Watir, pronounced water' should be high on the list.&amp;quot;&lt;br /&gt;
        puts &amp;quot; Actual Result:&amp;quot;&lt;br /&gt;
        if ie.text.include? &amp;quot;Watir, pronounced water&amp;quot;	&lt;br /&gt;
             puts &amp;quot;  Test Passed. Found the text string: 'Watir, pronounced water'. Actual Results match Expected Results.&amp;quot;&lt;br /&gt;
        else	&lt;br /&gt;
 	     puts &amp;quot;  Test Failed! Could not find text: 'Watir, pronounced water'.&amp;quot;&lt;br /&gt;
        end&lt;br /&gt;
        puts &amp;quot;End of test: Google search.&amp;quot;&lt;br /&gt;
        ie.close&lt;br /&gt;
&lt;br /&gt;
On compiling and running this and passing the test, you will see something like, &amp;lt;br /&amp;gt; &lt;br /&gt;
&lt;br /&gt;
        ''Output:''&lt;br /&gt;
        Beginning of the test for Google search engine &amp;lt;br /&amp;gt;&lt;br /&gt;
        Step 1:  Go to the Google homepage &amp;lt;br /&amp;gt;&lt;br /&gt;
        Step 2: enter Automation in the search text field. &amp;lt;br /&amp;gt;&lt;br /&gt;
        Step 3: click the 'Google Search' button. &amp;lt;br /&amp;gt;&lt;br /&gt;
        Expected Result: &amp;lt;br /&amp;gt;&lt;br /&gt;
        A Google page with results should be shown. 'Watir, pronounced water' should be high on the list. &amp;lt;br /&amp;gt;	&lt;br /&gt;
        Test Passed. Found the text string: 'Watir, pronounced water'. Actual Results match Expected Results. &amp;lt;br /&amp;gt;&lt;br /&gt;
        End of test: Google search. &amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Similar Tools==&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Sahi_(software) Sahi], uses the Sahi Scripting Language&amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Soatest SOATest], for testing and validating [http://en.wikipedia.org/wiki/Application_programming_interface API] driven applications &amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/TestComplete TestComplete], for Desktops, Web and Mobile&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
* [http://www.hiretheworld.com/blog/tech-blog/migrating-unit-tests-from-selenium-to-watir-webdriver Migrating unit tests from Selenium to Watir Web Driver] &amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://www.hiretheworld.com/blog/tech-blog/migrating-unit-tests-from-selenium-to-watir-webdriver Learning Selenium IDE] &amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/List_of_web_testing_tools List of web testing tools] &amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/List_of_web_testing_tools OWASP List of Acceptance Testing tools]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
{{reflist}}&lt;br /&gt;
&amp;lt;references /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==External Links==&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Selenium_(software) Selenium Wiki Page] &amp;lt;br /&amp;gt;&lt;br /&gt;
* [https://github.com/SeleniumHQ/selenium Selenium Source Code] &amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Watir Watir Wiki Page] &amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Watir Watir Source Code] &amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Watir SauceLabs HomePage] &amp;lt;br /&amp;gt;&lt;/div&gt;</summary>
		<author><name>Jjbeaver</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/ch1b_27_js&amp;diff=89448</id>
		<title>CSC/ECE 517 Fall 2014/ch1b 27 js</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/ch1b_27_js&amp;diff=89448"/>
		<updated>2014-10-07T04:21:59Z</updated>

		<summary type="html">&lt;p&gt;Jjbeaver: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;='''Selenium vs. Watir'''=&lt;br /&gt;
&lt;br /&gt;
Developing web applications is proving to be a challenging task with each passing day given the complex requirements and the demanding nature of the these applications. For the web applications to be robust we need to put in place some good testing strategies.&lt;br /&gt;
&lt;br /&gt;
'''''Selenium''''' is one of the most popularly used open source automation tools for web based applications. It is a JavaScript framework that runs in your web browser to interact with various elements in your browser. All in all, Selenium is a set of different software tools each with a different approach to supporting test automation. Selenium provides a rich set of testing functions that can be customized to suit the testing requirements.&lt;br /&gt;
 &lt;br /&gt;
'''''Watir''''', is another lightweight automation testing tool that is widely used for web app testing. It is an open-source ([http://en.wikipedia.org/wiki/BSD_licenses BSD])  family of Ruby libraries for automating web browsers. It allows you to write tests that are easy to read and maintain. Despite the fact that it is a set of Ruby libraries, it works perfectly, independent of the language that the web application is developed in. Watir as a tool is extremely simple and flexible.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=='''Motivation'''==&lt;br /&gt;
===Need for test automation===&lt;br /&gt;
With the majority of software applications today being implemented as [http://en.wikipedia.org/wiki/Web_application web applications] to be used over the internet, testing is becoming an indispensable part of the software development lifecycle ([http://en.wikipedia.org/wiki/Software_development_process SDLC]) of these applications. [http://en.wikipedia.org/wiki/Test_automation Test automation] is used where manual testing needs to be carried out repeatedly making it a cumbersome task. Test automation uses a software tool for this purpose on the application to be tested. It has proven to be highly efficient and critical in larger software development companies. Additionally, automation can be a valuable way to make Test Driven Development ([http://en.wikipedia.org/wiki/Test-driven_development TDD]) tasks an important part of the software development workflow.&lt;br /&gt;
 &lt;br /&gt;
Test Automation has a number of advantages mostly dealing with repetitiveness of the tests and the time taken,&lt;br /&gt;
* '''Covers cases that manual testing probably cannot'''&lt;br /&gt;
# Finds defects missed out my manual testing&lt;br /&gt;
# Automated testing can simulate numerous virtual users interacting with the web software/application&lt;br /&gt;
* '''Helps save time and money'''&lt;br /&gt;
# Once created, automated tests can be executed repeatedly at no additional   costs and at a much faster pace. Saving time directly translates into saving cost.&lt;br /&gt;
# Supports virtually unlimited iterations of test case execution&lt;br /&gt;
* '''Increase test coverage and accuracy'''&lt;br /&gt;
# Automated tests perform the exact same steps and records all details precisely&lt;br /&gt;
# They also increase the depth and scope of tests to improve the quality of the software&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=='''Brief History'''==&lt;br /&gt;
====Selenium====&lt;br /&gt;
&lt;br /&gt;
[[File: SE-logo.png|right|Selenium Logo|link=http://www.seleniumhq.org/images/big-logo.png]]&lt;br /&gt;
&lt;br /&gt;
''Selenium'' was developed in the year 2004 by Jason Huggins and has been continuously evolving ever since. Jason Huggins developed this as an internal tool for [http://en.wikipedia.org/wiki/ThoughtWorks ThoughtWorks] as a javascript library which came to be known as the Selenium core. Selenium core is now the basis of the Selenium Remote Control (the server) and Selenium IDE.&lt;br /&gt;
The year 2006 marked the beginning of the development of the WebDriver project which was what they believed ‘a tool of the future’. The WebDriver was initiated to solve the problems that were faced due to the fact that Selenium was a based on JavaScript and a lot of security limitations browsers apply to Javascript.&lt;br /&gt;
In 2008, both Selenium and WebDriver merged to provide a common set of features to all users which is called Selenium 2..&lt;br /&gt;
Simon Stewart, the creator of WebDriver, in a joint email to the WebDriver and Selenium community on August 6, 2009 said the following,&lt;br /&gt;
&lt;br /&gt;
“Why are the projects merging? Partly because webdriver addresses some shortcomings in selenium (by being able to bypass the JS sandbox, for example. And we’ve got a gorgeous API), partly because selenium addresses some shortcomings in webdriver (such as supporting a broader range of browsers) and partly because the main selenium contributors and I felt that it was the best way to offer users the best possible framework.”&amp;lt;ref name =&amp;quot;Introduction to Selenium&amp;quot;&amp;gt;[http://docs.seleniumhq.org/docs/01_introducing_selenium.jsp#selenium-history Introducing Selenium]. ''SeleniumHQ: Browser Automation''. Selenium Project, 4 Oct. 2014. Web. 06 Oct. 2014.&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Watir====&lt;br /&gt;
&lt;br /&gt;
''Watir'' started as a library to teach testers to write ruby code and grew to be an IE implementation which now supports IE, Firefox, Safari, Google Chrome and Opera.&lt;br /&gt;
Watir was primarily developed by Bret Pettichord and Paul Rogers. Watir has since then has a couple of stable releases for Watir classic as well as Watir WebDriver. The most recent releases being&amp;lt;ref&amp;gt;[http://watir.com/category/releases/ Watir Releases]. Watir: Web Application Testing in Ruby. 28 April, 2013&amp;lt;/ref&amp;gt;, &lt;br /&gt;
&lt;br /&gt;
[[File: Watir.gif|right|Watir logo|link=http://upload.wikimedia.org/wikipedia/commons/7/7e/Watir.gif]]&lt;br /&gt;
&lt;br /&gt;
* Watir-Classic	    &lt;br /&gt;
# 0.6.3 April 10, 2013 ([https://github.com/watir/watir-webdriver/blob/master/CHANGES.md#063 Release Notes]) &amp;lt;br /&amp;gt;&lt;br /&gt;
* Watir-WebDriver	    &lt;br /&gt;
# 3.6.0 March 16, 2013 ([https://groups.google.com/forum/#!msg/watir-general/MOOun5g3Hvg/JBVNy957lDYJ Release Notes]) &amp;lt;br /&amp;gt;&lt;br /&gt;
# 3.5.0 March 10, 2013 ([https://groups.google.com/forum/#!msg/watir-general/aeUqsglvK6k/Kq7FCBiERjYJ Release Notes]) &amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Watir has a google group ([https://groups.google.com/forum/#!forum/watir-general Watir General]) for its support and contribution while Selenium also has a [http://seleniumforum.forumotion.net/ Selenium forum] apart from its google group called [https://groups.google.com/forum/#!forum/selenium-users Selenium Users].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=='''Comparison of Features, Functionality, and More'''==&lt;br /&gt;
Some features or functionality may be repeated here.  However, we will go into a bit more detail than previously mentioned.&lt;br /&gt;
===='''Open Source'''====&lt;br /&gt;
Both Selenium and Watir are [http://en.wikipedia.org/wiki/Open-source_software open source]!  This allows for greater extensibility and a deeper understanding of the inner workings of both of the frameworks, if the developer/tester chooses to delve into such details.  Additionally, the open source community allows for a more transparent, user-driven development and support cycle.  Users (the tester/developer) can choose to submit bug fixes or enhancements as patches, or they can choose to just use it “straight out of the box.”&lt;br /&gt;
&lt;br /&gt;
====Application Language Agnostic====&lt;br /&gt;
&lt;br /&gt;
Both Selenium and Watir are application language agnostic.  Because both Selenium and Watir test UI functionality in the browser, they can be used to test any web application.    &lt;br /&gt;
&lt;br /&gt;
====Language-specific Test Cases====&lt;br /&gt;
&lt;br /&gt;
Both Selenium and Watir require test cases to be written in some programming language.  Traditionally, both frameworks had limited choices in terms of language bindings.  However, with the advent of WebDriver, both became much more flexible.  WebDriver provided the bindings needed for many languages.  Today, the following are supported:&lt;br /&gt;
&lt;br /&gt;
'''Selenium*'''&lt;br /&gt;
&lt;br /&gt;
* Officially-supported: [http://en.wikipedia.org/wiki/Java_(programming_language) Java], [http://en.wikipedia.org/wiki/C_Sharp_(programming_language) C#], [http://en.wikipedia.org/wiki/Ruby_(programming_language) Ruby], [http://en.wikipedia.org/wiki/Python_(programming_language) Python], [http://en.wikipedia.org/wiki/Node.js Javascript/Node.js]&lt;br /&gt;
&lt;br /&gt;
* Unofficial/community-supported: [http://en.wikipedia.org/wiki/Perl Perl], [http://en.wikipedia.org/wiki/PHP PHP], [http://en.wikipedia.org/wiki/Haskell_(programming_language) Haskell], [http://en.wikipedia.org/wiki/Objective-C Objective-C], [http://en.wikipedia.org/wiki/R_(programming_language) R], [http://en.wikipedia.org/wiki/Dart_(programming_language) Dart], [http://en.wikipedia.org/wiki/Tcl Tcl]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;According to SeleniumHQ’s download page.&lt;br /&gt;
&lt;br /&gt;
'''Watir'''&lt;br /&gt;
&lt;br /&gt;
Unfortunately (or fortunately), Ruby is the only supported language for Watir.  After all, Watir does stand for “Web Application Testing in Ruby.” However, there are other frameworks which were inspired by Watir (but entirely separate) available in Java and C# - [http://watij.com/ Watij] and [http://watin.org/ Watin],  respectively &amp;lt;ref&amp;gt;Djorgjievski, Darko. [http://www.sitepoint.com/watir-webdriver-control-browser/ Watir-WebDriver: Control the Browser]. ''SitePoint''. SitePoint Pty Ltd, 18 Apr. 2014. Web. 05 Oct. 2014.&amp;lt;/ref&amp;gt;.  There may be other similarly inspired frameworks available in other languages, but these are the most notable.&lt;br /&gt;
&lt;br /&gt;
====Cross-Browser and Headless Browser Support====&lt;br /&gt;
&lt;br /&gt;
[[File: watir_meet_webdriver.png | Watir Meets WebDriver |right|frame| link=http://yuml.me/diagram/scruffy/usecase/%5BTester%5D-%28Watir%20API%29,%20%28Watir%20API%29%3C%28FireWatir%29,%20%28Watir%20API%29%3C%28Watir%29,%20%28Watir%20API%29%3C%28SafariWatir%29,%20%28Watir%20API%29%3C%28Webdriver%29,%20%28Watir%20API%29%3C%28Celerity%29,%20%28Celerity%29-%28note:%20Celerity%20requires%20JRuby%29,%20%28Celerity%29-%28headless%29,%20%28Webdriver%29-%28Firefox%29,%20%28Webdriver%29-%28Chrome%29,%20%28Webdriver%29-%28IE%29,%20%28Webdriver%29-%28headless%29,%20%28FireWatir%29-%28Firefox%29,%20%28Watir%29-%28IE%29,%20%28SafariWatir%29-%28Safari%29.]]&lt;br /&gt;
&lt;br /&gt;
Traditionally, both Selenium and Watir were limited in the number of browsers they supported. Watir originally supported Internet Explorer and headless browsers exclusively.  Headless browsers were supported via the use of [https://github.com/jarib/celerity Celerity] &amp;lt;ref&amp;gt;Scott, Alister. [http://watirmelon.com/2010/04/10/watir-selenium-webdriver/ Watir, Selenium &amp;amp; WebDriver]. ''Watirmelon''. Watirmelon, 10 Apr. 2010. Web. 05 Oct. 2014.&amp;lt;/ref&amp;gt;.  Selenium started out as a Javascript library, so naturally it supported more browsers such as IE, Firefox, Safari, etc &amp;lt;ref name = &amp;quot;Introduction to Selenium&amp;quot; /&amp;gt;.  However, it did not support headless browsers.&lt;br /&gt;
Today, browser support looks much better for both Selenium and Watir, largely due to the introduction of WebDriver.  With WebDriver in existence, support for most browsers was added to Watir via the gem &amp;quot;watir-webdriver,&amp;quot; and Celerity became [https://github.com/jarib/celerity obsolete] because headless browser support was included in WebDriver.  Similarly for Selenium, support for headless browsers was added, as well as making the API much simpler and more concise &amp;lt;ref&amp;gt;[http://docs.seleniumhq.org/projects/webdriver/ Selenium WebDriver]. ''SeleniumHQ: Browser Automation''. Selenium Project, n.d. Web. 06 Oct. 2014.&amp;lt;/ref&amp;gt;.  Both Selenium &amp;lt;ref&amp;gt;Semerau, Luke. [https://code.google.com/p/selenium/wiki/WebDriverForMobileBrowsers WebDriverForMobileBrowsers]. ''Selenium''. Google Project Hosting, 14 Jan. 2013. Web. 06 Oct. 2014 &amp;lt;/ref&amp;gt; and Watir &amp;lt;ref&amp;gt;Scott, Alister. [http://watirwebdriver.com/mobile-devices/ Mobile Devices]. ''Watir WebDriver''. n.d. Web. 06 Oct. 2014. &amp;lt;/ref&amp;gt; have also gained support of Mobile browsers in recent years through WebDriver.  However, there is the obvious limitation that one can only test a browser which is supported on the running platform.  In other words, Safari and Internet explorer can only be tested on  OS X and Windows environments, respectively**.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;**&amp;lt;/nowiki&amp;gt; &amp;lt;span style=&amp;quot;font-size:88%&amp;quot;&amp;gt;Some work-arounds or programs may exist to allow these browsers to be tested on other platforms. Here, we are assuming no special additional configuration - just the base operating system and browsers.  With virtualization technologies such as [http://www.linux-kvm.org/page/Main_Page KVM], [https://www.virtualbox.org/ VirtualBox], and [http://en.wikipedia.org/wiki/Comparison_of_platform_virtualization_software others], this isn't a problem anyway.  [http://en.wikipedia.org/wiki/Virtual_machine Virtual machines] can be created with any operating system, as needed.&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Cross-Platform Support====&lt;br /&gt;
Both Watir and Selenium run on most popular distributions of Windows, Mac, and Linux.  Selenium doesn't have a list of officially supported operating system versions.  Instead they generally support any version that is currently popular.  Only a few versions are listed which they run test builds on.  These are versions which are officially known to work, but many more are supported as well.&lt;br /&gt;
&lt;br /&gt;
Because Watir is a collection of Ruby Gems, it runs on any platform that Ruby runs on.  Like Selenium, this includes nearly all popular platforms.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=='''Getting started'''==&lt;br /&gt;
===Selenium WebDriver=== &lt;br /&gt;
----&lt;br /&gt;
====Install/Configure (Java)====&lt;br /&gt;
Configuring Selenium requires you to download the binaries from [http://www.seleniumhq.org/download/ here]. &lt;br /&gt;
Once you have all your binaries in a directory, you can open any IDE of your choice and add this directory with all the .jar files to the CLASSPATH&lt;br /&gt;
*Example&lt;br /&gt;
This is how a typical Selenium code to find the term say, “Automation” on Google and display the results on the page would look like in Java using the [https://code.google.com/p/selenium/wiki/HtmlUnitDriver HtmlUnitDriver] would look like.&lt;br /&gt;
The HtmlUnitDriver is a pure Java driver that runs entirely in-memory. Because of this, you won't see a new browser window open &amp;lt;ref&amp;gt;[https://code.google.com/p/selenium/wiki/GettingStarted Getting started with Selenium]. Selenium: Browser Automation Framework. Google Code. 8 Feb, 2014.&amp;lt;/ref&amp;gt;,&lt;br /&gt;
&lt;br /&gt;
       package org.selenium.example;&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;
       import org.openqa.selenium.By;&lt;br /&gt;
       import org.openqa.selenium.WebDriver;&lt;br /&gt;
       import org.openqa.selenium.WebElement;&lt;br /&gt;
       import org.openqa.selenium.htmlunit.HtmlUnitDriver;&amp;lt;br /&amp;gt;&lt;br /&gt;
       public class Example  {&lt;br /&gt;
       public static void main(String[] args) {&lt;br /&gt;
        // Create a new instance of the html unit driver&lt;br /&gt;
        // Notice that the remainder of the code relies on the interface,&lt;br /&gt;
        // not the implementation.&lt;br /&gt;
        WebDriver driver = new HtmlUnitDriver();&amp;lt;br /&amp;gt;&lt;br /&gt;
        // And now use this to visit Google&lt;br /&gt;
        driver.get(&amp;quot;http://www.google.com&amp;quot;);&amp;lt;br /&amp;gt;&lt;br /&gt;
        // Find the text input element by its name&lt;br /&gt;
        WebElement element = driver.findElement(By.name(&amp;quot;q&amp;quot;));&amp;lt;br /&amp;gt;&lt;br /&gt;
        // Enter something to search for&lt;br /&gt;
        element.sendKeys(&amp;quot;Automation!&amp;quot;);&amp;lt;br /&amp;gt;&lt;br /&gt;
        // Now submit the form. WebDriver will find the form for us from the element&lt;br /&gt;
        element.submit();&amp;lt;br /&amp;gt;&lt;br /&gt;
        // Check the title of the page&lt;br /&gt;
        System.out.println(&amp;quot;Page title is: &amp;quot; + driver.getTitle());&lt;br /&gt;
        driver.quit();&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
If you compile and run it, you should see a line with the title of the Google search results as output.&lt;br /&gt;
&lt;br /&gt;
====Install/Configure for other languages====&lt;br /&gt;
Configuring Selenium for languages other than Java and for other development environments can be looked up [http://docs.seleniumhq.org/docs/03_webdriver.jsp#setting-up-a-selenium-webdriver-project here]. viz(C#, Ruby, Python, PHP, Perl, Javascript)&lt;br /&gt;
&lt;br /&gt;
===Watir===&lt;br /&gt;
----&lt;br /&gt;
====Install/Configure (Ruby)====&lt;br /&gt;
Drivers for Watir are installed as gems which are nothing but Ruby libraries which can be accessed over the internet.&lt;br /&gt;
All the instructions for installing Watir on various operating systems (viz. Windows, Mac OS, Linux) can be found [http://watir.com/installation/ here].&lt;br /&gt;
&lt;br /&gt;
*Example:&lt;br /&gt;
This is how a typical Watir code to find the term say, “Automation” on Google and display the results on the page would look like using Ruby&amp;lt;ref&amp;gt;Chernenko, Iryna. [http://blog.qatestlab.com/2011/02/23/automated-testing-with-watir-tutorial-for-begginers-part-1/ Watir Example]. QATestLab Blog: Automated Testing with Watir, 23 Feb 2011.&lt;br /&gt;
&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
        # Required in ruby 1.8.7&lt;br /&gt;
        require 'rubygems'&lt;br /&gt;
        # Watir IE driver&lt;br /&gt;
        require 'watir'&amp;lt;br /&amp;gt; &lt;br /&gt;
        ie = Watir::IE.new&amp;lt;br /&amp;gt; &lt;br /&gt;
        # text to show on console&lt;br /&gt;
        puts &amp;quot;Beginning of the test for Google search engine&amp;quot;&lt;br /&gt;
        puts &amp;quot;Step 1:  Go to the Google homepage&amp;quot;&lt;br /&gt;
        ie.goto &amp;quot;http://www.google.com&amp;quot;&amp;lt;br /&amp;gt;&lt;br /&gt;
        #set a variable&lt;br /&gt;
        search_text = &amp;quot;Automation&amp;quot;&lt;br /&gt;
        puts &amp;quot;Step 2: enter &amp;quot;+ search_text +&amp;quot; in the search text field.&amp;quot;&lt;br /&gt;
        ie.text_field(:name, &amp;quot;q&amp;quot;).set search_text   # &amp;quot;q&amp;quot; is the name of the search field&amp;lt;br /&amp;gt;&lt;br /&gt;
        puts &amp;quot; Step 3: click the 'Google Search' button.&amp;quot;&lt;br /&gt;
        ie.button(:name, &amp;quot;btnG&amp;quot;).click # &amp;quot;btnG&amp;quot; is the name of the Search button&amp;lt;br /&amp;gt;&lt;br /&gt;
        puts &amp;quot; Expected Result:&amp;quot;&lt;br /&gt;
        puts &amp;quot;  A Google page with results should be shown. 'Watir, pronounced water' should be high on the list.&amp;quot;&lt;br /&gt;
        puts &amp;quot; Actual Result:&amp;quot;&lt;br /&gt;
        if ie.text.include? &amp;quot;Watir, pronounced water&amp;quot;	&lt;br /&gt;
             puts &amp;quot;  Test Passed. Found the text string: 'Watir, pronounced water'. Actual Results match Expected Results.&amp;quot;&lt;br /&gt;
        else	&lt;br /&gt;
 	     puts &amp;quot;  Test Failed! Could not find text: 'Watir, pronounced water'.&amp;quot;&lt;br /&gt;
        end&lt;br /&gt;
        puts &amp;quot;End of test: Google search.&amp;quot;&lt;br /&gt;
        ie.close&lt;br /&gt;
&lt;br /&gt;
On compiling and running this and passing the test, you will see something like, &amp;lt;br /&amp;gt; &lt;br /&gt;
&lt;br /&gt;
        ''Output:''&lt;br /&gt;
        Beginning of the test for Google search engine &amp;lt;br /&amp;gt;&lt;br /&gt;
        Step 1:  Go to the Google homepage &amp;lt;br /&amp;gt;&lt;br /&gt;
        Step 2: enter Automation in the search text field. &amp;lt;br /&amp;gt;&lt;br /&gt;
        Step 3: click the 'Google Search' button. &amp;lt;br /&amp;gt;&lt;br /&gt;
        Expected Result: &amp;lt;br /&amp;gt;&lt;br /&gt;
        A Google page with results should be shown. 'Watir, pronounced water' should be high on the list. &amp;lt;br /&amp;gt;	&lt;br /&gt;
        Test Passed. Found the text string: 'Watir, pronounced water'. Actual Results match Expected Results. &amp;lt;br /&amp;gt;&lt;br /&gt;
        End of test: Google search. &amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Similar Tools==&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Sahi_(software) Sahi], uses the Sahi Scripting Language&amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Soatest SOATest], for testing and validating [http://en.wikipedia.org/wiki/Application_programming_interface API] driven applications &amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/TestComplete TestComplete], for Desktops, Web and Mobile&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
* [http://www.hiretheworld.com/blog/tech-blog/migrating-unit-tests-from-selenium-to-watir-webdriver Migrating unit tests from Selenium to Watir Web Driver] &amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://www.hiretheworld.com/blog/tech-blog/migrating-unit-tests-from-selenium-to-watir-webdriver Learning Selenium IDE] &amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/List_of_web_testing_tools List of web testing tools] &amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/List_of_web_testing_tools OWASP List of Acceptance Testing tools]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
{{reflist}}&lt;br /&gt;
&amp;lt;references /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==External Links==&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Selenium_(software) Selenium Wiki Page] &amp;lt;br /&amp;gt;&lt;br /&gt;
* [https://github.com/SeleniumHQ/selenium Selenium Source Code] &amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Watir Watir Wiki Page] &amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Watir Watir Source Code] &amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Watir SauceLabs HomePage] &amp;lt;br /&amp;gt;&lt;/div&gt;</summary>
		<author><name>Jjbeaver</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/ch1b_27_js&amp;diff=89447</id>
		<title>CSC/ECE 517 Fall 2014/ch1b 27 js</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/ch1b_27_js&amp;diff=89447"/>
		<updated>2014-10-07T04:21:43Z</updated>

		<summary type="html">&lt;p&gt;Jjbeaver: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;='''Selenium vs. Watir'''=&lt;br /&gt;
&lt;br /&gt;
Developing web applications is proving to be a challenging task with each passing day given the complex requirements and the demanding nature of the these applications. For the web applications to be robust we need to put in place some good testing strategies.&lt;br /&gt;
&lt;br /&gt;
'''''Selenium''''' is one of the most popularly used open source automation tools for web based applications. It is a JavaScript framework that runs in your web browser to interact with various elements in your browser. All in all, Selenium is a set of different software tools each with a different approach to supporting test automation. Selenium provides a rich set of testing functions that can be customized to suit the testing requirements.&lt;br /&gt;
 &lt;br /&gt;
'''''Watir''''', is another lightweight automation testing tool that is widely used for web app testing. It is an open-source ([http://en.wikipedia.org/wiki/BSD_licenses BSD])  family of Ruby libraries for automating web browsers. It allows you to write tests that are easy to read and maintain. Despite the fact that it is a set of Ruby libraries, it works perfectly, independent of the language that the web application is developed in. Watir as a tool is extremely simple and flexible.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=='''Motivation'''==&lt;br /&gt;
===Need for test automation===&lt;br /&gt;
With the majority of software applications today being implemented as [http://en.wikipedia.org/wiki/Web_application web applications] to be used over the internet, testing is becoming an indispensable part of the software development lifecycle ([http://en.wikipedia.org/wiki/Software_development_process SDLC]) of these applications. [http://en.wikipedia.org/wiki/Test_automation Test automation] is used where manual testing needs to be carried out repeatedly making it a cumbersome task. Test automation uses a software tool for this purpose on the application to be tested. It has proven to be highly efficient and critical in larger software development companies. Additionally, automation can be a valuable way to make Test Driven Development ([http://en.wikipedia.org/wiki/Test-driven_development TDD]) tasks an important part of the software development workflow.&lt;br /&gt;
 &lt;br /&gt;
Test Automation has a number of advantages mostly dealing with repetitiveness of the tests and the time taken,&lt;br /&gt;
* '''Covers cases that manual testing probably cannot'''&lt;br /&gt;
# Finds defects missed out my manual testing&lt;br /&gt;
# Automated testing can simulate numerous virtual users interacting with the web software/application&lt;br /&gt;
* '''Helps save time and money'''&lt;br /&gt;
# Once created, automated tests can be executed repeatedly at no additional   costs and at a much faster pace. Saving time directly translates into saving cost.&lt;br /&gt;
# Supports virtually unlimited iterations of test case execution&lt;br /&gt;
* '''Increase test coverage and accuracy'''&lt;br /&gt;
# Automated tests perform the exact same steps and records all details precisely&lt;br /&gt;
# They also increase the depth and scope of tests to improve the quality of the software&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=='''Brief History'''==&lt;br /&gt;
====Selenium====&lt;br /&gt;
&lt;br /&gt;
[[File: SE-logo.png|right|Selenium Logo|link=http://www.seleniumhq.org/images/big-logo.png]]&lt;br /&gt;
&lt;br /&gt;
''Selenium'' was developed in the year 2004 by Jason Huggins and has been continuously evolving ever since. Jason Huggins developed this as an internal tool for [http://en.wikipedia.org/wiki/ThoughtWorks ThoughtWorks] as a javascript library which came to be known as the Selenium core. Selenium core is now the basis of the Selenium Remote Control (the server) and Selenium IDE.&lt;br /&gt;
The year 2006 marked the beginning of the development of the WebDriver project which was what they believed ‘a tool of the future’. The WebDriver was initiated to solve the problems that were faced due to the fact that Selenium was a based on JavaScript and a lot of security limitations browsers apply to Javascript.&lt;br /&gt;
In 2008, both Selenium and WebDriver merged to provide a common set of features to all users which is called Selenium 2..&lt;br /&gt;
Simon Stewart, the creator of WebDriver, in a joint email to the WebDriver and Selenium community on August 6, 2009 said the following,&lt;br /&gt;
&lt;br /&gt;
“Why are the projects merging? Partly because webdriver addresses some shortcomings in selenium (by being able to bypass the JS sandbox, for example. And we’ve got a gorgeous API), partly because selenium addresses some shortcomings in webdriver (such as supporting a broader range of browsers) and partly because the main selenium contributors and I felt that it was the best way to offer users the best possible framework.”&amp;lt;ref name =&amp;quot;Introduction to Selenium&amp;quot;&amp;gt;[http://docs.seleniumhq.org/docs/01_introducing_selenium.jsp#selenium-history Introducing Selenium]. ''SeleniumHQ: Browser Automation''. Selenium Project, 4 Oct. 2014. Web. 06 Oct. 2014.&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Watir====&lt;br /&gt;
&lt;br /&gt;
''Watir'' started as a library to teach testers to write ruby code and grew to be an IE implementation which now supports IE, Firefox, Safari, Google Chrome and Opera.&lt;br /&gt;
Watir was primarily developed by Bret Pettichord and Paul Rogers. Watir has since then has a couple of stable releases for Watir classic as well as Watir WebDriver. The most recent releases being&amp;lt;ref&amp;gt;[http://watir.com/category/releases/ Watir Releases]. Watir: Web Application Testing in Ruby. 28 April, 2013&amp;lt;/ref&amp;gt;, &lt;br /&gt;
&lt;br /&gt;
[[File: Watir.gif|right|Watir logo|link=http://upload.wikimedia.org/wikipedia/commons/7/7e/Watir.gif]]&lt;br /&gt;
&lt;br /&gt;
* Watir-Classic	    &lt;br /&gt;
# 0.6.3 April 10, 2013 ([https://github.com/watir/watir-webdriver/blob/master/CHANGES.md#063 Release Notes]) &amp;lt;br /&amp;gt;&lt;br /&gt;
* Watir-WebDriver	    &lt;br /&gt;
# 3.6.0 March 16, 2013 ([https://groups.google.com/forum/#!msg/watir-general/MOOun5g3Hvg/JBVNy957lDYJ Release Notes]) &amp;lt;br /&amp;gt;&lt;br /&gt;
# 3.5.0 March 10, 2013 ([https://groups.google.com/forum/#!msg/watir-general/aeUqsglvK6k/Kq7FCBiERjYJ Release Notes]) &amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Watir has a google group ([https://groups.google.com/forum/#!forum/watir-general Watir General]) for its support and contribution while Selenium also has a [http://seleniumforum.forumotion.net/ Selenium forum] apart from its google group called [https://groups.google.com/forum/#!forum/selenium-users Selenium Users].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=='''Comparison of Features, Functionality, and More'''==&lt;br /&gt;
Some features or functionality may be repeated here.  However, we will go into a bit more detail than previously mentioned.&lt;br /&gt;
===='''Open Source'''====&lt;br /&gt;
Both Selenium and Watir are [http://en.wikipedia.org/wiki/Open-source_software open source]!  This allows for greater extensibility and a deeper understanding of the inner workings of both of the frameworks, if the developer/tester chooses to delve into such details.  Additionally, the open source community allows for a more transparent, user-driven development and support cycle.  Users (the tester/developer) can choose to submit bug fixes or enhancements as patches, or they can choose to just use it “straight out of the box.”&lt;br /&gt;
&lt;br /&gt;
====Application Language Agnostic====&lt;br /&gt;
&lt;br /&gt;
Both Selenium and Watir are application language agnostic.  Because both Selenium and Watir test UI functionality in the browser, they can be used to test any web application.    &lt;br /&gt;
&lt;br /&gt;
====Language-specific Test Cases====&lt;br /&gt;
&lt;br /&gt;
Both Selenium and Watir require test cases to be written in some programming language.  Traditionally, both frameworks had limited choices in terms of language bindings.  However, with the advent of WebDriver, both became much more flexible.  WebDriver provided the bindings needed for many languages.  Today, the following are supported:&lt;br /&gt;
&lt;br /&gt;
'''Selenium*'''&lt;br /&gt;
&lt;br /&gt;
* Officially-supported: [http://en.wikipedia.org/wiki/Java_(programming_language) Java], [http://en.wikipedia.org/wiki/C_Sharp_(programming_language) C#], [http://en.wikipedia.org/wiki/Ruby_(programming_language) Ruby], [http://en.wikipedia.org/wiki/Python_(programming_language) Python], [http://en.wikipedia.org/wiki/Node.js Javascript/Node.js]&lt;br /&gt;
&lt;br /&gt;
* Unofficial/community-supported: [http://en.wikipedia.org/wiki/Perl Perl], [http://en.wikipedia.org/wiki/PHP PHP], [http://en.wikipedia.org/wiki/Haskell_(programming_language) Haskell], [http://en.wikipedia.org/wiki/Objective-C Objective-C], [http://en.wikipedia.org/wiki/R_(programming_language) R], [http://en.wikipedia.org/wiki/Dart_(programming_language) Dart], [http://en.wikipedia.org/wiki/Tcl Tcl]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;According to SeleniumHQ’s download page.&lt;br /&gt;
&lt;br /&gt;
'''Watir'''&lt;br /&gt;
&lt;br /&gt;
Unfortunately (or fortunately), Ruby is the only supported language for Watir.  After all, Watir does stand for “Web Application Testing in Ruby.” However, there are other frameworks which were inspired by Watir (but entirely separate) available in Java and C# - [http://watij.com/ Watij] and [http://watin.org/ Watin],  respectively &amp;lt;ref&amp;gt;Djorgjievski, Darko. [http://www.sitepoint.com/watir-webdriver-control-browser/ Watir-WebDriver: Control the Browser]. ''SitePoint''. SitePoint Pty Ltd, 18 Apr. 2014. Web. 05 Oct. 2014.&amp;lt;/ref&amp;gt;.  There may be other similarly inspired frameworks available in other languages, but these are the most notable.&lt;br /&gt;
&lt;br /&gt;
====Cross-Browser and Headless Browser Support====&lt;br /&gt;
&lt;br /&gt;
[[File: watir_meet_webdriver.png | Watir Meets WebDriver |right|frame| link=http://yuml.me/diagram/scruffy/usecase/%5BTester%5D-%28Watir%20API%29,%20%28Watir%20API%29%3C%28FireWatir%29,%20%28Watir%20API%29%3C%28Watir%29,%20%28Watir%20API%29%3C%28SafariWatir%29,%20%28Watir%20API%29%3C%28Webdriver%29,%20%28Watir%20API%29%3C%28Celerity%29,%20%28Celerity%29-%28note:%20Celerity%20requires%20JRuby%29,%20%28Celerity%29-%28headless%29,%20%28Webdriver%29-%28Firefox%29,%20%28Webdriver%29-%28Chrome%29,%20%28Webdriver%29-%28IE%29,%20%28Webdriver%29-%28headless%29,%20%28FireWatir%29-%28Firefox%29,%20%28Watir%29-%28IE%29,%20%28SafariWatir%29-%28Safari%29.]]&lt;br /&gt;
&lt;br /&gt;
Traditionally, both Selenium and Watir were limited in the number of browsers they supported. Watir originally supported Internet Explorer and headless browsers exclusively.  Headless browsers were supported via the use of [https://github.com/jarib/celerity Celerity] &amp;lt;ref&amp;gt;Scott, Alister. [http://watirmelon.com/2010/04/10/watir-selenium-webdriver/ Watir, Selenium &amp;amp; WebDriver]. ''Watirmelon''. Watirmelon, 10 Apr. 2010. Web. 05 Oct. 2014.&amp;lt;/ref&amp;gt;.  Selenium started out as a Javascript library, so naturally it supported more browsers such as IE, Firefox, Safari, etc &amp;lt;ref name = &amp;quot;Introduction to Selenium&amp;quot; /&amp;gt;.  However, it did not support headless browsers.&lt;br /&gt;
Today, browser support looks much better for both Selenium and Watir, largely due to the introduction of WebDriver.  With WebDriver in existence, support for most browsers was added to Watir via the gem &amp;quot;watir-webdriver,&amp;quot; and Celerity became [https://github.com/jarib/celerity obsolete] because headless browser support was included in WebDriver.  Similarly for Selenium, support for headless browsers was added, as well as making the API much simpler and more concise &amp;lt;ref&amp;gt;[http://docs.seleniumhq.org/projects/webdriver/ Selenium WebDriver]. ''SeleniumHQ: Browser Automation''. Selenium Project, n.d. Web. 06 Oct. 2014.&amp;lt;/ref&amp;gt;.  Both Selenium &amp;lt;ref&amp;gt;Semerau, Luke. [https://code.google.com/p/selenium/wiki/WebDriverForMobileBrowsers WebDriverForMobileBrowsers]. ''Selenium''. Google Project Hosting, 14 Jan. 2013. Web. 06 Oct. 2014 &amp;lt;/ref&amp;gt; and Watir &amp;lt;ref&amp;gt;Scott, Alister. [http://watirwebdriver.com/mobile-devices/ Mobile Devices]. ''Watir WebDriver''. n.d. Web. 06 Oct. 2014. &amp;lt;/ref&amp;gt; have also gained support of Mobile browsers in recent years through WebDriver.  However, there is the obvious limitation that one can only test a browser which is supported on the running platform.  In other words, Safari and Internet explorer can only be tested on  OS X and Windows environments, respectively**.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;**&amp;lt;/nowiki&amp;gt; &amp;lt;span style=&amp;quot;font-size:88%&amp;quot;&amp;gt;Some work-arounds or programs may exist to allow these browsers to be tested on other platforms. Here, we are assuming no special additional configuration - just the base operating system and browsers.  With virtualization technologies such as [http://www.linux-kvm.org/page/Main_Page KVM], [https://www.virtualbox.org/ VirtualBox], and [http://en.wikipedia.org/wiki/Comparison_of_platform_virtualization_software others], this isn't a problem anyway.  [http://en.wikipedia.org/wiki/Virtual_machine Virtual machines] can be created with any operating system, as needed.&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Cross-Platform Support====&lt;br /&gt;
Both Watir and Selenium run on most popular distributions of Windows, Mac, and Linux.  Selenium doesn't have a list of officially supported operating system versions.  Instead they generally support any version that is currently popular.  Only a few versions are listed which they run test builds on.  These are versions which are officially known to work, but many more are supported as well.&lt;br /&gt;
&lt;br /&gt;
Because Watir is a collection of Ruby Gems, it runs on any platform that Ruby runs on.  Like Selenium, this includes nearly all popular platforms.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=='''Getting started'''==&lt;br /&gt;
===Selenium WebDriver=== &lt;br /&gt;
----&lt;br /&gt;
====Install/Configure (Java)====&lt;br /&gt;
Configuring Selenium requires you to download the binaries from [http://www.seleniumhq.org/download/ here]. &lt;br /&gt;
Once you have all your binaries in a directory, you can open any IDE of your choice and add this directory with all the .jar files to the CLASSPATH&lt;br /&gt;
*Example&lt;br /&gt;
This is how a typical Selenium code to find the term say, “Automation” on Google and display the results on the page would look like in Java using the [https://code.google.com/p/selenium/wiki/HtmlUnitDriver HtmlUnitDriver] would look like.&lt;br /&gt;
The HtmlUnitDriver is a pure Java driver that runs entirely in-memory. Because of this, you won't see a new browser window open &amp;lt;ref&amp;gt;[https://code.google.com/p/selenium/wiki/GettingStarted Getting started with Selenium]. Selenium: Browser Automation Framework. Google Code. 8 Feb, 2014.&amp;lt;/ref&amp;gt;,&lt;br /&gt;
&lt;br /&gt;
       package org.selenium.example;&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;
       import org.openqa.selenium.By;&lt;br /&gt;
       import org.openqa.selenium.WebDriver;&lt;br /&gt;
       import org.openqa.selenium.WebElement;&lt;br /&gt;
       import org.openqa.selenium.htmlunit.HtmlUnitDriver;&amp;lt;br /&amp;gt;&lt;br /&gt;
       public class Example  {&lt;br /&gt;
       public static void main(String[] args) {&lt;br /&gt;
        // Create a new instance of the html unit driver&lt;br /&gt;
        // Notice that the remainder of the code relies on the interface,&lt;br /&gt;
        // not the implementation.&lt;br /&gt;
        WebDriver driver = new HtmlUnitDriver();&amp;lt;br /&amp;gt;&lt;br /&gt;
        // And now use this to visit Google&lt;br /&gt;
        driver.get(&amp;quot;http://www.google.com&amp;quot;);&amp;lt;br /&amp;gt;&lt;br /&gt;
        // Find the text input element by its name&lt;br /&gt;
        WebElement element = driver.findElement(By.name(&amp;quot;q&amp;quot;));&amp;lt;br /&amp;gt;&lt;br /&gt;
        // Enter something to search for&lt;br /&gt;
        element.sendKeys(&amp;quot;Automation!&amp;quot;);&amp;lt;br /&amp;gt;&lt;br /&gt;
        // Now submit the form. WebDriver will find the form for us from the element&lt;br /&gt;
        element.submit();&amp;lt;br /&amp;gt;&lt;br /&gt;
        // Check the title of the page&lt;br /&gt;
        System.out.println(&amp;quot;Page title is: &amp;quot; + driver.getTitle());&lt;br /&gt;
        driver.quit();&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
If you compile and run it, you should see a line with the title of the Google search results as output.&lt;br /&gt;
&lt;br /&gt;
====Install/Configure for other languages====&lt;br /&gt;
Configuring Selenium for languages other than Java and for other development environments can be looked up [http://docs.seleniumhq.org/docs/03_webdriver.jsp#setting-up-a-selenium-webdriver-project here]. viz(C#, Ruby, Python, PHP, Perl, Javascript)&lt;br /&gt;
&lt;br /&gt;
===Watir===&lt;br /&gt;
----&lt;br /&gt;
====Install/Configure (Ruby)====&lt;br /&gt;
Drivers for Watir are installed as gems which are nothing but Ruby libraries which can be accessed over the internet.&lt;br /&gt;
All the instructions for installing Watir on various operating systems (viz. Windows, Mac OS, Linux) can be found [http://watir.com/installation/ here].&lt;br /&gt;
&lt;br /&gt;
*Example:&lt;br /&gt;
This is how a typical Watir code to find the term say, “Automation” on Google and display the results on the page would look like using Ruby&amp;lt;ref&amp;gt;Chernenko, Iryna. [http://blog.qatestlab.com/2011/02/23/automated-testing-with-watir-tutorial-for-begginers-part-1/ Watir Example]. QATestLab Blog: Automated Testing with Watir, 23 Feb 2011.&lt;br /&gt;
&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
        # Required in ruby 1.8.7&lt;br /&gt;
        require 'rubygems'&lt;br /&gt;
        # Watir IE driver&lt;br /&gt;
        require 'watir'&amp;lt;br /&amp;gt; &lt;br /&gt;
        ie = Watir::IE.new&amp;lt;br /&amp;gt; &lt;br /&gt;
        # text to show on console&lt;br /&gt;
        puts &amp;quot;Beginning of the test for Google search engine&amp;quot;&lt;br /&gt;
        puts &amp;quot;Step 1:  Go to the Google homepage&amp;quot;&lt;br /&gt;
        ie.goto &amp;quot;http://www.google.com&amp;quot;&amp;lt;br /&amp;gt;&lt;br /&gt;
        #set a variable&lt;br /&gt;
        search_text = &amp;quot;Automation&amp;quot;&lt;br /&gt;
        puts &amp;quot;Step 2: enter &amp;quot;+ search_text +&amp;quot; in the search text field.&amp;quot;&lt;br /&gt;
        ie.text_field(:name, &amp;quot;q&amp;quot;).set search_text   # &amp;quot;q&amp;quot; is the name of the search field&amp;lt;br /&amp;gt;&lt;br /&gt;
        puts &amp;quot; Step 3: click the 'Google Search' button.&amp;quot;&lt;br /&gt;
        ie.button(:name, &amp;quot;btnG&amp;quot;).click # &amp;quot;btnG&amp;quot; is the name of the Search button&amp;lt;br /&amp;gt;&lt;br /&gt;
        puts &amp;quot; Expected Result:&amp;quot;&lt;br /&gt;
        puts &amp;quot;  A Google page with results should be shown. 'Watir, pronounced water' should be high on the list.&amp;quot;&lt;br /&gt;
        puts &amp;quot; Actual Result:&amp;quot;&lt;br /&gt;
        if ie.text.include? &amp;quot;Watir, pronounced water&amp;quot;	&lt;br /&gt;
             puts &amp;quot;  Test Passed. Found the text string: 'Watir, pronounced water'. Actual Results match Expected Results.&amp;quot;&lt;br /&gt;
        else	&lt;br /&gt;
 	     puts &amp;quot;  Test Failed! Could not find text: 'Watir, pronounced water'.&amp;quot;&lt;br /&gt;
        end&lt;br /&gt;
        puts &amp;quot;End of test: Google search.&amp;quot;&lt;br /&gt;
        ie.close&lt;br /&gt;
&lt;br /&gt;
On compiling and running this and passing the test, you will see something like, &amp;lt;br /&amp;gt; &lt;br /&gt;
&lt;br /&gt;
        ''Output:''&lt;br /&gt;
        Beginning of the test for Google search engine &amp;lt;br /&amp;gt;&lt;br /&gt;
        Step 1:  Go to the Google homepage &amp;lt;br /&amp;gt;&lt;br /&gt;
        Step 2: enter Automation in the search text field. &amp;lt;br /&amp;gt;&lt;br /&gt;
        Step 3: click the 'Google Search' button. &amp;lt;br /&amp;gt;&lt;br /&gt;
        Expected Result: &amp;lt;br /&amp;gt;&lt;br /&gt;
        A Google page with results should be shown. 'Watir, pronounced water' should be high on the list. &amp;lt;br /&amp;gt;	&lt;br /&gt;
        Test Passed. Found the text string: 'Watir, pronounced water'. Actual Results match Expected Results. &amp;lt;br /&amp;gt;&lt;br /&gt;
        End of test: Google search. &amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Similar Tools==&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Sahi_(software) Sahi], uses the Sahi Scripting Language&amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Soatest SOATest], for testing and validating [http://en.wikipedia.org/wiki/Application_programming_interface API] driven applications &amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/TestComplete TestComplete], for Desktops, Web and Mobile&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
* [http://www.hiretheworld.com/blog/tech-blog/migrating-unit-tests-from-selenium-to-watir-webdriver Migrating unit tests from Selenium to Watir Web Driver] &amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://www.hiretheworld.com/blog/tech-blog/migrating-unit-tests-from-selenium-to-watir-webdriver Learning Selenium IDE] &amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/List_of_web_testing_tools List of web testing tools] &amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/List_of_web_testing_tools OWASP List of Acceptance Testing tools]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
{{reflist}}&lt;br /&gt;
&amp;lt;references /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==External Links==&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Selenium_(software) Selenium Wiki Page] &amp;lt;br /&amp;gt;&lt;br /&gt;
* [https://github.com/SeleniumHQ/selenium Selenium Source Code] &amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Watir Watir Wiki Page] &amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Watir Watir Source Code] &amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Watir SauceLabs HomePage] &amp;lt;br /&amp;gt;&lt;/div&gt;</summary>
		<author><name>Jjbeaver</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/ch1b_27_js&amp;diff=89446</id>
		<title>CSC/ECE 517 Fall 2014/ch1b 27 js</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/ch1b_27_js&amp;diff=89446"/>
		<updated>2014-10-07T04:20:57Z</updated>

		<summary type="html">&lt;p&gt;Jjbeaver: /* Language-specific Test Cases */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;='''Selenium vs. Watir'''=&lt;br /&gt;
&lt;br /&gt;
Developing web applications is proving to be a challenging task with each passing day given the complex requirements and the demanding nature of the these applications. For the web applications to be robust we need to put in place some good testing strategies.&lt;br /&gt;
&lt;br /&gt;
'''''Selenium''''' is one of the most popularly used open source automation tools for web based applications. It is a JavaScript framework that runs in your web browser to interact with various elements in your browser. All in all, Selenium is a set of different software tools each with a different approach to supporting test automation. Selenium provides a rich set of testing functions that can be customized to suit the testing requirements.&lt;br /&gt;
 &lt;br /&gt;
'''''Watir''''', is another lightweight automation testing tool that is widely used for web app testing. It is an open-source ([http://en.wikipedia.org/wiki/BSD_licenses BSD])  family of Ruby libraries for automating web browsers. It allows you to write tests that are easy to read and maintain. Despite the fact that it is a set of Ruby libraries, it works perfectly, independent of the language that the web application is developed in. Watir as a tool is extremely simple and flexible.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=='''Motivation'''==&lt;br /&gt;
===Need for test automation===&lt;br /&gt;
With the majority of software applications today being implemented as [http://en.wikipedia.org/wiki/Web_application web applications] to be used over the internet, testing is becoming an indispensable part of the software development lifecycle ([http://en.wikipedia.org/wiki/Software_development_process SDLC]) of these applications. [http://en.wikipedia.org/wiki/Test_automation Test automation] is used where manual testing needs to be carried out repeatedly making it a cumbersome task. Test automation uses a software tool for this purpose on the application to be tested. It has proven to be highly efficient and critical in larger software development companies. Additionally, automation can be a valuable way to make Test Driven Development ([http://en.wikipedia.org/wiki/Test-driven_development TDD]) tasks an important part of the software development workflow.&lt;br /&gt;
 &lt;br /&gt;
Test Automation has a number of advantages mostly dealing with repetitiveness of the tests and the time taken,&lt;br /&gt;
* '''Covers cases that manual testing probably cannot'''&lt;br /&gt;
# Finds defects missed out my manual testing&lt;br /&gt;
# Automated testing can simulate numerous virtual users interacting with the web software/application&lt;br /&gt;
* '''Helps save time and money'''&lt;br /&gt;
# Once created, automated tests can be executed repeatedly at no additional   costs and at a much faster pace. Saving time directly translates into saving cost.&lt;br /&gt;
# Supports virtually unlimited iterations of test case execution&lt;br /&gt;
* '''Increase test coverage and accuracy'''&lt;br /&gt;
# Automated tests perform the exact same steps and records all details precisely&lt;br /&gt;
# They also increase the depth and scope of tests to improve the quality of the software&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=='''Brief History'''==&lt;br /&gt;
====Selenium====&lt;br /&gt;
&lt;br /&gt;
[[File: SE-logo.png|right|Selenium Logo|link=http://www.seleniumhq.org/images/big-logo.png]]&lt;br /&gt;
&lt;br /&gt;
''Selenium'' was developed in the year 2004 by Jason Huggins and has been continuously evolving ever since. Jason Huggins developed this as an internal tool for [http://en.wikipedia.org/wiki/ThoughtWorks ThoughtWorks] as a javascript library which came to be known as the Selenium core. Selenium core is now the basis of the Selenium Remote Control (the server) and Selenium IDE.&lt;br /&gt;
The year 2006 marked the beginning of the development of the WebDriver project which was what they believed ‘a tool of the future’. The WebDriver was initiated to solve the problems that were faced due to the fact that Selenium was a based on JavaScript and a lot of security limitations browsers apply to Javascript.&lt;br /&gt;
In 2008, both Selenium and WebDriver merged to provide a common set of features to all users which is called Selenium 2..&lt;br /&gt;
Simon Stewart, the creator of WebDriver, in a joint email to the WebDriver and Selenium community on August 6, 2009 said the following,&lt;br /&gt;
&lt;br /&gt;
“Why are the projects merging? Partly because webdriver addresses some shortcomings in selenium (by being able to bypass the JS sandbox, for example. And we’ve got a gorgeous API), partly because selenium addresses some shortcomings in webdriver (such as supporting a broader range of browsers) and partly because the main selenium contributors and I felt that it was the best way to offer users the best possible framework.”&amp;lt;ref name =&amp;quot;Introduction to Selenium&amp;quot;&amp;gt;[http://docs.seleniumhq.org/docs/01_introducing_selenium.jsp#selenium-history Introducing Selenium]. ''SeleniumHQ: Browser Automation''. Selenium Project, 4 Oct. 2014. Web. 06 Oct. 2014.&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Watir====&lt;br /&gt;
&lt;br /&gt;
''Watir'' started as a library to teach testers to write ruby code and grew to be an IE implementation which now supports IE, Firefox, Safari, Google Chrome and Opera.&lt;br /&gt;
Watir was primarily developed by Bret Pettichord and Paul Rogers. Watir has since then has a couple of stable releases for Watir classic as well as Watir WebDriver. The most recent releases being&amp;lt;ref&amp;gt;[http://watir.com/category/releases/ Watir Releases]. Watir: Web Application Testing in Ruby. 28 April, 2013&amp;lt;/ref&amp;gt;, &lt;br /&gt;
&lt;br /&gt;
[[File: Watir.gif|right|Watir logo|link=http://upload.wikimedia.org/wikipedia/commons/7/7e/Watir.gif]]&lt;br /&gt;
&lt;br /&gt;
* Watir-Classic	    &lt;br /&gt;
# 0.6.3 April 10, 2013 ([https://github.com/watir/watir-webdriver/blob/master/CHANGES.md#063 Release Notes]) &amp;lt;br /&amp;gt;&lt;br /&gt;
* Watir-WebDriver	    &lt;br /&gt;
# 3.6.0 March 16, 2013 ([https://groups.google.com/forum/#!msg/watir-general/MOOun5g3Hvg/JBVNy957lDYJ Release Notes]) &amp;lt;br /&amp;gt;&lt;br /&gt;
# 3.5.0 March 10, 2013 ([https://groups.google.com/forum/#!msg/watir-general/aeUqsglvK6k/Kq7FCBiERjYJ Release Notes]) &amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Watir has a google group ([https://groups.google.com/forum/#!forum/watir-general Watir General]) for its support and contribution while Selenium also has a [http://seleniumforum.forumotion.net/ Selenium forum] apart from its google group called [https://groups.google.com/forum/#!forum/selenium-users Selenium Users].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=='''Comparison of Features, Functionality, and More'''==&lt;br /&gt;
Some features or functionality may be repeated here.  However, we will go into a bit more detail than previously mentioned.&lt;br /&gt;
===='''Open Source'''====&lt;br /&gt;
Both Selenium and Watir are [http://en.wikipedia.org/wiki/Open-source_software open source]!  This allows for greater extensibility and a deeper understanding of the inner workings of both of the frameworks, if the developer/tester chooses to delve into such details.  Additionally, the open source community allows for a more transparent, user-driven development and support cycle.  Users (the tester/developer) can choose to submit bug fixes or enhancements as patches, or they can choose to just use it “straight out of the box.”&lt;br /&gt;
&lt;br /&gt;
====Application Language Agnostic====&lt;br /&gt;
&lt;br /&gt;
Both Selenium and Watir are application language agnostic.  Because both Selenium and Watir test UI functionality in the browser, they can be used to test any web application.    &lt;br /&gt;
&lt;br /&gt;
====Language-specific Test Cases====&lt;br /&gt;
&lt;br /&gt;
Both Selenium and Watir require test cases to be written in some programming language.  Traditionally, both frameworks had limited choices in terms of language bindings.  However, with the advent of WebDriver, both became much more flexible.  WebDriver provided the bindings needed for many languages.  Today, the following are supported:&lt;br /&gt;
&lt;br /&gt;
'''Selenium*'''&lt;br /&gt;
&lt;br /&gt;
* Officially-supported: [http://en.wikipedia.org/wiki/Java_(programming_language) Java], [http://en.wikipedia.org/wiki/C_Sharp_(programming_language) C#], [http://en.wikipedia.org/wiki/Ruby_(programming_language) Ruby], [http://en.wikipedia.org/wiki/Python_(programming_language) Python], [http://en.wikipedia.org/wiki/Node.js Javascript/Node.js]&lt;br /&gt;
&lt;br /&gt;
* Unofficial/community-supported: [http://en.wikipedia.org/wiki/Perl Perl], [http://en.wikipedia.org/wiki/PHP PHP], [http://en.wikipedia.org/wiki/Haskell_(programming_language) Haskell], [http://en.wikipedia.org/wiki/Objective-C Objective-C], [http://en.wikipedia.org/wiki/R_(programming_language) R], [http://en.wikipedia.org/wiki/Dart_(programming_language) Dart], [http://en.wikipedia.org/wiki/Tcl Tcl]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;According to SeleniumHQ’s download page.&lt;br /&gt;
&lt;br /&gt;
'''Watir'''&lt;br /&gt;
&lt;br /&gt;
Unfortunately (or fortunately), Ruby is the only supported language for Watir.  After all, Watir does stand for “Web Application Testing in Ruby.” However, there are other frameworks which were inspired by Watir (but entirely separate) available in Java and C# - [http://watij.com/ Watij] and [http://watin.org/ Watin],  respectively &amp;lt;ref&amp;gt;Djorgjievski, Darko. [http://www.sitepoint.com/watir-webdriver-control-browser/ Watir-WebDriver: Control the Browser]. ''SitePoint''. SitePoint Pty Ltd, 18 Apr. 2014. Web. 05 Oct. 2014.&amp;lt;/ref&amp;gt;.  There may be other similarly inspired frameworks available in other languages, but these are the most notable.&lt;br /&gt;
&lt;br /&gt;
====Cross-Browser and Headless Browser Support====&lt;br /&gt;
&lt;br /&gt;
[[File: watir_meet_webdriver.png | Watir Meets WebDriver |right|frame| link=http://yuml.me/diagram/scruffy/usecase/%5BTester%5D-%28Watir%20API%29,%20%28Watir%20API%29%3C%28FireWatir%29,%20%28Watir%20API%29%3C%28Watir%29,%20%28Watir%20API%29%3C%28SafariWatir%29,%20%28Watir%20API%29%3C%28Webdriver%29,%20%28Watir%20API%29%3C%28Celerity%29,%20%28Celerity%29-%28note:%20Celerity%20requires%20JRuby%29,%20%28Celerity%29-%28headless%29,%20%28Webdriver%29-%28Firefox%29,%20%28Webdriver%29-%28Chrome%29,%20%28Webdriver%29-%28IE%29,%20%28Webdriver%29-%28headless%29,%20%28FireWatir%29-%28Firefox%29,%20%28Watir%29-%28IE%29,%20%28SafariWatir%29-%28Safari%29.]]&lt;br /&gt;
&lt;br /&gt;
Traditionally, both Selenium and Watir were limited in the number of browsers they supported. Watir originally supported Internet Explorer and headless browsers exclusively.  Headless browsers were supported via the use of [https://github.com/jarib/celerity Celerity] &amp;lt;ref&amp;gt;Scott, Alister. [http://watirmelon.com/2010/04/10/watir-selenium-webdriver/ Watir, Selenium &amp;amp; WebDriver]. ''Watirmelon''. Watirmelon, 10 Apr. 2010. Web. 05 Oct. 2014.&amp;lt;/ref&amp;gt;.  Selenium started out as a Javascript library, so naturally it supported more browsers such as IE, Firefox, Safari, etc &amp;lt;ref name = &amp;quot;Introduction to Selenium&amp;quot; /&amp;gt;.  However, it did not support headless browsers.&lt;br /&gt;
Today, browser support looks much better for both Selenium and Watir, largely due to the introduction of WebDriver.  With WebDriver in existence, support for most browsers was added to Watir via the gem &amp;quot;watir-webdriver,&amp;quot; and Celerity became [https://github.com/jarib/celerity obsolete] because headless browser support was included in WebDriver.  Similarly for Selenium, support for headless browsers was added, as well as making the API much simpler and more concise &amp;lt;ref&amp;gt;[http://docs.seleniumhq.org/projects/webdriver/ Selenium WebDriver]. ''SeleniumHQ: Browser Automation''. Selenium Project, n.d. Web. 06 Oct. 2014.&amp;lt;/ref&amp;gt;.  Both Selenium &amp;lt;ref&amp;gt;Semerau, Luke. [https://code.google.com/p/selenium/wiki/WebDriverForMobileBrowsers WebDriverForMobileBrowsers]. ''Selenium''. Google Project Hosting, 14 Jan. 2013. Web. 06 Oct. 2014 &amp;lt;/ref&amp;gt; and Watir &amp;lt;ref&amp;gt;Scott, Alister. [http://watirwebdriver.com/mobile-devices/ Mobile Devices]. ''Watir WebDriver''. n.d. Web. 06 Oct. 2014. &amp;lt;/ref&amp;gt; have also gained support of Mobile browsers in recent years through WebDriver.  However, there is the obvious limitation that one can only test a browser which is supported on the running platform.  In other words, Safari and Internet explorer can only be tested on  OS X and Windows environments, respectively**.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;**&amp;lt;/nowiki&amp;gt; &amp;lt;span style=&amp;quot;font-size:88%&amp;quot;&amp;gt;Some work-arounds or programs may exist to allow these browsers to be tested on other platforms. Here, we are assuming no special additional configuration - just the base operating system and browsers.  With virtualization technologies such as [http://www.linux-kvm.org/page/Main_Page KVM], [https://www.virtualbox.org/ VirtualBox], and [http://en.wikipedia.org/wiki/Comparison_of_platform_virtualization_software others], this isn't a problem anyway.  [http://en.wikipedia.org/wiki/Virtual_machine Virtual machines] can be created with any operating system, as needed.&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Cross-Platform Support====&lt;br /&gt;
Both Watir and Selenium run on most popular distributions of Windows, Mac, and Linux.  Selenium doesn't have a list of officially supported operating system versions.  Instead they generally support any version that is currently popular.  Only a few versions are listed which they run test builds on.  These are versions which are officially known to work, but many more are supported as well.&lt;br /&gt;
&lt;br /&gt;
Because Watir is a collection of Ruby Gems, it runs on any platform that Ruby runs on.  Like Selenium, this includes nearly all popular platforms.&lt;br /&gt;
&lt;br /&gt;
=='''Getting started'''==&lt;br /&gt;
===Selenium WebDriver=== &lt;br /&gt;
----&lt;br /&gt;
====Install/Configure (Java)====&lt;br /&gt;
Configuring Selenium requires you to download the binaries from [http://www.seleniumhq.org/download/ here]. &lt;br /&gt;
Once you have all your binaries in a directory, you can open any IDE of your choice and add this directory with all the .jar files to the CLASSPATH&lt;br /&gt;
*Example&lt;br /&gt;
This is how a typical Selenium code to find the term say, “Automation” on Google and display the results on the page would look like in Java using the [https://code.google.com/p/selenium/wiki/HtmlUnitDriver HtmlUnitDriver] would look like.&lt;br /&gt;
The HtmlUnitDriver is a pure Java driver that runs entirely in-memory. Because of this, you won't see a new browser window open &amp;lt;ref&amp;gt;[https://code.google.com/p/selenium/wiki/GettingStarted Getting started with Selenium]. Selenium: Browser Automation Framework. Google Code. 8 Feb, 2014.&amp;lt;/ref&amp;gt;,&lt;br /&gt;
&lt;br /&gt;
       package org.selenium.example;&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;
       import org.openqa.selenium.By;&lt;br /&gt;
       import org.openqa.selenium.WebDriver;&lt;br /&gt;
       import org.openqa.selenium.WebElement;&lt;br /&gt;
       import org.openqa.selenium.htmlunit.HtmlUnitDriver;&amp;lt;br /&amp;gt;&lt;br /&gt;
       public class Example  {&lt;br /&gt;
       public static void main(String[] args) {&lt;br /&gt;
        // Create a new instance of the html unit driver&lt;br /&gt;
        // Notice that the remainder of the code relies on the interface,&lt;br /&gt;
        // not the implementation.&lt;br /&gt;
        WebDriver driver = new HtmlUnitDriver();&amp;lt;br /&amp;gt;&lt;br /&gt;
        // And now use this to visit Google&lt;br /&gt;
        driver.get(&amp;quot;http://www.google.com&amp;quot;);&amp;lt;br /&amp;gt;&lt;br /&gt;
        // Find the text input element by its name&lt;br /&gt;
        WebElement element = driver.findElement(By.name(&amp;quot;q&amp;quot;));&amp;lt;br /&amp;gt;&lt;br /&gt;
        // Enter something to search for&lt;br /&gt;
        element.sendKeys(&amp;quot;Automation!&amp;quot;);&amp;lt;br /&amp;gt;&lt;br /&gt;
        // Now submit the form. WebDriver will find the form for us from the element&lt;br /&gt;
        element.submit();&amp;lt;br /&amp;gt;&lt;br /&gt;
        // Check the title of the page&lt;br /&gt;
        System.out.println(&amp;quot;Page title is: &amp;quot; + driver.getTitle());&lt;br /&gt;
        driver.quit();&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
If you compile and run it, you should see a line with the title of the Google search results as output.&lt;br /&gt;
&lt;br /&gt;
====Install/Configure for other languages====&lt;br /&gt;
Configuring Selenium for languages other than Java and for other development environments can be looked up [http://docs.seleniumhq.org/docs/03_webdriver.jsp#setting-up-a-selenium-webdriver-project here]. viz(C#, Ruby, Python, PHP, Perl, Javascript)&lt;br /&gt;
&lt;br /&gt;
===Watir===&lt;br /&gt;
----&lt;br /&gt;
====Install/Configure (Ruby)====&lt;br /&gt;
Drivers for Watir are installed as gems which are nothing but Ruby libraries which can be accessed over the internet.&lt;br /&gt;
All the instructions for installing Watir on various operating systems (viz. Windows, Mac OS, Linux) can be found [http://watir.com/installation/ here].&lt;br /&gt;
&lt;br /&gt;
*Example:&lt;br /&gt;
This is how a typical Watir code to find the term say, “Automation” on Google and display the results on the page would look like using Ruby&amp;lt;ref&amp;gt;Chernenko, Iryna. [http://blog.qatestlab.com/2011/02/23/automated-testing-with-watir-tutorial-for-begginers-part-1/ Watir Example]. QATestLab Blog: Automated Testing with Watir, 23 Feb 2011.&lt;br /&gt;
&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
        # Required in ruby 1.8.7&lt;br /&gt;
        require 'rubygems'&lt;br /&gt;
        # Watir IE driver&lt;br /&gt;
        require 'watir'&amp;lt;br /&amp;gt; &lt;br /&gt;
        ie = Watir::IE.new&amp;lt;br /&amp;gt; &lt;br /&gt;
        # text to show on console&lt;br /&gt;
        puts &amp;quot;Beginning of the test for Google search engine&amp;quot;&lt;br /&gt;
        puts &amp;quot;Step 1:  Go to the Google homepage&amp;quot;&lt;br /&gt;
        ie.goto &amp;quot;http://www.google.com&amp;quot;&amp;lt;br /&amp;gt;&lt;br /&gt;
        #set a variable&lt;br /&gt;
        search_text = &amp;quot;Automation&amp;quot;&lt;br /&gt;
        puts &amp;quot;Step 2: enter &amp;quot;+ search_text +&amp;quot; in the search text field.&amp;quot;&lt;br /&gt;
        ie.text_field(:name, &amp;quot;q&amp;quot;).set search_text   # &amp;quot;q&amp;quot; is the name of the search field&amp;lt;br /&amp;gt;&lt;br /&gt;
        puts &amp;quot; Step 3: click the 'Google Search' button.&amp;quot;&lt;br /&gt;
        ie.button(:name, &amp;quot;btnG&amp;quot;).click # &amp;quot;btnG&amp;quot; is the name of the Search button&amp;lt;br /&amp;gt;&lt;br /&gt;
        puts &amp;quot; Expected Result:&amp;quot;&lt;br /&gt;
        puts &amp;quot;  A Google page with results should be shown. 'Watir, pronounced water' should be high on the list.&amp;quot;&lt;br /&gt;
        puts &amp;quot; Actual Result:&amp;quot;&lt;br /&gt;
        if ie.text.include? &amp;quot;Watir, pronounced water&amp;quot;	&lt;br /&gt;
             puts &amp;quot;  Test Passed. Found the text string: 'Watir, pronounced water'. Actual Results match Expected Results.&amp;quot;&lt;br /&gt;
        else	&lt;br /&gt;
 	     puts &amp;quot;  Test Failed! Could not find text: 'Watir, pronounced water'.&amp;quot;&lt;br /&gt;
        end&lt;br /&gt;
        puts &amp;quot;End of test: Google search.&amp;quot;&lt;br /&gt;
        ie.close&lt;br /&gt;
&lt;br /&gt;
On compiling and running this and passing the test, you will see something like, &amp;lt;br /&amp;gt; &lt;br /&gt;
&lt;br /&gt;
        ''Output:''&lt;br /&gt;
        Beginning of the test for Google search engine &amp;lt;br /&amp;gt;&lt;br /&gt;
        Step 1:  Go to the Google homepage &amp;lt;br /&amp;gt;&lt;br /&gt;
        Step 2: enter Automation in the search text field. &amp;lt;br /&amp;gt;&lt;br /&gt;
        Step 3: click the 'Google Search' button. &amp;lt;br /&amp;gt;&lt;br /&gt;
        Expected Result: &amp;lt;br /&amp;gt;&lt;br /&gt;
        A Google page with results should be shown. 'Watir, pronounced water' should be high on the list. &amp;lt;br /&amp;gt;	&lt;br /&gt;
        Test Passed. Found the text string: 'Watir, pronounced water'. Actual Results match Expected Results. &amp;lt;br /&amp;gt;&lt;br /&gt;
        End of test: Google search. &amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Similar Tools==&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Sahi_(software) Sahi], uses the Sahi Scripting Language&amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Soatest SOATest], for testing and validating [http://en.wikipedia.org/wiki/Application_programming_interface API] driven applications &amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/TestComplete TestComplete], for Desktops, Web and Mobile&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
* [http://www.hiretheworld.com/blog/tech-blog/migrating-unit-tests-from-selenium-to-watir-webdriver Migrating unit tests from Selenium to Watir Web Driver] &amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://www.hiretheworld.com/blog/tech-blog/migrating-unit-tests-from-selenium-to-watir-webdriver Learning Selenium IDE] &amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/List_of_web_testing_tools List of web testing tools] &amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/List_of_web_testing_tools OWASP List of Acceptance Testing tools]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
{{reflist}}&lt;br /&gt;
&amp;lt;references /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==External Links==&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Selenium_(software) Selenium Wiki Page] &amp;lt;br /&amp;gt;&lt;br /&gt;
* [https://github.com/SeleniumHQ/selenium Selenium Source Code] &amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Watir Watir Wiki Page] &amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Watir Watir Source Code] &amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Watir SauceLabs HomePage] &amp;lt;br /&amp;gt;&lt;/div&gt;</summary>
		<author><name>Jjbeaver</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/ch1b_27_js&amp;diff=89445</id>
		<title>CSC/ECE 517 Fall 2014/ch1b 27 js</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/ch1b_27_js&amp;diff=89445"/>
		<updated>2014-10-07T04:18:32Z</updated>

		<summary type="html">&lt;p&gt;Jjbeaver: /* Cross-Browser and Headless Browser Support */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;='''Selenium vs. Watir'''=&lt;br /&gt;
&lt;br /&gt;
Developing web applications is proving to be a challenging task with each passing day given the complex requirements and the demanding nature of the these applications. For the web applications to be robust we need to put in place some good testing strategies.&lt;br /&gt;
&lt;br /&gt;
'''''Selenium''''' is one of the most popularly used open source automation tools for web based applications. It is a JavaScript framework that runs in your web browser to interact with various elements in your browser. All in all, Selenium is a set of different software tools each with a different approach to supporting test automation. Selenium provides a rich set of testing functions that can be customized to suit the testing requirements.&lt;br /&gt;
 &lt;br /&gt;
'''''Watir''''', is another lightweight automation testing tool that is widely used for web app testing. It is an open-source ([http://en.wikipedia.org/wiki/BSD_licenses BSD])  family of Ruby libraries for automating web browsers. It allows you to write tests that are easy to read and maintain. Despite the fact that it is a set of Ruby libraries, it works perfectly, independent of the language that the web application is developed in. Watir as a tool is extremely simple and flexible.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=='''Motivation'''==&lt;br /&gt;
===Need for test automation===&lt;br /&gt;
With the majority of software applications today being implemented as [http://en.wikipedia.org/wiki/Web_application web applications] to be used over the internet, testing is becoming an indispensable part of the software development lifecycle ([http://en.wikipedia.org/wiki/Software_development_process SDLC]) of these applications. [http://en.wikipedia.org/wiki/Test_automation Test automation] is used where manual testing needs to be carried out repeatedly making it a cumbersome task. Test automation uses a software tool for this purpose on the application to be tested. It has proven to be highly efficient and critical in larger software development companies. Additionally, automation can be a valuable way to make Test Driven Development ([http://en.wikipedia.org/wiki/Test-driven_development TDD]) tasks an important part of the software development workflow.&lt;br /&gt;
 &lt;br /&gt;
Test Automation has a number of advantages mostly dealing with repetitiveness of the tests and the time taken,&lt;br /&gt;
* '''Covers cases that manual testing probably cannot'''&lt;br /&gt;
# Finds defects missed out my manual testing&lt;br /&gt;
# Automated testing can simulate numerous virtual users interacting with the web software/application&lt;br /&gt;
* '''Helps save time and money'''&lt;br /&gt;
# Once created, automated tests can be executed repeatedly at no additional   costs and at a much faster pace. Saving time directly translates into saving cost.&lt;br /&gt;
# Supports virtually unlimited iterations of test case execution&lt;br /&gt;
* '''Increase test coverage and accuracy'''&lt;br /&gt;
# Automated tests perform the exact same steps and records all details precisely&lt;br /&gt;
# They also increase the depth and scope of tests to improve the quality of the software&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=='''Brief History'''==&lt;br /&gt;
====Selenium====&lt;br /&gt;
&lt;br /&gt;
[[File: SE-logo.png|right|Selenium Logo|link=http://www.seleniumhq.org/images/big-logo.png]]&lt;br /&gt;
&lt;br /&gt;
''Selenium'' was developed in the year 2004 by Jason Huggins and has been continuously evolving ever since. Jason Huggins developed this as an internal tool for [http://en.wikipedia.org/wiki/ThoughtWorks ThoughtWorks] as a javascript library which came to be known as the Selenium core. Selenium core is now the basis of the Selenium Remote Control (the server) and Selenium IDE.&lt;br /&gt;
The year 2006 marked the beginning of the development of the WebDriver project which was what they believed ‘a tool of the future’. The WebDriver was initiated to solve the problems that were faced due to the fact that Selenium was a based on JavaScript and a lot of security limitations browsers apply to Javascript.&lt;br /&gt;
In 2008, both Selenium and WebDriver merged to provide a common set of features to all users which is called Selenium 2..&lt;br /&gt;
Simon Stewart, the creator of WebDriver, in a joint email to the WebDriver and Selenium community on August 6, 2009 said the following,&lt;br /&gt;
&lt;br /&gt;
“Why are the projects merging? Partly because webdriver addresses some shortcomings in selenium (by being able to bypass the JS sandbox, for example. And we’ve got a gorgeous API), partly because selenium addresses some shortcomings in webdriver (such as supporting a broader range of browsers) and partly because the main selenium contributors and I felt that it was the best way to offer users the best possible framework.”&amp;lt;ref name =&amp;quot;Introduction to Selenium&amp;quot;&amp;gt;[http://docs.seleniumhq.org/docs/01_introducing_selenium.jsp#selenium-history Introducing Selenium]. ''SeleniumHQ: Browser Automation''. Selenium Project, 4 Oct. 2014. Web. 06 Oct. 2014.&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Watir====&lt;br /&gt;
&lt;br /&gt;
''Watir'' started as a library to teach testers to write ruby code and grew to be an IE implementation which now supports IE, Firefox, Safari, Google Chrome and Opera.&lt;br /&gt;
Watir was primarily developed by Bret Pettichord and Paul Rogers. Watir has since then has a couple of stable releases for Watir classic as well as Watir WebDriver. The most recent releases being&amp;lt;ref&amp;gt;[http://watir.com/category/releases/ Watir Releases]. Watir: Web Application Testing in Ruby. 28 April, 2013&amp;lt;/ref&amp;gt;, &lt;br /&gt;
&lt;br /&gt;
[[File: Watir.gif|right|Watir logo|link=http://upload.wikimedia.org/wikipedia/commons/7/7e/Watir.gif]]&lt;br /&gt;
&lt;br /&gt;
* Watir-Classic	    &lt;br /&gt;
# 0.6.3 April 10, 2013 ([https://github.com/watir/watir-webdriver/blob/master/CHANGES.md#063 Release Notes]) &amp;lt;br /&amp;gt;&lt;br /&gt;
* Watir-WebDriver	    &lt;br /&gt;
# 3.6.0 March 16, 2013 ([https://groups.google.com/forum/#!msg/watir-general/MOOun5g3Hvg/JBVNy957lDYJ Release Notes]) &amp;lt;br /&amp;gt;&lt;br /&gt;
# 3.5.0 March 10, 2013 ([https://groups.google.com/forum/#!msg/watir-general/aeUqsglvK6k/Kq7FCBiERjYJ Release Notes]) &amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Watir has a google group ([https://groups.google.com/forum/#!forum/watir-general Watir General]) for its support and contribution while Selenium also has a [http://seleniumforum.forumotion.net/ Selenium forum] apart from its google group called [https://groups.google.com/forum/#!forum/selenium-users Selenium Users].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=='''Comparison of Features, Functionality, and More'''==&lt;br /&gt;
Some features or functionality may be repeated here.  However, we will go into a bit more detail than previously mentioned.&lt;br /&gt;
===='''Open Source'''====&lt;br /&gt;
Both Selenium and Watir are [http://en.wikipedia.org/wiki/Open-source_software open source]!  This allows for greater extensibility and a deeper understanding of the inner workings of both of the frameworks, if the developer/tester chooses to delve into such details.  Additionally, the open source community allows for a more transparent, user-driven development and support cycle.  Users (the tester/developer) can choose to submit bug fixes or enhancements as patches, or they can choose to just use it “straight out of the box.”&lt;br /&gt;
&lt;br /&gt;
====Application Language Agnostic====&lt;br /&gt;
&lt;br /&gt;
Both Selenium and Watir are application language agnostic.  Because both Selenium and Watir test UI functionality in the browser, they can be used to test any web application.    &lt;br /&gt;
&lt;br /&gt;
====Language-specific Test Cases====&lt;br /&gt;
&lt;br /&gt;
Both Selenium and Watir require test cases to be written in some programming language.  Traditionally, both frameworks had limited choices in terms of language bindings.  However, with the advent of WebDriver, both became much more flexible.  WebDriver provided the bindings needed for many languages.  Today, the following are supported:&lt;br /&gt;
&lt;br /&gt;
'''Selenium*'''&lt;br /&gt;
&lt;br /&gt;
* Officially-supported: [http://en.wikipedia.org/wiki/Java_(programming_language) Java], [http://en.wikipedia.org/wiki/C_Sharp_(programming_language) C#], [http://en.wikipedia.org/wiki/Ruby_(programming_language) Ruby], [http://en.wikipedia.org/wiki/Python_(programming_language) Python], [http://en.wikipedia.org/wiki/Node.js Javascript/Node.js]&lt;br /&gt;
&lt;br /&gt;
* Unofficial/community-supported: [http://en.wikipedia.org/wiki/Perl Perl], [http://en.wikipedia.org/wiki/PHP PHP], [http://en.wikipedia.org/wiki/Haskell_(programming_language) Haskell], [http://en.wikipedia.org/wiki/Objective-C Objective-C], [http://en.wikipedia.org/wiki/R_(programming_language) R], [http://en.wikipedia.org/wiki/Dart_(programming_language) Dart], [http://en.wikipedia.org/wiki/Tcl Tcl]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;According to SeleniumHQ’s download page.&lt;br /&gt;
&lt;br /&gt;
'''Watir'''&lt;br /&gt;
&lt;br /&gt;
Unfortunately (or fortunately), Ruby is the only supported language for Watir.  After all, Watir does stand for “Web Application Testing in Ruby.” However, there are other frameworks which were inspired by Watir (but entirely separate) available in Java and C# - Watij and Watin,  respectively &amp;lt;ref&amp;gt;Djorgjievski, Darko. [http://www.sitepoint.com/watir-webdriver-control-browser/ Watir-WebDriver: Control the Browser]. ''SitePoint''. SitePoint Pty Ltd, 18 Apr. 2014. Web. 05 Oct. 2014.&amp;lt;/ref&amp;gt;.  There may be other similarly inspired frameworks available in other languages, but these are the most notable.&lt;br /&gt;
&lt;br /&gt;
====Cross-Browser and Headless Browser Support====&lt;br /&gt;
&lt;br /&gt;
[[File: watir_meet_webdriver.png | Watir Meets WebDriver |right|frame| link=http://yuml.me/diagram/scruffy/usecase/%5BTester%5D-%28Watir%20API%29,%20%28Watir%20API%29%3C%28FireWatir%29,%20%28Watir%20API%29%3C%28Watir%29,%20%28Watir%20API%29%3C%28SafariWatir%29,%20%28Watir%20API%29%3C%28Webdriver%29,%20%28Watir%20API%29%3C%28Celerity%29,%20%28Celerity%29-%28note:%20Celerity%20requires%20JRuby%29,%20%28Celerity%29-%28headless%29,%20%28Webdriver%29-%28Firefox%29,%20%28Webdriver%29-%28Chrome%29,%20%28Webdriver%29-%28IE%29,%20%28Webdriver%29-%28headless%29,%20%28FireWatir%29-%28Firefox%29,%20%28Watir%29-%28IE%29,%20%28SafariWatir%29-%28Safari%29.]]&lt;br /&gt;
&lt;br /&gt;
Traditionally, both Selenium and Watir were limited in the number of browsers they supported. Watir originally supported Internet Explorer and headless browsers exclusively.  Headless browsers were supported via the use of [https://github.com/jarib/celerity Celerity] &amp;lt;ref&amp;gt;Scott, Alister. [http://watirmelon.com/2010/04/10/watir-selenium-webdriver/ Watir, Selenium &amp;amp; WebDriver]. ''Watirmelon''. Watirmelon, 10 Apr. 2010. Web. 05 Oct. 2014.&amp;lt;/ref&amp;gt;.  Selenium started out as a Javascript library, so naturally it supported more browsers such as IE, Firefox, Safari, etc &amp;lt;ref name = &amp;quot;Introduction to Selenium&amp;quot; /&amp;gt;.  However, it did not support headless browsers.&lt;br /&gt;
Today, browser support looks much better for both Selenium and Watir, largely due to the introduction of WebDriver.  With WebDriver in existence, support for most browsers was added to Watir via the gem &amp;quot;watir-webdriver,&amp;quot; and Celerity became [https://github.com/jarib/celerity obsolete] because headless browser support was included in WebDriver.  Similarly for Selenium, support for headless browsers was added, as well as making the API much simpler and more concise &amp;lt;ref&amp;gt;[http://docs.seleniumhq.org/projects/webdriver/ Selenium WebDriver]. ''SeleniumHQ: Browser Automation''. Selenium Project, n.d. Web. 06 Oct. 2014.&amp;lt;/ref&amp;gt;.  Both Selenium &amp;lt;ref&amp;gt;Semerau, Luke. [https://code.google.com/p/selenium/wiki/WebDriverForMobileBrowsers WebDriverForMobileBrowsers]. ''Selenium''. Google Project Hosting, 14 Jan. 2013. Web. 06 Oct. 2014 &amp;lt;/ref&amp;gt; and Watir &amp;lt;ref&amp;gt;Scott, Alister. [http://watirwebdriver.com/mobile-devices/ Mobile Devices]. ''Watir WebDriver''. n.d. Web. 06 Oct. 2014. &amp;lt;/ref&amp;gt; have also gained support of Mobile browsers in recent years through WebDriver.  However, there is the obvious limitation that one can only test a browser which is supported on the running platform.  In other words, Safari and Internet explorer can only be tested on  OS X and Windows environments, respectively**.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;**&amp;lt;/nowiki&amp;gt; &amp;lt;span style=&amp;quot;font-size:88%&amp;quot;&amp;gt;Some work-arounds or programs may exist to allow these browsers to be tested on other platforms. Here, we are assuming no special additional configuration - just the base operating system and browsers.  With virtualization technologies such as [http://www.linux-kvm.org/page/Main_Page KVM], [https://www.virtualbox.org/ VirtualBox], and [http://en.wikipedia.org/wiki/Comparison_of_platform_virtualization_software others], this isn't a problem anyway.  [http://en.wikipedia.org/wiki/Virtual_machine Virtual machines] can be created with any operating system, as needed.&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Cross-Platform Support====&lt;br /&gt;
Both Watir and Selenium run on most popular distributions of Windows, Mac, and Linux.  Selenium doesn't have a list of officially supported operating system versions.  Instead they generally support any version that is currently popular.  Only a few versions are listed which they run test builds on.  These are versions which are officially known to work, but many more are supported as well.&lt;br /&gt;
&lt;br /&gt;
Because Watir is a collection of Ruby Gems, it runs on any platform that Ruby runs on.  Like Selenium, this includes nearly all popular platforms.&lt;br /&gt;
&lt;br /&gt;
=='''Getting started'''==&lt;br /&gt;
===Selenium WebDriver=== &lt;br /&gt;
----&lt;br /&gt;
====Install/Configure (Java)====&lt;br /&gt;
Configuring Selenium requires you to download the binaries from [http://www.seleniumhq.org/download/ here]. &lt;br /&gt;
Once you have all your binaries in a directory, you can open any IDE of your choice and add this directory with all the .jar files to the CLASSPATH&lt;br /&gt;
*Example&lt;br /&gt;
This is how a typical Selenium code to find the term say, “Automation” on Google and display the results on the page would look like in Java using the [https://code.google.com/p/selenium/wiki/HtmlUnitDriver HtmlUnitDriver] would look like.&lt;br /&gt;
The HtmlUnitDriver is a pure Java driver that runs entirely in-memory. Because of this, you won't see a new browser window open &amp;lt;ref&amp;gt;[https://code.google.com/p/selenium/wiki/GettingStarted Getting started with Selenium]. Selenium: Browser Automation Framework. Google Code. 8 Feb, 2014.&amp;lt;/ref&amp;gt;,&lt;br /&gt;
&lt;br /&gt;
       package org.selenium.example;&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;
       import org.openqa.selenium.By;&lt;br /&gt;
       import org.openqa.selenium.WebDriver;&lt;br /&gt;
       import org.openqa.selenium.WebElement;&lt;br /&gt;
       import org.openqa.selenium.htmlunit.HtmlUnitDriver;&amp;lt;br /&amp;gt;&lt;br /&gt;
       public class Example  {&lt;br /&gt;
       public static void main(String[] args) {&lt;br /&gt;
        // Create a new instance of the html unit driver&lt;br /&gt;
        // Notice that the remainder of the code relies on the interface,&lt;br /&gt;
        // not the implementation.&lt;br /&gt;
        WebDriver driver = new HtmlUnitDriver();&amp;lt;br /&amp;gt;&lt;br /&gt;
        // And now use this to visit Google&lt;br /&gt;
        driver.get(&amp;quot;http://www.google.com&amp;quot;);&amp;lt;br /&amp;gt;&lt;br /&gt;
        // Find the text input element by its name&lt;br /&gt;
        WebElement element = driver.findElement(By.name(&amp;quot;q&amp;quot;));&amp;lt;br /&amp;gt;&lt;br /&gt;
        // Enter something to search for&lt;br /&gt;
        element.sendKeys(&amp;quot;Automation!&amp;quot;);&amp;lt;br /&amp;gt;&lt;br /&gt;
        // Now submit the form. WebDriver will find the form for us from the element&lt;br /&gt;
        element.submit();&amp;lt;br /&amp;gt;&lt;br /&gt;
        // Check the title of the page&lt;br /&gt;
        System.out.println(&amp;quot;Page title is: &amp;quot; + driver.getTitle());&lt;br /&gt;
        driver.quit();&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
If you compile and run it, you should see a line with the title of the Google search results as output.&lt;br /&gt;
&lt;br /&gt;
====Install/Configure for other languages====&lt;br /&gt;
Configuring Selenium for languages other than Java and for other development environments can be looked up [http://docs.seleniumhq.org/docs/03_webdriver.jsp#setting-up-a-selenium-webdriver-project here]. viz(C#, Ruby, Python, PHP, Perl, Javascript)&lt;br /&gt;
&lt;br /&gt;
===Watir===&lt;br /&gt;
----&lt;br /&gt;
====Install/Configure (Ruby)====&lt;br /&gt;
Drivers for Watir are installed as gems which are nothing but Ruby libraries which can be accessed over the internet.&lt;br /&gt;
All the instructions for installing Watir on various operating systems (viz. Windows, Mac OS, Linux) can be found [http://watir.com/installation/ here].&lt;br /&gt;
&lt;br /&gt;
*Example:&lt;br /&gt;
This is how a typical Watir code to find the term say, “Automation” on Google and display the results on the page would look like using Ruby&amp;lt;ref&amp;gt;Chernenko, Iryna. [http://blog.qatestlab.com/2011/02/23/automated-testing-with-watir-tutorial-for-begginers-part-1/ Watir Example]. QATestLab Blog: Automated Testing with Watir, 23 Feb 2011.&lt;br /&gt;
&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
        # Required in ruby 1.8.7&lt;br /&gt;
        require 'rubygems'&lt;br /&gt;
        # Watir IE driver&lt;br /&gt;
        require 'watir'&amp;lt;br /&amp;gt; &lt;br /&gt;
        ie = Watir::IE.new&amp;lt;br /&amp;gt; &lt;br /&gt;
        # text to show on console&lt;br /&gt;
        puts &amp;quot;Beginning of the test for Google search engine&amp;quot;&lt;br /&gt;
        puts &amp;quot;Step 1:  Go to the Google homepage&amp;quot;&lt;br /&gt;
        ie.goto &amp;quot;http://www.google.com&amp;quot;&amp;lt;br /&amp;gt;&lt;br /&gt;
        #set a variable&lt;br /&gt;
        search_text = &amp;quot;Automation&amp;quot;&lt;br /&gt;
        puts &amp;quot;Step 2: enter &amp;quot;+ search_text +&amp;quot; in the search text field.&amp;quot;&lt;br /&gt;
        ie.text_field(:name, &amp;quot;q&amp;quot;).set search_text   # &amp;quot;q&amp;quot; is the name of the search field&amp;lt;br /&amp;gt;&lt;br /&gt;
        puts &amp;quot; Step 3: click the 'Google Search' button.&amp;quot;&lt;br /&gt;
        ie.button(:name, &amp;quot;btnG&amp;quot;).click # &amp;quot;btnG&amp;quot; is the name of the Search button&amp;lt;br /&amp;gt;&lt;br /&gt;
        puts &amp;quot; Expected Result:&amp;quot;&lt;br /&gt;
        puts &amp;quot;  A Google page with results should be shown. 'Watir, pronounced water' should be high on the list.&amp;quot;&lt;br /&gt;
        puts &amp;quot; Actual Result:&amp;quot;&lt;br /&gt;
        if ie.text.include? &amp;quot;Watir, pronounced water&amp;quot;	&lt;br /&gt;
             puts &amp;quot;  Test Passed. Found the text string: 'Watir, pronounced water'. Actual Results match Expected Results.&amp;quot;&lt;br /&gt;
        else	&lt;br /&gt;
 	     puts &amp;quot;  Test Failed! Could not find text: 'Watir, pronounced water'.&amp;quot;&lt;br /&gt;
        end&lt;br /&gt;
        puts &amp;quot;End of test: Google search.&amp;quot;&lt;br /&gt;
        ie.close&lt;br /&gt;
&lt;br /&gt;
On compiling and running this and passing the test, you will see something like, &amp;lt;br /&amp;gt; &lt;br /&gt;
&lt;br /&gt;
        ''Output:''&lt;br /&gt;
        Beginning of the test for Google search engine &amp;lt;br /&amp;gt;&lt;br /&gt;
        Step 1:  Go to the Google homepage &amp;lt;br /&amp;gt;&lt;br /&gt;
        Step 2: enter Automation in the search text field. &amp;lt;br /&amp;gt;&lt;br /&gt;
        Step 3: click the 'Google Search' button. &amp;lt;br /&amp;gt;&lt;br /&gt;
        Expected Result: &amp;lt;br /&amp;gt;&lt;br /&gt;
        A Google page with results should be shown. 'Watir, pronounced water' should be high on the list. &amp;lt;br /&amp;gt;	&lt;br /&gt;
        Test Passed. Found the text string: 'Watir, pronounced water'. Actual Results match Expected Results. &amp;lt;br /&amp;gt;&lt;br /&gt;
        End of test: Google search. &amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Similar Tools==&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Sahi_(software) Sahi], uses the Sahi Scripting Language&amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Soatest SOATest], for testing and validating [http://en.wikipedia.org/wiki/Application_programming_interface API] driven applications &amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/TestComplete TestComplete], for Desktops, Web and Mobile&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
* [http://www.hiretheworld.com/blog/tech-blog/migrating-unit-tests-from-selenium-to-watir-webdriver Migrating unit tests from Selenium to Watir Web Driver] &amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://www.hiretheworld.com/blog/tech-blog/migrating-unit-tests-from-selenium-to-watir-webdriver Learning Selenium IDE] &amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/List_of_web_testing_tools List of web testing tools] &amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/List_of_web_testing_tools OWASP List of Acceptance Testing tools]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
{{reflist}}&lt;br /&gt;
&amp;lt;references /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==External Links==&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Selenium_(software) Selenium Wiki Page] &amp;lt;br /&amp;gt;&lt;br /&gt;
* [https://github.com/SeleniumHQ/selenium Selenium Source Code] &amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Watir Watir Wiki Page] &amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Watir Watir Source Code] &amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Watir SauceLabs HomePage] &amp;lt;br /&amp;gt;&lt;/div&gt;</summary>
		<author><name>Jjbeaver</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/ch1b_27_js&amp;diff=89444</id>
		<title>CSC/ECE 517 Fall 2014/ch1b 27 js</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/ch1b_27_js&amp;diff=89444"/>
		<updated>2014-10-07T04:18:12Z</updated>

		<summary type="html">&lt;p&gt;Jjbeaver: /* Cross-Browser and Headless Browser Support */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;='''Selenium vs. Watir'''=&lt;br /&gt;
&lt;br /&gt;
Developing web applications is proving to be a challenging task with each passing day given the complex requirements and the demanding nature of the these applications. For the web applications to be robust we need to put in place some good testing strategies.&lt;br /&gt;
&lt;br /&gt;
'''''Selenium''''' is one of the most popularly used open source automation tools for web based applications. It is a JavaScript framework that runs in your web browser to interact with various elements in your browser. All in all, Selenium is a set of different software tools each with a different approach to supporting test automation. Selenium provides a rich set of testing functions that can be customized to suit the testing requirements.&lt;br /&gt;
 &lt;br /&gt;
'''''Watir''''', is another lightweight automation testing tool that is widely used for web app testing. It is an open-source ([http://en.wikipedia.org/wiki/BSD_licenses BSD])  family of Ruby libraries for automating web browsers. It allows you to write tests that are easy to read and maintain. Despite the fact that it is a set of Ruby libraries, it works perfectly, independent of the language that the web application is developed in. Watir as a tool is extremely simple and flexible.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=='''Motivation'''==&lt;br /&gt;
===Need for test automation===&lt;br /&gt;
With the majority of software applications today being implemented as [http://en.wikipedia.org/wiki/Web_application web applications] to be used over the internet, testing is becoming an indispensable part of the software development lifecycle ([http://en.wikipedia.org/wiki/Software_development_process SDLC]) of these applications. [http://en.wikipedia.org/wiki/Test_automation Test automation] is used where manual testing needs to be carried out repeatedly making it a cumbersome task. Test automation uses a software tool for this purpose on the application to be tested. It has proven to be highly efficient and critical in larger software development companies. Additionally, automation can be a valuable way to make Test Driven Development ([http://en.wikipedia.org/wiki/Test-driven_development TDD]) tasks an important part of the software development workflow.&lt;br /&gt;
 &lt;br /&gt;
Test Automation has a number of advantages mostly dealing with repetitiveness of the tests and the time taken,&lt;br /&gt;
* '''Covers cases that manual testing probably cannot'''&lt;br /&gt;
# Finds defects missed out my manual testing&lt;br /&gt;
# Automated testing can simulate numerous virtual users interacting with the web software/application&lt;br /&gt;
* '''Helps save time and money'''&lt;br /&gt;
# Once created, automated tests can be executed repeatedly at no additional   costs and at a much faster pace. Saving time directly translates into saving cost.&lt;br /&gt;
# Supports virtually unlimited iterations of test case execution&lt;br /&gt;
* '''Increase test coverage and accuracy'''&lt;br /&gt;
# Automated tests perform the exact same steps and records all details precisely&lt;br /&gt;
# They also increase the depth and scope of tests to improve the quality of the software&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=='''Brief History'''==&lt;br /&gt;
====Selenium====&lt;br /&gt;
&lt;br /&gt;
[[File: SE-logo.png|right|Selenium Logo|link=http://www.seleniumhq.org/images/big-logo.png]]&lt;br /&gt;
&lt;br /&gt;
''Selenium'' was developed in the year 2004 by Jason Huggins and has been continuously evolving ever since. Jason Huggins developed this as an internal tool for [http://en.wikipedia.org/wiki/ThoughtWorks ThoughtWorks] as a javascript library which came to be known as the Selenium core. Selenium core is now the basis of the Selenium Remote Control (the server) and Selenium IDE.&lt;br /&gt;
The year 2006 marked the beginning of the development of the WebDriver project which was what they believed ‘a tool of the future’. The WebDriver was initiated to solve the problems that were faced due to the fact that Selenium was a based on JavaScript and a lot of security limitations browsers apply to Javascript.&lt;br /&gt;
In 2008, both Selenium and WebDriver merged to provide a common set of features to all users which is called Selenium 2..&lt;br /&gt;
Simon Stewart, the creator of WebDriver, in a joint email to the WebDriver and Selenium community on August 6, 2009 said the following,&lt;br /&gt;
&lt;br /&gt;
“Why are the projects merging? Partly because webdriver addresses some shortcomings in selenium (by being able to bypass the JS sandbox, for example. And we’ve got a gorgeous API), partly because selenium addresses some shortcomings in webdriver (such as supporting a broader range of browsers) and partly because the main selenium contributors and I felt that it was the best way to offer users the best possible framework.”&amp;lt;ref name =&amp;quot;Introduction to Selenium&amp;quot;&amp;gt;[http://docs.seleniumhq.org/docs/01_introducing_selenium.jsp#selenium-history Introducing Selenium]. ''SeleniumHQ: Browser Automation''. Selenium Project, 4 Oct. 2014. Web. 06 Oct. 2014.&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Watir====&lt;br /&gt;
&lt;br /&gt;
''Watir'' started as a library to teach testers to write ruby code and grew to be an IE implementation which now supports IE, Firefox, Safari, Google Chrome and Opera.&lt;br /&gt;
Watir was primarily developed by Bret Pettichord and Paul Rogers. Watir has since then has a couple of stable releases for Watir classic as well as Watir WebDriver. The most recent releases being&amp;lt;ref&amp;gt;[http://watir.com/category/releases/ Watir Releases]. Watir: Web Application Testing in Ruby. 28 April, 2013&amp;lt;/ref&amp;gt;, &lt;br /&gt;
&lt;br /&gt;
[[File: Watir.gif|right|Watir logo|link=http://upload.wikimedia.org/wikipedia/commons/7/7e/Watir.gif]]&lt;br /&gt;
&lt;br /&gt;
* Watir-Classic	    &lt;br /&gt;
# 0.6.3 April 10, 2013 ([https://github.com/watir/watir-webdriver/blob/master/CHANGES.md#063 Release Notes]) &amp;lt;br /&amp;gt;&lt;br /&gt;
* Watir-WebDriver	    &lt;br /&gt;
# 3.6.0 March 16, 2013 ([https://groups.google.com/forum/#!msg/watir-general/MOOun5g3Hvg/JBVNy957lDYJ Release Notes]) &amp;lt;br /&amp;gt;&lt;br /&gt;
# 3.5.0 March 10, 2013 ([https://groups.google.com/forum/#!msg/watir-general/aeUqsglvK6k/Kq7FCBiERjYJ Release Notes]) &amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Watir has a google group ([https://groups.google.com/forum/#!forum/watir-general Watir General]) for its support and contribution while Selenium also has a [http://seleniumforum.forumotion.net/ Selenium forum] apart from its google group called [https://groups.google.com/forum/#!forum/selenium-users Selenium Users].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=='''Comparison of Features, Functionality, and More'''==&lt;br /&gt;
Some features or functionality may be repeated here.  However, we will go into a bit more detail than previously mentioned.&lt;br /&gt;
===='''Open Source'''====&lt;br /&gt;
Both Selenium and Watir are [http://en.wikipedia.org/wiki/Open-source_software open source]!  This allows for greater extensibility and a deeper understanding of the inner workings of both of the frameworks, if the developer/tester chooses to delve into such details.  Additionally, the open source community allows for a more transparent, user-driven development and support cycle.  Users (the tester/developer) can choose to submit bug fixes or enhancements as patches, or they can choose to just use it “straight out of the box.”&lt;br /&gt;
&lt;br /&gt;
====Application Language Agnostic====&lt;br /&gt;
&lt;br /&gt;
Both Selenium and Watir are application language agnostic.  Because both Selenium and Watir test UI functionality in the browser, they can be used to test any web application.    &lt;br /&gt;
&lt;br /&gt;
====Language-specific Test Cases====&lt;br /&gt;
&lt;br /&gt;
Both Selenium and Watir require test cases to be written in some programming language.  Traditionally, both frameworks had limited choices in terms of language bindings.  However, with the advent of WebDriver, both became much more flexible.  WebDriver provided the bindings needed for many languages.  Today, the following are supported:&lt;br /&gt;
&lt;br /&gt;
'''Selenium*'''&lt;br /&gt;
&lt;br /&gt;
* Officially-supported: [http://en.wikipedia.org/wiki/Java_(programming_language) Java], [http://en.wikipedia.org/wiki/C_Sharp_(programming_language) C#], [http://en.wikipedia.org/wiki/Ruby_(programming_language) Ruby], [http://en.wikipedia.org/wiki/Python_(programming_language) Python], [http://en.wikipedia.org/wiki/Node.js Javascript/Node.js]&lt;br /&gt;
&lt;br /&gt;
* Unofficial/community-supported: [http://en.wikipedia.org/wiki/Perl Perl], [http://en.wikipedia.org/wiki/PHP PHP], [http://en.wikipedia.org/wiki/Haskell_(programming_language) Haskell], [http://en.wikipedia.org/wiki/Objective-C Objective-C], [http://en.wikipedia.org/wiki/R_(programming_language) R], [http://en.wikipedia.org/wiki/Dart_(programming_language) Dart], [http://en.wikipedia.org/wiki/Tcl Tcl]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;According to SeleniumHQ’s download page.&lt;br /&gt;
&lt;br /&gt;
'''Watir'''&lt;br /&gt;
&lt;br /&gt;
Unfortunately (or fortunately), Ruby is the only supported language for Watir.  After all, Watir does stand for “Web Application Testing in Ruby.” However, there are other frameworks which were inspired by Watir (but entirely separate) available in Java and C# - Watij and Watin,  respectively &amp;lt;ref&amp;gt;Djorgjievski, Darko. [http://www.sitepoint.com/watir-webdriver-control-browser/ Watir-WebDriver: Control the Browser]. ''SitePoint''. SitePoint Pty Ltd, 18 Apr. 2014. Web. 05 Oct. 2014.&amp;lt;/ref&amp;gt;.  There may be other similarly inspired frameworks available in other languages, but these are the most notable.&lt;br /&gt;
&lt;br /&gt;
====Cross-Browser and Headless Browser Support====&lt;br /&gt;
&lt;br /&gt;
[[File: watir_meet_webdriver.png | Watir Meets WebDriver |right|frame| link=http://yuml.me/diagram/scruffy/usecase/%5BTester%5D-%28Watir%20API%29,%20%28Watir%20API%29%3C%28FireWatir%29,%20%28Watir%20API%29%3C%28Watir%29,%20%28Watir%20API%29%3C%28SafariWatir%29,%20%28Watir%20API%29%3C%28Webdriver%29,%20%28Watir%20API%29%3C%28Celerity%29,%20%28Celerity%29-%28note:%20Celerity%20requires%20JRuby%29,%20%28Celerity%29-%28headless%29,%20%28Webdriver%29-%28Firefox%29,%20%28Webdriver%29-%28Chrome%29,%20%28Webdriver%29-%28IE%29,%20%28Webdriver%29-%28headless%29,%20%28FireWatir%29-%28Firefox%29,%20%28Watir%29-%28IE%29,%20%28SafariWatir%29-%28Safari%29.]]&lt;br /&gt;
&lt;br /&gt;
Traditionally, both Selenium and Watir were limited in the number of browsers they supported. Watir originally supported Internet Explorer and headless browsers exclusively.  Headless browsers were supported via the use of [https://github.com/jarib/celerity Celerity] &amp;lt;ref&amp;gt;Scott, Alister. [http://watirmelon.com/2010/04/10/watir-selenium-webdriver/ Watir, Selenium &amp;amp; WebDriver]. ''Watirmelon''. Watirmelon, 10 Apr. 2010. Web. 05 Oct. 2014.&amp;lt;/ref&amp;gt;.  Selenium started out as a Javascript library, so naturally it supported more browsers such as IE, Firefox, Safari, etc &amp;lt;ref name = &amp;quot;Introduction to Selenium&amp;quot; /&amp;gt;.  However, it did not support headless browsers.&lt;br /&gt;
Today, browser support looks much better for both Selenium and Watir, largely due to the introduction of WebDriver.  With WebDriver in existence, support for most browsers was added to Watir via the gem &amp;quot;watir-webdriver,&amp;quot; and Celerity became [https://github.com/jarib/celerity obsolete] because headless browser support was included in WebDriver.  Similarly for Selenium, support for headless browsers was added, as well as making the API much simpler and more concise &amp;lt;ref&amp;gt;[http://docs.seleniumhq.org/projects/webdriver/ Selenium WebDriver]. ''SeleniumHQ: Browser Automation''. Selenium Project, n.d. Web. 06 Oct. 2014.&amp;lt;/ref&amp;gt;.  Both Selenium &amp;lt;ref&amp;gt;Semerau, Luke. [https://code.google.com/p/selenium/wiki/WebDriverForMobileBrowsers WebDriverForMobileBrowsers]. ''Selenium''. Google Project Hosting, 14 Jan. 2013. Web. 06 Oct. 2014 &amp;lt;/ref&amp;gt; and &amp;lt;ref&amp;gt;Scott, Alister. [http://watirwebdriver.com/mobile-devices/ Mobile Devices]. ''Watir WebDriver''. n.d. Web. 06 Oct. 2014. &amp;lt;/ref&amp;gt; have also gained support of Mobile browsers in recent years through WebDriver.  However, there is the obvious limitation that one can only test a browser which is supported on the running platform.  In other words, Safari and Internet explorer can only be tested on  OS X and Windows environments, respectively**.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;**&amp;lt;/nowiki&amp;gt; &amp;lt;span style=&amp;quot;font-size:88%&amp;quot;&amp;gt;Some work-arounds or programs may exist to allow these browsers to be tested on other platforms. Here, we are assuming no special additional configuration - just the base operating system and browsers.  With virtualization technologies such as [http://www.linux-kvm.org/page/Main_Page KVM], [https://www.virtualbox.org/ VirtualBox], and [http://en.wikipedia.org/wiki/Comparison_of_platform_virtualization_software others], this isn't a problem anyway.  [http://en.wikipedia.org/wiki/Virtual_machine Virtual machines] can be created with any operating system, as needed.&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Cross-Platform Support====&lt;br /&gt;
Both Watir and Selenium run on most popular distributions of Windows, Mac, and Linux.  Selenium doesn't have a list of officially supported operating system versions.  Instead they generally support any version that is currently popular.  Only a few versions are listed which they run test builds on.  These are versions which are officially known to work, but many more are supported as well.&lt;br /&gt;
&lt;br /&gt;
Because Watir is a collection of Ruby Gems, it runs on any platform that Ruby runs on.  Like Selenium, this includes nearly all popular platforms.&lt;br /&gt;
&lt;br /&gt;
=='''Getting started'''==&lt;br /&gt;
===Selenium WebDriver=== &lt;br /&gt;
----&lt;br /&gt;
====Install/Configure (Java)====&lt;br /&gt;
Configuring Selenium requires you to download the binaries from [http://www.seleniumhq.org/download/ here]. &lt;br /&gt;
Once you have all your binaries in a directory, you can open any IDE of your choice and add this directory with all the .jar files to the CLASSPATH&lt;br /&gt;
*Example&lt;br /&gt;
This is how a typical Selenium code to find the term say, “Automation” on Google and display the results on the page would look like in Java using the [https://code.google.com/p/selenium/wiki/HtmlUnitDriver HtmlUnitDriver] would look like.&lt;br /&gt;
The HtmlUnitDriver is a pure Java driver that runs entirely in-memory. Because of this, you won't see a new browser window open &amp;lt;ref&amp;gt;[https://code.google.com/p/selenium/wiki/GettingStarted Getting started with Selenium]. Selenium: Browser Automation Framework. Google Code. 8 Feb, 2014.&amp;lt;/ref&amp;gt;,&lt;br /&gt;
&lt;br /&gt;
       package org.selenium.example;&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;
       import org.openqa.selenium.By;&lt;br /&gt;
       import org.openqa.selenium.WebDriver;&lt;br /&gt;
       import org.openqa.selenium.WebElement;&lt;br /&gt;
       import org.openqa.selenium.htmlunit.HtmlUnitDriver;&amp;lt;br /&amp;gt;&lt;br /&gt;
       public class Example  {&lt;br /&gt;
       public static void main(String[] args) {&lt;br /&gt;
        // Create a new instance of the html unit driver&lt;br /&gt;
        // Notice that the remainder of the code relies on the interface,&lt;br /&gt;
        // not the implementation.&lt;br /&gt;
        WebDriver driver = new HtmlUnitDriver();&amp;lt;br /&amp;gt;&lt;br /&gt;
        // And now use this to visit Google&lt;br /&gt;
        driver.get(&amp;quot;http://www.google.com&amp;quot;);&amp;lt;br /&amp;gt;&lt;br /&gt;
        // Find the text input element by its name&lt;br /&gt;
        WebElement element = driver.findElement(By.name(&amp;quot;q&amp;quot;));&amp;lt;br /&amp;gt;&lt;br /&gt;
        // Enter something to search for&lt;br /&gt;
        element.sendKeys(&amp;quot;Automation!&amp;quot;);&amp;lt;br /&amp;gt;&lt;br /&gt;
        // Now submit the form. WebDriver will find the form for us from the element&lt;br /&gt;
        element.submit();&amp;lt;br /&amp;gt;&lt;br /&gt;
        // Check the title of the page&lt;br /&gt;
        System.out.println(&amp;quot;Page title is: &amp;quot; + driver.getTitle());&lt;br /&gt;
        driver.quit();&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
If you compile and run it, you should see a line with the title of the Google search results as output.&lt;br /&gt;
&lt;br /&gt;
====Install/Configure for other languages====&lt;br /&gt;
Configuring Selenium for languages other than Java and for other development environments can be looked up [http://docs.seleniumhq.org/docs/03_webdriver.jsp#setting-up-a-selenium-webdriver-project here]. viz(C#, Ruby, Python, PHP, Perl, Javascript)&lt;br /&gt;
&lt;br /&gt;
===Watir===&lt;br /&gt;
----&lt;br /&gt;
====Install/Configure (Ruby)====&lt;br /&gt;
Drivers for Watir are installed as gems which are nothing but Ruby libraries which can be accessed over the internet.&lt;br /&gt;
All the instructions for installing Watir on various operating systems (viz. Windows, Mac OS, Linux) can be found [http://watir.com/installation/ here].&lt;br /&gt;
&lt;br /&gt;
*Example:&lt;br /&gt;
This is how a typical Watir code to find the term say, “Automation” on Google and display the results on the page would look like using Ruby&amp;lt;ref&amp;gt;Chernenko, Iryna. [http://blog.qatestlab.com/2011/02/23/automated-testing-with-watir-tutorial-for-begginers-part-1/ Watir Example]. QATestLab Blog: Automated Testing with Watir, 23 Feb 2011.&lt;br /&gt;
&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
        # Required in ruby 1.8.7&lt;br /&gt;
        require 'rubygems'&lt;br /&gt;
        # Watir IE driver&lt;br /&gt;
        require 'watir'&amp;lt;br /&amp;gt; &lt;br /&gt;
        ie = Watir::IE.new&amp;lt;br /&amp;gt; &lt;br /&gt;
        # text to show on console&lt;br /&gt;
        puts &amp;quot;Beginning of the test for Google search engine&amp;quot;&lt;br /&gt;
        puts &amp;quot;Step 1:  Go to the Google homepage&amp;quot;&lt;br /&gt;
        ie.goto &amp;quot;http://www.google.com&amp;quot;&amp;lt;br /&amp;gt;&lt;br /&gt;
        #set a variable&lt;br /&gt;
        search_text = &amp;quot;Automation&amp;quot;&lt;br /&gt;
        puts &amp;quot;Step 2: enter &amp;quot;+ search_text +&amp;quot; in the search text field.&amp;quot;&lt;br /&gt;
        ie.text_field(:name, &amp;quot;q&amp;quot;).set search_text   # &amp;quot;q&amp;quot; is the name of the search field&amp;lt;br /&amp;gt;&lt;br /&gt;
        puts &amp;quot; Step 3: click the 'Google Search' button.&amp;quot;&lt;br /&gt;
        ie.button(:name, &amp;quot;btnG&amp;quot;).click # &amp;quot;btnG&amp;quot; is the name of the Search button&amp;lt;br /&amp;gt;&lt;br /&gt;
        puts &amp;quot; Expected Result:&amp;quot;&lt;br /&gt;
        puts &amp;quot;  A Google page with results should be shown. 'Watir, pronounced water' should be high on the list.&amp;quot;&lt;br /&gt;
        puts &amp;quot; Actual Result:&amp;quot;&lt;br /&gt;
        if ie.text.include? &amp;quot;Watir, pronounced water&amp;quot;	&lt;br /&gt;
             puts &amp;quot;  Test Passed. Found the text string: 'Watir, pronounced water'. Actual Results match Expected Results.&amp;quot;&lt;br /&gt;
        else	&lt;br /&gt;
 	     puts &amp;quot;  Test Failed! Could not find text: 'Watir, pronounced water'.&amp;quot;&lt;br /&gt;
        end&lt;br /&gt;
        puts &amp;quot;End of test: Google search.&amp;quot;&lt;br /&gt;
        ie.close&lt;br /&gt;
&lt;br /&gt;
On compiling and running this and passing the test, you will see something like, &amp;lt;br /&amp;gt; &lt;br /&gt;
&lt;br /&gt;
        ''Output:''&lt;br /&gt;
        Beginning of the test for Google search engine &amp;lt;br /&amp;gt;&lt;br /&gt;
        Step 1:  Go to the Google homepage &amp;lt;br /&amp;gt;&lt;br /&gt;
        Step 2: enter Automation in the search text field. &amp;lt;br /&amp;gt;&lt;br /&gt;
        Step 3: click the 'Google Search' button. &amp;lt;br /&amp;gt;&lt;br /&gt;
        Expected Result: &amp;lt;br /&amp;gt;&lt;br /&gt;
        A Google page with results should be shown. 'Watir, pronounced water' should be high on the list. &amp;lt;br /&amp;gt;	&lt;br /&gt;
        Test Passed. Found the text string: 'Watir, pronounced water'. Actual Results match Expected Results. &amp;lt;br /&amp;gt;&lt;br /&gt;
        End of test: Google search. &amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Similar Tools==&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Sahi_(software) Sahi], uses the Sahi Scripting Language&amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Soatest SOATest], for testing and validating [http://en.wikipedia.org/wiki/Application_programming_interface API] driven applications &amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/TestComplete TestComplete], for Desktops, Web and Mobile&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
* [http://www.hiretheworld.com/blog/tech-blog/migrating-unit-tests-from-selenium-to-watir-webdriver Migrating unit tests from Selenium to Watir Web Driver] &amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://www.hiretheworld.com/blog/tech-blog/migrating-unit-tests-from-selenium-to-watir-webdriver Learning Selenium IDE] &amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/List_of_web_testing_tools List of web testing tools] &amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/List_of_web_testing_tools OWASP List of Acceptance Testing tools]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
{{reflist}}&lt;br /&gt;
&amp;lt;references /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==External Links==&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Selenium_(software) Selenium Wiki Page] &amp;lt;br /&amp;gt;&lt;br /&gt;
* [https://github.com/SeleniumHQ/selenium Selenium Source Code] &amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Watir Watir Wiki Page] &amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Watir Watir Source Code] &amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Watir SauceLabs HomePage] &amp;lt;br /&amp;gt;&lt;/div&gt;</summary>
		<author><name>Jjbeaver</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/ch1b_27_js&amp;diff=89443</id>
		<title>CSC/ECE 517 Fall 2014/ch1b 27 js</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/ch1b_27_js&amp;diff=89443"/>
		<updated>2014-10-07T04:16:38Z</updated>

		<summary type="html">&lt;p&gt;Jjbeaver: /* Cross-Browser and Headless Browser Support */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;='''Selenium vs. Watir'''=&lt;br /&gt;
&lt;br /&gt;
Developing web applications is proving to be a challenging task with each passing day given the complex requirements and the demanding nature of the these applications. For the web applications to be robust we need to put in place some good testing strategies.&lt;br /&gt;
&lt;br /&gt;
'''''Selenium''''' is one of the most popularly used open source automation tools for web based applications. It is a JavaScript framework that runs in your web browser to interact with various elements in your browser. All in all, Selenium is a set of different software tools each with a different approach to supporting test automation. Selenium provides a rich set of testing functions that can be customized to suit the testing requirements.&lt;br /&gt;
 &lt;br /&gt;
'''''Watir''''', is another lightweight automation testing tool that is widely used for web app testing. It is an open-source ([http://en.wikipedia.org/wiki/BSD_licenses BSD])  family of Ruby libraries for automating web browsers. It allows you to write tests that are easy to read and maintain. Despite the fact that it is a set of Ruby libraries, it works perfectly, independent of the language that the web application is developed in. Watir as a tool is extremely simple and flexible.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=='''Motivation'''==&lt;br /&gt;
===Need for test automation===&lt;br /&gt;
With the majority of software applications today being implemented as [http://en.wikipedia.org/wiki/Web_application web applications] to be used over the internet, testing is becoming an indispensable part of the software development lifecycle ([http://en.wikipedia.org/wiki/Software_development_process SDLC]) of these applications. [http://en.wikipedia.org/wiki/Test_automation Test automation] is used where manual testing needs to be carried out repeatedly making it a cumbersome task. Test automation uses a software tool for this purpose on the application to be tested. It has proven to be highly efficient and critical in larger software development companies. Additionally, automation can be a valuable way to make Test Driven Development ([http://en.wikipedia.org/wiki/Test-driven_development TDD]) tasks an important part of the software development workflow.&lt;br /&gt;
 &lt;br /&gt;
Test Automation has a number of advantages mostly dealing with repetitiveness of the tests and the time taken,&lt;br /&gt;
* '''Covers cases that manual testing probably cannot'''&lt;br /&gt;
# Finds defects missed out my manual testing&lt;br /&gt;
# Automated testing can simulate numerous virtual users interacting with the web software/application&lt;br /&gt;
* '''Helps save time and money'''&lt;br /&gt;
# Once created, automated tests can be executed repeatedly at no additional   costs and at a much faster pace. Saving time directly translates into saving cost.&lt;br /&gt;
# Supports virtually unlimited iterations of test case execution&lt;br /&gt;
* '''Increase test coverage and accuracy'''&lt;br /&gt;
# Automated tests perform the exact same steps and records all details precisely&lt;br /&gt;
# They also increase the depth and scope of tests to improve the quality of the software&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=='''Brief History'''==&lt;br /&gt;
====Selenium====&lt;br /&gt;
&lt;br /&gt;
[[File: SE-logo.png|right|Selenium Logo|link=http://www.seleniumhq.org/images/big-logo.png]]&lt;br /&gt;
&lt;br /&gt;
''Selenium'' was developed in the year 2004 by Jason Huggins and has been continuously evolving ever since. Jason Huggins developed this as an internal tool for [http://en.wikipedia.org/wiki/ThoughtWorks ThoughtWorks] as a javascript library which came to be known as the Selenium core. Selenium core is now the basis of the Selenium Remote Control (the server) and Selenium IDE.&lt;br /&gt;
The year 2006 marked the beginning of the development of the WebDriver project which was what they believed ‘a tool of the future’. The WebDriver was initiated to solve the problems that were faced due to the fact that Selenium was a based on JavaScript and a lot of security limitations browsers apply to Javascript.&lt;br /&gt;
In 2008, both Selenium and WebDriver merged to provide a common set of features to all users which is called Selenium 2..&lt;br /&gt;
Simon Stewart, the creator of WebDriver, in a joint email to the WebDriver and Selenium community on August 6, 2009 said the following,&lt;br /&gt;
&lt;br /&gt;
“Why are the projects merging? Partly because webdriver addresses some shortcomings in selenium (by being able to bypass the JS sandbox, for example. And we’ve got a gorgeous API), partly because selenium addresses some shortcomings in webdriver (such as supporting a broader range of browsers) and partly because the main selenium contributors and I felt that it was the best way to offer users the best possible framework.”&amp;lt;ref name =&amp;quot;Introduction to Selenium&amp;quot;&amp;gt;[http://docs.seleniumhq.org/docs/01_introducing_selenium.jsp#selenium-history Introducing Selenium]. ''SeleniumHQ: Browser Automation''. Selenium Project, 4 Oct. 2014. Web. 06 Oct. 2014.&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Watir====&lt;br /&gt;
&lt;br /&gt;
''Watir'' started as a library to teach testers to write ruby code and grew to be an IE implementation which now supports IE, Firefox, Safari, Google Chrome and Opera.&lt;br /&gt;
Watir was primarily developed by Bret Pettichord and Paul Rogers. Watir has since then has a couple of stable releases for Watir classic as well as Watir WebDriver. The most recent releases being&amp;lt;ref&amp;gt;[http://watir.com/category/releases/ Watir Releases]. Watir: Web Application Testing in Ruby. 28 April, 2013&amp;lt;/ref&amp;gt;, &lt;br /&gt;
&lt;br /&gt;
[[File: Watir.gif|right|Watir logo|link=http://upload.wikimedia.org/wikipedia/commons/7/7e/Watir.gif]]&lt;br /&gt;
&lt;br /&gt;
* Watir-Classic	    &lt;br /&gt;
# 0.6.3 April 10, 2013 ([https://github.com/watir/watir-webdriver/blob/master/CHANGES.md#063 Release Notes]) &amp;lt;br /&amp;gt;&lt;br /&gt;
* Watir-WebDriver	    &lt;br /&gt;
# 3.6.0 March 16, 2013 ([https://groups.google.com/forum/#!msg/watir-general/MOOun5g3Hvg/JBVNy957lDYJ Release Notes]) &amp;lt;br /&amp;gt;&lt;br /&gt;
# 3.5.0 March 10, 2013 ([https://groups.google.com/forum/#!msg/watir-general/aeUqsglvK6k/Kq7FCBiERjYJ Release Notes]) &amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Watir has a google group ([https://groups.google.com/forum/#!forum/watir-general Watir General]) for its support and contribution while Selenium also has a [http://seleniumforum.forumotion.net/ Selenium forum] apart from its google group called [https://groups.google.com/forum/#!forum/selenium-users Selenium Users].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=='''Comparison of Features, Functionality, and More'''==&lt;br /&gt;
Some features or functionality may be repeated here.  However, we will go into a bit more detail than previously mentioned.&lt;br /&gt;
===='''Open Source'''====&lt;br /&gt;
Both Selenium and Watir are [http://en.wikipedia.org/wiki/Open-source_software open source]!  This allows for greater extensibility and a deeper understanding of the inner workings of both of the frameworks, if the developer/tester chooses to delve into such details.  Additionally, the open source community allows for a more transparent, user-driven development and support cycle.  Users (the tester/developer) can choose to submit bug fixes or enhancements as patches, or they can choose to just use it “straight out of the box.”&lt;br /&gt;
&lt;br /&gt;
====Application Language Agnostic====&lt;br /&gt;
&lt;br /&gt;
Both Selenium and Watir are application language agnostic.  Because both Selenium and Watir test UI functionality in the browser, they can be used to test any web application.    &lt;br /&gt;
&lt;br /&gt;
====Language-specific Test Cases====&lt;br /&gt;
&lt;br /&gt;
Both Selenium and Watir require test cases to be written in some programming language.  Traditionally, both frameworks had limited choices in terms of language bindings.  However, with the advent of WebDriver, both became much more flexible.  WebDriver provided the bindings needed for many languages.  Today, the following are supported:&lt;br /&gt;
&lt;br /&gt;
'''Selenium*'''&lt;br /&gt;
&lt;br /&gt;
* Officially-supported: [http://en.wikipedia.org/wiki/Java_(programming_language) Java], [http://en.wikipedia.org/wiki/C_Sharp_(programming_language) C#], [http://en.wikipedia.org/wiki/Ruby_(programming_language) Ruby], [http://en.wikipedia.org/wiki/Python_(programming_language) Python], [http://en.wikipedia.org/wiki/Node.js Javascript/Node.js]&lt;br /&gt;
&lt;br /&gt;
* Unofficial/community-supported: [http://en.wikipedia.org/wiki/Perl Perl], [http://en.wikipedia.org/wiki/PHP PHP], [http://en.wikipedia.org/wiki/Haskell_(programming_language) Haskell], [http://en.wikipedia.org/wiki/Objective-C Objective-C], [http://en.wikipedia.org/wiki/R_(programming_language) R], [http://en.wikipedia.org/wiki/Dart_(programming_language) Dart], [http://en.wikipedia.org/wiki/Tcl Tcl]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;According to SeleniumHQ’s download page.&lt;br /&gt;
&lt;br /&gt;
'''Watir'''&lt;br /&gt;
&lt;br /&gt;
Unfortunately (or fortunately), Ruby is the only supported language for Watir.  After all, Watir does stand for “Web Application Testing in Ruby.” However, there are other frameworks which were inspired by Watir (but entirely separate) available in Java and C# - Watij and Watin,  respectively &amp;lt;ref&amp;gt;Djorgjievski, Darko. [http://www.sitepoint.com/watir-webdriver-control-browser/ Watir-WebDriver: Control the Browser]. ''SitePoint''. SitePoint Pty Ltd, 18 Apr. 2014. Web. 05 Oct. 2014.&amp;lt;/ref&amp;gt;.  There may be other similarly inspired frameworks available in other languages, but these are the most notable.&lt;br /&gt;
&lt;br /&gt;
====Cross-Browser and Headless Browser Support====&lt;br /&gt;
&lt;br /&gt;
[[File: watir_meet_webdriver.png | Watir Meets WebDriver |right|frame| link=http://yuml.me/diagram/scruffy/usecase/%5BTester%5D-%28Watir%20API%29,%20%28Watir%20API%29%3C%28FireWatir%29,%20%28Watir%20API%29%3C%28Watir%29,%20%28Watir%20API%29%3C%28SafariWatir%29,%20%28Watir%20API%29%3C%28Webdriver%29,%20%28Watir%20API%29%3C%28Celerity%29,%20%28Celerity%29-%28note:%20Celerity%20requires%20JRuby%29,%20%28Celerity%29-%28headless%29,%20%28Webdriver%29-%28Firefox%29,%20%28Webdriver%29-%28Chrome%29,%20%28Webdriver%29-%28IE%29,%20%28Webdriver%29-%28headless%29,%20%28FireWatir%29-%28Firefox%29,%20%28Watir%29-%28IE%29,%20%28SafariWatir%29-%28Safari%29.]]&lt;br /&gt;
&lt;br /&gt;
Traditionally, both Selenium and Watir were limited in the number of browsers they supported. Watir originally supported Internet Explorer and headless browsers exclusively.  Headless browsers were supported via the use of [https://github.com/jarib/celerity Celerity] &amp;lt;ref&amp;gt;Scott, Alister. [http://watirmelon.com/2010/04/10/watir-selenium-webdriver/ Watir, Selenium &amp;amp; WebDriver]. ''Watirmelon''. Watirmelon, 10 Apr. 2010. Web. 05 Oct. 2014.&amp;lt;/ref&amp;gt;.  Selenium started out as a Javascript library, so naturally it supported more browsers such as IE, Firefox, Safari, etc &amp;lt;ref name = &amp;quot;Introduction to Selenium&amp;quot; /&amp;gt;.  However, it did not support headless browsers.&lt;br /&gt;
Today, browser support looks much better for both Selenium and Watir, largely due to the introduction of WebDriver.  With WebDriver in existence, support for most browsers was added to Watir via the gem &amp;quot;watir-webdriver,&amp;quot; and Celerity became [https://github.com/jarib/celerity obsolete] because headless browser support was included in WebDriver.  Similarly for Selenium, support for headless browsers was added, as well as making the API much simpler and more concise &amp;lt;ref&amp;gt;[http://docs.seleniumhq.org/projects/webdriver/ Selenium WebDriver]. ''SeleniumHQ: Browser Automation''. Selenium Project, n.d. Web. 06 Oct. 2014.&amp;lt;/ref&amp;gt;.  Both &amp;lt;ref&amp;gt;Semerau, Luke. [https://code.google.com/p/selenium/wiki/WebDriverForMobileBrowsers Selenium]. ''Selenium''. Google Project Hosting, 14 Jan. 2013. Web. 06 Oct. 2014 &amp;lt;/ref&amp;gt; and &amp;lt;ref&amp;gt;Scott, Alister. [http://watirwebdriver.com/mobile-devices/ Watir]. ''Watir WebDriver''. n.d. Web. 06 Oct. 2014. &amp;lt;/ref&amp;gt; have also gained support of Mobile browsers in recent years through WebDriver.  However, there is the obvious limitation that one can only test a browser which is supported on the running platform.  In other words, Safari and Internet explorer can only be tested on  OS X and Windows environments, respectively**.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;**&amp;lt;/nowiki&amp;gt; &amp;lt;span style=&amp;quot;font-size:88%&amp;quot;&amp;gt;Some work-arounds or programs may exist to allow these browsers to be tested on other platforms. Here, we are assuming no special additional configuration - just the base operating system and browsers.  With virtualization technologies such as [http://www.linux-kvm.org/page/Main_Page KVM], [https://www.virtualbox.org/ VirtualBox], and [http://en.wikipedia.org/wiki/Comparison_of_platform_virtualization_software others], this isn't a problem anyway.  [http://en.wikipedia.org/wiki/Virtual_machine Virtual machines] can be created with any operating system, as needed.&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Cross-Platform Support====&lt;br /&gt;
Both Watir and Selenium run on most popular distributions of Windows, Mac, and Linux.  Selenium doesn't have a list of officially supported operating system versions.  Instead they generally support any version that is currently popular.  Only a few versions are listed which they run test builds on.  These are versions which are officially known to work, but many more are supported as well.&lt;br /&gt;
&lt;br /&gt;
Because Watir is a collection of Ruby Gems, it runs on any platform that Ruby runs on.  Like Selenium, this includes nearly all popular platforms.&lt;br /&gt;
&lt;br /&gt;
=='''Getting started'''==&lt;br /&gt;
===Selenium WebDriver=== &lt;br /&gt;
----&lt;br /&gt;
====Install/Configure (Java)====&lt;br /&gt;
Configuring Selenium requires you to download the binaries from [http://www.seleniumhq.org/download/ here]. &lt;br /&gt;
Once you have all your binaries in a directory, you can open any IDE of your choice and add this directory with all the .jar files to the CLASSPATH&lt;br /&gt;
*Example&lt;br /&gt;
This is how a typical Selenium code to find the term say, “Automation” on Google and display the results on the page would look like in Java using the [https://code.google.com/p/selenium/wiki/HtmlUnitDriver HtmlUnitDriver] would look like.&lt;br /&gt;
The HtmlUnitDriver is a pure Java driver that runs entirely in-memory. Because of this, you won't see a new browser window open &amp;lt;ref&amp;gt;[https://code.google.com/p/selenium/wiki/GettingStarted Getting started with Selenium]. Selenium: Browser Automation Framework. Google Code. 8 Feb, 2014.&amp;lt;/ref&amp;gt;,&lt;br /&gt;
&lt;br /&gt;
       package org.selenium.example;&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;
       import org.openqa.selenium.By;&lt;br /&gt;
       import org.openqa.selenium.WebDriver;&lt;br /&gt;
       import org.openqa.selenium.WebElement;&lt;br /&gt;
       import org.openqa.selenium.htmlunit.HtmlUnitDriver;&amp;lt;br /&amp;gt;&lt;br /&gt;
       public class Example  {&lt;br /&gt;
       public static void main(String[] args) {&lt;br /&gt;
        // Create a new instance of the html unit driver&lt;br /&gt;
        // Notice that the remainder of the code relies on the interface,&lt;br /&gt;
        // not the implementation.&lt;br /&gt;
        WebDriver driver = new HtmlUnitDriver();&amp;lt;br /&amp;gt;&lt;br /&gt;
        // And now use this to visit Google&lt;br /&gt;
        driver.get(&amp;quot;http://www.google.com&amp;quot;);&amp;lt;br /&amp;gt;&lt;br /&gt;
        // Find the text input element by its name&lt;br /&gt;
        WebElement element = driver.findElement(By.name(&amp;quot;q&amp;quot;));&amp;lt;br /&amp;gt;&lt;br /&gt;
        // Enter something to search for&lt;br /&gt;
        element.sendKeys(&amp;quot;Automation!&amp;quot;);&amp;lt;br /&amp;gt;&lt;br /&gt;
        // Now submit the form. WebDriver will find the form for us from the element&lt;br /&gt;
        element.submit();&amp;lt;br /&amp;gt;&lt;br /&gt;
        // Check the title of the page&lt;br /&gt;
        System.out.println(&amp;quot;Page title is: &amp;quot; + driver.getTitle());&lt;br /&gt;
        driver.quit();&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
If you compile and run it, you should see a line with the title of the Google search results as output.&lt;br /&gt;
&lt;br /&gt;
====Install/Configure for other languages====&lt;br /&gt;
Configuring Selenium for languages other than Java and for other development environments can be looked up [http://docs.seleniumhq.org/docs/03_webdriver.jsp#setting-up-a-selenium-webdriver-project here]. viz(C#, Ruby, Python, PHP, Perl, Javascript)&lt;br /&gt;
&lt;br /&gt;
===Watir===&lt;br /&gt;
----&lt;br /&gt;
====Install/Configure (Ruby)====&lt;br /&gt;
Drivers for Watir are installed as gems which are nothing but Ruby libraries which can be accessed over the internet.&lt;br /&gt;
All the instructions for installing Watir on various operating systems (viz. Windows, Mac OS, Linux) can be found [http://watir.com/installation/ here].&lt;br /&gt;
&lt;br /&gt;
*Example:&lt;br /&gt;
This is how a typical Watir code to find the term say, “Automation” on Google and display the results on the page would look like using Ruby&amp;lt;ref&amp;gt;Chernenko, Iryna. [http://blog.qatestlab.com/2011/02/23/automated-testing-with-watir-tutorial-for-begginers-part-1/ Watir Example]. QATestLab Blog: Automated Testing with Watir, 23 Feb 2011.&lt;br /&gt;
&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
        # Required in ruby 1.8.7&lt;br /&gt;
        require 'rubygems'&lt;br /&gt;
        # Watir IE driver&lt;br /&gt;
        require 'watir'&amp;lt;br /&amp;gt; &lt;br /&gt;
        ie = Watir::IE.new&amp;lt;br /&amp;gt; &lt;br /&gt;
        # text to show on console&lt;br /&gt;
        puts &amp;quot;Beginning of the test for Google search engine&amp;quot;&lt;br /&gt;
        puts &amp;quot;Step 1:  Go to the Google homepage&amp;quot;&lt;br /&gt;
        ie.goto &amp;quot;http://www.google.com&amp;quot;&amp;lt;br /&amp;gt;&lt;br /&gt;
        #set a variable&lt;br /&gt;
        search_text = &amp;quot;Automation&amp;quot;&lt;br /&gt;
        puts &amp;quot;Step 2: enter &amp;quot;+ search_text +&amp;quot; in the search text field.&amp;quot;&lt;br /&gt;
        ie.text_field(:name, &amp;quot;q&amp;quot;).set search_text   # &amp;quot;q&amp;quot; is the name of the search field&amp;lt;br /&amp;gt;&lt;br /&gt;
        puts &amp;quot; Step 3: click the 'Google Search' button.&amp;quot;&lt;br /&gt;
        ie.button(:name, &amp;quot;btnG&amp;quot;).click # &amp;quot;btnG&amp;quot; is the name of the Search button&amp;lt;br /&amp;gt;&lt;br /&gt;
        puts &amp;quot; Expected Result:&amp;quot;&lt;br /&gt;
        puts &amp;quot;  A Google page with results should be shown. 'Watir, pronounced water' should be high on the list.&amp;quot;&lt;br /&gt;
        puts &amp;quot; Actual Result:&amp;quot;&lt;br /&gt;
        if ie.text.include? &amp;quot;Watir, pronounced water&amp;quot;	&lt;br /&gt;
             puts &amp;quot;  Test Passed. Found the text string: 'Watir, pronounced water'. Actual Results match Expected Results.&amp;quot;&lt;br /&gt;
        else	&lt;br /&gt;
 	     puts &amp;quot;  Test Failed! Could not find text: 'Watir, pronounced water'.&amp;quot;&lt;br /&gt;
        end&lt;br /&gt;
        puts &amp;quot;End of test: Google search.&amp;quot;&lt;br /&gt;
        ie.close&lt;br /&gt;
&lt;br /&gt;
On compiling and running this and passing the test, you will see something like, &amp;lt;br /&amp;gt; &lt;br /&gt;
&lt;br /&gt;
        ''Output:''&lt;br /&gt;
        Beginning of the test for Google search engine &amp;lt;br /&amp;gt;&lt;br /&gt;
        Step 1:  Go to the Google homepage &amp;lt;br /&amp;gt;&lt;br /&gt;
        Step 2: enter Automation in the search text field. &amp;lt;br /&amp;gt;&lt;br /&gt;
        Step 3: click the 'Google Search' button. &amp;lt;br /&amp;gt;&lt;br /&gt;
        Expected Result: &amp;lt;br /&amp;gt;&lt;br /&gt;
        A Google page with results should be shown. 'Watir, pronounced water' should be high on the list. &amp;lt;br /&amp;gt;	&lt;br /&gt;
        Test Passed. Found the text string: 'Watir, pronounced water'. Actual Results match Expected Results. &amp;lt;br /&amp;gt;&lt;br /&gt;
        End of test: Google search. &amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Similar Tools==&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Sahi_(software) Sahi], uses the Sahi Scripting Language&amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Soatest SOATest], for testing and validating [http://en.wikipedia.org/wiki/Application_programming_interface API] driven applications &amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/TestComplete TestComplete], for Desktops, Web and Mobile&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
* [http://www.hiretheworld.com/blog/tech-blog/migrating-unit-tests-from-selenium-to-watir-webdriver Migrating unit tests from Selenium to Watir Web Driver] &amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://www.hiretheworld.com/blog/tech-blog/migrating-unit-tests-from-selenium-to-watir-webdriver Learning Selenium IDE] &amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/List_of_web_testing_tools List of web testing tools] &amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/List_of_web_testing_tools OWASP List of Acceptance Testing tools]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
{{reflist}}&lt;br /&gt;
&amp;lt;references /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==External Links==&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Selenium_(software) Selenium Wiki Page] &amp;lt;br /&amp;gt;&lt;br /&gt;
* [https://github.com/SeleniumHQ/selenium Selenium Source Code] &amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Watir Watir Wiki Page] &amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Watir Watir Source Code] &amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Watir SauceLabs HomePage] &amp;lt;br /&amp;gt;&lt;/div&gt;</summary>
		<author><name>Jjbeaver</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/ch1b_27_js&amp;diff=89440</id>
		<title>CSC/ECE 517 Fall 2014/ch1b 27 js</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/ch1b_27_js&amp;diff=89440"/>
		<updated>2014-10-07T03:56:25Z</updated>

		<summary type="html">&lt;p&gt;Jjbeaver: /* Cross-Browser and Headless Browser Support */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;='''Selenium vs. Watir'''=&lt;br /&gt;
&lt;br /&gt;
Developing web applications is proving to be a challenging task with each passing day given the complex requirements and the demanding nature of the these applications. For the web applications to be robust we need to put in place some good testing strategies.&lt;br /&gt;
&lt;br /&gt;
'''''Selenium''''' is one of the most popularly used open source automation tools for web based applications. It is a JavaScript framework that runs in your web browser to interact with various elements in your browser. All in all, Selenium is a set of different software tools each with a different approach to supporting test automation. Selenium provides a rich set of testing functions that can be customized to suit the testing requirements.&lt;br /&gt;
 &lt;br /&gt;
'''''Watir''''', is another lightweight automation testing tool that is widely used for web app testing. It is an open-source ([http://en.wikipedia.org/wiki/BSD_licenses BSD])  family of Ruby libraries for automating web browsers. It allows you to write tests that are easy to read and maintain. Despite the fact that it is a set of Ruby libraries, it works perfectly, independent of the language that the web application is developed in. Watir as a tool is extremely simple and flexible.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=='''Motivation'''==&lt;br /&gt;
===Need for test automation===&lt;br /&gt;
With the majority of software applications today being implemented as [http://en.wikipedia.org/wiki/Web_application web applications] to be used over the internet, testing is becoming an indispensable part of the software development lifecycle ([http://en.wikipedia.org/wiki/Software_development_process SDLC]) of these applications. [http://en.wikipedia.org/wiki/Test_automation Test automation] is used where manual testing needs to be carried out repeatedly making it a cumbersome task. Test automation uses a software tool for this purpose on the application to be tested. It has proven to be highly efficient and critical in larger software development companies. Additionally, automation can be a valuable way to make Test Driven Development ([http://en.wikipedia.org/wiki/Test-driven_development TDD]) tasks an important part of the software development workflow.&lt;br /&gt;
 &lt;br /&gt;
Test Automation has a number of advantages mostly dealing with repetitiveness of the tests and the time taken,&lt;br /&gt;
* '''Covers cases that manual testing probably cannot'''&lt;br /&gt;
# Finds defects missed out my manual testing&lt;br /&gt;
# Automated testing can simulate numerous virtual users interacting with the web software/application&lt;br /&gt;
* '''Helps save time and money'''&lt;br /&gt;
# Once created, automated tests can be executed repeatedly at no additional   costs and at a much faster pace. Saving time directly translates into saving cost.&lt;br /&gt;
# Supports virtually unlimited iterations of test case execution&lt;br /&gt;
* '''Increase test coverage and accuracy'''&lt;br /&gt;
# Automated tests perform the exact same steps and records all details precisely&lt;br /&gt;
# They also increase the depth and scope of tests to improve the quality of the software&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=='''Brief History'''==&lt;br /&gt;
====Selenium====&lt;br /&gt;
&lt;br /&gt;
[[File: SE-logo.png|right|Selenium Logo|link=http://www.seleniumhq.org/images/big-logo.png]]&lt;br /&gt;
&lt;br /&gt;
''Selenium'' was developed in the year 2004 by Jason Huggins and has been continuously evolving ever since. Jason Huggins developed this as an internal tool for [http://en.wikipedia.org/wiki/ThoughtWorks ThoughtWorks] as a javascript library which came to be known as the Selenium core. Selenium core is now the basis of the Selenium Remote Control (the server) and Selenium IDE.&lt;br /&gt;
The year 2006 marked the beginning of the development of the WebDriver project which was what they believed ‘a tool of the future’. The WebDriver was initiated to solve the problems that were faced due to the fact that Selenium was a based on JavaScript and a lot of security limitations browsers apply to Javascript.&lt;br /&gt;
In 2008, both Selenium and WebDriver merged to provide a common set of features to all users which is called Selenium 2..&lt;br /&gt;
Simon Stewart, the creator of WebDriver, in a joint email to the WebDriver and Selenium community on August 6, 2009 said the following,&lt;br /&gt;
&lt;br /&gt;
“Why are the projects merging? Partly because webdriver addresses some shortcomings in selenium (by being able to bypass the JS sandbox, for example. And we’ve got a gorgeous API), partly because selenium addresses some shortcomings in webdriver (such as supporting a broader range of browsers) and partly because the main selenium contributors and I felt that it was the best way to offer users the best possible framework.”&amp;lt;ref name =&amp;quot;Introduction to Selenium&amp;quot;&amp;gt;[http://docs.seleniumhq.org/docs/01_introducing_selenium.jsp#selenium-history Introducing Selenium]. ''SeleniumHQ: Browser Automation''. Selenium Project, 4 Oct. 2014. Web. 06 Oct. 2014.&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Watir====&lt;br /&gt;
&lt;br /&gt;
''Watir'' started as a library to teach testers to write ruby code and grew to be an IE implementation which now supports IE, Firefox, Safari, Google Chrome and Opera.&lt;br /&gt;
Watir was primarily developed by Bret Pettichord and Paul Rogers. Watir has since then has a couple of stable releases for Watir classic as well as Watir WebDriver. The most recent releases being&amp;lt;ref&amp;gt;[http://watir.com/category/releases/ Watir Releases]. Watir: Web Application Testing in Ruby. 28 April, 2013&amp;lt;/ref&amp;gt;, &lt;br /&gt;
&lt;br /&gt;
[[File: Watir.gif|right|Watir logo|link=http://upload.wikimedia.org/wikipedia/commons/7/7e/Watir.gif]]&lt;br /&gt;
&lt;br /&gt;
* Watir-Classic	    &lt;br /&gt;
# 0.6.3 April 10, 2013 ([https://github.com/watir/watir-webdriver/blob/master/CHANGES.md#063 Release Notes]) &amp;lt;br /&amp;gt;&lt;br /&gt;
* Watir-WebDriver	    &lt;br /&gt;
# 3.6.0 March 16, 2013 ([https://groups.google.com/forum/#!msg/watir-general/MOOun5g3Hvg/JBVNy957lDYJ Release Notes]) &amp;lt;br /&amp;gt;&lt;br /&gt;
# 3.5.0 March 10, 2013 ([https://groups.google.com/forum/#!msg/watir-general/aeUqsglvK6k/Kq7FCBiERjYJ Release Notes]) &amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Watir has a google group ([https://groups.google.com/forum/#!forum/watir-general Watir General]) for its support and contribution while Selenium also has a [http://seleniumforum.forumotion.net/ Selenium forum] apart from its google group called [https://groups.google.com/forum/#!forum/selenium-users Selenium Users].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=='''Comparison of Features, Functionality, and More'''==&lt;br /&gt;
Some features or functionality may be repeated here.  However, we will go into a bit more detail than previously mentioned.&lt;br /&gt;
===='''Open Source'''====&lt;br /&gt;
Both Selenium and Watir are [http://en.wikipedia.org/wiki/Open-source_software open source]!  This allows for greater extensibility and a deeper understanding of the inner workings of both of the frameworks, if the developer/tester chooses to delve into such details.  Additionally, the open source community allows for a more transparent, user-driven development and support cycle.  Users (the tester/developer) can choose to submit bug fixes or enhancements as patches, or they can choose to just use it “straight out of the box.”&lt;br /&gt;
&lt;br /&gt;
====Application Language Agnostic====&lt;br /&gt;
&lt;br /&gt;
Both Selenium and Watir are application language agnostic.  Because both Selenium and Watir test UI functionality in the browser, they can be used to test any web application.    &lt;br /&gt;
&lt;br /&gt;
====Language-specific Test Cases====&lt;br /&gt;
&lt;br /&gt;
Both Selenium and Watir require test cases to be written in some programming language.  Traditionally, both frameworks had limited choices in terms of language bindings.  However, with the advent of WebDriver, both became much more flexible.  WebDriver provided the bindings needed for many languages.  Today, the following are supported:&lt;br /&gt;
&lt;br /&gt;
'''Selenium*'''&lt;br /&gt;
&lt;br /&gt;
* Officially-supported: [http://en.wikipedia.org/wiki/Java_(programming_language) Java], [http://en.wikipedia.org/wiki/C_Sharp_(programming_language) C#], [http://en.wikipedia.org/wiki/Ruby_(programming_language) Ruby], [http://en.wikipedia.org/wiki/Python_(programming_language) Python], [http://en.wikipedia.org/wiki/Node.js Javascript/Node.js]&lt;br /&gt;
&lt;br /&gt;
* Unofficial/community-supported: [http://en.wikipedia.org/wiki/Perl Perl], [http://en.wikipedia.org/wiki/PHP PHP], [http://en.wikipedia.org/wiki/Haskell_(programming_language) Haskell], [http://en.wikipedia.org/wiki/Objective-C Objective-C], [http://en.wikipedia.org/wiki/R_(programming_language) R], [http://en.wikipedia.org/wiki/Dart_(programming_language) Dart], [http://en.wikipedia.org/wiki/Tcl Tcl]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;According to SeleniumHQ’s download page.&lt;br /&gt;
&lt;br /&gt;
'''Watir'''&lt;br /&gt;
&lt;br /&gt;
Unfortunately (or fortunately), Ruby is the only supported language for Watir.  After all, Watir does stand for “Web Application Testing in Ruby.” However, there are other frameworks which were inspired by Watir (but entirely separate) available in Java and C# - Watij and Watin,  respectively &amp;lt;ref&amp;gt;Djorgjievski, Darko. [http://www.sitepoint.com/watir-webdriver-control-browser/ Watir-WebDriver: Control the Browser]. ''SitePoint''. SitePoint Pty Ltd, 18 Apr. 2014. Web. 05 Oct. 2014.&amp;lt;/ref&amp;gt;.  There may be other similarly inspired frameworks available in other languages, but these are the most notable.&lt;br /&gt;
&lt;br /&gt;
====Cross-Browser and Headless Browser Support====&lt;br /&gt;
&lt;br /&gt;
[[File: watir_meet_webdriver.png | Watir Meets WebDriver |right|frame| link=http://yuml.me/diagram/scruffy/usecase/%5BTester%5D-%28Watir%20API%29,%20%28Watir%20API%29%3C%28FireWatir%29,%20%28Watir%20API%29%3C%28Watir%29,%20%28Watir%20API%29%3C%28SafariWatir%29,%20%28Watir%20API%29%3C%28Webdriver%29,%20%28Watir%20API%29%3C%28Celerity%29,%20%28Celerity%29-%28note:%20Celerity%20requires%20JRuby%29,%20%28Celerity%29-%28headless%29,%20%28Webdriver%29-%28Firefox%29,%20%28Webdriver%29-%28Chrome%29,%20%28Webdriver%29-%28IE%29,%20%28Webdriver%29-%28headless%29,%20%28FireWatir%29-%28Firefox%29,%20%28Watir%29-%28IE%29,%20%28SafariWatir%29-%28Safari%29.]]&lt;br /&gt;
&lt;br /&gt;
Traditionally, both Selenium and Watir were limited in the number of browsers they supported. Watir originally supported Internet Explorer and headless browsers exclusively.  Headless browsers were supported via the use of [https://github.com/jarib/celerity Celerity] &amp;lt;ref&amp;gt;Scott, Alister. [http://watirmelon.com/2010/04/10/watir-selenium-webdriver/ Watir, Selenium &amp;amp; WebDriver]. ''Watirmelon''. Watirmelon, 10 Apr. 2010. Web. 05 Oct. 2014.&amp;lt;/ref&amp;gt;.  Selenium started out as a Javascript library, so naturally it supported more browsers such as IE, Firefox, Safari, etc &amp;lt;ref name = &amp;quot;Introduction to Selenium&amp;quot; /&amp;gt;.  However, it did not support headless browsers.&lt;br /&gt;
Today, browser support looks much better for both Selenium and Watir, largely due to the introduction of WebDriver.  With WebDriver in existence, support for most browsers was added to Watir via the gem &amp;quot;watir-webdriver,&amp;quot; and Celerity became [https://github.com/jarib/celerity obsolete] because headless browser support was included in WebDriver.  Similarly for Selenium, support for headless browsers was added, as well as making the API much simpler and more concise &amp;lt;ref&amp;gt;[http://docs.seleniumhq.org/projects/webdriver/ Selenium WebDriver]. ''SeleniumHQ: Browser Automation''. Selenium Project, n.d. Web. 06 Oct. 2014.&amp;lt;/ref&amp;gt;.  However, there is the obvious limitation that one can only test a browser which is supported on the running platform.  In other words, Safari and Internet explorer can only be tested on  OS X and Windows environments, respectively**.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;**&amp;lt;/nowiki&amp;gt; &amp;lt;span style=&amp;quot;font-size:88%&amp;quot;&amp;gt;Some work-arounds or programs may exist to allow these browsers to be tested on other platforms. Here, we are assuming no special additional configuration - just the base operating system and browsers.  With virtualization technologies such as [http://www.linux-kvm.org/page/Main_Page KVM], [https://www.virtualbox.org/ VirtualBox], and [http://en.wikipedia.org/wiki/Comparison_of_platform_virtualization_software others], this isn't a problem anyway.  [http://en.wikipedia.org/wiki/Virtual_machine Virtual machines] can be created with any operating system, as needed.&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Cross-Platform Support====&lt;br /&gt;
Both Watir and Selenium run on most popular distributions of Windows, Mac, and Linux.  Selenium doesn't have a list of officially supported operating system versions.  Instead they generally support any version that is currently popular.  Only a few versions are listed which they run test builds on.  These are versions which are officially known to work, but many more are supported as well.&lt;br /&gt;
&lt;br /&gt;
Because Watir is a collection of Ruby Gems, it runs on any platform that Ruby runs on.  Like Selenium, this includes nearly all popular platforms.&lt;br /&gt;
&lt;br /&gt;
=='''Getting started'''==&lt;br /&gt;
===Selenium WebDriver=== &lt;br /&gt;
----&lt;br /&gt;
====Install/Configure (Java)====&lt;br /&gt;
Configuring Selenium requires you to download the binaries from [http://www.seleniumhq.org/download/ here]. &lt;br /&gt;
Once you have all your binaries in a directory, you can open any IDE of your choice and add this directory with all the .jar files to the CLASSPATH&lt;br /&gt;
*Example&lt;br /&gt;
This is how a typical Selenium code to find the term say, “Automation” on Google and display the results on the page would look like in Java using the [https://code.google.com/p/selenium/wiki/HtmlUnitDriver HtmlUnitDriver] would look like.&lt;br /&gt;
The HtmlUnitDriver is a pure Java driver that runs entirely in-memory. Because of this, you won't see a new browser window open &amp;lt;ref&amp;gt;[https://code.google.com/p/selenium/wiki/GettingStarted Getting started with Selenium]. Selenium: Browser Automation Framework. Google Code. 8 Feb, 2014.&amp;lt;/ref&amp;gt;,&lt;br /&gt;
&lt;br /&gt;
       package org.selenium.example;&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;
       import org.openqa.selenium.By;&lt;br /&gt;
       import org.openqa.selenium.WebDriver;&lt;br /&gt;
       import org.openqa.selenium.WebElement;&lt;br /&gt;
       import org.openqa.selenium.htmlunit.HtmlUnitDriver;&amp;lt;br /&amp;gt;&lt;br /&gt;
       public class Example  {&lt;br /&gt;
       public static void main(String[] args) {&lt;br /&gt;
        // Create a new instance of the html unit driver&lt;br /&gt;
        // Notice that the remainder of the code relies on the interface,&lt;br /&gt;
        // not the implementation.&lt;br /&gt;
        WebDriver driver = new HtmlUnitDriver();&amp;lt;br /&amp;gt;&lt;br /&gt;
        // And now use this to visit Google&lt;br /&gt;
        driver.get(&amp;quot;http://www.google.com&amp;quot;);&amp;lt;br /&amp;gt;&lt;br /&gt;
        // Find the text input element by its name&lt;br /&gt;
        WebElement element = driver.findElement(By.name(&amp;quot;q&amp;quot;));&amp;lt;br /&amp;gt;&lt;br /&gt;
        // Enter something to search for&lt;br /&gt;
        element.sendKeys(&amp;quot;Automation!&amp;quot;);&amp;lt;br /&amp;gt;&lt;br /&gt;
        // Now submit the form. WebDriver will find the form for us from the element&lt;br /&gt;
        element.submit();&amp;lt;br /&amp;gt;&lt;br /&gt;
        // Check the title of the page&lt;br /&gt;
        System.out.println(&amp;quot;Page title is: &amp;quot; + driver.getTitle());&lt;br /&gt;
        driver.quit();&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
If you compile and run it, you should see a line with the title of the Google search results as output.&lt;br /&gt;
&lt;br /&gt;
====Install/Configure for other languages====&lt;br /&gt;
Configuring Selenium for languages other than Java and for other development environments can be looked up [http://docs.seleniumhq.org/docs/03_webdriver.jsp#setting-up-a-selenium-webdriver-project here]. viz(C#, Ruby, Python, PHP, Perl, Javascript)&lt;br /&gt;
&lt;br /&gt;
===Watir===&lt;br /&gt;
----&lt;br /&gt;
====Install/Configure (Ruby)====&lt;br /&gt;
Drivers for Watir are installed as gems which are nothing but Ruby libraries which can be accessed over the internet.&lt;br /&gt;
All the instructions for installing Watir on various operating systems (viz. Windows, Mac OS, Linux) can be found [http://watir.com/installation/ here].&lt;br /&gt;
&lt;br /&gt;
*Example:&lt;br /&gt;
This is how a typical Watir code to find the term say, “Automation” on Google and display the results on the page would look like using Ruby&amp;lt;ref&amp;gt;Chernenko, Iryna. [http://blog.qatestlab.com/2011/02/23/automated-testing-with-watir-tutorial-for-begginers-part-1/ Watir Example]. QATestLab Blog: Automated Testing with Watir, 23 Feb 2011.&lt;br /&gt;
&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
        # Required in ruby 1.8.7&lt;br /&gt;
        require 'rubygems'&lt;br /&gt;
        # Watir IE driver&lt;br /&gt;
        require 'watir'&amp;lt;br /&amp;gt; &lt;br /&gt;
        ie = Watir::IE.new&amp;lt;br /&amp;gt; &lt;br /&gt;
        # text to show on console&lt;br /&gt;
        puts &amp;quot;Beginning of the test for Google search engine&amp;quot;&lt;br /&gt;
        puts &amp;quot;Step 1:  Go to the Google homepage&amp;quot;&lt;br /&gt;
        ie.goto &amp;quot;http://www.google.com&amp;quot;&amp;lt;br /&amp;gt;&lt;br /&gt;
        #set a variable&lt;br /&gt;
        search_text = &amp;quot;Automation&amp;quot;&lt;br /&gt;
        puts &amp;quot;Step 2: enter &amp;quot;+ search_text +&amp;quot; in the search text field.&amp;quot;&lt;br /&gt;
        ie.text_field(:name, &amp;quot;q&amp;quot;).set search_text   # &amp;quot;q&amp;quot; is the name of the search field&amp;lt;br /&amp;gt;&lt;br /&gt;
        puts &amp;quot; Step 3: click the 'Google Search' button.&amp;quot;&lt;br /&gt;
        ie.button(:name, &amp;quot;btnG&amp;quot;).click # &amp;quot;btnG&amp;quot; is the name of the Search button&amp;lt;br /&amp;gt;&lt;br /&gt;
        puts &amp;quot; Expected Result:&amp;quot;&lt;br /&gt;
        puts &amp;quot;  A Google page with results should be shown. 'Watir, pronounced water' should be high on the list.&amp;quot;&lt;br /&gt;
        puts &amp;quot; Actual Result:&amp;quot;&lt;br /&gt;
        if ie.text.include? &amp;quot;Watir, pronounced water&amp;quot;	&lt;br /&gt;
             puts &amp;quot;  Test Passed. Found the text string: 'Watir, pronounced water'. Actual Results match Expected Results.&amp;quot;&lt;br /&gt;
        else	&lt;br /&gt;
 	     puts &amp;quot;  Test Failed! Could not find text: 'Watir, pronounced water'.&amp;quot;&lt;br /&gt;
        end&lt;br /&gt;
        puts &amp;quot;End of test: Google search.&amp;quot;&lt;br /&gt;
        ie.close&lt;br /&gt;
&lt;br /&gt;
On compiling and running this and passing the test, you will see something like, &amp;lt;br /&amp;gt; &lt;br /&gt;
&lt;br /&gt;
        ''Output:''&lt;br /&gt;
        Beginning of the test for Google search engine &amp;lt;br /&amp;gt;&lt;br /&gt;
        Step 1:  Go to the Google homepage &amp;lt;br /&amp;gt;&lt;br /&gt;
        Step 2: enter Automation in the search text field. &amp;lt;br /&amp;gt;&lt;br /&gt;
        Step 3: click the 'Google Search' button. &amp;lt;br /&amp;gt;&lt;br /&gt;
        Expected Result: &amp;lt;br /&amp;gt;&lt;br /&gt;
        A Google page with results should be shown. 'Watir, pronounced water' should be high on the list. &amp;lt;br /&amp;gt;	&lt;br /&gt;
        Test Passed. Found the text string: 'Watir, pronounced water'. Actual Results match Expected Results. &amp;lt;br /&amp;gt;&lt;br /&gt;
        End of test: Google search. &amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Similar Tools==&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Sahi_(software) Sahi], uses the Sahi Scripting Language&amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Soatest SOATest], for testing and validating [http://en.wikipedia.org/wiki/Application_programming_interface API] driven applications &amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/TestComplete TestComplete], for Desktops, Web and Mobile&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
* [http://www.hiretheworld.com/blog/tech-blog/migrating-unit-tests-from-selenium-to-watir-webdriver Migrating unit tests from Selenium to Watir Web Driver] &amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://www.hiretheworld.com/blog/tech-blog/migrating-unit-tests-from-selenium-to-watir-webdriver Learning Selenium IDE] &amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/List_of_web_testing_tools List of web testing tools] &amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/List_of_web_testing_tools OWASP List of Acceptance Testing tools]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
{{reflist}}&lt;br /&gt;
&amp;lt;references /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==External Links==&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Selenium_(software) Selenium Wiki Page] &amp;lt;br /&amp;gt;&lt;br /&gt;
* [https://github.com/SeleniumHQ/selenium Selenium Source Code] &amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Watir Watir Wiki Page] &amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Watir Watir Source Code] &amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Watir SauceLabs HomePage] &amp;lt;br /&amp;gt;&lt;/div&gt;</summary>
		<author><name>Jjbeaver</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/ch1b_27_js&amp;diff=89439</id>
		<title>CSC/ECE 517 Fall 2014/ch1b 27 js</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/ch1b_27_js&amp;diff=89439"/>
		<updated>2014-10-07T03:55:33Z</updated>

		<summary type="html">&lt;p&gt;Jjbeaver: /* Comparison of Features, Functionality, and More */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;='''Selenium vs. Watir'''=&lt;br /&gt;
&lt;br /&gt;
Developing web applications is proving to be a challenging task with each passing day given the complex requirements and the demanding nature of the these applications. For the web applications to be robust we need to put in place some good testing strategies.&lt;br /&gt;
&lt;br /&gt;
'''''Selenium''''' is one of the most popularly used open source automation tools for web based applications. It is a JavaScript framework that runs in your web browser to interact with various elements in your browser. All in all, Selenium is a set of different software tools each with a different approach to supporting test automation. Selenium provides a rich set of testing functions that can be customized to suit the testing requirements.&lt;br /&gt;
 &lt;br /&gt;
'''''Watir''''', is another lightweight automation testing tool that is widely used for web app testing. It is an open-source ([http://en.wikipedia.org/wiki/BSD_licenses BSD])  family of Ruby libraries for automating web browsers. It allows you to write tests that are easy to read and maintain. Despite the fact that it is a set of Ruby libraries, it works perfectly, independent of the language that the web application is developed in. Watir as a tool is extremely simple and flexible.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=='''Motivation'''==&lt;br /&gt;
===Need for test automation===&lt;br /&gt;
With the majority of software applications today being implemented as [http://en.wikipedia.org/wiki/Web_application web applications] to be used over the internet, testing is becoming an indispensable part of the software development lifecycle ([http://en.wikipedia.org/wiki/Software_development_process SDLC]) of these applications. [http://en.wikipedia.org/wiki/Test_automation Test automation] is used where manual testing needs to be carried out repeatedly making it a cumbersome task. Test automation uses a software tool for this purpose on the application to be tested. It has proven to be highly efficient and critical in larger software development companies. Additionally, automation can be a valuable way to make Test Driven Development ([http://en.wikipedia.org/wiki/Test-driven_development TDD]) tasks an important part of the software development workflow.&lt;br /&gt;
 &lt;br /&gt;
Test Automation has a number of advantages mostly dealing with repetitiveness of the tests and the time taken,&lt;br /&gt;
* '''Covers cases that manual testing probably cannot'''&lt;br /&gt;
# Finds defects missed out my manual testing&lt;br /&gt;
# Automated testing can simulate numerous virtual users interacting with the web software/application&lt;br /&gt;
* '''Helps save time and money'''&lt;br /&gt;
# Once created, automated tests can be executed repeatedly at no additional   costs and at a much faster pace. Saving time directly translates into saving cost.&lt;br /&gt;
# Supports virtually unlimited iterations of test case execution&lt;br /&gt;
* '''Increase test coverage and accuracy'''&lt;br /&gt;
# Automated tests perform the exact same steps and records all details precisely&lt;br /&gt;
# They also increase the depth and scope of tests to improve the quality of the software&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=='''Brief History'''==&lt;br /&gt;
====Selenium====&lt;br /&gt;
&lt;br /&gt;
[[File: SE-logo.png|right|Selenium Logo|link=http://www.seleniumhq.org/images/big-logo.png]]&lt;br /&gt;
&lt;br /&gt;
''Selenium'' was developed in the year 2004 by Jason Huggins and has been continuously evolving ever since. Jason Huggins developed this as an internal tool for [http://en.wikipedia.org/wiki/ThoughtWorks ThoughtWorks] as a javascript library which came to be known as the Selenium core. Selenium core is now the basis of the Selenium Remote Control (the server) and Selenium IDE.&lt;br /&gt;
The year 2006 marked the beginning of the development of the WebDriver project which was what they believed ‘a tool of the future’. The WebDriver was initiated to solve the problems that were faced due to the fact that Selenium was a based on JavaScript and a lot of security limitations browsers apply to Javascript.&lt;br /&gt;
In 2008, both Selenium and WebDriver merged to provide a common set of features to all users which is called Selenium 2..&lt;br /&gt;
Simon Stewart, the creator of WebDriver, in a joint email to the WebDriver and Selenium community on August 6, 2009 said the following,&lt;br /&gt;
&lt;br /&gt;
“Why are the projects merging? Partly because webdriver addresses some shortcomings in selenium (by being able to bypass the JS sandbox, for example. And we’ve got a gorgeous API), partly because selenium addresses some shortcomings in webdriver (such as supporting a broader range of browsers) and partly because the main selenium contributors and I felt that it was the best way to offer users the best possible framework.”&amp;lt;ref name =&amp;quot;Introduction to Selenium&amp;quot;&amp;gt;[http://docs.seleniumhq.org/docs/01_introducing_selenium.jsp#selenium-history Introducing Selenium]. ''SeleniumHQ: Browser Automation''. Selenium Project, 4 Oct. 2014. Web. 06 Oct. 2014.&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Watir====&lt;br /&gt;
&lt;br /&gt;
''Watir'' started as a library to teach testers to write ruby code and grew to be an IE implementation which now supports IE, Firefox, Safari, Google Chrome and Opera.&lt;br /&gt;
Watir was primarily developed by Bret Pettichord and Paul Rogers. Watir has since then has a couple of stable releases for Watir classic as well as Watir WebDriver. The most recent releases being&amp;lt;ref&amp;gt;[http://watir.com/category/releases/ Watir Releases]. Watir: Web Application Testing in Ruby. 28 April, 2013&amp;lt;/ref&amp;gt;, &lt;br /&gt;
&lt;br /&gt;
[[File: Watir.gif|right|Watir logo|link=http://upload.wikimedia.org/wikipedia/commons/7/7e/Watir.gif]]&lt;br /&gt;
&lt;br /&gt;
* Watir-Classic	    &lt;br /&gt;
# 0.6.3 April 10, 2013 ([https://github.com/watir/watir-webdriver/blob/master/CHANGES.md#063 Release Notes]) &amp;lt;br /&amp;gt;&lt;br /&gt;
* Watir-WebDriver	    &lt;br /&gt;
# 3.6.0 March 16, 2013 ([https://groups.google.com/forum/#!msg/watir-general/MOOun5g3Hvg/JBVNy957lDYJ Release Notes]) &amp;lt;br /&amp;gt;&lt;br /&gt;
# 3.5.0 March 10, 2013 ([https://groups.google.com/forum/#!msg/watir-general/aeUqsglvK6k/Kq7FCBiERjYJ Release Notes]) &amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Watir has a google group ([https://groups.google.com/forum/#!forum/watir-general Watir General]) for its support and contribution while Selenium also has a [http://seleniumforum.forumotion.net/ Selenium forum] apart from its google group called [https://groups.google.com/forum/#!forum/selenium-users Selenium Users].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=='''Comparison of Features, Functionality, and More'''==&lt;br /&gt;
Some features or functionality may be repeated here.  However, we will go into a bit more detail than previously mentioned.&lt;br /&gt;
===='''Open Source'''====&lt;br /&gt;
Both Selenium and Watir are [http://en.wikipedia.org/wiki/Open-source_software open source]!  This allows for greater extensibility and a deeper understanding of the inner workings of both of the frameworks, if the developer/tester chooses to delve into such details.  Additionally, the open source community allows for a more transparent, user-driven development and support cycle.  Users (the tester/developer) can choose to submit bug fixes or enhancements as patches, or they can choose to just use it “straight out of the box.”&lt;br /&gt;
&lt;br /&gt;
====Application Language Agnostic====&lt;br /&gt;
&lt;br /&gt;
Both Selenium and Watir are application language agnostic.  Because both Selenium and Watir test UI functionality in the browser, they can be used to test any web application.    &lt;br /&gt;
&lt;br /&gt;
====Language-specific Test Cases====&lt;br /&gt;
&lt;br /&gt;
Both Selenium and Watir require test cases to be written in some programming language.  Traditionally, both frameworks had limited choices in terms of language bindings.  However, with the advent of WebDriver, both became much more flexible.  WebDriver provided the bindings needed for many languages.  Today, the following are supported:&lt;br /&gt;
&lt;br /&gt;
'''Selenium*'''&lt;br /&gt;
&lt;br /&gt;
* Officially-supported: [http://en.wikipedia.org/wiki/Java_(programming_language) Java], [http://en.wikipedia.org/wiki/C_Sharp_(programming_language) C#], [http://en.wikipedia.org/wiki/Ruby_(programming_language) Ruby], [http://en.wikipedia.org/wiki/Python_(programming_language) Python], [http://en.wikipedia.org/wiki/Node.js Javascript/Node.js]&lt;br /&gt;
&lt;br /&gt;
* Unofficial/community-supported: [http://en.wikipedia.org/wiki/Perl Perl], [http://en.wikipedia.org/wiki/PHP PHP], [http://en.wikipedia.org/wiki/Haskell_(programming_language) Haskell], [http://en.wikipedia.org/wiki/Objective-C Objective-C], [http://en.wikipedia.org/wiki/R_(programming_language) R], [http://en.wikipedia.org/wiki/Dart_(programming_language) Dart], [http://en.wikipedia.org/wiki/Tcl Tcl]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;According to SeleniumHQ’s download page.&lt;br /&gt;
&lt;br /&gt;
'''Watir'''&lt;br /&gt;
&lt;br /&gt;
Unfortunately (or fortunately), Ruby is the only supported language for Watir.  After all, Watir does stand for “Web Application Testing in Ruby.” However, there are other frameworks which were inspired by Watir (but entirely separate) available in Java and C# - Watij and Watin,  respectively &amp;lt;ref&amp;gt;Djorgjievski, Darko. [http://www.sitepoint.com/watir-webdriver-control-browser/ Watir-WebDriver: Control the Browser]. ''SitePoint''. SitePoint Pty Ltd, 18 Apr. 2014. Web. 05 Oct. 2014.&amp;lt;/ref&amp;gt;.  There may be other similarly inspired frameworks available in other languages, but these are the most notable.&lt;br /&gt;
&lt;br /&gt;
====Cross-Browser and Headless Browser Support====&lt;br /&gt;
&lt;br /&gt;
[[File: watir_meet_webdriver.png | Watir Meets WebDriver |right|frame| link=http://yuml.me/diagram/scruffy/usecase/%5BTester%5D-%28Watir%20API%29,%20%28Watir%20API%29%3C%28FireWatir%29,%20%28Watir%20API%29%3C%28Watir%29,%20%28Watir%20API%29%3C%28SafariWatir%29,%20%28Watir%20API%29%3C%28Webdriver%29,%20%28Watir%20API%29%3C%28Celerity%29,%20%28Celerity%29-%28note:%20Celerity%20requires%20JRuby%29,%20%28Celerity%29-%28headless%29,%20%28Webdriver%29-%28Firefox%29,%20%28Webdriver%29-%28Chrome%29,%20%28Webdriver%29-%28IE%29,%20%28Webdriver%29-%28headless%29,%20%28FireWatir%29-%28Firefox%29,%20%28Watir%29-%28IE%29,%20%28SafariWatir%29-%28Safari%29.]]&lt;br /&gt;
&lt;br /&gt;
Traditionally, both Selenium and Watir were limited in the number of browsers they supported. Watir originally supported Internet Explorer and headless browsers exclusively.  Headless browsers were supported via the use of [https://github.com/jarib/celerity Celerity] &amp;lt;ref&amp;gt;Scott, Alister. [http://watirmelon.com/2010/04/10/watir-selenium-webdriver/ Watir, Selenium &amp;amp; WebDriver]. ''Watirmelon''. Watirmelon, 10 Apr. 2010. Web. 05 Oct. 2014.&amp;lt;/ref&amp;gt;.  Selenium started out as a Javascript library, so naturally it supported more browsers such as IE, Firefox, Safari, etc &amp;lt;ref name = &amp;quot;Introduction to Selenium&amp;quot; /&amp;gt;.  However, it did not support headless browsers.&lt;br /&gt;
Today, browser support looks much better for both Selenium and Watir, largely due to the introduction of WebDriver.  With WebDriver in existence, support for most browsers was added to Watir via the gem &amp;quot;watir-webdriver,&amp;quot; and [https://github.com/jarib/celerity Celerity] became obsolete because headless browser support was included in WebDriver.  Similarly for Selenium, support for headless browsers was added, as well as making the API much simpler and more concise &amp;lt;ref&amp;gt;[http://docs.seleniumhq.org/projects/webdriver/ Selenium WebDriver]. ''SeleniumHQ: Browser Automation''. Selenium Project, n.d. Web. 06 Oct. 2014.&amp;lt;/ref&amp;gt;.  However, there is the obvious limitation that one can only test a browser which is supported on the running platform.  In other words, Safari and Internet explorer can only be tested on  OS X and Windows environments, respectively**.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;**&amp;lt;/nowiki&amp;gt; &amp;lt;span style=&amp;quot;font-size:88%&amp;quot;&amp;gt;Some work-arounds or programs may exist to allow these browsers to be tested on other platforms. Here, we are assuming no special additional configuration - just the base operating system and browsers.  With virtualization technologies such as [http://www.linux-kvm.org/page/Main_Page KVM], [https://www.virtualbox.org/ VirtualBox], and [http://en.wikipedia.org/wiki/Comparison_of_platform_virtualization_software others], this isn't a problem anyway.  [http://en.wikipedia.org/wiki/Virtual_machine Virtual machines] can be created with any operating system, as needed.&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Cross-Platform Support====&lt;br /&gt;
Both Watir and Selenium run on most popular distributions of Windows, Mac, and Linux.  Selenium doesn't have a list of officially supported operating system versions.  Instead they generally support any version that is currently popular.  Only a few versions are listed which they run test builds on.  These are versions which are officially known to work, but many more are supported as well.&lt;br /&gt;
&lt;br /&gt;
Because Watir is a collection of Ruby Gems, it runs on any platform that Ruby runs on.  Like Selenium, this includes nearly all popular platforms.&lt;br /&gt;
&lt;br /&gt;
=='''Getting started'''==&lt;br /&gt;
===Selenium WebDriver=== &lt;br /&gt;
----&lt;br /&gt;
====Install/Configure (Java)====&lt;br /&gt;
Configuring Selenium requires you to download the binaries from [http://www.seleniumhq.org/download/ here]. &lt;br /&gt;
Once you have all your binaries in a directory, you can open any IDE of your choice and add this directory with all the .jar files to the CLASSPATH&lt;br /&gt;
*Example&lt;br /&gt;
This is how a typical Selenium code to find the term say, “Automation” on Google and display the results on the page would look like in Java using the [https://code.google.com/p/selenium/wiki/HtmlUnitDriver HtmlUnitDriver] would look like.&lt;br /&gt;
The HtmlUnitDriver is a pure Java driver that runs entirely in-memory. Because of this, you won't see a new browser window open &amp;lt;ref&amp;gt;[https://code.google.com/p/selenium/wiki/GettingStarted Getting started with Selenium]. Selenium: Browser Automation Framework. Google Code. 8 Feb, 2014.&amp;lt;/ref&amp;gt;,&lt;br /&gt;
&lt;br /&gt;
       package org.selenium.example;&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;
       import org.openqa.selenium.By;&lt;br /&gt;
       import org.openqa.selenium.WebDriver;&lt;br /&gt;
       import org.openqa.selenium.WebElement;&lt;br /&gt;
       import org.openqa.selenium.htmlunit.HtmlUnitDriver;&amp;lt;br /&amp;gt;&lt;br /&gt;
       public class Example  {&lt;br /&gt;
       public static void main(String[] args) {&lt;br /&gt;
        // Create a new instance of the html unit driver&lt;br /&gt;
        // Notice that the remainder of the code relies on the interface,&lt;br /&gt;
        // not the implementation.&lt;br /&gt;
        WebDriver driver = new HtmlUnitDriver();&amp;lt;br /&amp;gt;&lt;br /&gt;
        // And now use this to visit Google&lt;br /&gt;
        driver.get(&amp;quot;http://www.google.com&amp;quot;);&amp;lt;br /&amp;gt;&lt;br /&gt;
        // Find the text input element by its name&lt;br /&gt;
        WebElement element = driver.findElement(By.name(&amp;quot;q&amp;quot;));&amp;lt;br /&amp;gt;&lt;br /&gt;
        // Enter something to search for&lt;br /&gt;
        element.sendKeys(&amp;quot;Automation!&amp;quot;);&amp;lt;br /&amp;gt;&lt;br /&gt;
        // Now submit the form. WebDriver will find the form for us from the element&lt;br /&gt;
        element.submit();&amp;lt;br /&amp;gt;&lt;br /&gt;
        // Check the title of the page&lt;br /&gt;
        System.out.println(&amp;quot;Page title is: &amp;quot; + driver.getTitle());&lt;br /&gt;
        driver.quit();&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
If you compile and run it, you should see a line with the title of the Google search results as output.&lt;br /&gt;
&lt;br /&gt;
====Install/Configure for other languages====&lt;br /&gt;
Configuring Selenium for languages other than Java and for other development environments can be looked up [http://docs.seleniumhq.org/docs/03_webdriver.jsp#setting-up-a-selenium-webdriver-project here]. viz(C#, Ruby, Python, PHP, Perl, Javascript)&lt;br /&gt;
&lt;br /&gt;
===Watir===&lt;br /&gt;
----&lt;br /&gt;
====Install/Configure (Ruby)====&lt;br /&gt;
Drivers for Watir are installed as gems which are nothing but Ruby libraries which can be accessed over the internet.&lt;br /&gt;
All the instructions for installing Watir on various operating systems (viz. Windows, Mac OS, Linux) can be found [http://watir.com/installation/ here].&lt;br /&gt;
&lt;br /&gt;
*Example:&lt;br /&gt;
This is how a typical Watir code to find the term say, “Automation” on Google and display the results on the page would look like using Ruby&amp;lt;ref&amp;gt;Chernenko, Iryna. [http://blog.qatestlab.com/2011/02/23/automated-testing-with-watir-tutorial-for-begginers-part-1/ Watir Example]. QATestLab Blog: Automated Testing with Watir, 23 Feb 2011.&lt;br /&gt;
&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
        # Required in ruby 1.8.7&lt;br /&gt;
        require 'rubygems'&lt;br /&gt;
        # Watir IE driver&lt;br /&gt;
        require 'watir'&amp;lt;br /&amp;gt; &lt;br /&gt;
        ie = Watir::IE.new&amp;lt;br /&amp;gt; &lt;br /&gt;
        # text to show on console&lt;br /&gt;
        puts &amp;quot;Beginning of the test for Google search engine&amp;quot;&lt;br /&gt;
        puts &amp;quot;Step 1:  Go to the Google homepage&amp;quot;&lt;br /&gt;
        ie.goto &amp;quot;http://www.google.com&amp;quot;&amp;lt;br /&amp;gt;&lt;br /&gt;
        #set a variable&lt;br /&gt;
        search_text = &amp;quot;Automation&amp;quot;&lt;br /&gt;
        puts &amp;quot;Step 2: enter &amp;quot;+ search_text +&amp;quot; in the search text field.&amp;quot;&lt;br /&gt;
        ie.text_field(:name, &amp;quot;q&amp;quot;).set search_text   # &amp;quot;q&amp;quot; is the name of the search field&amp;lt;br /&amp;gt;&lt;br /&gt;
        puts &amp;quot; Step 3: click the 'Google Search' button.&amp;quot;&lt;br /&gt;
        ie.button(:name, &amp;quot;btnG&amp;quot;).click # &amp;quot;btnG&amp;quot; is the name of the Search button&amp;lt;br /&amp;gt;&lt;br /&gt;
        puts &amp;quot; Expected Result:&amp;quot;&lt;br /&gt;
        puts &amp;quot;  A Google page with results should be shown. 'Watir, pronounced water' should be high on the list.&amp;quot;&lt;br /&gt;
        puts &amp;quot; Actual Result:&amp;quot;&lt;br /&gt;
        if ie.text.include? &amp;quot;Watir, pronounced water&amp;quot;	&lt;br /&gt;
             puts &amp;quot;  Test Passed. Found the text string: 'Watir, pronounced water'. Actual Results match Expected Results.&amp;quot;&lt;br /&gt;
        else	&lt;br /&gt;
 	     puts &amp;quot;  Test Failed! Could not find text: 'Watir, pronounced water'.&amp;quot;&lt;br /&gt;
        end&lt;br /&gt;
        puts &amp;quot;End of test: Google search.&amp;quot;&lt;br /&gt;
        ie.close&lt;br /&gt;
&lt;br /&gt;
On compiling and running this and passing the test, you will see something like, &amp;lt;br /&amp;gt; &lt;br /&gt;
&lt;br /&gt;
        ''Output:''&lt;br /&gt;
        Beginning of the test for Google search engine &amp;lt;br /&amp;gt;&lt;br /&gt;
        Step 1:  Go to the Google homepage &amp;lt;br /&amp;gt;&lt;br /&gt;
        Step 2: enter Automation in the search text field. &amp;lt;br /&amp;gt;&lt;br /&gt;
        Step 3: click the 'Google Search' button. &amp;lt;br /&amp;gt;&lt;br /&gt;
        Expected Result: &amp;lt;br /&amp;gt;&lt;br /&gt;
        A Google page with results should be shown. 'Watir, pronounced water' should be high on the list. &amp;lt;br /&amp;gt;	&lt;br /&gt;
        Test Passed. Found the text string: 'Watir, pronounced water'. Actual Results match Expected Results. &amp;lt;br /&amp;gt;&lt;br /&gt;
        End of test: Google search. &amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Similar Tools==&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Sahi_(software) Sahi], uses the Sahi Scripting Language&amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Soatest SOATest], for testing and validating [http://en.wikipedia.org/wiki/Application_programming_interface API] driven applications &amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/TestComplete TestComplete], for Desktops, Web and Mobile&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
* [http://www.hiretheworld.com/blog/tech-blog/migrating-unit-tests-from-selenium-to-watir-webdriver Migrating unit tests from Selenium to Watir Web Driver] &amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://www.hiretheworld.com/blog/tech-blog/migrating-unit-tests-from-selenium-to-watir-webdriver Learning Selenium IDE] &amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/List_of_web_testing_tools List of web testing tools] &amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/List_of_web_testing_tools OWASP List of Acceptance Testing tools]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
{{reflist}}&lt;br /&gt;
&amp;lt;references /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==External Links==&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Selenium_(software) Selenium Wiki Page] &amp;lt;br /&amp;gt;&lt;br /&gt;
* [https://github.com/SeleniumHQ/selenium Selenium Source Code] &amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Watir Watir Wiki Page] &amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Watir Watir Source Code] &amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Watir SauceLabs HomePage] &amp;lt;br /&amp;gt;&lt;/div&gt;</summary>
		<author><name>Jjbeaver</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/ch1b_27_js&amp;diff=89438</id>
		<title>CSC/ECE 517 Fall 2014/ch1b 27 js</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/ch1b_27_js&amp;diff=89438"/>
		<updated>2014-10-07T03:51:15Z</updated>

		<summary type="html">&lt;p&gt;Jjbeaver: /* Install/Configure for Java */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;='''Selenium vs. Watir'''=&lt;br /&gt;
&lt;br /&gt;
Developing web applications is proving to be a challenging task with each passing day given the complex requirements and the demanding nature of the these applications. For the web applications to be robust we need to put in place some good testing strategies.&lt;br /&gt;
&lt;br /&gt;
'''''Selenium''''' is one of the most popularly used open source automation tools for web based applications. It is a JavaScript framework that runs in your web browser to interact with various elements in your browser. All in all, Selenium is a set of different software tools each with a different approach to supporting test automation. Selenium provides a rich set of testing functions that can be customized to suit the testing requirements.&lt;br /&gt;
 &lt;br /&gt;
'''''Watir''''', is another lightweight automation testing tool that is widely used for web app testing. It is an open-source ([http://en.wikipedia.org/wiki/BSD_licenses BSD])  family of Ruby libraries for automating web browsers. It allows you to write tests that are easy to read and maintain. Despite the fact that it is a set of Ruby libraries, it works perfectly, independent of the language that the web application is developed in. Watir as a tool is extremely simple and flexible.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=='''Motivation'''==&lt;br /&gt;
===Need for test automation===&lt;br /&gt;
With the majority of software applications today being implemented as [http://en.wikipedia.org/wiki/Web_application web applications] to be used over the internet, testing is becoming an indispensable part of the software development lifecycle ([http://en.wikipedia.org/wiki/Software_development_process SDLC]) of these applications. [http://en.wikipedia.org/wiki/Test_automation Test automation] is used where manual testing needs to be carried out repeatedly making it a cumbersome task. Test automation uses a software tool for this purpose on the application to be tested. It has proven to be highly efficient and critical in larger software development companies. Additionally, automation can be a valuable way to make Test Driven Development ([http://en.wikipedia.org/wiki/Test-driven_development TDD]) tasks an important part of the software development workflow.&lt;br /&gt;
 &lt;br /&gt;
Test Automation has a number of advantages mostly dealing with repetitiveness of the tests and the time taken,&lt;br /&gt;
* '''Covers cases that manual testing probably cannot'''&lt;br /&gt;
# Finds defects missed out my manual testing&lt;br /&gt;
# Automated testing can simulate numerous virtual users interacting with the web software/application&lt;br /&gt;
* '''Helps save time and money'''&lt;br /&gt;
# Once created, automated tests can be executed repeatedly at no additional   costs and at a much faster pace. Saving time directly translates into saving cost.&lt;br /&gt;
# Supports virtually unlimited iterations of test case execution&lt;br /&gt;
* '''Increase test coverage and accuracy'''&lt;br /&gt;
# Automated tests perform the exact same steps and records all details precisely&lt;br /&gt;
# They also increase the depth and scope of tests to improve the quality of the software&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=='''Brief History'''==&lt;br /&gt;
====Selenium====&lt;br /&gt;
&lt;br /&gt;
[[File: SE-logo.png|right|Selenium Logo|link=http://www.seleniumhq.org/images/big-logo.png]]&lt;br /&gt;
&lt;br /&gt;
''Selenium'' was developed in the year 2004 by Jason Huggins and has been continuously evolving ever since. Jason Huggins developed this as an internal tool for [http://en.wikipedia.org/wiki/ThoughtWorks ThoughtWorks] as a javascript library which came to be known as the Selenium core. Selenium core is now the basis of the Selenium Remote Control (the server) and Selenium IDE.&lt;br /&gt;
The year 2006 marked the beginning of the development of the WebDriver project which was what they believed ‘a tool of the future’. The WebDriver was initiated to solve the problems that were faced due to the fact that Selenium was a based on JavaScript and a lot of security limitations browsers apply to Javascript.&lt;br /&gt;
In 2008, both Selenium and WebDriver merged to provide a common set of features to all users which is called Selenium 2..&lt;br /&gt;
Simon Stewart, the creator of WebDriver, in a joint email to the WebDriver and Selenium community on August 6, 2009 said the following,&lt;br /&gt;
&lt;br /&gt;
“Why are the projects merging? Partly because webdriver addresses some shortcomings in selenium (by being able to bypass the JS sandbox, for example. And we’ve got a gorgeous API), partly because selenium addresses some shortcomings in webdriver (such as supporting a broader range of browsers) and partly because the main selenium contributors and I felt that it was the best way to offer users the best possible framework.”&amp;lt;ref name =&amp;quot;Introduction to Selenium&amp;quot;&amp;gt;[http://docs.seleniumhq.org/docs/01_introducing_selenium.jsp#selenium-history Introducing Selenium]. ''SeleniumHQ: Browser Automation''. Selenium Project, 4 Oct. 2014. Web. 06 Oct. 2014.&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Watir====&lt;br /&gt;
&lt;br /&gt;
''Watir'' started as a library to teach testers to write ruby code and grew to be an IE implementation which now supports IE, Firefox, Safari, Google Chrome and Opera.&lt;br /&gt;
Watir was primarily developed by Bret Pettichord and Paul Rogers. Watir has since then has a couple of stable releases for Watir classic as well as Watir WebDriver. The most recent releases being&amp;lt;ref&amp;gt;[http://watir.com/category/releases/ Watir Releases]. Watir: Web Application Testing in Ruby. 28 April, 2013&amp;lt;/ref&amp;gt;, &lt;br /&gt;
&lt;br /&gt;
[[File: Watir.gif|right|Watir logo|link=http://upload.wikimedia.org/wikipedia/commons/7/7e/Watir.gif]]&lt;br /&gt;
&lt;br /&gt;
* Watir-Classic	    &lt;br /&gt;
# 0.6.3 April 10, 2013 ([https://github.com/watir/watir-webdriver/blob/master/CHANGES.md#063 Release Notes]) &amp;lt;br /&amp;gt;&lt;br /&gt;
* Watir-WebDriver	    &lt;br /&gt;
# 3.6.0 March 16, 2013 ([https://groups.google.com/forum/#!msg/watir-general/MOOun5g3Hvg/JBVNy957lDYJ Release Notes]) &amp;lt;br /&amp;gt;&lt;br /&gt;
# 3.5.0 March 10, 2013 ([https://groups.google.com/forum/#!msg/watir-general/aeUqsglvK6k/Kq7FCBiERjYJ Release Notes]) &amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Watir has a google group ([https://groups.google.com/forum/#!forum/watir-general Watir General]) for its support and contribution while Selenium also has a [http://seleniumforum.forumotion.net/ Selenium forum] apart from its google group called [https://groups.google.com/forum/#!forum/selenium-users Selenium Users].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=='''Comparison of Features, Functionality, and More'''==&lt;br /&gt;
Some features or functionality may be repeated here.  However, we will go into a bit more detail than previously mentioned.&lt;br /&gt;
===='''Open Source'''====&lt;br /&gt;
Both Selenium and Watir are [http://en.wikipedia.org/wiki/Open-source_software open source]!  This allows for greater extensibility and a deeper understanding of the inner workings of both of the frameworks, if the developer/tester chooses to delve into such details.  Additionally, the open source community allows for a more transparent, user-driven development and support cycle.  Users (the tester/developer) can choose to submit bug fixes or enhancements as patches, or they can choose to just use it “straight out of the box.”&lt;br /&gt;
&lt;br /&gt;
====Application Language Agnostic====&lt;br /&gt;
&lt;br /&gt;
Both Selenium and Watir are application language agnostic.  Because both Selenium and Watir test UI functionality in the browser, they can be used to test any web application.    &lt;br /&gt;
&lt;br /&gt;
====Language-specific Test Cases====&lt;br /&gt;
&lt;br /&gt;
Both Selenium and Watir require test cases to be written in some programming language.  Traditionally, both frameworks had limited choices in terms of language bindings.  However, with the advent of WebDriver, both became much more flexible.  WebDriver provided the bindings needed for many languages.  Today, the following are supported:&lt;br /&gt;
&lt;br /&gt;
'''Selenium*'''&lt;br /&gt;
&lt;br /&gt;
* Officially-supported: [http://en.wikipedia.org/wiki/Java_(programming_language) Java], [http://en.wikipedia.org/wiki/C_Sharp_(programming_language) C#], [http://en.wikipedia.org/wiki/Ruby_(programming_language) Ruby], [http://en.wikipedia.org/wiki/Python_(programming_language) Python], [http://en.wikipedia.org/wiki/Node.js Javascript/Node.js]&lt;br /&gt;
&lt;br /&gt;
* Unofficial/community-supported: [http://en.wikipedia.org/wiki/Perl Perl], [http://en.wikipedia.org/wiki/PHP PHP], [http://en.wikipedia.org/wiki/Haskell_(programming_language) Haskell], [http://en.wikipedia.org/wiki/Objective-C Objective-C], [http://en.wikipedia.org/wiki/R_(programming_language) R], [http://en.wikipedia.org/wiki/Dart_(programming_language) Dart], [http://en.wikipedia.org/wiki/Tcl Tcl]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;According to SeleniumHQ’s download page.&lt;br /&gt;
&lt;br /&gt;
'''Watir'''&lt;br /&gt;
&lt;br /&gt;
Unfortunately (or fortunately), Ruby is the only supported language for Watir.  After all, Watir does stand for “Web Application Testing in Ruby.” However, there are other frameworks which were inspired by Watir (but entirely separate) available in Java and C# - Watij and Watin,  respectively &amp;lt;ref&amp;gt;Djorgjievski, Darko. [http://www.sitepoint.com/watir-webdriver-control-browser/ Watir-WebDriver: Control the Browser]. ''SitePoint''. SitePoint Pty Ltd, 18 Apr. 2014. Web. 05 Oct. 2014.&amp;lt;/ref&amp;gt;.  There may be other similarly inspired frameworks available in other languages, but these are the most notable.&lt;br /&gt;
&lt;br /&gt;
====Cross-Browser and Headless Browser Support====&lt;br /&gt;
&lt;br /&gt;
[[File: watir_meet_webdriver.png | Watir Meets WebDriver |right|frame| link=http://yuml.me/diagram/scruffy/usecase/%5BTester%5D-%28Watir%20API%29,%20%28Watir%20API%29%3C%28FireWatir%29,%20%28Watir%20API%29%3C%28Watir%29,%20%28Watir%20API%29%3C%28SafariWatir%29,%20%28Watir%20API%29%3C%28Webdriver%29,%20%28Watir%20API%29%3C%28Celerity%29,%20%28Celerity%29-%28note:%20Celerity%20requires%20JRuby%29,%20%28Celerity%29-%28headless%29,%20%28Webdriver%29-%28Firefox%29,%20%28Webdriver%29-%28Chrome%29,%20%28Webdriver%29-%28IE%29,%20%28Webdriver%29-%28headless%29,%20%28FireWatir%29-%28Firefox%29,%20%28Watir%29-%28IE%29,%20%28SafariWatir%29-%28Safari%29.]]&lt;br /&gt;
&lt;br /&gt;
Traditionally, both Selenium and Watir were limited in the number of browsers they supported. Watir originally supported Internet Explorer and headless browsers exclusively.  Headless browsers were supported via the use of Celerity &amp;lt;ref&amp;gt;Scott, Alister. [http://watirmelon.com/2010/04/10/watir-selenium-webdriver/ Watir, Selenium &amp;amp; WebDriver]. ''Watirmelon''. Watirmelon, 10 Apr. 2010. Web. 05 Oct. 2014.&amp;lt;/ref&amp;gt;.  Selenium started out as a Javascript library, so naturally it supported more browsers such as IE, Firefox, Safari, etc &amp;lt;ref name = &amp;quot;Introduction to Selenium&amp;quot; /&amp;gt;.  However, it did not support headless browsers.&lt;br /&gt;
Today, browser support looks much better for both Selenium and Watir, largely due to the introduction of WebDriver.  With WebDriver in existence, support for most browsers was added to Watir via the gem &amp;quot;watir-webdriver,&amp;quot; and Celerity became obsolete because headless browser support was included in WebDriver.  Similarly for Selenium, support for headless browsers was added, as well as making the API much simpler and more concise &amp;lt;ref&amp;gt;[http://docs.seleniumhq.org/projects/webdriver/ Selenium WebDriver]. ''SeleniumHQ: Browser Automation''. Selenium Project, n.d. Web. 06 Oct. 2014.&amp;lt;/ref&amp;gt;.  However, there is the obvious limitation that one can only test a browser which is supported on the running platform.  In other words, Safari and Internet explorer can only be tested on  OS X and Windows environments, respectively**.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;**&amp;lt;/nowiki&amp;gt; &amp;lt;span style=&amp;quot;font-size:88%&amp;quot;&amp;gt;Some work-arounds or programs may exist to allow these browsers to be tested on other platforms. Here, we are assuming no special additional configuration - just the base operating system and browsers.  With virtualization technologies such as [http://www.linux-kvm.org/page/Main_Page KVM], [https://www.virtualbox.org/ VirtualBox], and [http://en.wikipedia.org/wiki/Comparison_of_platform_virtualization_software others], this isn't a problem anyway.  [http://en.wikipedia.org/wiki/Virtual_machine Virtual machines] can be created with any operating system, as needed.&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Cross-Platform Support====&lt;br /&gt;
Both Watir and Selenium run on most popular distributions of Windows, Mac, and Linux.  Selenium doesn't have a list of officially supported operating system versions.  Instead they generally support any version that is currently popular.  Only a few versions are listed which they run test builds on.  These are versions which are officially known to work, but many more are supported as well.&lt;br /&gt;
&lt;br /&gt;
Because Watir is a collection of Ruby Gems, it runs on any platform that Ruby runs on.  Like Selenium, this includes nearly all popular platforms.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=='''Getting started'''==&lt;br /&gt;
===Selenium WebDriver=== &lt;br /&gt;
----&lt;br /&gt;
====Install/Configure (Java)====&lt;br /&gt;
Configuring Selenium requires you to download the binaries from [http://www.seleniumhq.org/download/ here]. &lt;br /&gt;
Once you have all your binaries in a directory, you can open any IDE of your choice and add this directory with all the .jar files to the CLASSPATH&lt;br /&gt;
*Example&lt;br /&gt;
This is how a typical Selenium code to find the term say, “Automation” on Google and display the results on the page would look like in Java using the [https://code.google.com/p/selenium/wiki/HtmlUnitDriver HtmlUnitDriver] would look like.&lt;br /&gt;
The HtmlUnitDriver is a pure Java driver that runs entirely in-memory. Because of this, you won't see a new browser window open &amp;lt;ref&amp;gt;[https://code.google.com/p/selenium/wiki/GettingStarted Getting started with Selenium]. Selenium: Browser Automation Framework. Google Code. 8 Feb, 2014.&amp;lt;/ref&amp;gt;,&lt;br /&gt;
&lt;br /&gt;
       package org.selenium.example;&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;
       import org.openqa.selenium.By;&lt;br /&gt;
       import org.openqa.selenium.WebDriver;&lt;br /&gt;
       import org.openqa.selenium.WebElement;&lt;br /&gt;
       import org.openqa.selenium.htmlunit.HtmlUnitDriver;&amp;lt;br /&amp;gt;&lt;br /&gt;
       public class Example  {&lt;br /&gt;
       public static void main(String[] args) {&lt;br /&gt;
        // Create a new instance of the html unit driver&lt;br /&gt;
        // Notice that the remainder of the code relies on the interface,&lt;br /&gt;
        // not the implementation.&lt;br /&gt;
        WebDriver driver = new HtmlUnitDriver();&amp;lt;br /&amp;gt;&lt;br /&gt;
        // And now use this to visit Google&lt;br /&gt;
        driver.get(&amp;quot;http://www.google.com&amp;quot;);&amp;lt;br /&amp;gt;&lt;br /&gt;
        // Find the text input element by its name&lt;br /&gt;
        WebElement element = driver.findElement(By.name(&amp;quot;q&amp;quot;));&amp;lt;br /&amp;gt;&lt;br /&gt;
        // Enter something to search for&lt;br /&gt;
        element.sendKeys(&amp;quot;Automation!&amp;quot;);&amp;lt;br /&amp;gt;&lt;br /&gt;
        // Now submit the form. WebDriver will find the form for us from the element&lt;br /&gt;
        element.submit();&amp;lt;br /&amp;gt;&lt;br /&gt;
        // Check the title of the page&lt;br /&gt;
        System.out.println(&amp;quot;Page title is: &amp;quot; + driver.getTitle());&lt;br /&gt;
        driver.quit();&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
If you compile and run it, you should see a line with the title of the Google search results as output.&lt;br /&gt;
&lt;br /&gt;
====Install/Configure for other languages====&lt;br /&gt;
Configuring Selenium for languages other than Java and for other development environments can be looked up [http://docs.seleniumhq.org/docs/03_webdriver.jsp#setting-up-a-selenium-webdriver-project here]. viz(C#, Ruby, Python, PHP, Perl, Javascript)&lt;br /&gt;
&lt;br /&gt;
===Watir===&lt;br /&gt;
----&lt;br /&gt;
====Install/Configure (Ruby)====&lt;br /&gt;
Drivers for Watir are installed as gems which are nothing but Ruby libraries which can be accessed over the internet.&lt;br /&gt;
All the instructions for installing Watir on various operating systems (viz. Windows, Mac OS, Linux) can be found [http://watir.com/installation/ here].&lt;br /&gt;
&lt;br /&gt;
*Example:&lt;br /&gt;
This is how a typical Watir code to find the term say, “Automation” on Google and display the results on the page would look like using Ruby&amp;lt;ref&amp;gt;Chernenko, Iryna. [http://blog.qatestlab.com/2011/02/23/automated-testing-with-watir-tutorial-for-begginers-part-1/ Watir Example]. QATestLab Blog: Automated Testing with Watir, 23 Feb 2011.&lt;br /&gt;
&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
        # Required in ruby 1.8.7&lt;br /&gt;
        require 'rubygems'&lt;br /&gt;
        # Watir IE driver&lt;br /&gt;
        require 'watir'&amp;lt;br /&amp;gt; &lt;br /&gt;
        ie = Watir::IE.new&amp;lt;br /&amp;gt; &lt;br /&gt;
        # text to show on console&lt;br /&gt;
        puts &amp;quot;Beginning of the test for Google search engine&amp;quot;&lt;br /&gt;
        puts &amp;quot;Step 1:  Go to the Google homepage&amp;quot;&lt;br /&gt;
        ie.goto &amp;quot;http://www.google.com&amp;quot;&amp;lt;br /&amp;gt;&lt;br /&gt;
        #set a variable&lt;br /&gt;
        search_text = &amp;quot;Automation&amp;quot;&lt;br /&gt;
        puts &amp;quot;Step 2: enter &amp;quot;+ search_text +&amp;quot; in the search text field.&amp;quot;&lt;br /&gt;
        ie.text_field(:name, &amp;quot;q&amp;quot;).set search_text   # &amp;quot;q&amp;quot; is the name of the search field&amp;lt;br /&amp;gt;&lt;br /&gt;
        puts &amp;quot; Step 3: click the 'Google Search' button.&amp;quot;&lt;br /&gt;
        ie.button(:name, &amp;quot;btnG&amp;quot;).click # &amp;quot;btnG&amp;quot; is the name of the Search button&amp;lt;br /&amp;gt;&lt;br /&gt;
        puts &amp;quot; Expected Result:&amp;quot;&lt;br /&gt;
        puts &amp;quot;  A Google page with results should be shown. 'Watir, pronounced water' should be high on the list.&amp;quot;&lt;br /&gt;
        puts &amp;quot; Actual Result:&amp;quot;&lt;br /&gt;
        if ie.text.include? &amp;quot;Watir, pronounced water&amp;quot;	&lt;br /&gt;
             puts &amp;quot;  Test Passed. Found the text string: 'Watir, pronounced water'. Actual Results match Expected Results.&amp;quot;&lt;br /&gt;
        else	&lt;br /&gt;
 	     puts &amp;quot;  Test Failed! Could not find text: 'Watir, pronounced water'.&amp;quot;&lt;br /&gt;
        end&lt;br /&gt;
        puts &amp;quot;End of test: Google search.&amp;quot;&lt;br /&gt;
        ie.close&lt;br /&gt;
&lt;br /&gt;
On compiling and running this and passing the test, you will see something like, &amp;lt;br /&amp;gt; &lt;br /&gt;
&lt;br /&gt;
        ''Output:''&lt;br /&gt;
        Beginning of the test for Google search engine &amp;lt;br /&amp;gt;&lt;br /&gt;
        Step 1:  Go to the Google homepage &amp;lt;br /&amp;gt;&lt;br /&gt;
        Step 2: enter Automation in the search text field. &amp;lt;br /&amp;gt;&lt;br /&gt;
        Step 3: click the 'Google Search' button. &amp;lt;br /&amp;gt;&lt;br /&gt;
        Expected Result: &amp;lt;br /&amp;gt;&lt;br /&gt;
        A Google page with results should be shown. 'Watir, pronounced water' should be high on the list. &amp;lt;br /&amp;gt;	&lt;br /&gt;
        Test Passed. Found the text string: 'Watir, pronounced water'. Actual Results match Expected Results. &amp;lt;br /&amp;gt;&lt;br /&gt;
        End of test: Google search. &amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Similar Tools==&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Sahi_(software) Sahi], uses the Sahi Scripting Language&amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Soatest SOATest], for testing and validating [http://en.wikipedia.org/wiki/Application_programming_interface API] driven applications &amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/TestComplete TestComplete], for Desktops, Web and Mobile&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
* [http://www.hiretheworld.com/blog/tech-blog/migrating-unit-tests-from-selenium-to-watir-webdriver Migrating unit tests from Selenium to Watir Web Driver] &amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://www.hiretheworld.com/blog/tech-blog/migrating-unit-tests-from-selenium-to-watir-webdriver Learning Selenium IDE] &amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/List_of_web_testing_tools List of web testing tools] &amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/List_of_web_testing_tools OWASP List of Acceptance Testing tools]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
{{reflist}}&lt;br /&gt;
&amp;lt;references /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==External Links==&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Selenium_(software) Selenium Wiki Page] &amp;lt;br /&amp;gt;&lt;br /&gt;
* [https://github.com/SeleniumHQ/selenium Selenium Source Code] &amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Watir Watir Wiki Page] &amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Watir Watir Source Code] &amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Watir SauceLabs HomePage] &amp;lt;br /&amp;gt;&lt;/div&gt;</summary>
		<author><name>Jjbeaver</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/ch1b_27_js&amp;diff=89437</id>
		<title>CSC/ECE 517 Fall 2014/ch1b 27 js</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/ch1b_27_js&amp;diff=89437"/>
		<updated>2014-10-07T03:50:58Z</updated>

		<summary type="html">&lt;p&gt;Jjbeaver: /* Install/Configure */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;='''Selenium vs. Watir'''=&lt;br /&gt;
&lt;br /&gt;
Developing web applications is proving to be a challenging task with each passing day given the complex requirements and the demanding nature of the these applications. For the web applications to be robust we need to put in place some good testing strategies.&lt;br /&gt;
&lt;br /&gt;
'''''Selenium''''' is one of the most popularly used open source automation tools for web based applications. It is a JavaScript framework that runs in your web browser to interact with various elements in your browser. All in all, Selenium is a set of different software tools each with a different approach to supporting test automation. Selenium provides a rich set of testing functions that can be customized to suit the testing requirements.&lt;br /&gt;
 &lt;br /&gt;
'''''Watir''''', is another lightweight automation testing tool that is widely used for web app testing. It is an open-source ([http://en.wikipedia.org/wiki/BSD_licenses BSD])  family of Ruby libraries for automating web browsers. It allows you to write tests that are easy to read and maintain. Despite the fact that it is a set of Ruby libraries, it works perfectly, independent of the language that the web application is developed in. Watir as a tool is extremely simple and flexible.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=='''Motivation'''==&lt;br /&gt;
===Need for test automation===&lt;br /&gt;
With the majority of software applications today being implemented as [http://en.wikipedia.org/wiki/Web_application web applications] to be used over the internet, testing is becoming an indispensable part of the software development lifecycle ([http://en.wikipedia.org/wiki/Software_development_process SDLC]) of these applications. [http://en.wikipedia.org/wiki/Test_automation Test automation] is used where manual testing needs to be carried out repeatedly making it a cumbersome task. Test automation uses a software tool for this purpose on the application to be tested. It has proven to be highly efficient and critical in larger software development companies. Additionally, automation can be a valuable way to make Test Driven Development ([http://en.wikipedia.org/wiki/Test-driven_development TDD]) tasks an important part of the software development workflow.&lt;br /&gt;
 &lt;br /&gt;
Test Automation has a number of advantages mostly dealing with repetitiveness of the tests and the time taken,&lt;br /&gt;
* '''Covers cases that manual testing probably cannot'''&lt;br /&gt;
# Finds defects missed out my manual testing&lt;br /&gt;
# Automated testing can simulate numerous virtual users interacting with the web software/application&lt;br /&gt;
* '''Helps save time and money'''&lt;br /&gt;
# Once created, automated tests can be executed repeatedly at no additional   costs and at a much faster pace. Saving time directly translates into saving cost.&lt;br /&gt;
# Supports virtually unlimited iterations of test case execution&lt;br /&gt;
* '''Increase test coverage and accuracy'''&lt;br /&gt;
# Automated tests perform the exact same steps and records all details precisely&lt;br /&gt;
# They also increase the depth and scope of tests to improve the quality of the software&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=='''Brief History'''==&lt;br /&gt;
====Selenium====&lt;br /&gt;
&lt;br /&gt;
[[File: SE-logo.png|right|Selenium Logo|link=http://www.seleniumhq.org/images/big-logo.png]]&lt;br /&gt;
&lt;br /&gt;
''Selenium'' was developed in the year 2004 by Jason Huggins and has been continuously evolving ever since. Jason Huggins developed this as an internal tool for [http://en.wikipedia.org/wiki/ThoughtWorks ThoughtWorks] as a javascript library which came to be known as the Selenium core. Selenium core is now the basis of the Selenium Remote Control (the server) and Selenium IDE.&lt;br /&gt;
The year 2006 marked the beginning of the development of the WebDriver project which was what they believed ‘a tool of the future’. The WebDriver was initiated to solve the problems that were faced due to the fact that Selenium was a based on JavaScript and a lot of security limitations browsers apply to Javascript.&lt;br /&gt;
In 2008, both Selenium and WebDriver merged to provide a common set of features to all users which is called Selenium 2..&lt;br /&gt;
Simon Stewart, the creator of WebDriver, in a joint email to the WebDriver and Selenium community on August 6, 2009 said the following,&lt;br /&gt;
&lt;br /&gt;
“Why are the projects merging? Partly because webdriver addresses some shortcomings in selenium (by being able to bypass the JS sandbox, for example. And we’ve got a gorgeous API), partly because selenium addresses some shortcomings in webdriver (such as supporting a broader range of browsers) and partly because the main selenium contributors and I felt that it was the best way to offer users the best possible framework.”&amp;lt;ref name =&amp;quot;Introduction to Selenium&amp;quot;&amp;gt;[http://docs.seleniumhq.org/docs/01_introducing_selenium.jsp#selenium-history Introducing Selenium]. ''SeleniumHQ: Browser Automation''. Selenium Project, 4 Oct. 2014. Web. 06 Oct. 2014.&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Watir====&lt;br /&gt;
&lt;br /&gt;
''Watir'' started as a library to teach testers to write ruby code and grew to be an IE implementation which now supports IE, Firefox, Safari, Google Chrome and Opera.&lt;br /&gt;
Watir was primarily developed by Bret Pettichord and Paul Rogers. Watir has since then has a couple of stable releases for Watir classic as well as Watir WebDriver. The most recent releases being&amp;lt;ref&amp;gt;[http://watir.com/category/releases/ Watir Releases]. Watir: Web Application Testing in Ruby. 28 April, 2013&amp;lt;/ref&amp;gt;, &lt;br /&gt;
&lt;br /&gt;
[[File: Watir.gif|right|Watir logo|link=http://upload.wikimedia.org/wikipedia/commons/7/7e/Watir.gif]]&lt;br /&gt;
&lt;br /&gt;
* Watir-Classic	    &lt;br /&gt;
# 0.6.3 April 10, 2013 ([https://github.com/watir/watir-webdriver/blob/master/CHANGES.md#063 Release Notes]) &amp;lt;br /&amp;gt;&lt;br /&gt;
* Watir-WebDriver	    &lt;br /&gt;
# 3.6.0 March 16, 2013 ([https://groups.google.com/forum/#!msg/watir-general/MOOun5g3Hvg/JBVNy957lDYJ Release Notes]) &amp;lt;br /&amp;gt;&lt;br /&gt;
# 3.5.0 March 10, 2013 ([https://groups.google.com/forum/#!msg/watir-general/aeUqsglvK6k/Kq7FCBiERjYJ Release Notes]) &amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Watir has a google group ([https://groups.google.com/forum/#!forum/watir-general Watir General]) for its support and contribution while Selenium also has a [http://seleniumforum.forumotion.net/ Selenium forum] apart from its google group called [https://groups.google.com/forum/#!forum/selenium-users Selenium Users].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=='''Comparison of Features, Functionality, and More'''==&lt;br /&gt;
Some features or functionality may be repeated here.  However, we will go into a bit more detail than previously mentioned.&lt;br /&gt;
===='''Open Source'''====&lt;br /&gt;
Both Selenium and Watir are [http://en.wikipedia.org/wiki/Open-source_software open source]!  This allows for greater extensibility and a deeper understanding of the inner workings of both of the frameworks, if the developer/tester chooses to delve into such details.  Additionally, the open source community allows for a more transparent, user-driven development and support cycle.  Users (the tester/developer) can choose to submit bug fixes or enhancements as patches, or they can choose to just use it “straight out of the box.”&lt;br /&gt;
&lt;br /&gt;
====Application Language Agnostic====&lt;br /&gt;
&lt;br /&gt;
Both Selenium and Watir are application language agnostic.  Because both Selenium and Watir test UI functionality in the browser, they can be used to test any web application.    &lt;br /&gt;
&lt;br /&gt;
====Language-specific Test Cases====&lt;br /&gt;
&lt;br /&gt;
Both Selenium and Watir require test cases to be written in some programming language.  Traditionally, both frameworks had limited choices in terms of language bindings.  However, with the advent of WebDriver, both became much more flexible.  WebDriver provided the bindings needed for many languages.  Today, the following are supported:&lt;br /&gt;
&lt;br /&gt;
'''Selenium*'''&lt;br /&gt;
&lt;br /&gt;
* Officially-supported: [http://en.wikipedia.org/wiki/Java_(programming_language) Java], [http://en.wikipedia.org/wiki/C_Sharp_(programming_language) C#], [http://en.wikipedia.org/wiki/Ruby_(programming_language) Ruby], [http://en.wikipedia.org/wiki/Python_(programming_language) Python], [http://en.wikipedia.org/wiki/Node.js Javascript/Node.js]&lt;br /&gt;
&lt;br /&gt;
* Unofficial/community-supported: [http://en.wikipedia.org/wiki/Perl Perl], [http://en.wikipedia.org/wiki/PHP PHP], [http://en.wikipedia.org/wiki/Haskell_(programming_language) Haskell], [http://en.wikipedia.org/wiki/Objective-C Objective-C], [http://en.wikipedia.org/wiki/R_(programming_language) R], [http://en.wikipedia.org/wiki/Dart_(programming_language) Dart], [http://en.wikipedia.org/wiki/Tcl Tcl]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;According to SeleniumHQ’s download page.&lt;br /&gt;
&lt;br /&gt;
'''Watir'''&lt;br /&gt;
&lt;br /&gt;
Unfortunately (or fortunately), Ruby is the only supported language for Watir.  After all, Watir does stand for “Web Application Testing in Ruby.” However, there are other frameworks which were inspired by Watir (but entirely separate) available in Java and C# - Watij and Watin,  respectively &amp;lt;ref&amp;gt;Djorgjievski, Darko. [http://www.sitepoint.com/watir-webdriver-control-browser/ Watir-WebDriver: Control the Browser]. ''SitePoint''. SitePoint Pty Ltd, 18 Apr. 2014. Web. 05 Oct. 2014.&amp;lt;/ref&amp;gt;.  There may be other similarly inspired frameworks available in other languages, but these are the most notable.&lt;br /&gt;
&lt;br /&gt;
====Cross-Browser and Headless Browser Support====&lt;br /&gt;
&lt;br /&gt;
[[File: watir_meet_webdriver.png | Watir Meets WebDriver |right|frame| link=http://yuml.me/diagram/scruffy/usecase/%5BTester%5D-%28Watir%20API%29,%20%28Watir%20API%29%3C%28FireWatir%29,%20%28Watir%20API%29%3C%28Watir%29,%20%28Watir%20API%29%3C%28SafariWatir%29,%20%28Watir%20API%29%3C%28Webdriver%29,%20%28Watir%20API%29%3C%28Celerity%29,%20%28Celerity%29-%28note:%20Celerity%20requires%20JRuby%29,%20%28Celerity%29-%28headless%29,%20%28Webdriver%29-%28Firefox%29,%20%28Webdriver%29-%28Chrome%29,%20%28Webdriver%29-%28IE%29,%20%28Webdriver%29-%28headless%29,%20%28FireWatir%29-%28Firefox%29,%20%28Watir%29-%28IE%29,%20%28SafariWatir%29-%28Safari%29.]]&lt;br /&gt;
&lt;br /&gt;
Traditionally, both Selenium and Watir were limited in the number of browsers they supported. Watir originally supported Internet Explorer and headless browsers exclusively.  Headless browsers were supported via the use of Celerity &amp;lt;ref&amp;gt;Scott, Alister. [http://watirmelon.com/2010/04/10/watir-selenium-webdriver/ Watir, Selenium &amp;amp; WebDriver]. ''Watirmelon''. Watirmelon, 10 Apr. 2010. Web. 05 Oct. 2014.&amp;lt;/ref&amp;gt;.  Selenium started out as a Javascript library, so naturally it supported more browsers such as IE, Firefox, Safari, etc &amp;lt;ref name = &amp;quot;Introduction to Selenium&amp;quot; /&amp;gt;.  However, it did not support headless browsers.&lt;br /&gt;
Today, browser support looks much better for both Selenium and Watir, largely due to the introduction of WebDriver.  With WebDriver in existence, support for most browsers was added to Watir via the gem &amp;quot;watir-webdriver,&amp;quot; and Celerity became obsolete because headless browser support was included in WebDriver.  Similarly for Selenium, support for headless browsers was added, as well as making the API much simpler and more concise &amp;lt;ref&amp;gt;[http://docs.seleniumhq.org/projects/webdriver/ Selenium WebDriver]. ''SeleniumHQ: Browser Automation''. Selenium Project, n.d. Web. 06 Oct. 2014.&amp;lt;/ref&amp;gt;.  However, there is the obvious limitation that one can only test a browser which is supported on the running platform.  In other words, Safari and Internet explorer can only be tested on  OS X and Windows environments, respectively**.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;**&amp;lt;/nowiki&amp;gt; &amp;lt;span style=&amp;quot;font-size:88%&amp;quot;&amp;gt;Some work-arounds or programs may exist to allow these browsers to be tested on other platforms. Here, we are assuming no special additional configuration - just the base operating system and browsers.  With virtualization technologies such as [http://www.linux-kvm.org/page/Main_Page KVM], [https://www.virtualbox.org/ VirtualBox], and [http://en.wikipedia.org/wiki/Comparison_of_platform_virtualization_software others], this isn't a problem anyway.  [http://en.wikipedia.org/wiki/Virtual_machine Virtual machines] can be created with any operating system, as needed.&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Cross-Platform Support====&lt;br /&gt;
Both Watir and Selenium run on most popular distributions of Windows, Mac, and Linux.  Selenium doesn't have a list of officially supported operating system versions.  Instead they generally support any version that is currently popular.  Only a few versions are listed which they run test builds on.  These are versions which are officially known to work, but many more are supported as well.&lt;br /&gt;
&lt;br /&gt;
Because Watir is a collection of Ruby Gems, it runs on any platform that Ruby runs on.  Like Selenium, this includes nearly all popular platforms.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=='''Getting started'''==&lt;br /&gt;
===Selenium WebDriver=== &lt;br /&gt;
----&lt;br /&gt;
====Install/Configure for Java====&lt;br /&gt;
Configuring Selenium requires you to download the binaries from [http://www.seleniumhq.org/download/ here]. &lt;br /&gt;
Once you have all your binaries in a directory, you can open any IDE of your choice and add this directory with all the .jar files to the CLASSPATH&lt;br /&gt;
*Example&lt;br /&gt;
This is how a typical Selenium code to find the term say, “Automation” on Google and display the results on the page would look like in Java using the [https://code.google.com/p/selenium/wiki/HtmlUnitDriver HtmlUnitDriver] would look like.&lt;br /&gt;
The HtmlUnitDriver is a pure Java driver that runs entirely in-memory. Because of this, you won't see a new browser window open &amp;lt;ref&amp;gt;[https://code.google.com/p/selenium/wiki/GettingStarted Getting started with Selenium]. Selenium: Browser Automation Framework. Google Code. 8 Feb, 2014.&amp;lt;/ref&amp;gt;,&lt;br /&gt;
&lt;br /&gt;
       package org.selenium.example;&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;
       import org.openqa.selenium.By;&lt;br /&gt;
       import org.openqa.selenium.WebDriver;&lt;br /&gt;
       import org.openqa.selenium.WebElement;&lt;br /&gt;
       import org.openqa.selenium.htmlunit.HtmlUnitDriver;&amp;lt;br /&amp;gt;&lt;br /&gt;
       public class Example  {&lt;br /&gt;
       public static void main(String[] args) {&lt;br /&gt;
        // Create a new instance of the html unit driver&lt;br /&gt;
        // Notice that the remainder of the code relies on the interface,&lt;br /&gt;
        // not the implementation.&lt;br /&gt;
        WebDriver driver = new HtmlUnitDriver();&amp;lt;br /&amp;gt;&lt;br /&gt;
        // And now use this to visit Google&lt;br /&gt;
        driver.get(&amp;quot;http://www.google.com&amp;quot;);&amp;lt;br /&amp;gt;&lt;br /&gt;
        // Find the text input element by its name&lt;br /&gt;
        WebElement element = driver.findElement(By.name(&amp;quot;q&amp;quot;));&amp;lt;br /&amp;gt;&lt;br /&gt;
        // Enter something to search for&lt;br /&gt;
        element.sendKeys(&amp;quot;Automation!&amp;quot;);&amp;lt;br /&amp;gt;&lt;br /&gt;
        // Now submit the form. WebDriver will find the form for us from the element&lt;br /&gt;
        element.submit();&amp;lt;br /&amp;gt;&lt;br /&gt;
        // Check the title of the page&lt;br /&gt;
        System.out.println(&amp;quot;Page title is: &amp;quot; + driver.getTitle());&lt;br /&gt;
        driver.quit();&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
If you compile and run it, you should see a line with the title of the Google search results as output. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Install/Configure for other languages====&lt;br /&gt;
Configuring Selenium for languages other than Java and for other development environments can be looked up [http://docs.seleniumhq.org/docs/03_webdriver.jsp#setting-up-a-selenium-webdriver-project here]. viz(C#, Ruby, Python, PHP, Perl, Javascript)&lt;br /&gt;
&lt;br /&gt;
===Watir===&lt;br /&gt;
----&lt;br /&gt;
====Install/Configure (Ruby)====&lt;br /&gt;
Drivers for Watir are installed as gems which are nothing but Ruby libraries which can be accessed over the internet.&lt;br /&gt;
All the instructions for installing Watir on various operating systems (viz. Windows, Mac OS, Linux) can be found [http://watir.com/installation/ here].&lt;br /&gt;
&lt;br /&gt;
*Example:&lt;br /&gt;
This is how a typical Watir code to find the term say, “Automation” on Google and display the results on the page would look like using Ruby&amp;lt;ref&amp;gt;Chernenko, Iryna. [http://blog.qatestlab.com/2011/02/23/automated-testing-with-watir-tutorial-for-begginers-part-1/ Watir Example]. QATestLab Blog: Automated Testing with Watir, 23 Feb 2011.&lt;br /&gt;
&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
        # Required in ruby 1.8.7&lt;br /&gt;
        require 'rubygems'&lt;br /&gt;
        # Watir IE driver&lt;br /&gt;
        require 'watir'&amp;lt;br /&amp;gt; &lt;br /&gt;
        ie = Watir::IE.new&amp;lt;br /&amp;gt; &lt;br /&gt;
        # text to show on console&lt;br /&gt;
        puts &amp;quot;Beginning of the test for Google search engine&amp;quot;&lt;br /&gt;
        puts &amp;quot;Step 1:  Go to the Google homepage&amp;quot;&lt;br /&gt;
        ie.goto &amp;quot;http://www.google.com&amp;quot;&amp;lt;br /&amp;gt;&lt;br /&gt;
        #set a variable&lt;br /&gt;
        search_text = &amp;quot;Automation&amp;quot;&lt;br /&gt;
        puts &amp;quot;Step 2: enter &amp;quot;+ search_text +&amp;quot; in the search text field.&amp;quot;&lt;br /&gt;
        ie.text_field(:name, &amp;quot;q&amp;quot;).set search_text   # &amp;quot;q&amp;quot; is the name of the search field&amp;lt;br /&amp;gt;&lt;br /&gt;
        puts &amp;quot; Step 3: click the 'Google Search' button.&amp;quot;&lt;br /&gt;
        ie.button(:name, &amp;quot;btnG&amp;quot;).click # &amp;quot;btnG&amp;quot; is the name of the Search button&amp;lt;br /&amp;gt;&lt;br /&gt;
        puts &amp;quot; Expected Result:&amp;quot;&lt;br /&gt;
        puts &amp;quot;  A Google page with results should be shown. 'Watir, pronounced water' should be high on the list.&amp;quot;&lt;br /&gt;
        puts &amp;quot; Actual Result:&amp;quot;&lt;br /&gt;
        if ie.text.include? &amp;quot;Watir, pronounced water&amp;quot;	&lt;br /&gt;
             puts &amp;quot;  Test Passed. Found the text string: 'Watir, pronounced water'. Actual Results match Expected Results.&amp;quot;&lt;br /&gt;
        else	&lt;br /&gt;
 	     puts &amp;quot;  Test Failed! Could not find text: 'Watir, pronounced water'.&amp;quot;&lt;br /&gt;
        end&lt;br /&gt;
        puts &amp;quot;End of test: Google search.&amp;quot;&lt;br /&gt;
        ie.close&lt;br /&gt;
&lt;br /&gt;
On compiling and running this and passing the test, you will see something like, &amp;lt;br /&amp;gt; &lt;br /&gt;
&lt;br /&gt;
        ''Output:''&lt;br /&gt;
        Beginning of the test for Google search engine &amp;lt;br /&amp;gt;&lt;br /&gt;
        Step 1:  Go to the Google homepage &amp;lt;br /&amp;gt;&lt;br /&gt;
        Step 2: enter Automation in the search text field. &amp;lt;br /&amp;gt;&lt;br /&gt;
        Step 3: click the 'Google Search' button. &amp;lt;br /&amp;gt;&lt;br /&gt;
        Expected Result: &amp;lt;br /&amp;gt;&lt;br /&gt;
        A Google page with results should be shown. 'Watir, pronounced water' should be high on the list. &amp;lt;br /&amp;gt;	&lt;br /&gt;
        Test Passed. Found the text string: 'Watir, pronounced water'. Actual Results match Expected Results. &amp;lt;br /&amp;gt;&lt;br /&gt;
        End of test: Google search. &amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Similar Tools==&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Sahi_(software) Sahi], uses the Sahi Scripting Language&amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Soatest SOATest], for testing and validating [http://en.wikipedia.org/wiki/Application_programming_interface API] driven applications &amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/TestComplete TestComplete], for Desktops, Web and Mobile&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
* [http://www.hiretheworld.com/blog/tech-blog/migrating-unit-tests-from-selenium-to-watir-webdriver Migrating unit tests from Selenium to Watir Web Driver] &amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://www.hiretheworld.com/blog/tech-blog/migrating-unit-tests-from-selenium-to-watir-webdriver Learning Selenium IDE] &amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/List_of_web_testing_tools List of web testing tools] &amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/List_of_web_testing_tools OWASP List of Acceptance Testing tools]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
{{reflist}}&lt;br /&gt;
&amp;lt;references /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==External Links==&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Selenium_(software) Selenium Wiki Page] &amp;lt;br /&amp;gt;&lt;br /&gt;
* [https://github.com/SeleniumHQ/selenium Selenium Source Code] &amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Watir Watir Wiki Page] &amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Watir Watir Source Code] &amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Watir SauceLabs HomePage] &amp;lt;br /&amp;gt;&lt;/div&gt;</summary>
		<author><name>Jjbeaver</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/ch1b_27_js&amp;diff=89436</id>
		<title>CSC/ECE 517 Fall 2014/ch1b 27 js</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/ch1b_27_js&amp;diff=89436"/>
		<updated>2014-10-07T03:50:11Z</updated>

		<summary type="html">&lt;p&gt;Jjbeaver: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;='''Selenium vs. Watir'''=&lt;br /&gt;
&lt;br /&gt;
Developing web applications is proving to be a challenging task with each passing day given the complex requirements and the demanding nature of the these applications. For the web applications to be robust we need to put in place some good testing strategies.&lt;br /&gt;
&lt;br /&gt;
'''''Selenium''''' is one of the most popularly used open source automation tools for web based applications. It is a JavaScript framework that runs in your web browser to interact with various elements in your browser. All in all, Selenium is a set of different software tools each with a different approach to supporting test automation. Selenium provides a rich set of testing functions that can be customized to suit the testing requirements.&lt;br /&gt;
 &lt;br /&gt;
'''''Watir''''', is another lightweight automation testing tool that is widely used for web app testing. It is an open-source ([http://en.wikipedia.org/wiki/BSD_licenses BSD])  family of Ruby libraries for automating web browsers. It allows you to write tests that are easy to read and maintain. Despite the fact that it is a set of Ruby libraries, it works perfectly, independent of the language that the web application is developed in. Watir as a tool is extremely simple and flexible.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=='''Motivation'''==&lt;br /&gt;
===Need for test automation===&lt;br /&gt;
With the majority of software applications today being implemented as [http://en.wikipedia.org/wiki/Web_application web applications] to be used over the internet, testing is becoming an indispensable part of the software development lifecycle ([http://en.wikipedia.org/wiki/Software_development_process SDLC]) of these applications. [http://en.wikipedia.org/wiki/Test_automation Test automation] is used where manual testing needs to be carried out repeatedly making it a cumbersome task. Test automation uses a software tool for this purpose on the application to be tested. It has proven to be highly efficient and critical in larger software development companies. Additionally, automation can be a valuable way to make Test Driven Development ([http://en.wikipedia.org/wiki/Test-driven_development TDD]) tasks an important part of the software development workflow.&lt;br /&gt;
 &lt;br /&gt;
Test Automation has a number of advantages mostly dealing with repetitiveness of the tests and the time taken,&lt;br /&gt;
* '''Covers cases that manual testing probably cannot'''&lt;br /&gt;
# Finds defects missed out my manual testing&lt;br /&gt;
# Automated testing can simulate numerous virtual users interacting with the web software/application&lt;br /&gt;
* '''Helps save time and money'''&lt;br /&gt;
# Once created, automated tests can be executed repeatedly at no additional   costs and at a much faster pace. Saving time directly translates into saving cost.&lt;br /&gt;
# Supports virtually unlimited iterations of test case execution&lt;br /&gt;
* '''Increase test coverage and accuracy'''&lt;br /&gt;
# Automated tests perform the exact same steps and records all details precisely&lt;br /&gt;
# They also increase the depth and scope of tests to improve the quality of the software&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=='''Brief History'''==&lt;br /&gt;
====Selenium====&lt;br /&gt;
&lt;br /&gt;
[[File: SE-logo.png|right|Selenium Logo|link=http://www.seleniumhq.org/images/big-logo.png]]&lt;br /&gt;
&lt;br /&gt;
''Selenium'' was developed in the year 2004 by Jason Huggins and has been continuously evolving ever since. Jason Huggins developed this as an internal tool for [http://en.wikipedia.org/wiki/ThoughtWorks ThoughtWorks] as a javascript library which came to be known as the Selenium core. Selenium core is now the basis of the Selenium Remote Control (the server) and Selenium IDE.&lt;br /&gt;
The year 2006 marked the beginning of the development of the WebDriver project which was what they believed ‘a tool of the future’. The WebDriver was initiated to solve the problems that were faced due to the fact that Selenium was a based on JavaScript and a lot of security limitations browsers apply to Javascript.&lt;br /&gt;
In 2008, both Selenium and WebDriver merged to provide a common set of features to all users which is called Selenium 2..&lt;br /&gt;
Simon Stewart, the creator of WebDriver, in a joint email to the WebDriver and Selenium community on August 6, 2009 said the following,&lt;br /&gt;
&lt;br /&gt;
“Why are the projects merging? Partly because webdriver addresses some shortcomings in selenium (by being able to bypass the JS sandbox, for example. And we’ve got a gorgeous API), partly because selenium addresses some shortcomings in webdriver (such as supporting a broader range of browsers) and partly because the main selenium contributors and I felt that it was the best way to offer users the best possible framework.”&amp;lt;ref name =&amp;quot;Introduction to Selenium&amp;quot;&amp;gt;[http://docs.seleniumhq.org/docs/01_introducing_selenium.jsp#selenium-history Introducing Selenium]. ''SeleniumHQ: Browser Automation''. Selenium Project, 4 Oct. 2014. Web. 06 Oct. 2014.&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Watir====&lt;br /&gt;
&lt;br /&gt;
''Watir'' started as a library to teach testers to write ruby code and grew to be an IE implementation which now supports IE, Firefox, Safari, Google Chrome and Opera.&lt;br /&gt;
Watir was primarily developed by Bret Pettichord and Paul Rogers. Watir has since then has a couple of stable releases for Watir classic as well as Watir WebDriver. The most recent releases being&amp;lt;ref&amp;gt;[http://watir.com/category/releases/ Watir Releases]. Watir: Web Application Testing in Ruby. 28 April, 2013&amp;lt;/ref&amp;gt;, &lt;br /&gt;
&lt;br /&gt;
[[File: Watir.gif|right|Watir logo|link=http://upload.wikimedia.org/wikipedia/commons/7/7e/Watir.gif]]&lt;br /&gt;
&lt;br /&gt;
* Watir-Classic	    &lt;br /&gt;
# 0.6.3 April 10, 2013 ([https://github.com/watir/watir-webdriver/blob/master/CHANGES.md#063 Release Notes]) &amp;lt;br /&amp;gt;&lt;br /&gt;
* Watir-WebDriver	    &lt;br /&gt;
# 3.6.0 March 16, 2013 ([https://groups.google.com/forum/#!msg/watir-general/MOOun5g3Hvg/JBVNy957lDYJ Release Notes]) &amp;lt;br /&amp;gt;&lt;br /&gt;
# 3.5.0 March 10, 2013 ([https://groups.google.com/forum/#!msg/watir-general/aeUqsglvK6k/Kq7FCBiERjYJ Release Notes]) &amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Watir has a google group ([https://groups.google.com/forum/#!forum/watir-general Watir General]) for its support and contribution while Selenium also has a [http://seleniumforum.forumotion.net/ Selenium forum] apart from its google group called [https://groups.google.com/forum/#!forum/selenium-users Selenium Users].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=='''Comparison of Features, Functionality, and More'''==&lt;br /&gt;
Some features or functionality may be repeated here.  However, we will go into a bit more detail than previously mentioned.&lt;br /&gt;
===='''Open Source'''====&lt;br /&gt;
Both Selenium and Watir are [http://en.wikipedia.org/wiki/Open-source_software open source]!  This allows for greater extensibility and a deeper understanding of the inner workings of both of the frameworks, if the developer/tester chooses to delve into such details.  Additionally, the open source community allows for a more transparent, user-driven development and support cycle.  Users (the tester/developer) can choose to submit bug fixes or enhancements as patches, or they can choose to just use it “straight out of the box.”&lt;br /&gt;
&lt;br /&gt;
====Application Language Agnostic====&lt;br /&gt;
&lt;br /&gt;
Both Selenium and Watir are application language agnostic.  Because both Selenium and Watir test UI functionality in the browser, they can be used to test any web application.    &lt;br /&gt;
&lt;br /&gt;
====Language-specific Test Cases====&lt;br /&gt;
&lt;br /&gt;
Both Selenium and Watir require test cases to be written in some programming language.  Traditionally, both frameworks had limited choices in terms of language bindings.  However, with the advent of WebDriver, both became much more flexible.  WebDriver provided the bindings needed for many languages.  Today, the following are supported:&lt;br /&gt;
&lt;br /&gt;
'''Selenium*'''&lt;br /&gt;
&lt;br /&gt;
* Officially-supported: [http://en.wikipedia.org/wiki/Java_(programming_language) Java], [http://en.wikipedia.org/wiki/C_Sharp_(programming_language) C#], [http://en.wikipedia.org/wiki/Ruby_(programming_language) Ruby], [http://en.wikipedia.org/wiki/Python_(programming_language) Python], [http://en.wikipedia.org/wiki/Node.js Javascript/Node.js]&lt;br /&gt;
&lt;br /&gt;
* Unofficial/community-supported: [http://en.wikipedia.org/wiki/Perl Perl], [http://en.wikipedia.org/wiki/PHP PHP], [http://en.wikipedia.org/wiki/Haskell_(programming_language) Haskell], [http://en.wikipedia.org/wiki/Objective-C Objective-C], [http://en.wikipedia.org/wiki/R_(programming_language) R], [http://en.wikipedia.org/wiki/Dart_(programming_language) Dart], [http://en.wikipedia.org/wiki/Tcl Tcl]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;According to SeleniumHQ’s download page.&lt;br /&gt;
&lt;br /&gt;
'''Watir'''&lt;br /&gt;
&lt;br /&gt;
Unfortunately (or fortunately), Ruby is the only supported language for Watir.  After all, Watir does stand for “Web Application Testing in Ruby.” However, there are other frameworks which were inspired by Watir (but entirely separate) available in Java and C# - Watij and Watin,  respectively &amp;lt;ref&amp;gt;Djorgjievski, Darko. [http://www.sitepoint.com/watir-webdriver-control-browser/ Watir-WebDriver: Control the Browser]. ''SitePoint''. SitePoint Pty Ltd, 18 Apr. 2014. Web. 05 Oct. 2014.&amp;lt;/ref&amp;gt;.  There may be other similarly inspired frameworks available in other languages, but these are the most notable.&lt;br /&gt;
&lt;br /&gt;
====Cross-Browser and Headless Browser Support====&lt;br /&gt;
&lt;br /&gt;
[[File: watir_meet_webdriver.png | Watir Meets WebDriver |right|frame| link=http://yuml.me/diagram/scruffy/usecase/%5BTester%5D-%28Watir%20API%29,%20%28Watir%20API%29%3C%28FireWatir%29,%20%28Watir%20API%29%3C%28Watir%29,%20%28Watir%20API%29%3C%28SafariWatir%29,%20%28Watir%20API%29%3C%28Webdriver%29,%20%28Watir%20API%29%3C%28Celerity%29,%20%28Celerity%29-%28note:%20Celerity%20requires%20JRuby%29,%20%28Celerity%29-%28headless%29,%20%28Webdriver%29-%28Firefox%29,%20%28Webdriver%29-%28Chrome%29,%20%28Webdriver%29-%28IE%29,%20%28Webdriver%29-%28headless%29,%20%28FireWatir%29-%28Firefox%29,%20%28Watir%29-%28IE%29,%20%28SafariWatir%29-%28Safari%29.]]&lt;br /&gt;
&lt;br /&gt;
Traditionally, both Selenium and Watir were limited in the number of browsers they supported. Watir originally supported Internet Explorer and headless browsers exclusively.  Headless browsers were supported via the use of Celerity &amp;lt;ref&amp;gt;Scott, Alister. [http://watirmelon.com/2010/04/10/watir-selenium-webdriver/ Watir, Selenium &amp;amp; WebDriver]. ''Watirmelon''. Watirmelon, 10 Apr. 2010. Web. 05 Oct. 2014.&amp;lt;/ref&amp;gt;.  Selenium started out as a Javascript library, so naturally it supported more browsers such as IE, Firefox, Safari, etc &amp;lt;ref name = &amp;quot;Introduction to Selenium&amp;quot; /&amp;gt;.  However, it did not support headless browsers.&lt;br /&gt;
Today, browser support looks much better for both Selenium and Watir, largely due to the introduction of WebDriver.  With WebDriver in existence, support for most browsers was added to Watir via the gem &amp;quot;watir-webdriver,&amp;quot; and Celerity became obsolete because headless browser support was included in WebDriver.  Similarly for Selenium, support for headless browsers was added, as well as making the API much simpler and more concise &amp;lt;ref&amp;gt;[http://docs.seleniumhq.org/projects/webdriver/ Selenium WebDriver]. ''SeleniumHQ: Browser Automation''. Selenium Project, n.d. Web. 06 Oct. 2014.&amp;lt;/ref&amp;gt;.  However, there is the obvious limitation that one can only test a browser which is supported on the running platform.  In other words, Safari and Internet explorer can only be tested on  OS X and Windows environments, respectively**.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;**&amp;lt;/nowiki&amp;gt; &amp;lt;span style=&amp;quot;font-size:88%&amp;quot;&amp;gt;Some work-arounds or programs may exist to allow these browsers to be tested on other platforms. Here, we are assuming no special additional configuration - just the base operating system and browsers.  With virtualization technologies such as [http://www.linux-kvm.org/page/Main_Page KVM], [https://www.virtualbox.org/ VirtualBox], and [http://en.wikipedia.org/wiki/Comparison_of_platform_virtualization_software others], this isn't a problem anyway.  [http://en.wikipedia.org/wiki/Virtual_machine Virtual machines] can be created with any operating system, as needed.&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Cross-Platform Support====&lt;br /&gt;
Both Watir and Selenium run on most popular distributions of Windows, Mac, and Linux.  Selenium doesn't have a list of officially supported operating system versions.  Instead they generally support any version that is currently popular.  Only a few versions are listed which they run test builds on.  These are versions which are officially known to work, but many more are supported as well.&lt;br /&gt;
&lt;br /&gt;
Because Watir is a collection of Ruby Gems, it runs on any platform that Ruby runs on.  Like Selenium, this includes nearly all popular platforms.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=='''Getting started'''==&lt;br /&gt;
===Selenium WebDriver=== &lt;br /&gt;
----&lt;br /&gt;
====Install/Configure for Java====&lt;br /&gt;
Configuring Selenium requires you to download the binaries from [http://www.seleniumhq.org/download/ here]. &lt;br /&gt;
Once you have all your binaries in a directory, you can open any IDE of your choice and add this directory with all the .jar files to the CLASSPATH&lt;br /&gt;
*Example&lt;br /&gt;
This is how a typical Selenium code to find the term say, “Automation” on Google and display the results on the page would look like in Java using the [https://code.google.com/p/selenium/wiki/HtmlUnitDriver HtmlUnitDriver] would look like.&lt;br /&gt;
The HtmlUnitDriver is a pure Java driver that runs entirely in-memory. Because of this, you won't see a new browser window open &amp;lt;ref&amp;gt;[https://code.google.com/p/selenium/wiki/GettingStarted Getting started with Selenium]. Selenium: Browser Automation Framework. Google Code. 8 Feb, 2014.&amp;lt;/ref&amp;gt;,&lt;br /&gt;
&lt;br /&gt;
       package org.selenium.example;&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;
       import org.openqa.selenium.By;&lt;br /&gt;
       import org.openqa.selenium.WebDriver;&lt;br /&gt;
       import org.openqa.selenium.WebElement;&lt;br /&gt;
       import org.openqa.selenium.htmlunit.HtmlUnitDriver;&amp;lt;br /&amp;gt;&lt;br /&gt;
       public class Example  {&lt;br /&gt;
       public static void main(String[] args) {&lt;br /&gt;
        // Create a new instance of the html unit driver&lt;br /&gt;
        // Notice that the remainder of the code relies on the interface,&lt;br /&gt;
        // not the implementation.&lt;br /&gt;
        WebDriver driver = new HtmlUnitDriver();&amp;lt;br /&amp;gt;&lt;br /&gt;
        // And now use this to visit Google&lt;br /&gt;
        driver.get(&amp;quot;http://www.google.com&amp;quot;);&amp;lt;br /&amp;gt;&lt;br /&gt;
        // Find the text input element by its name&lt;br /&gt;
        WebElement element = driver.findElement(By.name(&amp;quot;q&amp;quot;));&amp;lt;br /&amp;gt;&lt;br /&gt;
        // Enter something to search for&lt;br /&gt;
        element.sendKeys(&amp;quot;Automation!&amp;quot;);&amp;lt;br /&amp;gt;&lt;br /&gt;
        // Now submit the form. WebDriver will find the form for us from the element&lt;br /&gt;
        element.submit();&amp;lt;br /&amp;gt;&lt;br /&gt;
        // Check the title of the page&lt;br /&gt;
        System.out.println(&amp;quot;Page title is: &amp;quot; + driver.getTitle());&lt;br /&gt;
        driver.quit();&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
If you compile and run it, you should see a line with the title of the Google search results as output. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Install/Configure for other languages====&lt;br /&gt;
Configuring Selenium for languages other than Java and for other development environments can be looked up [http://docs.seleniumhq.org/docs/03_webdriver.jsp#setting-up-a-selenium-webdriver-project here]. viz(C#, Ruby, Python, PHP, Perl, Javascript)&lt;br /&gt;
&lt;br /&gt;
===Watir===&lt;br /&gt;
----&lt;br /&gt;
====Install/Configure====&lt;br /&gt;
Drivers for Watir are installed as gems which are nothing but Ruby libraries which can be accessed over the internet.&lt;br /&gt;
All the instructions for installing Watir on various operating systems (viz. Windows, Mac OS, Linux) can be found [http://watir.com/installation/ here].&lt;br /&gt;
&lt;br /&gt;
*Example:&lt;br /&gt;
This is how a typical Watir code to find the term say, “Automation” on Google and display the results on the page would look like using Ruby&amp;lt;ref&amp;gt;Chernenko, Iryna. [http://blog.qatestlab.com/2011/02/23/automated-testing-with-watir-tutorial-for-begginers-part-1/ Watir Example]. QATestLab Blog: Automated Testing with Watir, 23 Feb 2011.&lt;br /&gt;
&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
        # Required in ruby 1.8.7&lt;br /&gt;
        require 'rubygems'&lt;br /&gt;
        # Watir IE driver&lt;br /&gt;
        require 'watir'&amp;lt;br /&amp;gt; &lt;br /&gt;
        ie = Watir::IE.new&amp;lt;br /&amp;gt; &lt;br /&gt;
        # text to show on console&lt;br /&gt;
        puts &amp;quot;Beginning of the test for Google search engine&amp;quot;&lt;br /&gt;
        puts &amp;quot;Step 1:  Go to the Google homepage&amp;quot;&lt;br /&gt;
        ie.goto &amp;quot;http://www.google.com&amp;quot;&amp;lt;br /&amp;gt;&lt;br /&gt;
        #set a variable&lt;br /&gt;
        search_text = &amp;quot;Automation&amp;quot;&lt;br /&gt;
        puts &amp;quot;Step 2: enter &amp;quot;+ search_text +&amp;quot; in the search text field.&amp;quot;&lt;br /&gt;
        ie.text_field(:name, &amp;quot;q&amp;quot;).set search_text   # &amp;quot;q&amp;quot; is the name of the search field&amp;lt;br /&amp;gt;&lt;br /&gt;
        puts &amp;quot; Step 3: click the 'Google Search' button.&amp;quot;&lt;br /&gt;
        ie.button(:name, &amp;quot;btnG&amp;quot;).click # &amp;quot;btnG&amp;quot; is the name of the Search button&amp;lt;br /&amp;gt;&lt;br /&gt;
        puts &amp;quot; Expected Result:&amp;quot;&lt;br /&gt;
        puts &amp;quot;  A Google page with results should be shown. 'Watir, pronounced water' should be high on the list.&amp;quot;&lt;br /&gt;
        puts &amp;quot; Actual Result:&amp;quot;&lt;br /&gt;
        if ie.text.include? &amp;quot;Watir, pronounced water&amp;quot;	&lt;br /&gt;
             puts &amp;quot;  Test Passed. Found the text string: 'Watir, pronounced water'. Actual Results match Expected Results.&amp;quot;&lt;br /&gt;
        else	&lt;br /&gt;
 	     puts &amp;quot;  Test Failed! Could not find text: 'Watir, pronounced water'.&amp;quot;&lt;br /&gt;
        end&lt;br /&gt;
        puts &amp;quot;End of test: Google search.&amp;quot;&lt;br /&gt;
        ie.close&lt;br /&gt;
&lt;br /&gt;
On compiling and running this and passing the test, you will see something like, &amp;lt;br /&amp;gt; &lt;br /&gt;
&lt;br /&gt;
        ''Output:''&lt;br /&gt;
        Beginning of the test for Google search engine &amp;lt;br /&amp;gt;&lt;br /&gt;
        Step 1:  Go to the Google homepage &amp;lt;br /&amp;gt;&lt;br /&gt;
        Step 2: enter Automation in the search text field. &amp;lt;br /&amp;gt;&lt;br /&gt;
        Step 3: click the 'Google Search' button. &amp;lt;br /&amp;gt;&lt;br /&gt;
        Expected Result: &amp;lt;br /&amp;gt;&lt;br /&gt;
        A Google page with results should be shown. 'Watir, pronounced water' should be high on the list. &amp;lt;br /&amp;gt;	&lt;br /&gt;
        Test Passed. Found the text string: 'Watir, pronounced water'. Actual Results match Expected Results. &amp;lt;br /&amp;gt;&lt;br /&gt;
        End of test: Google search. &amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Similar Tools==&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Sahi_(software) Sahi], uses the Sahi Scripting Language&amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Soatest SOATest], for testing and validating [http://en.wikipedia.org/wiki/Application_programming_interface API] driven applications &amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/TestComplete TestComplete], for Desktops, Web and Mobile&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
* [http://www.hiretheworld.com/blog/tech-blog/migrating-unit-tests-from-selenium-to-watir-webdriver Migrating unit tests from Selenium to Watir Web Driver] &amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://www.hiretheworld.com/blog/tech-blog/migrating-unit-tests-from-selenium-to-watir-webdriver Learning Selenium IDE] &amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/List_of_web_testing_tools List of web testing tools] &amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/List_of_web_testing_tools OWASP List of Acceptance Testing tools]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
{{reflist}}&lt;br /&gt;
&amp;lt;references /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==External Links==&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Selenium_(software) Selenium Wiki Page] &amp;lt;br /&amp;gt;&lt;br /&gt;
* [https://github.com/SeleniumHQ/selenium Selenium Source Code] &amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Watir Watir Wiki Page] &amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Watir Watir Source Code] &amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Watir SauceLabs HomePage] &amp;lt;br /&amp;gt;&lt;/div&gt;</summary>
		<author><name>Jjbeaver</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/ch1b_27_js&amp;diff=89435</id>
		<title>CSC/ECE 517 Fall 2014/ch1b 27 js</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/ch1b_27_js&amp;diff=89435"/>
		<updated>2014-10-07T03:49:48Z</updated>

		<summary type="html">&lt;p&gt;Jjbeaver: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;='''Selenium vs. Watir'''=&lt;br /&gt;
&lt;br /&gt;
Developing web applications is proving to be a challenging task with each passing day given the complex requirements and the demanding nature of the these applications. For the web applications to be robust we need to put in place some good testing strategies.&lt;br /&gt;
&lt;br /&gt;
'''''Selenium''''' is one of the most popularly used open source automation tools for web based applications. It is a JavaScript framework that runs in your web browser to interact with various elements in your browser. All in all, Selenium is a set of different software tools each with a different approach to supporting test automation. Selenium provides a rich set of testing functions that can be customized to suit the testing requirements.&lt;br /&gt;
 &lt;br /&gt;
'''''Watir''''', is another lightweight automation testing tool that is widely used for web app testing. It is an open-source ([http://en.wikipedia.org/wiki/BSD_licenses BSD])  family of Ruby libraries for automating web browsers. It allows you to write tests that are easy to read and maintain. Despite the fact that it is a set of Ruby libraries, it works perfectly, independent of the language that the web application is developed in. Watir as a tool is extremely simple and flexible.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=='''Motivation'''==&lt;br /&gt;
===Need for test automation===&lt;br /&gt;
With the majority of software applications today being implemented as [http://en.wikipedia.org/wiki/Web_application web applications] to be used over the internet, testing is becoming an indispensable part of the software development lifecycle ([http://en.wikipedia.org/wiki/Software_development_process SDLC]) of these applications. [http://en.wikipedia.org/wiki/Test_automation Test automation] is used where manual testing needs to be carried out repeatedly making it a cumbersome task. Test automation uses a software tool for this purpose on the application to be tested. It has proven to be highly efficient and critical in larger software development companies. Additionally, automation can be a valuable way to make Test Driven Development ([http://en.wikipedia.org/wiki/Test-driven_development TDD]) tasks an important part of the software development workflow.&lt;br /&gt;
 &lt;br /&gt;
Test Automation has a number of advantages mostly dealing with repetitiveness of the tests and the time taken,&lt;br /&gt;
* '''Covers cases that manual testing probably cannot'''&lt;br /&gt;
# Finds defects missed out my manual testing&lt;br /&gt;
# Automated testing can simulate numerous virtual users interacting with the web software/application&lt;br /&gt;
* '''Helps save time and money'''&lt;br /&gt;
# Once created, automated tests can be executed repeatedly at no additional   costs and at a much faster pace. Saving time directly translates into saving cost.&lt;br /&gt;
# Supports virtually unlimited iterations of test case execution&lt;br /&gt;
* '''Increase test coverage and accuracy'''&lt;br /&gt;
# Automated tests perform the exact same steps and records all details precisely&lt;br /&gt;
# They also increase the depth and scope of tests to improve the quality of the software&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=='''Brief History'''==&lt;br /&gt;
====Selenium====&lt;br /&gt;
&lt;br /&gt;
[[File: SE-logo.png|right|Selenium Logo|link=http://www.seleniumhq.org/images/big-logo.png]]&lt;br /&gt;
&lt;br /&gt;
''Selenium'' was developed in the year 2004 by Jason Huggins and has been continuously evolving ever since. Jason Huggins developed this as an internal tool for [http://en.wikipedia.org/wiki/ThoughtWorks ThoughtWorks] as a javascript library which came to be known as the Selenium core. Selenium core is now the basis of the Selenium Remote Control (the server) and Selenium IDE.&lt;br /&gt;
The year 2006 marked the beginning of the development of the WebDriver project which was what they believed ‘a tool of the future’. The WebDriver was initiated to solve the problems that were faced due to the fact that Selenium was a based on JavaScript and a lot of security limitations browsers apply to Javascript.&lt;br /&gt;
In 2008, both Selenium and WebDriver merged to provide a common set of features to all users which is called Selenium 2..&lt;br /&gt;
Simon Stewart, the creator of WebDriver, in a joint email to the WebDriver and Selenium community on August 6, 2009 said the following,&lt;br /&gt;
&lt;br /&gt;
“Why are the projects merging? Partly because webdriver addresses some shortcomings in selenium (by being able to bypass the JS sandbox, for example. And we’ve got a gorgeous API), partly because selenium addresses some shortcomings in webdriver (such as supporting a broader range of browsers) and partly because the main selenium contributors and I felt that it was the best way to offer users the best possible framework.”&amp;lt;ref name =&amp;quot;Introduction to Selenium&amp;quot;&amp;gt;[http://docs.seleniumhq.org/docs/01_introducing_selenium.jsp#selenium-history Introducing Selenium]. ''SeleniumHQ: Browser Automation''. Selenium Project, 4 Oct. 2014. Web. 06 Oct. 2014.&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Watir====&lt;br /&gt;
&lt;br /&gt;
''Watir'' started as a library to teach testers to write ruby code and grew to be an IE implementation which now supports IE, Firefox, Safari, Google Chrome and Opera.&lt;br /&gt;
Watir was primarily developed by Bret Pettichord and Paul Rogers. Watir has since then has a couple of stable releases for Watir classic as well as Watir WebDriver. The most recent releases being&amp;lt;ref&amp;gt;[http://watir.com/category/releases/ Watir Releases]. Watir: Web Application Testing in Ruby. 28 April, 2013&amp;lt;/ref&amp;gt;, &lt;br /&gt;
&lt;br /&gt;
[[File: Watir.gif|right|Watir logo|link=http://upload.wikimedia.org/wikipedia/commons/7/7e/Watir.gif]]&lt;br /&gt;
&lt;br /&gt;
* Watir-Classic	    &lt;br /&gt;
# 0.6.3 April 10, 2013 ([https://github.com/watir/watir-webdriver/blob/master/CHANGES.md#063 Release Notes]) &amp;lt;br /&amp;gt;&lt;br /&gt;
* Watir-WebDriver	    &lt;br /&gt;
# 3.6.0 March 16, 2013 ([https://groups.google.com/forum/#!msg/watir-general/MOOun5g3Hvg/JBVNy957lDYJ Release Notes]) &amp;lt;br /&amp;gt;&lt;br /&gt;
# 3.5.0 March 10, 2013 ([https://groups.google.com/forum/#!msg/watir-general/aeUqsglvK6k/Kq7FCBiERjYJ Release Notes]) &amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Watir has a google group ([https://groups.google.com/forum/#!forum/watir-general Watir General]) for its support and contribution while Selenium also has a [http://seleniumforum.forumotion.net/ Selenium forum] apart from its google group called [https://groups.google.com/forum/#!forum/selenium-users Selenium Users].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=='''Comparison of Features, Functionality, and More'''==&lt;br /&gt;
Some features or functionality may be repeated here.  However, we will go into a bit more detail than previously mentioned.&lt;br /&gt;
===='''Open Source'''====&lt;br /&gt;
Both Selenium and Watir are [http://en.wikipedia.org/wiki/Open-source_software open source]!  This allows for greater extensibility and a deeper understanding of the inner workings of both of the frameworks, if the developer/tester chooses to delve into such details.  Additionally, the open source community allows for a more transparent, user-driven development and support cycle.  Users (the tester/developer) can choose to submit bug fixes or enhancements as patches, or they can choose to just use it “straight out of the box.”&lt;br /&gt;
&lt;br /&gt;
====Application Language Agnostic====&lt;br /&gt;
&lt;br /&gt;
Both Selenium and Watir are application language agnostic.  Because both Selenium and Watir test UI functionality in the browser, they can be used to test any web application.    &lt;br /&gt;
&lt;br /&gt;
====Language-specific Test Cases====&lt;br /&gt;
&lt;br /&gt;
Both Selenium and Watir require test cases to be written in some programming language.  Traditionally, both frameworks had limited choices in terms of language bindings.  However, with the advent of WebDriver, both became much more flexible.  WebDriver provided the bindings needed for many languages.  Today, the following are supported:&lt;br /&gt;
&lt;br /&gt;
'''Selenium*'''&lt;br /&gt;
&lt;br /&gt;
* Officially-supported: [http://en.wikipedia.org/wiki/Java_(programming_language) Java], [http://en.wikipedia.org/wiki/C_Sharp_(programming_language) C#], [http://en.wikipedia.org/wiki/Ruby_(programming_language) Ruby], [http://en.wikipedia.org/wiki/Python_(programming_language) Python], [http://en.wikipedia.org/wiki/Node.js Javascript/Node.js]&lt;br /&gt;
&lt;br /&gt;
* Unofficial/community-supported: [http://en.wikipedia.org/wiki/Perl Perl], [http://en.wikipedia.org/wiki/PHP PHP], [http://en.wikipedia.org/wiki/Haskell_(programming_language) Haskell], [http://en.wikipedia.org/wiki/Objective-C Objective-C], [http://en.wikipedia.org/wiki/R_(programming_language) R], [http://en.wikipedia.org/wiki/Dart_(programming_language) Dart], [http://en.wikipedia.org/wiki/Tcl Tcl]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;According to SeleniumHQ’s download page.&lt;br /&gt;
&lt;br /&gt;
'''Watir'''&lt;br /&gt;
&lt;br /&gt;
Unfortunately (or fortunately), Ruby is the only supported language for Watir.  After all, Watir does stand for “Web Application Testing in Ruby.” However, there are other frameworks which were inspired by Watir (but entirely separate) available in Java and C# - Watij and Watin,  respectively &amp;lt;ref&amp;gt;Djorgjievski, Darko. [http://www.sitepoint.com/watir-webdriver-control-browser/ Watir-WebDriver: Control the Browser]. ''SitePoint''. SitePoint Pty Ltd, 18 Apr. 2014. Web. 05 Oct. 2014.&amp;lt;/ref&amp;gt;.  There may be other similarly inspired frameworks available in other languages, but these are the most notable.&lt;br /&gt;
&lt;br /&gt;
====Cross-Browser and Headless Browser Support====&lt;br /&gt;
&lt;br /&gt;
[[File: watir_meet_webdriver.png | Watir Meets WebDriver |right|frame| link=http://yuml.me/diagram/scruffy/usecase/%5BTester%5D-%28Watir%20API%29,%20%28Watir%20API%29%3C%28FireWatir%29,%20%28Watir%20API%29%3C%28Watir%29,%20%28Watir%20API%29%3C%28SafariWatir%29,%20%28Watir%20API%29%3C%28Webdriver%29,%20%28Watir%20API%29%3C%28Celerity%29,%20%28Celerity%29-%28note:%20Celerity%20requires%20JRuby%29,%20%28Celerity%29-%28headless%29,%20%28Webdriver%29-%28Firefox%29,%20%28Webdriver%29-%28Chrome%29,%20%28Webdriver%29-%28IE%29,%20%28Webdriver%29-%28headless%29,%20%28FireWatir%29-%28Firefox%29,%20%28Watir%29-%28IE%29,%20%28SafariWatir%29-%28Safari%29.]]&lt;br /&gt;
&lt;br /&gt;
Traditionally, both Selenium and Watir were limited in the number of browsers they supported. Watir originally supported Internet Explorer and headless browsers exclusively.  Headless browsers were supported via the use of Celerity &amp;lt;ref&amp;gt;Scott, Alister. [http://watirmelon.com/2010/04/10/watir-selenium-webdriver/ Watir, Selenium &amp;amp; WebDriver]. ''Watirmelon''. Watirmelon, 10 Apr. 2010. Web. 05 Oct. 2014.&amp;lt;/ref&amp;gt;.  Selenium started out as a Javascript library, so naturally it supported more browsers such as IE, Firefox, Safari, etc &amp;lt;ref name = &amp;quot;Introduction to Selenium&amp;quot; /&amp;gt;.  However, it did not support headless browsers.&lt;br /&gt;
Today, browser support looks much better for both Selenium and Watir, largely due to the introduction of WebDriver.  With WebDriver in existence, support for most browsers was added to Watir via the gem &amp;quot;watir-webdriver,&amp;quot; and Celerity became obsolete because headless browser support was included in WebDriver.  Similarly for Selenium, support for headless browsers was added, as well as making the API much simpler and more concise &amp;lt;ref&amp;gt;[http://docs.seleniumhq.org/projects/webdriver/ Selenium WebDriver]. ''SeleniumHQ: Browser Automation''. Selenium Project, n.d. Web. 06 Oct. 2014.&amp;lt;/ref&amp;gt;.  However, there is the obvious limitation that one can only test a browser which is supported on the running platform.  In other words, Safari and Internet explorer can only be tested on  OS X and Windows environments, respectively**.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;**&amp;lt;/nowiki&amp;gt; &amp;lt;span style=&amp;quot;font-size:88%&amp;quot;&amp;gt;Some work-arounds or programs may exist to allow these browsers to be tested on other platforms. Here, we are assuming no special additional configuration - just the base operating system and browsers.  With virtualization technologies such as [http://www.linux-kvm.org/page/Main_Page KVM], [https://www.virtualbox.org/ VirtualBox], and [http://en.wikipedia.org/wiki/Comparison_of_platform_virtualization_software others], this isn't a problem anyway.  [http://en.wikipedia.org/wiki/Virtual_machine Virtual machines] can be created with any operating system, as needed.&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Cross-Platform Support====&lt;br /&gt;
Both Watir and Selenium run on most popular distributions of Windows, Mac, and Linux.  Selenium doesn't have a list of officially supported operating system versions.  Instead they generally support any version that is currently popular.  Only a few versions are listed which they run test builds on.  These are versions which are officially known to work, but many more are supported as well.&lt;br /&gt;
&lt;br /&gt;
Because Watir is a collection of Ruby Gems, it runs on any platform that Ruby runs on.  Like Selenium, this includes nearly all popular platforms.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=='''Getting started'''==&lt;br /&gt;
===Selenium WebDriver=== &lt;br /&gt;
----&lt;br /&gt;
====Install/Configure for Java====&lt;br /&gt;
Configuring Selenium requires you to download the binaries from [http://www.seleniumhq.org/download/ here]. &lt;br /&gt;
Once you have all your binaries in a directory, you can open any IDE of your choice and add this directory with all the .jar files to the CLASSPATH&lt;br /&gt;
*Example&lt;br /&gt;
This is how a typical Selenium code to find the term say, “Automation” on Google and display the results on the page would look like in Java using the [https://code.google.com/p/selenium/wiki/HtmlUnitDriver HtmlUnitDriver] would look like.&lt;br /&gt;
The HtmlUnitDriver is a pure Java driver that runs entirely in-memory. Because of this, you won't see a new browser window open &amp;lt;ref&amp;gt;[https://code.google.com/p/selenium/wiki/GettingStarted Getting started with Selenium]. Selenium: Browser Automation Framework. Google Code. 8 Feb, 2014.&amp;lt;/ref&amp;gt;,&lt;br /&gt;
&lt;br /&gt;
       package org.selenium.example;&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;
       import org.openqa.selenium.By;&lt;br /&gt;
       import org.openqa.selenium.WebDriver;&lt;br /&gt;
       import org.openqa.selenium.WebElement;&lt;br /&gt;
       import org.openqa.selenium.htmlunit.HtmlUnitDriver;&amp;lt;br /&amp;gt;&lt;br /&gt;
       public class Example  {&lt;br /&gt;
       public static void main(String[] args) {&lt;br /&gt;
        // Create a new instance of the html unit driver&lt;br /&gt;
        // Notice that the remainder of the code relies on the interface,&lt;br /&gt;
        // not the implementation.&lt;br /&gt;
        WebDriver driver = new HtmlUnitDriver();&amp;lt;br /&amp;gt;&lt;br /&gt;
        // And now use this to visit Google&lt;br /&gt;
        driver.get(&amp;quot;http://www.google.com&amp;quot;);&amp;lt;br /&amp;gt;&lt;br /&gt;
        // Find the text input element by its name&lt;br /&gt;
        WebElement element = driver.findElement(By.name(&amp;quot;q&amp;quot;));&amp;lt;br /&amp;gt;&lt;br /&gt;
        // Enter something to search for&lt;br /&gt;
        element.sendKeys(&amp;quot;Automation!&amp;quot;);&amp;lt;br /&amp;gt;&lt;br /&gt;
        // Now submit the form. WebDriver will find the form for us from the element&lt;br /&gt;
        element.submit();&amp;lt;br /&amp;gt;&lt;br /&gt;
        // Check the title of the page&lt;br /&gt;
        System.out.println(&amp;quot;Page title is: &amp;quot; + driver.getTitle());&lt;br /&gt;
        driver.quit();&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
If you compile and run it, you should see a line with the title of the Google search results as output. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Install/Configure for other languages====&lt;br /&gt;
Configuring Selenium for languages other than Java and for other development environments can be looked up [http://docs.seleniumhq.org/docs/03_webdriver.jsp#setting-up-a-selenium-webdriver-project here]. viz(C#, Ruby, Python, PHP, Perl, Javascript)&lt;br /&gt;
&lt;br /&gt;
===Watir===&lt;br /&gt;
----&lt;br /&gt;
====Install/Configure====&lt;br /&gt;
Drivers for Watir are installed as gems which are nothing but Ruby libraries which can be accessed over the internet.&lt;br /&gt;
All the instructions for installing Watir on various operating systems (viz. Windows, Mac OS, Linux) can be found [http://watir.com/installation/ here].&lt;br /&gt;
&lt;br /&gt;
*Example:&lt;br /&gt;
This is how a typical Watir code to find the term say, “Automation” on Google and display the results on the page would look like using Ruby&amp;lt;ref&amp;gt;Chernenko, Iryna. [http://blog.qatestlab.com/2011/02/23/automated-testing-with-watir-tutorial-for-begginers-part-1/ Watir Example]. QATestLab Blog: Automated Testing with Watir, 23 Feb 2011.&lt;br /&gt;
&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
        # Required in ruby 1.8.7&lt;br /&gt;
        require 'rubygems'&lt;br /&gt;
        # Watir IE driver&lt;br /&gt;
        require 'watir'&amp;lt;br /&amp;gt; &lt;br /&gt;
        ie = Watir::IE.new&amp;lt;br /&amp;gt; &lt;br /&gt;
        # text to show on console&lt;br /&gt;
        puts &amp;quot;Beginning of the test for Google search engine&amp;quot;&lt;br /&gt;
        puts &amp;quot;Step 1:  Go to the Google homepage&amp;quot;&lt;br /&gt;
        ie.goto &amp;quot;http://www.google.com&amp;quot;&amp;lt;br /&amp;gt;&lt;br /&gt;
        #set a variable&lt;br /&gt;
        search_text = &amp;quot;Automation&amp;quot;&lt;br /&gt;
        puts &amp;quot;Step 2: enter &amp;quot;+ search_text +&amp;quot; in the search text field.&amp;quot;&lt;br /&gt;
        ie.text_field(:name, &amp;quot;q&amp;quot;).set search_text   # &amp;quot;q&amp;quot; is the name of the search field&amp;lt;br /&amp;gt;&lt;br /&gt;
        puts &amp;quot; Step 3: click the 'Google Search' button.&amp;quot;&lt;br /&gt;
        ie.button(:name, &amp;quot;btnG&amp;quot;).click # &amp;quot;btnG&amp;quot; is the name of the Search button&amp;lt;br /&amp;gt;&lt;br /&gt;
        puts &amp;quot; Expected Result:&amp;quot;&lt;br /&gt;
        puts &amp;quot;  A Google page with results should be shown. 'Watir, pronounced water' should be high on the list.&amp;quot;&lt;br /&gt;
        puts &amp;quot; Actual Result:&amp;quot;&lt;br /&gt;
        if ie.text.include? &amp;quot;Watir, pronounced water&amp;quot;	&lt;br /&gt;
             puts &amp;quot;  Test Passed. Found the text string: 'Watir, pronounced water'. Actual Results match Expected Results.&amp;quot;&lt;br /&gt;
        else	&lt;br /&gt;
 	     puts &amp;quot;  Test Failed! Could not find text: 'Watir, pronounced water'.&amp;quot;&lt;br /&gt;
        end&lt;br /&gt;
        puts &amp;quot;End of test: Google search.&amp;quot;&lt;br /&gt;
        ie.close&lt;br /&gt;
&lt;br /&gt;
On compiling and running this and passing the test, you will see something like, &amp;lt;br /&amp;gt; &lt;br /&gt;
&lt;br /&gt;
        ''Output:''&lt;br /&gt;
        Beginning of the test for Google search engine &amp;lt;br /&amp;gt;&lt;br /&gt;
        Step 1:  Go to the Google homepage &amp;lt;br /&amp;gt;&lt;br /&gt;
        Step 2: enter Automation in the search text field. &amp;lt;br /&amp;gt;&lt;br /&gt;
        Step 3: click the 'Google Search' button. &amp;lt;br /&amp;gt;&lt;br /&gt;
        Expected Result: &amp;lt;br /&amp;gt;&lt;br /&gt;
        A Google page with results should be shown. 'Watir, pronounced water' should be high on the list. &amp;lt;br /&amp;gt;	&lt;br /&gt;
        Test Passed. Found the text string: 'Watir, pronounced water'. Actual Results match Expected Results. &amp;lt;br /&amp;gt;&lt;br /&gt;
        End of test: Google search. &amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Similar Tools==&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Sahi_(software) Sahi], uses the Sahi Scripting Language&amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Soatest SOATest], for testing and validating [http://en.wikipedia.org/wiki/Application_programming_interface API] driven applications &amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/TestComplete TestComplete], for Desktops, Web and Mobile&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
* [http://www.hiretheworld.com/blog/tech-blog/migrating-unit-tests-from-selenium-to-watir-webdriver Migrating unit tests from Selenium to Watir Web Driver] &amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://www.hiretheworld.com/blog/tech-blog/migrating-unit-tests-from-selenium-to-watir-webdriver Learning Selenium IDE] &amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/List_of_web_testing_tools List of web testing tools] &amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/List_of_web_testing_tools OWASP List of Acceptance Testing tools]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
{{reflist}}&lt;br /&gt;
&amp;lt;references /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==External Links==&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Selenium_(software) Selenium Wiki Page] &amp;lt;br /&amp;gt;&lt;br /&gt;
* [https://github.com/SeleniumHQ/selenium Selenium Source Code] &amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Watir Watir Wiki Page] &amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Watir Watir Source Code] &amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Watir SauceLabs HomePage] &amp;lt;br /&amp;gt;&lt;/div&gt;</summary>
		<author><name>Jjbeaver</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/ch1b_27_js&amp;diff=89434</id>
		<title>CSC/ECE 517 Fall 2014/ch1b 27 js</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/ch1b_27_js&amp;diff=89434"/>
		<updated>2014-10-07T03:48:47Z</updated>

		<summary type="html">&lt;p&gt;Jjbeaver: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;='''Selenium vs. Watir'''=&lt;br /&gt;
&lt;br /&gt;
Developing web applications is proving to be a challenging task with each passing day given the complex requirements and the demanding nature of the these applications. For the web applications to be robust we need to put in place some good testing strategies.&lt;br /&gt;
&lt;br /&gt;
'''''Selenium''''' is one of the most popularly used open source automation tools for web based applications. It is a JavaScript framework that runs in your web browser to interact with various elements in your browser. All in all, Selenium is a set of different software tools each with a different approach to supporting test automation. Selenium provides a rich set of testing functions that can be customized to suit the testing requirements.&lt;br /&gt;
 &lt;br /&gt;
'''''Watir''''', is another lightweight automation testing tool that is widely used for web app testing. It is an open-source ([http://en.wikipedia.org/wiki/BSD_licenses BSD])  family of Ruby libraries for automating web browsers. It allows you to write tests that are easy to read and maintain. Despite the fact that it is a set of Ruby libraries, it works perfectly, independent of the language that the web application is developed in. Watir as a tool is extremely simple and flexible.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=='''Motivation'''==&lt;br /&gt;
===Need for test automation===&lt;br /&gt;
With the majority of software applications today being implemented as [http://en.wikipedia.org/wiki/Web_application web applications] to be used over the internet, testing is becoming an indispensable part of the software development lifecycle ([http://en.wikipedia.org/wiki/Software_development_process SDLC]) of these applications. [http://en.wikipedia.org/wiki/Test_automation Test automation] is used where manual testing needs to be carried out repeatedly making it a cumbersome task. Test automation uses a software tool for this purpose on the application to be tested. It has proven to be highly efficient and critical in larger software development companies. Additionally, automation can be a valuable way to make Test Driven Development ([http://en.wikipedia.org/wiki/Test-driven_development TDD]) tasks an important part of the software development workflow.&lt;br /&gt;
 &lt;br /&gt;
Test Automation has a number of advantages mostly dealing with repetitiveness of the tests and the time taken,&lt;br /&gt;
* '''Covers cases that manual testing probably cannot'''&lt;br /&gt;
# Finds defects missed out my manual testing&lt;br /&gt;
# Automated testing can simulate numerous virtual users interacting with the web software/application&lt;br /&gt;
* '''Helps save time and money'''&lt;br /&gt;
# Once created, automated tests can be executed repeatedly at no additional   costs and at a much faster pace. Saving time directly translates into saving cost.&lt;br /&gt;
# Supports virtually unlimited iterations of test case execution&lt;br /&gt;
* '''Increase test coverage and accuracy'''&lt;br /&gt;
# Automated tests perform the exact same steps and records all details precisely&lt;br /&gt;
# They also increase the depth and scope of tests to improve the quality of the software&lt;br /&gt;
&lt;br /&gt;
=='''Brief History'''==&lt;br /&gt;
====Selenium====&lt;br /&gt;
&lt;br /&gt;
[[File: SE-logo.png|right|Selenium Logo|link=http://www.seleniumhq.org/images/big-logo.png]]&lt;br /&gt;
&lt;br /&gt;
''Selenium'' was developed in the year 2004 by Jason Huggins and has been continuously evolving ever since. Jason Huggins developed this as an internal tool for [http://en.wikipedia.org/wiki/ThoughtWorks ThoughtWorks] as a javascript library which came to be known as the Selenium core. Selenium core is now the basis of the Selenium Remote Control (the server) and Selenium IDE.&lt;br /&gt;
The year 2006 marked the beginning of the development of the WebDriver project which was what they believed ‘a tool of the future’. The WebDriver was initiated to solve the problems that were faced due to the fact that Selenium was a based on JavaScript and a lot of security limitations browsers apply to Javascript.&lt;br /&gt;
In 2008, both Selenium and WebDriver merged to provide a common set of features to all users which is called Selenium 2..&lt;br /&gt;
Simon Stewart, the creator of WebDriver, in a joint email to the WebDriver and Selenium community on August 6, 2009 said the following,&lt;br /&gt;
&lt;br /&gt;
“Why are the projects merging? Partly because webdriver addresses some shortcomings in selenium (by being able to bypass the JS sandbox, for example. And we’ve got a gorgeous API), partly because selenium addresses some shortcomings in webdriver (such as supporting a broader range of browsers) and partly because the main selenium contributors and I felt that it was the best way to offer users the best possible framework.”&amp;lt;ref name =&amp;quot;Introduction to Selenium&amp;quot;&amp;gt;[http://docs.seleniumhq.org/docs/01_introducing_selenium.jsp#selenium-history Introducing Selenium]. ''SeleniumHQ: Browser Automation''. Selenium Project, 4 Oct. 2014. Web. 06 Oct. 2014.&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Watir====&lt;br /&gt;
&lt;br /&gt;
''Watir'' started as a library to teach testers to write ruby code and grew to be an IE implementation which now supports IE, Firefox, Safari, Google Chrome and Opera.&lt;br /&gt;
Watir was primarily developed by Bret Pettichord and Paul Rogers. Watir has since then has a couple of stable releases for Watir classic as well as Watir WebDriver. The most recent releases being&amp;lt;ref&amp;gt;[http://watir.com/category/releases/ Watir Releases]. Watir: Web Application Testing in Ruby. 28 April, 2013&amp;lt;/ref&amp;gt;, &lt;br /&gt;
&lt;br /&gt;
[[File: Watir.gif|right|Watir logo|link=http://upload.wikimedia.org/wikipedia/commons/7/7e/Watir.gif]]&lt;br /&gt;
&lt;br /&gt;
* Watir-Classic	    &lt;br /&gt;
# 0.6.3 April 10, 2013 ([https://github.com/watir/watir-webdriver/blob/master/CHANGES.md#063 Release Notes]) &amp;lt;br /&amp;gt;&lt;br /&gt;
* Watir-WebDriver	    &lt;br /&gt;
# 3.6.0 March 16, 2013 ([https://groups.google.com/forum/#!msg/watir-general/MOOun5g3Hvg/JBVNy957lDYJ Release Notes]) &amp;lt;br /&amp;gt;&lt;br /&gt;
# 3.5.0 March 10, 2013 ([https://groups.google.com/forum/#!msg/watir-general/aeUqsglvK6k/Kq7FCBiERjYJ Release Notes]) &amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Watir has a google group ([https://groups.google.com/forum/#!forum/watir-general Watir General]) for its support and contribution while Selenium also has a [http://seleniumforum.forumotion.net/ Selenium forum] apart from its google group called [https://groups.google.com/forum/#!forum/selenium-users Selenium Users].&lt;br /&gt;
&lt;br /&gt;
=='''Comparison of Features, Functionality, and More'''==&lt;br /&gt;
Some features or functionality may be repeated here.  However, we will go into a bit more detail than previously mentioned.&lt;br /&gt;
===='''Open Source'''====&lt;br /&gt;
Both Selenium and Watir are [http://en.wikipedia.org/wiki/Open-source_software open source]!  This allows for greater extensibility and a deeper understanding of the inner workings of both of the frameworks, if the developer/tester chooses to delve into such details.  Additionally, the open source community allows for a more transparent, user-driven development and support cycle.  Users (the tester/developer) can choose to submit bug fixes or enhancements as patches, or they can choose to just use it “straight out of the box.”&lt;br /&gt;
&lt;br /&gt;
====Application Language Agnostic====&lt;br /&gt;
&lt;br /&gt;
Both Selenium and Watir are application language agnostic.  Because both Selenium and Watir test UI functionality in the browser, they can be used to test any web application.    &lt;br /&gt;
&lt;br /&gt;
====Language-specific Test Cases====&lt;br /&gt;
&lt;br /&gt;
Both Selenium and Watir require test cases to be written in some programming language.  Traditionally, both frameworks had limited choices in terms of language bindings.  However, with the advent of WebDriver, both became much more flexible.  WebDriver provided the bindings needed for many languages.  Today, the following are supported:&lt;br /&gt;
&lt;br /&gt;
'''Selenium*'''&lt;br /&gt;
&lt;br /&gt;
* Officially-supported: [http://en.wikipedia.org/wiki/Java_(programming_language) Java], [http://en.wikipedia.org/wiki/C_Sharp_(programming_language) C#], [http://en.wikipedia.org/wiki/Ruby_(programming_language) Ruby], [http://en.wikipedia.org/wiki/Python_(programming_language) Python], [http://en.wikipedia.org/wiki/Node.js Javascript/Node.js]&lt;br /&gt;
&lt;br /&gt;
* Unofficial/community-supported: [http://en.wikipedia.org/wiki/Perl Perl], [http://en.wikipedia.org/wiki/PHP PHP], [http://en.wikipedia.org/wiki/Haskell_(programming_language) Haskell], [http://en.wikipedia.org/wiki/Objective-C Objective-C], [http://en.wikipedia.org/wiki/R_(programming_language) R], [http://en.wikipedia.org/wiki/Dart_(programming_language) Dart], [http://en.wikipedia.org/wiki/Tcl Tcl]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;According to SeleniumHQ’s download page.&lt;br /&gt;
&lt;br /&gt;
'''Watir'''&lt;br /&gt;
&lt;br /&gt;
Unfortunately (or fortunately), Ruby is the only supported language for Watir.  After all, Watir does stand for “Web Application Testing in Ruby.” However, there are other frameworks which were inspired by Watir (but entirely separate) available in Java and C# - Watij and Watin,  respectively &amp;lt;ref&amp;gt;Djorgjievski, Darko. [http://www.sitepoint.com/watir-webdriver-control-browser/ Watir-WebDriver: Control the Browser]. ''SitePoint''. SitePoint Pty Ltd, 18 Apr. 2014. Web. 05 Oct. 2014.&amp;lt;/ref&amp;gt;.  There may be other similarly inspired frameworks available in other languages, but these are the most notable.&lt;br /&gt;
&lt;br /&gt;
====Cross-Browser and Headless Browser Support====&lt;br /&gt;
&lt;br /&gt;
[[File: watir_meet_webdriver.png | Watir Meets WebDriver |right|frame| link=http://yuml.me/diagram/scruffy/usecase/%5BTester%5D-%28Watir%20API%29,%20%28Watir%20API%29%3C%28FireWatir%29,%20%28Watir%20API%29%3C%28Watir%29,%20%28Watir%20API%29%3C%28SafariWatir%29,%20%28Watir%20API%29%3C%28Webdriver%29,%20%28Watir%20API%29%3C%28Celerity%29,%20%28Celerity%29-%28note:%20Celerity%20requires%20JRuby%29,%20%28Celerity%29-%28headless%29,%20%28Webdriver%29-%28Firefox%29,%20%28Webdriver%29-%28Chrome%29,%20%28Webdriver%29-%28IE%29,%20%28Webdriver%29-%28headless%29,%20%28FireWatir%29-%28Firefox%29,%20%28Watir%29-%28IE%29,%20%28SafariWatir%29-%28Safari%29.]]&lt;br /&gt;
&lt;br /&gt;
Traditionally, both Selenium and Watir were limited in the number of browsers they supported. Watir originally supported Internet Explorer and headless browsers exclusively.  Headless browsers were supported via the use of Celerity &amp;lt;ref&amp;gt;Scott, Alister. [http://watirmelon.com/2010/04/10/watir-selenium-webdriver/ Watir, Selenium &amp;amp; WebDriver]. ''Watirmelon''. Watirmelon, 10 Apr. 2010. Web. 05 Oct. 2014.&amp;lt;/ref&amp;gt;.  Selenium started out as a Javascript library, so naturally it supported more browsers such as IE, Firefox, Safari, etc &amp;lt;ref name = &amp;quot;Introduction to Selenium&amp;quot; /&amp;gt;.  However, it did not support headless browsers.&lt;br /&gt;
Today, browser support looks much better for both Selenium and Watir, largely due to the introduction of WebDriver.  With WebDriver in existence, support for most browsers was added to Watir via the gem &amp;quot;watir-webdriver,&amp;quot; and Celerity became obsolete because headless browser support was included in WebDriver.  Similarly for Selenium, support for headless browsers was added, as well as making the API much simpler and more concise &amp;lt;ref&amp;gt;[http://docs.seleniumhq.org/projects/webdriver/ Selenium WebDriver]. ''SeleniumHQ: Browser Automation''. Selenium Project, n.d. Web. 06 Oct. 2014.&amp;lt;/ref&amp;gt;.  However, there is the obvious limitation that one can only test a browser which is supported on the running platform.  In other words, Safari and Internet explorer can only be tested on  OS X and Windows environments, respectively**.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;**&amp;lt;/nowiki&amp;gt; &amp;lt;span style=&amp;quot;font-size:88%&amp;quot;&amp;gt;Some work-arounds or programs may exist to allow these browsers to be tested on other platforms. Here, we are assuming no special additional configuration - just the base operating system and browsers.  With virtualization technologies such as [http://www.linux-kvm.org/page/Main_Page KVM], [https://www.virtualbox.org/ VirtualBox], and [http://en.wikipedia.org/wiki/Comparison_of_platform_virtualization_software others], this isn't a problem anyway.  [http://en.wikipedia.org/wiki/Virtual_machine Virtual machines] can be created with any operating system, as needed.&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Cross-Platform Support====&lt;br /&gt;
Both Watir and Selenium run on most popular distributions of Windows, Mac, and Linux.  Selenium doesn't have a list of officially supported operating system versions.  Instead they generally support any version that is currently popular.  Only a few versions are listed which they run test builds on.  These are versions which are officially known to work, but many more are supported as well.&lt;br /&gt;
&lt;br /&gt;
Because Watir is a collection of Ruby Gems, it runs on any platform that Ruby runs on.  Like Selenium, this includes nearly all popular platforms.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=='''Getting started'''==&lt;br /&gt;
===Selenium WebDriver=== &lt;br /&gt;
----&lt;br /&gt;
====Install/Configure for Java====&lt;br /&gt;
Configuring Selenium requires you to download the binaries from [http://www.seleniumhq.org/download/ here]. &lt;br /&gt;
Once you have all your binaries in a directory, you can open any IDE of your choice and add this directory with all the .jar files to the CLASSPATH&lt;br /&gt;
*Example&lt;br /&gt;
This is how a typical Selenium code to find the term say, “Automation” on Google and display the results on the page would look like in Java using the [https://code.google.com/p/selenium/wiki/HtmlUnitDriver HtmlUnitDriver] would look like.&lt;br /&gt;
The HtmlUnitDriver is a pure Java driver that runs entirely in-memory. Because of this, you won't see a new browser window open &amp;lt;ref&amp;gt;[https://code.google.com/p/selenium/wiki/GettingStarted Getting started with Selenium]. Selenium: Browser Automation Framework. Google Code. 8 Feb, 2014.&amp;lt;/ref&amp;gt;,&lt;br /&gt;
&lt;br /&gt;
       package org.selenium.example;&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;
       import org.openqa.selenium.By;&lt;br /&gt;
       import org.openqa.selenium.WebDriver;&lt;br /&gt;
       import org.openqa.selenium.WebElement;&lt;br /&gt;
       import org.openqa.selenium.htmlunit.HtmlUnitDriver;&amp;lt;br /&amp;gt;&lt;br /&gt;
       public class Example  {&lt;br /&gt;
       public static void main(String[] args) {&lt;br /&gt;
        // Create a new instance of the html unit driver&lt;br /&gt;
        // Notice that the remainder of the code relies on the interface,&lt;br /&gt;
        // not the implementation.&lt;br /&gt;
        WebDriver driver = new HtmlUnitDriver();&amp;lt;br /&amp;gt;&lt;br /&gt;
        // And now use this to visit Google&lt;br /&gt;
        driver.get(&amp;quot;http://www.google.com&amp;quot;);&amp;lt;br /&amp;gt;&lt;br /&gt;
        // Find the text input element by its name&lt;br /&gt;
        WebElement element = driver.findElement(By.name(&amp;quot;q&amp;quot;));&amp;lt;br /&amp;gt;&lt;br /&gt;
        // Enter something to search for&lt;br /&gt;
        element.sendKeys(&amp;quot;Automation!&amp;quot;);&amp;lt;br /&amp;gt;&lt;br /&gt;
        // Now submit the form. WebDriver will find the form for us from the element&lt;br /&gt;
        element.submit();&amp;lt;br /&amp;gt;&lt;br /&gt;
        // Check the title of the page&lt;br /&gt;
        System.out.println(&amp;quot;Page title is: &amp;quot; + driver.getTitle());&lt;br /&gt;
        driver.quit();&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
If you compile and run it, you should see a line with the title of the Google search results as output. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Install/Configure for other languages====&lt;br /&gt;
Configuring Selenium for languages other than Java and for other development environments can be looked up [http://docs.seleniumhq.org/docs/03_webdriver.jsp#setting-up-a-selenium-webdriver-project here]. viz(C#, Ruby, Python, PHP, Perl, Javascript)&lt;br /&gt;
&lt;br /&gt;
===Watir===&lt;br /&gt;
----&lt;br /&gt;
====Install/Configure====&lt;br /&gt;
Drivers for Watir are installed as gems which are nothing but Ruby libraries which can be accessed over the internet.&lt;br /&gt;
All the instructions for installing Watir on various operating systems (viz. Windows, Mac OS, Linux) can be found [http://watir.com/installation/ here].&lt;br /&gt;
&lt;br /&gt;
*Example:&lt;br /&gt;
This is how a typical Watir code to find the term say, “Automation” on Google and display the results on the page would look like using Ruby&amp;lt;ref&amp;gt;Chernenko, Iryna. [http://blog.qatestlab.com/2011/02/23/automated-testing-with-watir-tutorial-for-begginers-part-1/ Watir Example]. QATestLab Blog: Automated Testing with Watir, 23 Feb 2011.&lt;br /&gt;
&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
        # Required in ruby 1.8.7&lt;br /&gt;
        require 'rubygems'&lt;br /&gt;
        # Watir IE driver&lt;br /&gt;
        require 'watir'&amp;lt;br /&amp;gt; &lt;br /&gt;
        ie = Watir::IE.new&amp;lt;br /&amp;gt; &lt;br /&gt;
        # text to show on console&lt;br /&gt;
        puts &amp;quot;Beginning of the test for Google search engine&amp;quot;&lt;br /&gt;
        puts &amp;quot;Step 1:  Go to the Google homepage&amp;quot;&lt;br /&gt;
        ie.goto &amp;quot;http://www.google.com&amp;quot;&amp;lt;br /&amp;gt;&lt;br /&gt;
        #set a variable&lt;br /&gt;
        search_text = &amp;quot;Automation&amp;quot;&lt;br /&gt;
        puts &amp;quot;Step 2: enter &amp;quot;+ search_text +&amp;quot; in the search text field.&amp;quot;&lt;br /&gt;
        ie.text_field(:name, &amp;quot;q&amp;quot;).set search_text   # &amp;quot;q&amp;quot; is the name of the search field&amp;lt;br /&amp;gt;&lt;br /&gt;
        puts &amp;quot; Step 3: click the 'Google Search' button.&amp;quot;&lt;br /&gt;
        ie.button(:name, &amp;quot;btnG&amp;quot;).click # &amp;quot;btnG&amp;quot; is the name of the Search button&amp;lt;br /&amp;gt;&lt;br /&gt;
        puts &amp;quot; Expected Result:&amp;quot;&lt;br /&gt;
        puts &amp;quot;  A Google page with results should be shown. 'Watir, pronounced water' should be high on the list.&amp;quot;&lt;br /&gt;
        puts &amp;quot; Actual Result:&amp;quot;&lt;br /&gt;
        if ie.text.include? &amp;quot;Watir, pronounced water&amp;quot;	&lt;br /&gt;
             puts &amp;quot;  Test Passed. Found the text string: 'Watir, pronounced water'. Actual Results match Expected Results.&amp;quot;&lt;br /&gt;
        else	&lt;br /&gt;
 	     puts &amp;quot;  Test Failed! Could not find text: 'Watir, pronounced water'.&amp;quot;&lt;br /&gt;
        end&lt;br /&gt;
        puts &amp;quot;End of test: Google search.&amp;quot;&lt;br /&gt;
        ie.close&lt;br /&gt;
&lt;br /&gt;
On compiling and running this and passing the test, you will see something like, &amp;lt;br /&amp;gt; &lt;br /&gt;
&lt;br /&gt;
        ''Output:''&lt;br /&gt;
        Beginning of the test for Google search engine &amp;lt;br /&amp;gt;&lt;br /&gt;
        Step 1:  Go to the Google homepage &amp;lt;br /&amp;gt;&lt;br /&gt;
        Step 2: enter Automation in the search text field. &amp;lt;br /&amp;gt;&lt;br /&gt;
        Step 3: click the 'Google Search' button. &amp;lt;br /&amp;gt;&lt;br /&gt;
        Expected Result: &amp;lt;br /&amp;gt;&lt;br /&gt;
        A Google page with results should be shown. 'Watir, pronounced water' should be high on the list. &amp;lt;br /&amp;gt;	&lt;br /&gt;
        Test Passed. Found the text string: 'Watir, pronounced water'. Actual Results match Expected Results. &amp;lt;br /&amp;gt;&lt;br /&gt;
        End of test: Google search. &amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Similar Tools==&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Sahi_(software) Sahi], uses the Sahi Scripting Language&amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Soatest SOATest], for testing and validating [http://en.wikipedia.org/wiki/Application_programming_interface API] driven applications &amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/TestComplete TestComplete], for Desktops, Web and Mobile&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
* [http://www.hiretheworld.com/blog/tech-blog/migrating-unit-tests-from-selenium-to-watir-webdriver Migrating unit tests from Selenium to Watir Web Driver] &amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://www.hiretheworld.com/blog/tech-blog/migrating-unit-tests-from-selenium-to-watir-webdriver Learning Selenium IDE] &amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/List_of_web_testing_tools List of web testing tools] &amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/List_of_web_testing_tools OWASP List of Acceptance Testing tools]&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
{{reflist}}&lt;br /&gt;
&amp;lt;references /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==External Links==&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Selenium_(software) Selenium Wiki Page] &amp;lt;br /&amp;gt;&lt;br /&gt;
* [https://github.com/SeleniumHQ/selenium Selenium Source Code] &amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Watir Watir Wiki Page] &amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Watir Watir Source Code] &amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Watir SauceLabs HomePage] &amp;lt;br /&amp;gt;&lt;/div&gt;</summary>
		<author><name>Jjbeaver</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/ch1b_27_js&amp;diff=89433</id>
		<title>CSC/ECE 517 Fall 2014/ch1b 27 js</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/ch1b_27_js&amp;diff=89433"/>
		<updated>2014-10-07T03:48:25Z</updated>

		<summary type="html">&lt;p&gt;Jjbeaver: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;='''Selenium vs. Watir'''=&lt;br /&gt;
&lt;br /&gt;
Developing web applications is proving to be a challenging task with each passing day given the complex requirements and the demanding nature of the these applications. For the web applications to be robust we need to put in place some good testing strategies.&lt;br /&gt;
&lt;br /&gt;
'''''Selenium''''' is one of the most popularly used open source automation tools for web based applications. It is a JavaScript framework that runs in your web browser to interact with various elements in your browser. All in all, Selenium is a set of different software tools each with a different approach to supporting test automation. Selenium provides a rich set of testing functions that can be customized to suit the testing requirements.&lt;br /&gt;
 &lt;br /&gt;
'''''Watir''''', is another lightweight automation testing tool that is widely used for web app testing. It is an open-source ([http://en.wikipedia.org/wiki/BSD_licenses BSD])  family of Ruby libraries for automating web browsers. It allows you to write tests that are easy to read and maintain. Despite the fact that it is a set of Ruby libraries, it works perfectly, independent of the language that the web application is developed in. Watir as a tool is extremely simple and flexible.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=='''Motivation'''==&lt;br /&gt;
===Need for test automation===&lt;br /&gt;
With the majority of software applications today being implemented as [http://en.wikipedia.org/wiki/Web_application web applications] to be used over the internet, testing is becoming an indispensable part of the software development lifecycle ([http://en.wikipedia.org/wiki/Software_development_process SDLC]) of these applications. [http://en.wikipedia.org/wiki/Test_automation Test automation] is used where manual testing needs to be carried out repeatedly making it a cumbersome task. Test automation uses a software tool for this purpose on the application to be tested. It has proven to be highly efficient and critical in larger software development companies. Additionally, automation can be a valuable way to make Test Driven Development ([http://en.wikipedia.org/wiki/Test-driven_development TDD]) tasks an important part of the software development workflow.&lt;br /&gt;
 &lt;br /&gt;
Test Automation has a number of advantages mostly dealing with repetitiveness of the tests and the time taken,&lt;br /&gt;
* '''Covers cases that manual testing probably cannot'''&lt;br /&gt;
# Finds defects missed out my manual testing&lt;br /&gt;
# Automated testing can simulate numerous virtual users interacting with the web software/application&lt;br /&gt;
* '''Helps save time and money'''&lt;br /&gt;
# Once created, automated tests can be executed repeatedly at no additional   costs and at a much faster pace. Saving time directly translates into saving cost.&lt;br /&gt;
# Supports virtually unlimited iterations of test case execution&lt;br /&gt;
* '''Increase test coverage and accuracy'''&lt;br /&gt;
# Automated tests perform the exact same steps and records all details precisely&lt;br /&gt;
# They also increase the depth and scope of tests to improve the quality of the software&lt;br /&gt;
&lt;br /&gt;
=='''Brief History'''==&lt;br /&gt;
====Selenium====&lt;br /&gt;
&lt;br /&gt;
[[File: SE-logo.png|right|Selenium Logo|link=http://www.seleniumhq.org/images/big-logo.png]]&lt;br /&gt;
&lt;br /&gt;
''Selenium'' was developed in the year 2004 by Jason Huggins and has been continuously evolving ever since. Jason Huggins developed this as an internal tool for [http://en.wikipedia.org/wiki/ThoughtWorks ThoughtWorks] as a javascript library which came to be known as the Selenium core. Selenium core is now the basis of the Selenium Remote Control (the server) and Selenium IDE.&lt;br /&gt;
The year 2006 marked the beginning of the development of the WebDriver project which was what they believed ‘a tool of the future’. The WebDriver was initiated to solve the problems that were faced due to the fact that Selenium was a based on JavaScript and a lot of security limitations browsers apply to Javascript.&lt;br /&gt;
In 2008, both Selenium and WebDriver merged to provide a common set of features to all users which is called Selenium 2..&lt;br /&gt;
Simon Stewart, the creator of WebDriver, in a joint email to the WebDriver and Selenium community on August 6, 2009 said the following,&lt;br /&gt;
&lt;br /&gt;
“Why are the projects merging? Partly because webdriver addresses some shortcomings in selenium (by being able to bypass the JS sandbox, for example. And we’ve got a gorgeous API), partly because selenium addresses some shortcomings in webdriver (such as supporting a broader range of browsers) and partly because the main selenium contributors and I felt that it was the best way to offer users the best possible framework.”&amp;lt;ref name =&amp;quot;Introduction to Selenium&amp;quot;&amp;gt;[http://docs.seleniumhq.org/docs/01_introducing_selenium.jsp#selenium-history Introducing Selenium]. ''SeleniumHQ: Browser Automation''. Selenium Project, 4 Oct. 2014. Web. 06 Oct. 2014.&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Watir====&lt;br /&gt;
&lt;br /&gt;
''Watir'' started as a library to teach testers to write ruby code and grew to be an IE implementation which now supports IE, Firefox, Safari, Google Chrome and Opera.&lt;br /&gt;
Watir was primarily developed by Bret Pettichord and Paul Rogers. Watir has since then has a couple of stable releases for Watir classic as well as Watir WebDriver. The most recent releases being&amp;lt;ref&amp;gt;[http://watir.com/category/releases/ Watir Releases]. Watir: Web Application Testing in Ruby. 28 April, 2013&amp;lt;/ref&amp;gt;, &lt;br /&gt;
&lt;br /&gt;
[[File: Watir.gif|right|Watir logo|link=http://upload.wikimedia.org/wikipedia/commons/7/7e/Watir.gif]]&lt;br /&gt;
&lt;br /&gt;
* Watir-Classic	    &lt;br /&gt;
# 0.6.3 April 10, 2013 ([https://github.com/watir/watir-webdriver/blob/master/CHANGES.md#063 Release Notes]) &amp;lt;br /&amp;gt;&lt;br /&gt;
* Watir-WebDriver	    &lt;br /&gt;
# 3.6.0 March 16, 2013 ([https://groups.google.com/forum/#!msg/watir-general/MOOun5g3Hvg/JBVNy957lDYJ Release Notes]) &amp;lt;br /&amp;gt;&lt;br /&gt;
# 3.5.0 March 10, 2013 ([https://groups.google.com/forum/#!msg/watir-general/aeUqsglvK6k/Kq7FCBiERjYJ Release Notes]) &amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Watir has a google group ([https://groups.google.com/forum/#!forum/watir-general Watir General]) for its support and contribution while Selenium also has a [http://seleniumforum.forumotion.net/ Selenium forum] apart from its google group called [https://groups.google.com/forum/#!forum/selenium-users Selenium Users].&lt;br /&gt;
&lt;br /&gt;
=='''Comparison of Features, Functionality, and More'''==&lt;br /&gt;
Some features or functionality may be repeated here.  However, we will go into a bit more detail than previously mentioned.&lt;br /&gt;
===='''Open Source'''====&lt;br /&gt;
Both Selenium and Watir are [http://en.wikipedia.org/wiki/Open-source_software open source]!  This allows for greater extensibility and a deeper understanding of the inner workings of both of the frameworks, if the developer/tester chooses to delve into such details.  Additionally, the open source community allows for a more transparent, user-driven development and support cycle.  Users (the tester/developer) can choose to submit bug fixes or enhancements as patches, or they can choose to just use it “straight out of the box.”&lt;br /&gt;
&lt;br /&gt;
====Application Language Agnostic====&lt;br /&gt;
&lt;br /&gt;
Both Selenium and Watir are application language agnostic.  Because both Selenium and Watir test UI functionality in the browser, they can be used to test any web application.    &lt;br /&gt;
&lt;br /&gt;
====Language-specific Test Cases====&lt;br /&gt;
&lt;br /&gt;
Both Selenium and Watir require test cases to be written in some programming language.  Traditionally, both frameworks had limited choices in terms of language bindings.  However, with the advent of WebDriver, both became much more flexible.  WebDriver provided the bindings needed for many languages.  Today, the following are supported:&lt;br /&gt;
&lt;br /&gt;
'''Selenium*'''&lt;br /&gt;
&lt;br /&gt;
* Officially-supported: [http://en.wikipedia.org/wiki/Java_(programming_language) Java], [http://en.wikipedia.org/wiki/C_Sharp_(programming_language) C#], [http://en.wikipedia.org/wiki/Ruby_(programming_language) Ruby], [http://en.wikipedia.org/wiki/Python_(programming_language) Python], [http://en.wikipedia.org/wiki/Node.js Javascript/Node.js]&lt;br /&gt;
&lt;br /&gt;
* Unofficial/community-supported: [http://en.wikipedia.org/wiki/Perl Perl], [http://en.wikipedia.org/wiki/PHP PHP], [http://en.wikipedia.org/wiki/Haskell_(programming_language) Haskell], [http://en.wikipedia.org/wiki/Objective-C Objective-C], [http://en.wikipedia.org/wiki/R_(programming_language) R], [http://en.wikipedia.org/wiki/Dart_(programming_language) Dart], [http://en.wikipedia.org/wiki/Tcl Tcl]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;According to SeleniumHQ’s download page.&lt;br /&gt;
&lt;br /&gt;
'''Watir'''&lt;br /&gt;
&lt;br /&gt;
Unfortunately (or fortunately), Ruby is the only supported language for Watir.  After all, Watir does stand for “Web Application Testing in Ruby.” However, there are other frameworks which were inspired by Watir (but entirely separate) available in Java and C# - Watij and Watin,  respectively &amp;lt;ref&amp;gt;Djorgjievski, Darko. [http://www.sitepoint.com/watir-webdriver-control-browser/ Watir-WebDriver: Control the Browser]. ''SitePoint''. SitePoint Pty Ltd, 18 Apr. 2014. Web. 05 Oct. 2014.&amp;lt;/ref&amp;gt;.  There may be other similarly inspired frameworks available in other languages, but these are the most notable.&lt;br /&gt;
&lt;br /&gt;
====Cross-Browser and Headless Browser Support====&lt;br /&gt;
&lt;br /&gt;
[[File: watir_meet_webdriver.png | Watir Meets WebDriver |right|frame| link=http://yuml.me/diagram/scruffy/usecase/%5BTester%5D-%28Watir%20API%29,%20%28Watir%20API%29%3C%28FireWatir%29,%20%28Watir%20API%29%3C%28Watir%29,%20%28Watir%20API%29%3C%28SafariWatir%29,%20%28Watir%20API%29%3C%28Webdriver%29,%20%28Watir%20API%29%3C%28Celerity%29,%20%28Celerity%29-%28note:%20Celerity%20requires%20JRuby%29,%20%28Celerity%29-%28headless%29,%20%28Webdriver%29-%28Firefox%29,%20%28Webdriver%29-%28Chrome%29,%20%28Webdriver%29-%28IE%29,%20%28Webdriver%29-%28headless%29,%20%28FireWatir%29-%28Firefox%29,%20%28Watir%29-%28IE%29,%20%28SafariWatir%29-%28Safari%29.]]&lt;br /&gt;
&lt;br /&gt;
Traditionally, both Selenium and Watir were limited in the number of browsers they supported. Watir originally supported Internet Explorer and headless browsers exclusively.  Headless browsers were supported via the use of Celerity &amp;lt;ref&amp;gt;Scott, Alister. [http://watirmelon.com/2010/04/10/watir-selenium-webdriver/ Watir, Selenium &amp;amp; WebDriver]. ''Watirmelon''. Watirmelon, 10 Apr. 2010. Web. 05 Oct. 2014.&amp;lt;/ref&amp;gt;.  Selenium started out as a Javascript library, so naturally it supported more browsers such as IE, Firefox, Safari, etc &amp;lt;ref name = &amp;quot;Introduction to Selenium&amp;quot; /&amp;gt;.  However, it did not support headless browsers.&lt;br /&gt;
Today, browser support looks much better for both Selenium and Watir, largely due to the introduction of WebDriver.  With WebDriver in existence, support for most browsers was added to Watir via the gem &amp;quot;watir-webdriver,&amp;quot; and Celerity became obsolete because headless browser support was included in WebDriver.  Similarly for Selenium, support for headless browsers was added, as well as making the API much simpler and more concise &amp;lt;ref&amp;gt;[http://docs.seleniumhq.org/projects/webdriver/ Selenium WebDriver]. ''SeleniumHQ: Browser Automation''. Selenium Project, n.d. Web. 06 Oct. 2014.&amp;lt;/ref&amp;gt;.  However, there is the obvious limitation that one can only test a browser which is supported on the running platform.  In other words, Safari and Internet explorer can only be tested on  OS X and Windows environments, respectively**.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;**&amp;lt;/nowiki&amp;gt; &amp;lt;span style=&amp;quot;font-size:88%&amp;quot;&amp;gt;Some work-arounds or programs may exist to allow these browsers to be tested on other platforms. Here, we are assuming no special additional configuration - just the base operating system and browsers.  With virtualization technologies such as [http://www.linux-kvm.org/page/Main_Page KVM], [https://www.virtualbox.org/ VirtualBox], and [http://en.wikipedia.org/wiki/Comparison_of_platform_virtualization_software others], this isn't a problem anyway.  [http://en.wikipedia.org/wiki/Virtual_machine Virtual machines] can be created with any operating system, as needed.&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Cross-Platform Support====&lt;br /&gt;
Both Watir and Selenium run on most popular distributions of Windows, Mac, and Linux.  Selenium doesn't have a list of officially supported operating system versions.  Instead they generally support any version that is currently popular.  Only a few versions are listed which they run test builds on.  These are versions which are officially known to work, but many more are supported as well.&lt;br /&gt;
&lt;br /&gt;
Because Watir is a collection of Ruby Gems, it runs on any platform that Ruby runs on.  Like Selenium, this includes nearly all popular platforms.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=='''Getting started'''==&lt;br /&gt;
===Selenium WebDriver=== &lt;br /&gt;
----&lt;br /&gt;
====Install/Configure for Java====&lt;br /&gt;
Configuring Selenium requires you to download the binaries from [http://www.seleniumhq.org/download/ here]. &lt;br /&gt;
Once you have all your binaries in a directory, you can open any IDE of your choice and add this directory with all the .jar files to the CLASSPATH&lt;br /&gt;
*Example&lt;br /&gt;
This is how a typical Selenium code to find the term say, “Automation” on Google and display the results on the page would look like in Java using the [https://code.google.com/p/selenium/wiki/HtmlUnitDriver HtmlUnitDriver] would look like.&lt;br /&gt;
The HtmlUnitDriver is a pure Java driver that runs entirely in-memory. Because of this, you won't see a new browser window open &amp;lt;ref&amp;gt;[https://code.google.com/p/selenium/wiki/GettingStarted Getting started with Selenium]. Selenium: Browser Automation Framework. Google Code. 8 Feb, 2014.&amp;lt;/ref&amp;gt;,&lt;br /&gt;
&lt;br /&gt;
       package org.selenium.example;&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;
       import org.openqa.selenium.By;&lt;br /&gt;
       import org.openqa.selenium.WebDriver;&lt;br /&gt;
       import org.openqa.selenium.WebElement;&lt;br /&gt;
       import org.openqa.selenium.htmlunit.HtmlUnitDriver;&amp;lt;br /&amp;gt;&lt;br /&gt;
       public class Example  {&lt;br /&gt;
       public static void main(String[] args) {&lt;br /&gt;
        // Create a new instance of the html unit driver&lt;br /&gt;
        // Notice that the remainder of the code relies on the interface,&lt;br /&gt;
        // not the implementation.&lt;br /&gt;
        WebDriver driver = new HtmlUnitDriver();&amp;lt;br /&amp;gt;&lt;br /&gt;
        // And now use this to visit Google&lt;br /&gt;
        driver.get(&amp;quot;http://www.google.com&amp;quot;);&amp;lt;br /&amp;gt;&lt;br /&gt;
        // Find the text input element by its name&lt;br /&gt;
        WebElement element = driver.findElement(By.name(&amp;quot;q&amp;quot;));&amp;lt;br /&amp;gt;&lt;br /&gt;
        // Enter something to search for&lt;br /&gt;
        element.sendKeys(&amp;quot;Automation!&amp;quot;);&amp;lt;br /&amp;gt;&lt;br /&gt;
        // Now submit the form. WebDriver will find the form for us from the element&lt;br /&gt;
        element.submit();&amp;lt;br /&amp;gt;&lt;br /&gt;
        // Check the title of the page&lt;br /&gt;
        System.out.println(&amp;quot;Page title is: &amp;quot; + driver.getTitle());&lt;br /&gt;
        driver.quit();&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
If you compile and run it, you should see a line with the title of the Google search results as output. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Install/Configure for other languages====&lt;br /&gt;
Configuring Selenium for languages other than Java and for other development environments can be looked up [http://docs.seleniumhq.org/docs/03_webdriver.jsp#setting-up-a-selenium-webdriver-project here]. viz(C#, Ruby, Python, PHP, Perl, Javascript)&lt;br /&gt;
&lt;br /&gt;
===Watir===&lt;br /&gt;
----&lt;br /&gt;
====Install/Configure====&lt;br /&gt;
Drivers for Watir are installed as gems which are nothing but Ruby libraries which can be accessed over the internet.&lt;br /&gt;
All the instructions for installing Watir on various operating systems (viz. Windows, Mac OS, Linux) can be found [http://watir.com/installation/ here].&lt;br /&gt;
&lt;br /&gt;
*Example:&lt;br /&gt;
This is how a typical Watir code to find the term say, “Automation” on Google and display the results on the page would look like using Ruby&amp;lt;ref&amp;gt;Chernenko, Iryna. [http://blog.qatestlab.com/2011/02/23/automated-testing-with-watir-tutorial-for-begginers-part-1/ Watir Example]. QATestLab Blog: Automated Testing with Watir, 23 Feb 2011.&lt;br /&gt;
&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
        # Required in ruby 1.8.7&lt;br /&gt;
        require 'rubygems'&lt;br /&gt;
        # Watir IE driver&lt;br /&gt;
        require 'watir'&amp;lt;br /&amp;gt; &lt;br /&gt;
        ie = Watir::IE.new&amp;lt;br /&amp;gt; &lt;br /&gt;
        # text to show on console&lt;br /&gt;
        puts &amp;quot;Beginning of the test for Google search engine&amp;quot;&lt;br /&gt;
        puts &amp;quot;Step 1:  Go to the Google homepage&amp;quot;&lt;br /&gt;
        ie.goto &amp;quot;http://www.google.com&amp;quot;&amp;lt;br /&amp;gt;&lt;br /&gt;
        #set a variable&lt;br /&gt;
        search_text = &amp;quot;Automation&amp;quot;&lt;br /&gt;
        puts &amp;quot;Step 2: enter &amp;quot;+ search_text +&amp;quot; in the search text field.&amp;quot;&lt;br /&gt;
        ie.text_field(:name, &amp;quot;q&amp;quot;).set search_text   # &amp;quot;q&amp;quot; is the name of the search field&amp;lt;br /&amp;gt;&lt;br /&gt;
        puts &amp;quot; Step 3: click the 'Google Search' button.&amp;quot;&lt;br /&gt;
        ie.button(:name, &amp;quot;btnG&amp;quot;).click # &amp;quot;btnG&amp;quot; is the name of the Search button&amp;lt;br /&amp;gt;&lt;br /&gt;
        puts &amp;quot; Expected Result:&amp;quot;&lt;br /&gt;
        puts &amp;quot;  A Google page with results should be shown. 'Watir, pronounced water' should be high on the list.&amp;quot;&lt;br /&gt;
        puts &amp;quot; Actual Result:&amp;quot;&lt;br /&gt;
        if ie.text.include? &amp;quot;Watir, pronounced water&amp;quot;	&lt;br /&gt;
             puts &amp;quot;  Test Passed. Found the text string: 'Watir, pronounced water'. Actual Results match Expected Results.&amp;quot;&lt;br /&gt;
        else	&lt;br /&gt;
 	     puts &amp;quot;  Test Failed! Could not find text: 'Watir, pronounced water'.&amp;quot;&lt;br /&gt;
        end&lt;br /&gt;
        puts &amp;quot;End of test: Google search.&amp;quot;&lt;br /&gt;
        ie.close&lt;br /&gt;
&lt;br /&gt;
On compiling and running this and passing the test, you will see something like, &amp;lt;br /&amp;gt; &lt;br /&gt;
&lt;br /&gt;
        ''Output:''&lt;br /&gt;
        Beginning of the test for Google search engine &amp;lt;br /&amp;gt;&lt;br /&gt;
        Step 1:  Go to the Google homepage &amp;lt;br /&amp;gt;&lt;br /&gt;
        Step 2: enter Automation in the search text field. &amp;lt;br /&amp;gt;&lt;br /&gt;
        Step 3: click the 'Google Search' button. &amp;lt;br /&amp;gt;&lt;br /&gt;
        Expected Result: &amp;lt;br /&amp;gt;&lt;br /&gt;
        A Google page with results should be shown. 'Watir, pronounced water' should be high on the list. &amp;lt;br /&amp;gt;	&lt;br /&gt;
        Test Passed. Found the text string: 'Watir, pronounced water'. Actual Results match Expected Results. &amp;lt;br /&amp;gt;&lt;br /&gt;
        End of test: Google search. &amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Similar Tools==&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Sahi_(software) Sahi], uses the Sahi Scripting Language&amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Soatest SOATest], for testing and validating [http://en.wikipedia.org/wiki/Application_programming_interface API] driven applications &amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/TestComplete TestComplete], for Desktops, Web and Mobile&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
* [http://www.hiretheworld.com/blog/tech-blog/migrating-unit-tests-from-selenium-to-watir-webdriver Migrating unit tests from Selenium to Watir Web Driver] &amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://www.hiretheworld.com/blog/tech-blog/migrating-unit-tests-from-selenium-to-watir-webdriver Learning Selenium IDE] &amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/List_of_web_testing_tools List of web testing tools] &amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/List_of_web_testing_tools OWASP List of Acceptance Testing tools]&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
{{reflist}}&lt;br /&gt;
&amp;lt;references /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==External Links==&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Selenium_(software) Selenium Wiki Page] &amp;lt;br /&amp;gt;&lt;br /&gt;
* [https://github.com/SeleniumHQ/selenium Selenium Source Code] &amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Watir Watir Wiki Page] &amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Watir Watir Source Code] &amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Watir SauceLabs HomePage] &amp;lt;br /&amp;gt;&lt;/div&gt;</summary>
		<author><name>Jjbeaver</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/ch1b_27_js&amp;diff=89432</id>
		<title>CSC/ECE 517 Fall 2014/ch1b 27 js</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/ch1b_27_js&amp;diff=89432"/>
		<updated>2014-10-07T03:47:08Z</updated>

		<summary type="html">&lt;p&gt;Jjbeaver: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;='''Selenium vs. Watir'''=&lt;br /&gt;
&lt;br /&gt;
Developing web applications is proving to be a challenging task with each passing day given the complex requirements and the demanding nature of the these applications. For the web applications to be robust we need to put in place some good testing strategies.&lt;br /&gt;
&lt;br /&gt;
'''''Selenium''''' is one of the most popularly used open source automation tools for web based applications. It is a JavaScript framework that runs in your web browser to interact with various elements in your browser. All in all, Selenium is a set of different software tools each with a different approach to supporting test automation. Selenium provides a rich set of testing functions that can be customized to suit the testing requirements.&lt;br /&gt;
 &lt;br /&gt;
'''''Watir''''', is another lightweight automation testing tool that is widely used for web app testing. It is an open-source ([http://en.wikipedia.org/wiki/BSD_licenses BSD])  family of Ruby libraries for automating web browsers. It allows you to write tests that are easy to read and maintain. Despite the fact that it is a set of Ruby libraries, it works perfectly, independent of the language that the web application is developed in. Watir as a tool is extremely simple and flexible.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=='''Motivation'''==&lt;br /&gt;
===Need for test automation===&lt;br /&gt;
With the majority of software applications today being implemented as [http://en.wikipedia.org/wiki/Web_application web applications] to be used over the internet, testing is becoming an indispensable part of the software development lifecycle ([http://en.wikipedia.org/wiki/Software_development_process SDLC]) of these applications. [http://en.wikipedia.org/wiki/Test_automation Test automation] is used where manual testing needs to be carried out repeatedly making it a cumbersome task. Test automation uses a software tool for this purpose on the application to be tested. It has proven to be highly efficient and critical in larger software development companies. Additionally, automation can be a valuable way to make Test Driven Development ([http://en.wikipedia.org/wiki/Test-driven_development TDD]) tasks an important part of the software development workflow.&lt;br /&gt;
 &lt;br /&gt;
Test Automation has a number of advantages mostly dealing with repetitiveness of the tests and the time taken,&lt;br /&gt;
* '''Covers cases that manual testing probably cannot'''&lt;br /&gt;
# Finds defects missed out my manual testing&lt;br /&gt;
# Automated testing can simulate numerous virtual users interacting with the web software/application&lt;br /&gt;
* '''Helps save time and money'''&lt;br /&gt;
# Once created, automated tests can be executed repeatedly at no additional   costs and at a much faster pace. Saving time directly translates into saving cost.&lt;br /&gt;
# Supports virtually unlimited iterations of test case execution&lt;br /&gt;
* '''Increase test coverage and accuracy'''&lt;br /&gt;
# Automated tests perform the exact same steps and records all details precisely&lt;br /&gt;
# They also increase the depth and scope of tests to improve the quality of the software&lt;br /&gt;
&lt;br /&gt;
=='''Brief History'''==&lt;br /&gt;
====Selenium====&lt;br /&gt;
&lt;br /&gt;
[[File: SE-logo.png|right|Selenium Logo|link=http://www.seleniumhq.org/images/big-logo.png]]&lt;br /&gt;
&lt;br /&gt;
''Selenium'' was developed in the year 2004 by Jason Huggins and has been continuously evolving ever since. Jason Huggins developed this as an internal tool for [http://en.wikipedia.org/wiki/ThoughtWorks ThoughtWorks] as a javascript library which came to be known as the Selenium core. Selenium core is now the basis of the Selenium Remote Control (the server) and Selenium IDE.&lt;br /&gt;
The year 2006 marked the beginning of the development of the WebDriver project which was what they believed ‘a tool of the future’. The WebDriver was initiated to solve the problems that were faced due to the fact that Selenium was a based on JavaScript and a lot of security limitations browsers apply to Javascript.&lt;br /&gt;
In 2008, both Selenium and WebDriver merged to provide a common set of features to all users which is called Selenium 2..&lt;br /&gt;
Simon Stewart, the creator of WebDriver, in a joint email to the WebDriver and Selenium community on August 6, 2009 said the following,&lt;br /&gt;
&lt;br /&gt;
“Why are the projects merging? Partly because webdriver addresses some shortcomings in selenium (by being able to bypass the JS sandbox, for example. And we’ve got a gorgeous API), partly because selenium addresses some shortcomings in webdriver (such as supporting a broader range of browsers) and partly because the main selenium contributors and I felt that it was the best way to offer users the best possible framework.”&amp;lt;ref name =&amp;quot;Introduction to Selenium&amp;quot;&amp;gt;[http://docs.seleniumhq.org/docs/01_introducing_selenium.jsp#selenium-history Introducing Selenium]. ''SeleniumHQ: Browser Automation''. Selenium Project, 4 Oct. 2014. Web. 06 Oct. 2014.&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Watir====&lt;br /&gt;
&lt;br /&gt;
''Watir'' started as a library to teach testers to write ruby code and grew to be an IE implementation which now supports IE, Firefox, Safari, Google Chrome and Opera.&lt;br /&gt;
Watir was primarily developed by Bret Pettichord and Paul Rogers. Watir has since then has a couple of stable releases for Watir classic as well as Watir WebDriver. The most recent releases being&amp;lt;ref&amp;gt;[http://watir.com/category/releases/ Watir Releases]. Watir: Web Application Testing in Ruby. 28 April, 2013&amp;lt;/ref&amp;gt;, &lt;br /&gt;
&lt;br /&gt;
[[File: Watir.gif|right|Watir logo|link=http://upload.wikimedia.org/wikipedia/commons/7/7e/Watir.gif]]&lt;br /&gt;
&lt;br /&gt;
* Watir-Classic	    &lt;br /&gt;
# 0.6.3 April 10, 2013 ([https://github.com/watir/watir-webdriver/blob/master/CHANGES.md#063 Release Notes]) &amp;lt;br /&amp;gt;&lt;br /&gt;
* Watir-WebDriver	    &lt;br /&gt;
# 3.6.0 March 16, 2013 ([https://groups.google.com/forum/#!msg/watir-general/MOOun5g3Hvg/JBVNy957lDYJ Release Notes]) &amp;lt;br /&amp;gt;&lt;br /&gt;
# 3.5.0 March 10, 2013 ([https://groups.google.com/forum/#!msg/watir-general/aeUqsglvK6k/Kq7FCBiERjYJ Release Notes]) &amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Watir has a google group ([https://groups.google.com/forum/#!forum/watir-general Watir General]) for its support and contribution while Selenium also has a [http://seleniumforum.forumotion.net/ Selenium forum] apart from its google group called [https://groups.google.com/forum/#!forum/selenium-users Selenium Users].&lt;br /&gt;
&lt;br /&gt;
=='''Comparison of Features, Functionality, and More'''==&lt;br /&gt;
Some features or functionality may be repeated here.  However, we will go into a bit more detail than previously mentioned.&lt;br /&gt;
===='''Open Source'''====&lt;br /&gt;
Both Selenium and Watir are [http://en.wikipedia.org/wiki/Open-source_software open source]!  This allows for greater extensibility and a deeper understanding of the inner workings of both of the frameworks, if the developer/tester chooses to delve into such details.  Additionally, the open source community allows for a more transparent, user-driven development and support cycle.  Users (the tester/developer) can choose to submit bug fixes or enhancements as patches, or they can choose to just use it “straight out of the box.”&lt;br /&gt;
&lt;br /&gt;
====Application Language Agnostic====&lt;br /&gt;
&lt;br /&gt;
Both Selenium and Watir are application language agnostic.  Because both Selenium and Watir test UI functionality in the browser, they can be used to test any web application.    &lt;br /&gt;
&lt;br /&gt;
====Language-specific Test Cases====&lt;br /&gt;
&lt;br /&gt;
Both Selenium and Watir require test cases to be written in some programming language.  Traditionally, both frameworks had limited choices in terms of language bindings.  However, with the advent of WebDriver, both became much more flexible.  WebDriver provided the bindings needed for many languages.  Today, the following are supported:&lt;br /&gt;
&lt;br /&gt;
'''Selenium*'''&lt;br /&gt;
&lt;br /&gt;
* Officially-supported: [http://en.wikipedia.org/wiki/Java_(programming_language) Java], [http://en.wikipedia.org/wiki/C_Sharp_(programming_language) C#], [http://en.wikipedia.org/wiki/Ruby_(programming_language) Ruby], [http://en.wikipedia.org/wiki/Python_(programming_language) Python], [http://en.wikipedia.org/wiki/Node.js Javascript/Node.js]&lt;br /&gt;
&lt;br /&gt;
* Unofficial/community-supported: [http://en.wikipedia.org/wiki/Perl Perl], [http://en.wikipedia.org/wiki/PHP PHP], [http://en.wikipedia.org/wiki/Haskell_(programming_language) Haskell], [http://en.wikipedia.org/wiki/Objective-C Objective-C], [http://en.wikipedia.org/wiki/R_(programming_language) R], [http://en.wikipedia.org/wiki/Dart_(programming_language) Dart], [http://en.wikipedia.org/wiki/Tcl Tcl]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;According to SeleniumHQ’s download page.&lt;br /&gt;
&lt;br /&gt;
'''Watir'''&lt;br /&gt;
&lt;br /&gt;
Unfortunately (or fortunately), Ruby is the only supported language for Watir.  After all, Watir does stand for “Web Application Testing in Ruby.” However, there are other frameworks which were inspired by Watir (but entirely separate) available in Java and C# - Watij and Watin,  respectively &amp;lt;ref&amp;gt;Djorgjievski, Darko. [http://www.sitepoint.com/watir-webdriver-control-browser/ Watir-WebDriver: Control the Browser]. ''SitePoint''. SitePoint Pty Ltd, 18 Apr. 2014. Web. 05 Oct. 2014.&amp;lt;/ref&amp;gt;.  There may be other similarly inspired frameworks available in other languages, but these are the most notable.&lt;br /&gt;
&lt;br /&gt;
====Cross-Browser and Headless Browser Support====&lt;br /&gt;
&lt;br /&gt;
[[File: watir_meet_webdriver.png | Watir Meets WebDriver |right|frame| link=http://yuml.me/diagram/scruffy/usecase/%5BTester%5D-%28Watir%20API%29,%20%28Watir%20API%29%3C%28FireWatir%29,%20%28Watir%20API%29%3C%28Watir%29,%20%28Watir%20API%29%3C%28SafariWatir%29,%20%28Watir%20API%29%3C%28Webdriver%29,%20%28Watir%20API%29%3C%28Celerity%29,%20%28Celerity%29-%28note:%20Celerity%20requires%20JRuby%29,%20%28Celerity%29-%28headless%29,%20%28Webdriver%29-%28Firefox%29,%20%28Webdriver%29-%28Chrome%29,%20%28Webdriver%29-%28IE%29,%20%28Webdriver%29-%28headless%29,%20%28FireWatir%29-%28Firefox%29,%20%28Watir%29-%28IE%29,%20%28SafariWatir%29-%28Safari%29.]]&lt;br /&gt;
&lt;br /&gt;
Traditionally, both Selenium and Watir were limited in the number of browsers they supported. Watir originally supported Internet Explorer and headless browsers exclusively.  Headless browsers were supported via the use of Celerity &amp;lt;ref&amp;gt;Scott, Alister. [http://watirmelon.com/2010/04/10/watir-selenium-webdriver/ Watir, Selenium &amp;amp; WebDriver]. ''Watirmelon''. Watirmelon, 10 Apr. 2010. Web. 05 Oct. 2014.&amp;lt;/ref&amp;gt;.  Selenium started out as a Javascript library, so naturally it supported more browsers such as IE, Firefox, Safari, etc &amp;lt;ref name = &amp;quot;Introduction to Selenium&amp;quot; /&amp;gt;.  However, it did not support headless browsers.&lt;br /&gt;
Today, browser support looks much better for both Selenium and Watir, largely due to the introduction of WebDriver.  With WebDriver in existence, support for most browsers was added to Watir via the gem &amp;quot;watir-webdriver,&amp;quot; and Celerity became obsolete because headless browser support was included in WebDriver.  Similarly for Selenium, support for headless browsers was added, as well as making the API much simpler and more concise &amp;lt;ref&amp;gt;[http://docs.seleniumhq.org/projects/webdriver/ Selenium WebDriver]. ''SeleniumHQ: Browser Automation''. Selenium Project, n.d. Web. 06 Oct. 2014.&amp;lt;/ref&amp;gt;.  However, there is the obvious limitation that one can only test a browser which is supported on the running platform.  In other words, Safari and Internet explorer can only be tested on  OS X and Windows environments, respectively**.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;**&amp;lt;/nowiki&amp;gt; &amp;lt;span style=&amp;quot;font-size:88%&amp;quot;&amp;gt;Some work-arounds or programs may exist to allow these browsers to be tested on other platforms. Here, we are assuming no special additional configuration - just the base operating system and browsers.  With virtualization technologies such as [http://www.linux-kvm.org/page/Main_Page KVM], [https://www.virtualbox.org/ VirtualBox], and [http://en.wikipedia.org/wiki/Comparison_of_platform_virtualization_software others], this isn't a problem anyway.  [http://en.wikipedia.org/wiki/Virtual_machine Virtual machines] can be created with any operating system, as needed.&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Cross-Platform Support====&lt;br /&gt;
Both Watir and Selenium run on most popular distributions of Windows, Mac, and Linux.  Selenium doesn't have a list of officially supported operating system versions.  Instead they generally support any version that is currently popular.  Only a few versions are listed which they run test builds on.  These are versions which are officially known to work, but many more are supported as well.&lt;br /&gt;
&lt;br /&gt;
Because Watir is a collection of Ruby Gems, it runs on any platform that Ruby runs on.  Like Selenium, this includes nearly all popular platforms.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=='''Getting started'''==&lt;br /&gt;
===Selenium WebDriver=== &lt;br /&gt;
----&lt;br /&gt;
====Install/Configure for Java====&lt;br /&gt;
Configuring Selenium requires you to download the binaries from [http://www.seleniumhq.org/download/ here]. &lt;br /&gt;
Once you have all your binaries in a directory, you can open any IDE of your choice and add this directory with all the .jar files to the CLASSPATH&lt;br /&gt;
*Example&lt;br /&gt;
This is how a typical Selenium code to find the term say, “Automation” on Google and display the results on the page would look like in Java using the [https://code.google.com/p/selenium/wiki/HtmlUnitDriver HtmlUnitDriver] would look like.&lt;br /&gt;
The HtmlUnitDriver is a pure Java driver that runs entirely in-memory. Because of this, you won't see a new browser window open &amp;lt;ref&amp;gt;[https://code.google.com/p/selenium/wiki/GettingStarted Getting started with Selenium]. Selenium: Browser Automation Framework. Google Code. 8 Feb, 2014.&amp;lt;/ref&amp;gt;,&lt;br /&gt;
&lt;br /&gt;
       package org.selenium.example;&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;
       import org.openqa.selenium.By;&lt;br /&gt;
       import org.openqa.selenium.WebDriver;&lt;br /&gt;
       import org.openqa.selenium.WebElement;&lt;br /&gt;
       import org.openqa.selenium.htmlunit.HtmlUnitDriver;&amp;lt;br /&amp;gt;&lt;br /&gt;
       public class Example  {&lt;br /&gt;
       public static void main(String[] args) {&lt;br /&gt;
        // Create a new instance of the html unit driver&lt;br /&gt;
        // Notice that the remainder of the code relies on the interface,&lt;br /&gt;
        // not the implementation.&lt;br /&gt;
        WebDriver driver = new HtmlUnitDriver();&amp;lt;br /&amp;gt;&lt;br /&gt;
        // And now use this to visit Google&lt;br /&gt;
        driver.get(&amp;quot;http://www.google.com&amp;quot;);&amp;lt;br /&amp;gt;&lt;br /&gt;
        // Find the text input element by its name&lt;br /&gt;
        WebElement element = driver.findElement(By.name(&amp;quot;q&amp;quot;));&amp;lt;br /&amp;gt;&lt;br /&gt;
        // Enter something to search for&lt;br /&gt;
        element.sendKeys(&amp;quot;Automation!&amp;quot;);&amp;lt;br /&amp;gt;&lt;br /&gt;
        // Now submit the form. WebDriver will find the form for us from the element&lt;br /&gt;
        element.submit();&amp;lt;br /&amp;gt;&lt;br /&gt;
        // Check the title of the page&lt;br /&gt;
        System.out.println(&amp;quot;Page title is: &amp;quot; + driver.getTitle());&lt;br /&gt;
        driver.quit();&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
If you compile and run it, you should see a line with the title of the Google search results as output. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Install/Configure for other languages====&lt;br /&gt;
Configuring Selenium for languages other than Java and for other development environments can be looked up [http://docs.seleniumhq.org/docs/03_webdriver.jsp#setting-up-a-selenium-webdriver-project here]. viz(C#, Ruby, Python, PHP, Perl, Javascript)&lt;br /&gt;
&lt;br /&gt;
===Watir===&lt;br /&gt;
----&lt;br /&gt;
====Install/Configure====&lt;br /&gt;
Drivers for Watir are installed as gems which are nothing but Ruby libraries which can be accessed over the internet.&lt;br /&gt;
All the instructions for installing Watir on various operating systems (viz. Windows, Mac OS, Linux) can be found [http://watir.com/installation/ here].&lt;br /&gt;
&lt;br /&gt;
*Example:&lt;br /&gt;
This is how a typical Watir code to find the term say, “Automation” on Google and display the results on the page would look like using Ruby&amp;lt;ref&amp;gt;Chernenko, Iryna. [http://blog.qatestlab.com/2011/02/23/automated-testing-with-watir-tutorial-for-begginers-part-1/ Watir Example]. QATestLab Blog: Automated Testing with Watir, 23 Feb 2011.&lt;br /&gt;
&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
        # Required in ruby 1.8.7&lt;br /&gt;
        require 'rubygems'&lt;br /&gt;
        # Watir IE driver&lt;br /&gt;
        require 'watir'&amp;lt;br /&amp;gt; &lt;br /&gt;
        ie = Watir::IE.new&amp;lt;br /&amp;gt; &lt;br /&gt;
        # text to show on console&lt;br /&gt;
        puts &amp;quot;Beginning of the test for Google search engine&amp;quot;&lt;br /&gt;
        puts &amp;quot;Step 1:  Go to the Google homepage&amp;quot;&lt;br /&gt;
        ie.goto &amp;quot;http://www.google.com&amp;quot;&amp;lt;br /&amp;gt;&lt;br /&gt;
        #set a variable&lt;br /&gt;
        search_text = &amp;quot;Automation&amp;quot;&lt;br /&gt;
        puts &amp;quot;Step 2: enter &amp;quot;+ search_text +&amp;quot; in the search text field.&amp;quot;&lt;br /&gt;
        ie.text_field(:name, &amp;quot;q&amp;quot;).set search_text   # &amp;quot;q&amp;quot; is the name of the search field&amp;lt;br /&amp;gt;&lt;br /&gt;
        puts &amp;quot; Step 3: click the 'Google Search' button.&amp;quot;&lt;br /&gt;
        ie.button(:name, &amp;quot;btnG&amp;quot;).click # &amp;quot;btnG&amp;quot; is the name of the Search button&amp;lt;br /&amp;gt;&lt;br /&gt;
        puts &amp;quot; Expected Result:&amp;quot;&lt;br /&gt;
        puts &amp;quot;  A Google page with results should be shown. 'Watir, pronounced water' should be high on the list.&amp;quot;&lt;br /&gt;
        puts &amp;quot; Actual Result:&amp;quot;&lt;br /&gt;
        if ie.text.include? &amp;quot;Watir, pronounced water&amp;quot;	&lt;br /&gt;
             puts &amp;quot;  Test Passed. Found the text string: 'Watir, pronounced water'. Actual Results match Expected Results.&amp;quot;&lt;br /&gt;
        else	&lt;br /&gt;
 	     puts &amp;quot;  Test Failed! Could not find text: 'Watir, pronounced water'.&amp;quot;&lt;br /&gt;
        end&lt;br /&gt;
        puts &amp;quot;End of test: Google search.&amp;quot;&lt;br /&gt;
        ie.close&lt;br /&gt;
&lt;br /&gt;
On compiling and running this and passing the test, you will see something like, &amp;lt;br /&amp;gt; &lt;br /&gt;
&lt;br /&gt;
        ''Output:''&lt;br /&gt;
        Beginning of the test for Google search engine &amp;lt;br /&amp;gt;&lt;br /&gt;
        Step 1:  Go to the Google homepage &amp;lt;br /&amp;gt;&lt;br /&gt;
        Step 2: enter Automation in the search text field. &amp;lt;br /&amp;gt;&lt;br /&gt;
        Step 3: click the 'Google Search' button. &amp;lt;br /&amp;gt;&lt;br /&gt;
        Expected Result: &amp;lt;br /&amp;gt;&lt;br /&gt;
        A Google page with results should be shown. 'Watir, pronounced water' should be high on the list. &amp;lt;br /&amp;gt;	&lt;br /&gt;
        Test Passed. Found the text string: 'Watir, pronounced water'. Actual Results match Expected Results. &amp;lt;br /&amp;gt;&lt;br /&gt;
        End of test: Google search. &amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Similar Tools==&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Sahi_(software) Sahi], uses the Sahi Scripting Language&amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Soatest SOATest], for testing and validating [http://en.wikipedia.org/wiki/Application_programming_interface API] driven applications &amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/TestComplete TestComplete], for Desktops, Web and Mobile&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
* [http://www.hiretheworld.com/blog/tech-blog/migrating-unit-tests-from-selenium-to-watir-webdriver Migrating unit tests from Selenium to Watir Web Driver] &amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://www.hiretheworld.com/blog/tech-blog/migrating-unit-tests-from-selenium-to-watir-webdriver Learning Selenium IDE] &amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/List_of_web_testing_tools List of web testing tools] &amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/List_of_web_testing_tools OWASP List of Acceptance Testing tools]&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
{{reflist}}&lt;br /&gt;
&amp;lt;references /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==External Links==&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Selenium_(software) Selenium Wiki Page] &amp;lt;br /&amp;gt;&lt;br /&gt;
* [https://github.com/SeleniumHQ/selenium Selenium Source Code] &amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Watir Watir Wiki Page] &amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Watir Watir Source Code] &amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Watir SauceLabs HomePage] &amp;lt;br /&amp;gt;&lt;/div&gt;</summary>
		<author><name>Jjbeaver</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/ch1b_27_js&amp;diff=89431</id>
		<title>CSC/ECE 517 Fall 2014/ch1b 27 js</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/ch1b_27_js&amp;diff=89431"/>
		<updated>2014-10-07T03:46:53Z</updated>

		<summary type="html">&lt;p&gt;Jjbeaver: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;='''Selenium vs. Watir'''=&lt;br /&gt;
&lt;br /&gt;
Developing web applications is proving to be a challenging task with each passing day given the complex requirements and the demanding nature of the these applications. For the web applications to be robust we need to put in place some good testing strategies.&lt;br /&gt;
&lt;br /&gt;
'''''Selenium''''' is one of the most popularly used open source automation tools for web based applications. It is a JavaScript framework that runs in your web browser to interact with various elements in your browser. All in all, Selenium is a set of different software tools each with a different approach to supporting test automation. Selenium provides a rich set of testing functions that can be customized to suit the testing requirements.&lt;br /&gt;
 &lt;br /&gt;
'''''Watir''''', is another lightweight automation testing tool that is widely used for web app testing. It is an open-source ([http://en.wikipedia.org/wiki/BSD_licenses BSD])  family of Ruby libraries for automating web browsers. It allows you to write tests that are easy to read and maintain. Despite the fact that it is a set of Ruby libraries, it works perfectly, independent of the language that the web application is developed in. Watir as a tool is extremely simple and flexible.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=='''Motivation'''==&lt;br /&gt;
===Need for test automation===&lt;br /&gt;
With the majority of software applications today being implemented as [http://en.wikipedia.org/wiki/Web_application web applications] to be used over the internet, testing is becoming an indispensable part of the software development lifecycle ([http://en.wikipedia.org/wiki/Software_development_process SDLC]) of these applications. [http://en.wikipedia.org/wiki/Test_automation Test automation] is used where manual testing needs to be carried out repeatedly making it a cumbersome task. Test automation uses a software tool for this purpose on the application to be tested. It has proven to be highly efficient and critical in larger software development companies. Additionally, automation can be a valuable way to make Test Driven Development ([http://en.wikipedia.org/wiki/Test-driven_development TDD]) tasks an important part of the software development workflow.&lt;br /&gt;
 &lt;br /&gt;
Test Automation has a number of advantages mostly dealing with repetitiveness of the tests and the time taken,&lt;br /&gt;
* '''Covers cases that manual testing probably cannot'''&lt;br /&gt;
# Finds defects missed out my manual testing&lt;br /&gt;
# Automated testing can simulate numerous virtual users interacting with the web software/application&lt;br /&gt;
* '''Helps save time and money'''&lt;br /&gt;
# Once created, automated tests can be executed repeatedly at no additional   costs and at a much faster pace. Saving time directly translates into saving cost.&lt;br /&gt;
# Supports virtually unlimited iterations of test case execution&lt;br /&gt;
* '''Increase test coverage and accuracy'''&lt;br /&gt;
# Automated tests perform the exact same steps and records all details precisely&lt;br /&gt;
# They also increase the depth and scope of tests to improve the quality of the software&lt;br /&gt;
&lt;br /&gt;
=='''Brief History'''==&lt;br /&gt;
====Selenium====&lt;br /&gt;
&lt;br /&gt;
[[File: SE-logo.png|right|Selenium Logo|link=http://www.seleniumhq.org/images/big-logo.png]]&lt;br /&gt;
&lt;br /&gt;
''Selenium'' was developed in the year 2004 by Jason Huggins and has been continuously evolving ever since. Jason Huggins developed this as an internal tool for [http://en.wikipedia.org/wiki/ThoughtWorks ThoughtWorks] as a javascript library which came to be known as the Selenium core. Selenium core is now the basis of the Selenium Remote Control (the server) and Selenium IDE.&lt;br /&gt;
The year 2006 marked the beginning of the development of the WebDriver project which was what they believed ‘a tool of the future’. The WebDriver was initiated to solve the problems that were faced due to the fact that Selenium was a based on JavaScript and a lot of security limitations browsers apply to Javascript.&lt;br /&gt;
In 2008, both Selenium and WebDriver merged to provide a common set of features to all users which is called Selenium 2..&lt;br /&gt;
Simon Stewart, the creator of WebDriver, in a joint email to the WebDriver and Selenium community on August 6, 2009 said the following,&lt;br /&gt;
&lt;br /&gt;
“Why are the projects merging? Partly because webdriver addresses some shortcomings in selenium (by being able to bypass the JS sandbox, for example. And we’ve got a gorgeous API), partly because selenium addresses some shortcomings in webdriver (such as supporting a broader range of browsers) and partly because the main selenium contributors and I felt that it was the best way to offer users the best possible framework.”&amp;lt;ref name =&amp;quot;Introduction to Selenium&amp;quot;&amp;gt;[http://docs.seleniumhq.org/docs/01_introducing_selenium.jsp#selenium-history Introducing Selenium]. ''SeleniumHQ: Browser Automation''. Selenium Project, 4 Oct. 2014. Web. 06 Oct. 2014.&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Watir====&lt;br /&gt;
&lt;br /&gt;
''Watir'' started as a library to teach testers to write ruby code and grew to be an IE implementation which now supports IE, Firefox, Safari, Google Chrome and Opera.&lt;br /&gt;
Watir was primarily developed by Bret Pettichord and Paul Rogers. Watir has since then has a couple of stable releases for Watir classic as well as Watir WebDriver. The most recent releases being&amp;lt;ref&amp;gt;[http://watir.com/category/releases/ Watir Releases]. Watir: Web Application Testing in Ruby. 28 April, 2013&amp;lt;/ref&amp;gt;, &lt;br /&gt;
&lt;br /&gt;
[[File: Watir.gif|right|Watir logo|link=http://upload.wikimedia.org/wikipedia/commons/7/7e/Watir.gif]]&lt;br /&gt;
&lt;br /&gt;
* Watir-Classic	    &lt;br /&gt;
# 0.6.3 April 10, 2013 ([https://github.com/watir/watir-webdriver/blob/master/CHANGES.md#063 Release Notes]) &amp;lt;br /&amp;gt;&lt;br /&gt;
* Watir-WebDriver	    &lt;br /&gt;
# 3.6.0 March 16, 2013 ([https://groups.google.com/forum/#!msg/watir-general/MOOun5g3Hvg/JBVNy957lDYJ Release Notes]) &amp;lt;br /&amp;gt;&lt;br /&gt;
# 3.5.0 March 10, 2013 ([https://groups.google.com/forum/#!msg/watir-general/aeUqsglvK6k/Kq7FCBiERjYJ Release Notes]) &amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Watir has a google group ([https://groups.google.com/forum/#!forum/watir-general Watir General]) for its support and contribution while Selenium also has a [http://seleniumforum.forumotion.net/ Selenium forum] apart from its google group called [https://groups.google.com/forum/#!forum/selenium-users Selenium Users].&lt;br /&gt;
&lt;br /&gt;
=='''Comparison of Features, Functionality, and More'''==&lt;br /&gt;
Some features or functionality may be repeated here.  However, we will go into a bit more detail than previously mentioned.&lt;br /&gt;
===='''Open Source'''====&lt;br /&gt;
Both Selenium and Watir are [http://en.wikipedia.org/wiki/Open-source_software open source]!  This allows for greater extensibility and a deeper understanding of the inner workings of both of the frameworks, if the developer/tester chooses to delve into such details.  Additionally, the open source community allows for a more transparent, user-driven development and support cycle.  Users (the tester/developer) can choose to submit bug fixes or enhancements as patches, or they can choose to just use it “straight out of the box.”&lt;br /&gt;
&lt;br /&gt;
====Application Language Agnostic====&lt;br /&gt;
&lt;br /&gt;
Both Selenium and Watir are application language agnostic.  Because both Selenium and Watir test UI functionality in the browser, they can be used to test any web application.    &lt;br /&gt;
&lt;br /&gt;
====Language-specific Test Cases====&lt;br /&gt;
&lt;br /&gt;
Both Selenium and Watir require test cases to be written in some programming language.  Traditionally, both frameworks had limited choices in terms of language bindings.  However, with the advent of WebDriver, both became much more flexible.  WebDriver provided the bindings needed for many languages.  Today, the following are supported:&lt;br /&gt;
&lt;br /&gt;
'''Selenium*'''&lt;br /&gt;
&lt;br /&gt;
* Officially-supported: [http://en.wikipedia.org/wiki/Java_(programming_language) Java], [http://en.wikipedia.org/wiki/C_Sharp_(programming_language) C#], [http://en.wikipedia.org/wiki/Ruby_(programming_language) Ruby], [http://en.wikipedia.org/wiki/Python_(programming_language) Python], [http://en.wikipedia.org/wiki/Node.js Javascript/Node.js]&lt;br /&gt;
&lt;br /&gt;
* Unofficial/community-supported: [http://en.wikipedia.org/wiki/Perl Perl], [http://en.wikipedia.org/wiki/PHP PHP], [http://en.wikipedia.org/wiki/Haskell_(programming_language) Haskell], [http://en.wikipedia.org/wiki/Objective-C Objective-C], [http://en.wikipedia.org/wiki/R_(programming_language) R], [http://en.wikipedia.org/wiki/Dart_(programming_language) Dart], [http://en.wikipedia.org/wiki/Tcl Tcl]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;According to SeleniumHQ’s download page.&lt;br /&gt;
&lt;br /&gt;
'''Watir'''&lt;br /&gt;
&lt;br /&gt;
Unfortunately (or fortunately), Ruby is the only supported language for Watir.  After all, Watir does stand for “Web Application Testing in Ruby.” However, there are other frameworks which were inspired by Watir (but entirely separate) available in Java and C# - Watij and Watin,  respectively &amp;lt;ref&amp;gt;Djorgjievski, Darko. [http://www.sitepoint.com/watir-webdriver-control-browser/ Watir-WebDriver: Control the Browser]. ''SitePoint''. SitePoint Pty Ltd, 18 Apr. 2014. Web. 05 Oct. 2014.&amp;lt;/ref&amp;gt;.  There may be other similarly inspired frameworks available in other languages, but these are the most notable.&lt;br /&gt;
&lt;br /&gt;
====Cross-Browser and Headless Browser Support====&lt;br /&gt;
&lt;br /&gt;
[[File: watir_meet_webdriver.png | Watir Meets WebDriver |right|frame| link=http://yuml.me/diagram/scruffy/usecase/%5BTester%5D-%28Watir%20API%29,%20%28Watir%20API%29%3C%28FireWatir%29,%20%28Watir%20API%29%3C%28Watir%29,%20%28Watir%20API%29%3C%28SafariWatir%29,%20%28Watir%20API%29%3C%28Webdriver%29,%20%28Watir%20API%29%3C%28Celerity%29,%20%28Celerity%29-%28note:%20Celerity%20requires%20JRuby%29,%20%28Celerity%29-%28headless%29,%20%28Webdriver%29-%28Firefox%29,%20%28Webdriver%29-%28Chrome%29,%20%28Webdriver%29-%28IE%29,%20%28Webdriver%29-%28headless%29,%20%28FireWatir%29-%28Firefox%29,%20%28Watir%29-%28IE%29,%20%28SafariWatir%29-%28Safari%29.]]&lt;br /&gt;
&lt;br /&gt;
Traditionally, both Selenium and Watir were limited in the number of browsers they supported. Watir originally supported Internet Explorer and headless browsers exclusively.  Headless browsers were supported via the use of Celerity &amp;lt;ref&amp;gt;Scott, Alister. [http://watirmelon.com/2010/04/10/watir-selenium-webdriver/ Watir, Selenium &amp;amp; WebDriver]. ''Watirmelon''. Watirmelon, 10 Apr. 2010. Web. 05 Oct. 2014.&amp;lt;/ref&amp;gt;.  Selenium started out as a Javascript library, so naturally it supported more browsers such as IE, Firefox, Safari, etc &amp;lt;ref name = &amp;quot;Introduction to Selenium&amp;quot; /&amp;gt;.  However, it did not support headless browsers.&lt;br /&gt;
Today, browser support looks much better for both Selenium and Watir, largely due to the introduction of WebDriver.  With WebDriver in existence, support for most browsers was added to Watir via the gem &amp;quot;watir-webdriver,&amp;quot; and Celerity became obsolete because headless browser support was included in WebDriver.  Similarly for Selenium, support for headless browsers was added, as well as making the API much simpler and more concise &amp;lt;ref&amp;gt;[http://docs.seleniumhq.org/projects/webdriver/ Selenium WebDriver]. ''SeleniumHQ: Browser Automation''. Selenium Project, n.d. Web. 06 Oct. 2014.&amp;lt;/ref&amp;gt;.  However, there is the obvious limitation that one can only test a browser which is supported on the running platform.  In other words, Safari and Internet explorer can only be tested on  OS X and Windows environments, respectively**.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;**&amp;lt;/nowiki&amp;gt; &amp;lt;span style=&amp;quot;font-size:88%&amp;quot;&amp;gt;Some work-arounds or programs may exist to allow these browsers to be tested on other platforms. Here, we are assuming no special additional configuration - just the base operating system and browsers.  With virtualization technologies such as [http://www.linux-kvm.org/page/Main_Page KVM], [https://www.virtualbox.org/ VirtualBox], and [http://en.wikipedia.org/wiki/Comparison_of_platform_virtualization_software others], this isn't a problem anyway.  [http://en.wikipedia.org/wiki/Virtual_machine Virtual machines] can be created with any operating system, as needed.&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Cross-Platform Support====&lt;br /&gt;
Both Watir and Selenium run on most popular distributions of Windows, Mac, and Linux.  Selenium doesn't have a list of officially supported operating system versions.  Instead they generally support any version that is currently popular.  Only a few versions are listed which they run test builds on.  These are versions which are officially known to work, but many more are supported as well.&lt;br /&gt;
&lt;br /&gt;
Because Watir is a collection of Ruby Gems, it runs on any platform that Ruby runs on.  Like Selenium, this includes nearly all popular platforms.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=='''Getting started'''==&lt;br /&gt;
===Selenium WebDriver=== &lt;br /&gt;
----&lt;br /&gt;
====Install/Configure for Java====&lt;br /&gt;
Configuring Selenium requires you to download the binaries from [http://www.seleniumhq.org/download/ here]. &lt;br /&gt;
Once you have all your binaries in a directory, you can open any IDE of your choice and add this directory with all the .jar files to the CLASSPATH&lt;br /&gt;
*Example&lt;br /&gt;
This is how a typical Selenium code to find the term say, “Automation” on Google and display the results on the page would look like in Java using the [https://code.google.com/p/selenium/wiki/HtmlUnitDriver HtmlUnitDriver] would look like.&lt;br /&gt;
The HtmlUnitDriver is a pure Java driver that runs entirely in-memory. Because of this, you won't see a new browser window open &amp;lt;ref&amp;gt;[https://code.google.com/p/selenium/wiki/GettingStarted Getting started with Selenium]. Selenium: Browser Automation Framework. Google Code. 8 Feb, 2014.&amp;lt;/ref&amp;gt;,&lt;br /&gt;
&lt;br /&gt;
       package org.selenium.example;&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;
       import org.openqa.selenium.By;&lt;br /&gt;
       import org.openqa.selenium.WebDriver;&lt;br /&gt;
       import org.openqa.selenium.WebElement;&lt;br /&gt;
       import org.openqa.selenium.htmlunit.HtmlUnitDriver;&amp;lt;br /&amp;gt;&lt;br /&gt;
       public class Example  {&lt;br /&gt;
       public static void main(String[] args) {&lt;br /&gt;
        // Create a new instance of the html unit driver&lt;br /&gt;
        // Notice that the remainder of the code relies on the interface,&lt;br /&gt;
        // not the implementation.&lt;br /&gt;
        WebDriver driver = new HtmlUnitDriver();&amp;lt;br /&amp;gt;&lt;br /&gt;
        // And now use this to visit Google&lt;br /&gt;
        driver.get(&amp;quot;http://www.google.com&amp;quot;);&amp;lt;br /&amp;gt;&lt;br /&gt;
        // Find the text input element by its name&lt;br /&gt;
        WebElement element = driver.findElement(By.name(&amp;quot;q&amp;quot;));&amp;lt;br /&amp;gt;&lt;br /&gt;
        // Enter something to search for&lt;br /&gt;
        element.sendKeys(&amp;quot;Automation!&amp;quot;);&amp;lt;br /&amp;gt;&lt;br /&gt;
        // Now submit the form. WebDriver will find the form for us from the element&lt;br /&gt;
        element.submit();&amp;lt;br /&amp;gt;&lt;br /&gt;
        // Check the title of the page&lt;br /&gt;
        System.out.println(&amp;quot;Page title is: &amp;quot; + driver.getTitle());&lt;br /&gt;
        driver.quit();&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
If you compile and run it, you should see a line with the title of the Google search results as output. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Install/Configure for other languages====&lt;br /&gt;
Configuring Selenium for languages other than Java and for other development environments can be looked up [http://docs.seleniumhq.org/docs/03_webdriver.jsp#setting-up-a-selenium-webdriver-project here]. viz(C#, Ruby, Python, PHP, Perl, Javascript)&lt;br /&gt;
&lt;br /&gt;
===Watir===&lt;br /&gt;
----&lt;br /&gt;
====Install/Configure====&lt;br /&gt;
Drivers for Watir are installed as gems which are nothing but Ruby libraries which can be accessed over the internet.&lt;br /&gt;
All the instructions for installing Watir on various operating systems (viz. Windows, Mac OS, Linux) can be found [http://watir.com/installation/ here].&lt;br /&gt;
&lt;br /&gt;
*Example:&lt;br /&gt;
This is how a typical Watir code to find the term say, “Automation” on Google and display the results on the page would look like using Ruby&amp;lt;ref&amp;gt;Chernenko, Iryna. [http://blog.qatestlab.com/2011/02/23/automated-testing-with-watir-tutorial-for-begginers-part-1/ Watir Example]. QATestLab Blog: Automated Testing with Watir, 23 Feb 2011.&lt;br /&gt;
&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
        # Required in ruby 1.8.7&lt;br /&gt;
        require 'rubygems'&lt;br /&gt;
        # Watir IE driver&lt;br /&gt;
        require 'watir'&amp;lt;br /&amp;gt; &lt;br /&gt;
        ie = Watir::IE.new&amp;lt;br /&amp;gt; &lt;br /&gt;
        # text to show on console&lt;br /&gt;
        puts &amp;quot;Beginning of the test for Google search engine&amp;quot;&lt;br /&gt;
        puts &amp;quot;Step 1:  Go to the Google homepage&amp;quot;&lt;br /&gt;
        ie.goto &amp;quot;http://www.google.com&amp;quot;&amp;lt;br /&amp;gt;&lt;br /&gt;
        #set a variable&lt;br /&gt;
        search_text = &amp;quot;Automation&amp;quot;&lt;br /&gt;
        puts &amp;quot;Step 2: enter &amp;quot;+ search_text +&amp;quot; in the search text field.&amp;quot;&lt;br /&gt;
        ie.text_field(:name, &amp;quot;q&amp;quot;).set search_text   # &amp;quot;q&amp;quot; is the name of the search field&amp;lt;br /&amp;gt;&lt;br /&gt;
        puts &amp;quot; Step 3: click the 'Google Search' button.&amp;quot;&lt;br /&gt;
        ie.button(:name, &amp;quot;btnG&amp;quot;).click # &amp;quot;btnG&amp;quot; is the name of the Search button&amp;lt;br /&amp;gt;&lt;br /&gt;
        puts &amp;quot; Expected Result:&amp;quot;&lt;br /&gt;
        puts &amp;quot;  A Google page with results should be shown. 'Watir, pronounced water' should be high on the list.&amp;quot;&lt;br /&gt;
        puts &amp;quot; Actual Result:&amp;quot;&lt;br /&gt;
        if ie.text.include? &amp;quot;Watir, pronounced water&amp;quot;	&lt;br /&gt;
             puts &amp;quot;  Test Passed. Found the text string: 'Watir, pronounced water'. Actual Results match Expected Results.&amp;quot;&lt;br /&gt;
        else	&lt;br /&gt;
 	     puts &amp;quot;  Test Failed! Could not find text: 'Watir, pronounced water'.&amp;quot;&lt;br /&gt;
        end&lt;br /&gt;
        puts &amp;quot;End of test: Google search.&amp;quot;&lt;br /&gt;
        ie.close&lt;br /&gt;
&lt;br /&gt;
On compiling and running this and passing the test, you will see something like, &amp;lt;br /&amp;gt; &lt;br /&gt;
&lt;br /&gt;
        ''Output:''&lt;br /&gt;
        Beginning of the test for Google search engine &amp;lt;br /&amp;gt;&lt;br /&gt;
        Step 1:  Go to the Google homepage &amp;lt;br /&amp;gt;&lt;br /&gt;
        Step 2: enter Automation in the search text field. &amp;lt;br /&amp;gt;&lt;br /&gt;
        Step 3: click the 'Google Search' button. &amp;lt;br /&amp;gt;&lt;br /&gt;
        Expected Result: &amp;lt;br /&amp;gt;&lt;br /&gt;
        A Google page with results should be shown. 'Watir, pronounced water' should be high on the list. &amp;lt;br /&amp;gt;	&lt;br /&gt;
        Test Passed. Found the text string: 'Watir, pronounced water'. Actual Results match Expected Results. &amp;lt;br /&amp;gt;&lt;br /&gt;
        End of test: Google search. &amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Similar Tools==&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Sahi_(software) Sahi], uses the Sahi Scripting Language&amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Soatest SOATest], for testing and validating [http://en.wikipedia.org/wiki/Application_programming_interface API] driven applications &amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/TestComplete TestComplete], for Desktops, Web and Mobile&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
* [http://www.hiretheworld.com/blog/tech-blog/migrating-unit-tests-from-selenium-to-watir-webdriver Migrating unit tests from Selenium to Watir Web Driver] &amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://www.hiretheworld.com/blog/tech-blog/migrating-unit-tests-from-selenium-to-watir-webdriver Learning Selenium IDE] &amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/List_of_web_testing_tools List of web testing tools] &amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/List_of_web_testing_tools OWASP List of Acceptance Testing tools]&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
{{reflist}}&lt;br /&gt;
&amp;lt;references /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==External Links==&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Selenium_(software) Selenium Wiki Page] &amp;lt;br /&amp;gt;&lt;br /&gt;
* [https://github.com/SeleniumHQ/selenium Selenium Source Code] &amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Watir Watir Wiki Page] &amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Watir Watir Source Code] &amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Watir SauceLabs HomePage] &amp;lt;br /&amp;gt;&lt;/div&gt;</summary>
		<author><name>Jjbeaver</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/ch1b_27_js&amp;diff=89430</id>
		<title>CSC/ECE 517 Fall 2014/ch1b 27 js</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/ch1b_27_js&amp;diff=89430"/>
		<updated>2014-10-07T03:45:55Z</updated>

		<summary type="html">&lt;p&gt;Jjbeaver: /* Cross-Browser and Headless Browser Support */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;='''Selenium vs. Watir'''=&lt;br /&gt;
&lt;br /&gt;
Developing web applications is proving to be a challenging task with each passing day given the complex requirements and the demanding nature of the these applications. For the web applications to be robust we need to put in place some good testing strategies.&lt;br /&gt;
&lt;br /&gt;
'''''Selenium''''' is one of the most popularly used open source automation tools for web based applications. It is a JavaScript framework that runs in your web browser to interact with various elements in your browser. All in all, Selenium is a set of different software tools each with a different approach to supporting test automation. Selenium provides a rich set of testing functions that can be customized to suit the testing requirements.&lt;br /&gt;
 &lt;br /&gt;
'''''Watir''''', is another lightweight automation testing tool that is widely used for web app testing. It is an open-source ([http://en.wikipedia.org/wiki/BSD_licenses BSD])  family of Ruby libraries for automating web browsers. It allows you to write tests that are easy to read and maintain. Despite the fact that it is a set of Ruby libraries, it works perfectly, independent of the language that the web application is developed in. Watir as a tool is extremely simple and flexible.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=='''Motivation'''==&lt;br /&gt;
===Need for test automation===&lt;br /&gt;
With the majority of software applications today being implemented as [http://en.wikipedia.org/wiki/Web_application web applications] to be used over the internet, testing is becoming an indispensable part of the software development lifecycle ([http://en.wikipedia.org/wiki/Software_development_process SDLC]) of these applications. [http://en.wikipedia.org/wiki/Test_automation Test automation] is used where manual testing needs to be carried out repeatedly making it a cumbersome task. Test automation uses a software tool for this purpose on the application to be tested. It has proven to be highly efficient and critical in larger software development companies. Additionally, automation can be a valuable way to make Test Driven Development ([http://en.wikipedia.org/wiki/Test-driven_development TDD]) tasks an important part of the software development workflow.&lt;br /&gt;
 &lt;br /&gt;
Test Automation has a number of advantages mostly dealing with repetitiveness of the tests and the time taken,&lt;br /&gt;
* '''Covers cases that manual testing probably cannot'''&lt;br /&gt;
# Finds defects missed out my manual testing&lt;br /&gt;
# Automated testing can simulate numerous virtual users interacting with the web software/application&lt;br /&gt;
* '''Helps save time and money'''&lt;br /&gt;
# Once created, automated tests can be executed repeatedly at no additional   costs and at a much faster pace. Saving time directly translates into saving cost.&lt;br /&gt;
# Supports virtually unlimited iterations of test case execution&lt;br /&gt;
* '''Increase test coverage and accuracy'''&lt;br /&gt;
# Automated tests perform the exact same steps and records all details precisely&lt;br /&gt;
# They also increase the depth and scope of tests to improve the quality of the software&lt;br /&gt;
&lt;br /&gt;
=='''Brief History'''==&lt;br /&gt;
====Selenium====&lt;br /&gt;
&lt;br /&gt;
[[File: SE-logo.png|right|Selenium Logo|link=http://www.seleniumhq.org/images/big-logo.png]]&lt;br /&gt;
&lt;br /&gt;
''Selenium'' was developed in the year 2004 by Jason Huggins and has been continuously evolving ever since. Jason Huggins developed this as an internal tool for [http://en.wikipedia.org/wiki/ThoughtWorks ThoughtWorks] as a javascript library which came to be known as the Selenium core. Selenium core is now the basis of the Selenium Remote Control (the server) and Selenium IDE.&lt;br /&gt;
The year 2006 marked the beginning of the development of the WebDriver project which was what they believed ‘a tool of the future’. The WebDriver was initiated to solve the problems that were faced due to the fact that Selenium was a based on JavaScript and a lot of security limitations browsers apply to Javascript.&lt;br /&gt;
In 2008, both Selenium and WebDriver merged to provide a common set of features to all users which is called Selenium 2..&lt;br /&gt;
Simon Stewart, the creator of WebDriver, in a joint email to the WebDriver and Selenium community on August 6, 2009 said the following,&lt;br /&gt;
&lt;br /&gt;
“Why are the projects merging? Partly because webdriver addresses some shortcomings in selenium (by being able to bypass the JS sandbox, for example. And we’ve got a gorgeous API), partly because selenium addresses some shortcomings in webdriver (such as supporting a broader range of browsers) and partly because the main selenium contributors and I felt that it was the best way to offer users the best possible framework.”&amp;lt;ref name =&amp;quot;Introduction to Selenium&amp;quot;&amp;gt;[http://docs.seleniumhq.org/docs/01_introducing_selenium.jsp#selenium-history Introducing Selenium]. ''SeleniumHQ: Browser Automation''. Selenium Project, 4 Oct. 2014. Web. 06 Oct. 2014.&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Watir====&lt;br /&gt;
&lt;br /&gt;
''Watir'' started as a library to teach testers to write ruby code and grew to be an IE implementation which now supports IE, Firefox, Safari, Google Chrome and Opera.&lt;br /&gt;
Watir was primarily developed by Bret Pettichord and Paul Rogers. Watir has since then has a couple of stable releases for Watir classic as well as Watir WebDriver. The most recent releases being&amp;lt;ref&amp;gt;[http://watir.com/category/releases/ Watir Releases]. Watir: Web Application Testing in Ruby. 28 April, 2013&amp;lt;/ref&amp;gt;, &lt;br /&gt;
&lt;br /&gt;
[[File: Watir.gif|right|Watir logo|link=http://upload.wikimedia.org/wikipedia/commons/7/7e/Watir.gif]]&lt;br /&gt;
&lt;br /&gt;
* Watir-Classic	    &lt;br /&gt;
# 0.6.3 April 10, 2013 ([https://github.com/watir/watir-webdriver/blob/master/CHANGES.md#063 Release Notes]) &amp;lt;br /&amp;gt;&lt;br /&gt;
* Watir-WebDriver	    &lt;br /&gt;
# 3.6.0 March 16, 2013 ([https://groups.google.com/forum/#!msg/watir-general/MOOun5g3Hvg/JBVNy957lDYJ Release Notes]) &amp;lt;br /&amp;gt;&lt;br /&gt;
# 3.5.0 March 10, 2013 ([https://groups.google.com/forum/#!msg/watir-general/aeUqsglvK6k/Kq7FCBiERjYJ Release Notes]) &amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Watir has a google group ([https://groups.google.com/forum/#!forum/watir-general Watir General]) for its support and contribution while Selenium also has a [http://seleniumforum.forumotion.net/ Selenium forum] apart from its google group called [https://groups.google.com/forum/#!forum/selenium-users Selenium Users].&lt;br /&gt;
&lt;br /&gt;
=='''Comparison of Features, Functionality, and More'''==&lt;br /&gt;
Some features or functionality may be repeated here.  However, we will go into a bit more detail than previously mentioned.&lt;br /&gt;
===='''Open Source'''====&lt;br /&gt;
Both Selenium and Watir are [http://en.wikipedia.org/wiki/Open-source_software open source]!  This allows for greater extensibility and a deeper understanding of the inner workings of both of the frameworks, if the developer/tester chooses to delve into such details.  Additionally, the open source community allows for a more transparent, user-driven development and support cycle.  Users (the tester/developer) can choose to submit bug fixes or enhancements as patches, or they can choose to just use it “straight out of the box.”&lt;br /&gt;
&lt;br /&gt;
====Application Language Agnostic====&lt;br /&gt;
&lt;br /&gt;
Both Selenium and Watir are application language agnostic.  Because both Selenium and Watir test UI functionality in the browser, they can be used to test any web application.    &lt;br /&gt;
&lt;br /&gt;
====Language-specific Test Cases====&lt;br /&gt;
&lt;br /&gt;
Both Selenium and Watir require test cases to be written in some programming language.  Traditionally, both frameworks had limited choices in terms of language bindings.  However, with the advent of WebDriver, both became much more flexible.  WebDriver provided the bindings needed for many languages.  Today, the following are supported:&lt;br /&gt;
&lt;br /&gt;
'''Selenium*'''&lt;br /&gt;
&lt;br /&gt;
* Officially-supported: [http://en.wikipedia.org/wiki/Java_(programming_language) Java], [http://en.wikipedia.org/wiki/C_Sharp_(programming_language) C#], [http://en.wikipedia.org/wiki/Ruby_(programming_language) Ruby], [http://en.wikipedia.org/wiki/Python_(programming_language) Python], [http://en.wikipedia.org/wiki/Node.js Javascript/Node.js]&lt;br /&gt;
&lt;br /&gt;
* Unofficial/community-supported: [http://en.wikipedia.org/wiki/Perl Perl], [http://en.wikipedia.org/wiki/PHP PHP], [http://en.wikipedia.org/wiki/Haskell_(programming_language) Haskell], [http://en.wikipedia.org/wiki/Objective-C Objective-C], [http://en.wikipedia.org/wiki/R_(programming_language) R], [http://en.wikipedia.org/wiki/Dart_(programming_language) Dart], [http://en.wikipedia.org/wiki/Tcl Tcl]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;According to SeleniumHQ’s download page.&lt;br /&gt;
&lt;br /&gt;
'''Watir'''&lt;br /&gt;
&lt;br /&gt;
Unfortunately (or fortunately), Ruby is the only supported language for Watir.  After all, Watir does stand for “Web Application Testing in Ruby.” However, there are other frameworks which were inspired by Watir (but entirely separate) available in Java and C# - Watij and Watin,  respectively &amp;lt;ref&amp;gt;Djorgjievski, Darko. [http://www.sitepoint.com/watir-webdriver-control-browser/ Watir-WebDriver: Control the Browser]. ''SitePoint''. SitePoint Pty Ltd, 18 Apr. 2014. Web. 05 Oct. 2014.&amp;lt;/ref&amp;gt;.  There may be other similarly inspired frameworks available in other languages, but these are the most notable.&lt;br /&gt;
&lt;br /&gt;
====Cross-Browser and Headless Browser Support====&lt;br /&gt;
&lt;br /&gt;
[[File: watir_meet_webdriver.png | Watir Meets WebDriver |right|frame| link=http://yuml.me/diagram/scruffy/usecase/%5BTester%5D-%28Watir%20API%29,%20%28Watir%20API%29%3C%28FireWatir%29,%20%28Watir%20API%29%3C%28Watir%29,%20%28Watir%20API%29%3C%28SafariWatir%29,%20%28Watir%20API%29%3C%28Webdriver%29,%20%28Watir%20API%29%3C%28Celerity%29,%20%28Celerity%29-%28note:%20Celerity%20requires%20JRuby%29,%20%28Celerity%29-%28headless%29,%20%28Webdriver%29-%28Firefox%29,%20%28Webdriver%29-%28Chrome%29,%20%28Webdriver%29-%28IE%29,%20%28Webdriver%29-%28headless%29,%20%28FireWatir%29-%28Firefox%29,%20%28Watir%29-%28IE%29,%20%28SafariWatir%29-%28Safari%29.]]&lt;br /&gt;
&lt;br /&gt;
Traditionally, both Selenium and Watir were limited in the number of browsers they supported. Watir originally supported Internet Explorer and headless browsers exclusively.  Headless browsers were supported via the use of Celerity &amp;lt;ref&amp;gt;Scott, Alister. [http://watirmelon.com/2010/04/10/watir-selenium-webdriver/ Watir, Selenium &amp;amp; WebDriver]. ''Watirmelon''. Watirmelon, 10 Apr. 2010. Web. 05 Oct. 2014.&amp;lt;/ref&amp;gt;.  Selenium started out as a Javascript library, so naturally it supported more browsers such as IE, Firefox, Safari, etc &amp;lt;ref name = &amp;quot;Introduction to Selenium&amp;quot; /&amp;gt;.  However, it did not support headless browsers.&lt;br /&gt;
Today, browser support looks much better for both Selenium and Watir, largely due to the introduction of WebDriver.  With WebDriver in existence, support for most browsers was added to Watir via the gem &amp;quot;watir-webdriver,&amp;quot; and Celerity became obsolete because headless browser support was included in WebDriver.  Similarly for Selenium, support for headless browsers was added, as well as making the API much simpler and more concise &amp;lt;ref&amp;gt;[http://docs.seleniumhq.org/projects/webdriver/ Selenium WebDriver]. ''SeleniumHQ: Browser Automation''. Selenium Project, n.d. Web. 06 Oct. 2014.&amp;lt;/ref&amp;gt;.  However, there is the obvious limitation that one can only test a browser which is supported on the running platform.  In other words, Safari and Internet explorer can only be tested on  OS X and Windows environments, respectively**.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;**&amp;lt;/nowiki&amp;gt; &amp;lt;span style=&amp;quot;font-size:88%&amp;quot;&amp;gt;Some work-arounds or programs may exist to allow these browsers to be tested on other platforms. Here, we are assuming no special additional configuration - just the base operating system and browsers.  With virtualization technologies such as [http://www.linux-kvm.org/page/Main_Page KVM], [https://www.virtualbox.org/ VirtualBox], and [http://en.wikipedia.org/wiki/Comparison_of_platform_virtualization_software others], this isn't a problem anyway.  [http://en.wikipedia.org/wiki/Virtual_machine Virtual machines] can be created with any operating system, as needed.&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Cross-Platform Support====&lt;br /&gt;
Both Watir and Selenium run on most popular distributions of Windows, Mac, and Linux.  Selenium doesn't have a list of officially supported operating system versions.  Instead they generally support any version that is currently popular.  Only a few versions are listed which they run test builds on.  These are versions which are officially known to work, but many more are supported as well.&lt;br /&gt;
&lt;br /&gt;
Because Watir is a collection of Ruby Gems, it runs on any platform that Ruby runs on.  Like Selenium, this includes nearly all popular platforms.&lt;br /&gt;
&lt;br /&gt;
=='''Getting started'''==&lt;br /&gt;
===Selenium WebDriver=== &lt;br /&gt;
----&lt;br /&gt;
====Install/Configure for Java====&lt;br /&gt;
Configuring Selenium requires you to download the binaries from [http://www.seleniumhq.org/download/ here]. &lt;br /&gt;
Once you have all your binaries in a directory, you can open any IDE of your choice and add this directory with all the .jar files to the CLASSPATH&lt;br /&gt;
*Example&lt;br /&gt;
This is how a typical Selenium code to find the term say, “Automation” on Google and display the results on the page would look like in Java using the [https://code.google.com/p/selenium/wiki/HtmlUnitDriver HtmlUnitDriver] would look like.&lt;br /&gt;
The HtmlUnitDriver is a pure Java driver that runs entirely in-memory. Because of this, you won't see a new browser window open &amp;lt;ref&amp;gt;[https://code.google.com/p/selenium/wiki/GettingStarted Getting started with Selenium]. Selenium: Browser Automation Framework. Google Code. 8 Feb, 2014.&amp;lt;/ref&amp;gt;,&lt;br /&gt;
&lt;br /&gt;
       package org.selenium.example;&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;
       import org.openqa.selenium.By;&lt;br /&gt;
       import org.openqa.selenium.WebDriver;&lt;br /&gt;
       import org.openqa.selenium.WebElement;&lt;br /&gt;
       import org.openqa.selenium.htmlunit.HtmlUnitDriver;&amp;lt;br /&amp;gt;&lt;br /&gt;
       public class Example  {&lt;br /&gt;
       public static void main(String[] args) {&lt;br /&gt;
        // Create a new instance of the html unit driver&lt;br /&gt;
        // Notice that the remainder of the code relies on the interface,&lt;br /&gt;
        // not the implementation.&lt;br /&gt;
        WebDriver driver = new HtmlUnitDriver();&amp;lt;br /&amp;gt;&lt;br /&gt;
        // And now use this to visit Google&lt;br /&gt;
        driver.get(&amp;quot;http://www.google.com&amp;quot;);&amp;lt;br /&amp;gt;&lt;br /&gt;
        // Find the text input element by its name&lt;br /&gt;
        WebElement element = driver.findElement(By.name(&amp;quot;q&amp;quot;));&amp;lt;br /&amp;gt;&lt;br /&gt;
        // Enter something to search for&lt;br /&gt;
        element.sendKeys(&amp;quot;Automation!&amp;quot;);&amp;lt;br /&amp;gt;&lt;br /&gt;
        // Now submit the form. WebDriver will find the form for us from the element&lt;br /&gt;
        element.submit();&amp;lt;br /&amp;gt;&lt;br /&gt;
        // Check the title of the page&lt;br /&gt;
        System.out.println(&amp;quot;Page title is: &amp;quot; + driver.getTitle());&lt;br /&gt;
        driver.quit();&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
If you compile and run it, you should see a line with the title of the Google search results as output. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Install/Configure for other languages====&lt;br /&gt;
Configuring Selenium for languages other than Java and for other development environments can be looked up [http://docs.seleniumhq.org/docs/03_webdriver.jsp#setting-up-a-selenium-webdriver-project here]. viz(C#, Ruby, Python, PHP, Perl, Javascript)&lt;br /&gt;
&lt;br /&gt;
===Watir===&lt;br /&gt;
----&lt;br /&gt;
====Install/Configure====&lt;br /&gt;
Drivers for Watir are installed as gems which are nothing but Ruby libraries which can be accessed over the internet.&lt;br /&gt;
All the instructions for installing Watir on various operating systems (viz. Windows, Mac OS, Linux) can be found [http://watir.com/installation/ here].&lt;br /&gt;
&lt;br /&gt;
*Example:&lt;br /&gt;
This is how a typical Watir code to find the term say, “Automation” on Google and display the results on the page would look like using Ruby&amp;lt;ref&amp;gt;Chernenko, Iryna. [http://blog.qatestlab.com/2011/02/23/automated-testing-with-watir-tutorial-for-begginers-part-1/ Watir Example]. QATestLab Blog: Automated Testing with Watir, 23 Feb 2011.&lt;br /&gt;
&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
        # Required in ruby 1.8.7&lt;br /&gt;
        require 'rubygems'&lt;br /&gt;
        # Watir IE driver&lt;br /&gt;
        require 'watir'&amp;lt;br /&amp;gt; &lt;br /&gt;
        ie = Watir::IE.new&amp;lt;br /&amp;gt; &lt;br /&gt;
        # text to show on console&lt;br /&gt;
        puts &amp;quot;Beginning of the test for Google search engine&amp;quot;&lt;br /&gt;
        puts &amp;quot;Step 1:  Go to the Google homepage&amp;quot;&lt;br /&gt;
        ie.goto &amp;quot;http://www.google.com&amp;quot;&amp;lt;br /&amp;gt;&lt;br /&gt;
        #set a variable&lt;br /&gt;
        search_text = &amp;quot;Automation&amp;quot;&lt;br /&gt;
        puts &amp;quot;Step 2: enter &amp;quot;+ search_text +&amp;quot; in the search text field.&amp;quot;&lt;br /&gt;
        ie.text_field(:name, &amp;quot;q&amp;quot;).set search_text   # &amp;quot;q&amp;quot; is the name of the search field&amp;lt;br /&amp;gt;&lt;br /&gt;
        puts &amp;quot; Step 3: click the 'Google Search' button.&amp;quot;&lt;br /&gt;
        ie.button(:name, &amp;quot;btnG&amp;quot;).click # &amp;quot;btnG&amp;quot; is the name of the Search button&amp;lt;br /&amp;gt;&lt;br /&gt;
        puts &amp;quot; Expected Result:&amp;quot;&lt;br /&gt;
        puts &amp;quot;  A Google page with results should be shown. 'Watir, pronounced water' should be high on the list.&amp;quot;&lt;br /&gt;
        puts &amp;quot; Actual Result:&amp;quot;&lt;br /&gt;
        if ie.text.include? &amp;quot;Watir, pronounced water&amp;quot;	&lt;br /&gt;
             puts &amp;quot;  Test Passed. Found the text string: 'Watir, pronounced water'. Actual Results match Expected Results.&amp;quot;&lt;br /&gt;
        else	&lt;br /&gt;
 	     puts &amp;quot;  Test Failed! Could not find text: 'Watir, pronounced water'.&amp;quot;&lt;br /&gt;
        end&lt;br /&gt;
        puts &amp;quot;End of test: Google search.&amp;quot;&lt;br /&gt;
        ie.close&lt;br /&gt;
&lt;br /&gt;
On compiling and running this and passing the test, you will see something like, &amp;lt;br /&amp;gt; &lt;br /&gt;
&lt;br /&gt;
        ''Output:''&lt;br /&gt;
        Beginning of the test for Google search engine &amp;lt;br /&amp;gt;&lt;br /&gt;
        Step 1:  Go to the Google homepage &amp;lt;br /&amp;gt;&lt;br /&gt;
        Step 2: enter Automation in the search text field. &amp;lt;br /&amp;gt;&lt;br /&gt;
        Step 3: click the 'Google Search' button. &amp;lt;br /&amp;gt;&lt;br /&gt;
        Expected Result: &amp;lt;br /&amp;gt;&lt;br /&gt;
        A Google page with results should be shown. 'Watir, pronounced water' should be high on the list. &amp;lt;br /&amp;gt;	&lt;br /&gt;
        Test Passed. Found the text string: 'Watir, pronounced water'. Actual Results match Expected Results. &amp;lt;br /&amp;gt;&lt;br /&gt;
        End of test: Google search. &amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Similar Tools==&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Sahi_(software) Sahi], uses the Sahi Scripting Language&amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Soatest SOATest], for testing and validating [http://en.wikipedia.org/wiki/Application_programming_interface API] driven applications &amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/TestComplete TestComplete], for Desktops, Web and Mobile&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
* [http://www.hiretheworld.com/blog/tech-blog/migrating-unit-tests-from-selenium-to-watir-webdriver Migrating unit tests from Selenium to Watir Web Driver] &amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://www.hiretheworld.com/blog/tech-blog/migrating-unit-tests-from-selenium-to-watir-webdriver Learning Selenium IDE] &amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/List_of_web_testing_tools List of web testing tools] &amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/List_of_web_testing_tools OWASP List of Acceptance Testing tools]&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
{{reflist}}&lt;br /&gt;
&amp;lt;references /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==External Links==&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Selenium_(software) Selenium Wiki Page] &amp;lt;br /&amp;gt;&lt;br /&gt;
* [https://github.com/SeleniumHQ/selenium Selenium Source Code] &amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Watir Watir Wiki Page] &amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Watir Watir Source Code] &amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Watir SauceLabs HomePage] &amp;lt;br /&amp;gt;&lt;/div&gt;</summary>
		<author><name>Jjbeaver</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/ch1b_27_js&amp;diff=89429</id>
		<title>CSC/ECE 517 Fall 2014/ch1b 27 js</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/ch1b_27_js&amp;diff=89429"/>
		<updated>2014-10-07T03:43:24Z</updated>

		<summary type="html">&lt;p&gt;Jjbeaver: /* Comparison of Features, Functionality, and More */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;='''Selenium vs. Watir'''=&lt;br /&gt;
&lt;br /&gt;
Developing web applications is proving to be a challenging task with each passing day given the complex requirements and the demanding nature of the these applications. For the web applications to be robust we need to put in place some good testing strategies.&lt;br /&gt;
&lt;br /&gt;
'''''Selenium''''' is one of the most popularly used open source automation tools for web based applications. It is a JavaScript framework that runs in your web browser to interact with various elements in your browser. All in all, Selenium is a set of different software tools each with a different approach to supporting test automation. Selenium provides a rich set of testing functions that can be customized to suit the testing requirements.&lt;br /&gt;
 &lt;br /&gt;
'''''Watir''''', is another lightweight automation testing tool that is widely used for web app testing. It is an open-source ([http://en.wikipedia.org/wiki/BSD_licenses BSD])  family of Ruby libraries for automating web browsers. It allows you to write tests that are easy to read and maintain. Despite the fact that it is a set of Ruby libraries, it works perfectly, independent of the language that the web application is developed in. Watir as a tool is extremely simple and flexible.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=='''Motivation'''==&lt;br /&gt;
===Need for test automation===&lt;br /&gt;
With the majority of software applications today being implemented as [http://en.wikipedia.org/wiki/Web_application web applications] to be used over the internet, testing is becoming an indispensable part of the software development lifecycle ([http://en.wikipedia.org/wiki/Software_development_process SDLC]) of these applications. [http://en.wikipedia.org/wiki/Test_automation Test automation] is used where manual testing needs to be carried out repeatedly making it a cumbersome task. Test automation uses a software tool for this purpose on the application to be tested. It has proven to be highly efficient and critical in larger software development companies. Additionally, automation can be a valuable way to make Test Driven Development ([http://en.wikipedia.org/wiki/Test-driven_development TDD]) tasks an important part of the software development workflow.&lt;br /&gt;
 &lt;br /&gt;
Test Automation has a number of advantages mostly dealing with repetitiveness of the tests and the time taken,&lt;br /&gt;
* '''Covers cases that manual testing probably cannot'''&lt;br /&gt;
# Finds defects missed out my manual testing&lt;br /&gt;
# Automated testing can simulate numerous virtual users interacting with the web software/application&lt;br /&gt;
* '''Helps save time and money'''&lt;br /&gt;
# Once created, automated tests can be executed repeatedly at no additional   costs and at a much faster pace. Saving time directly translates into saving cost.&lt;br /&gt;
# Supports virtually unlimited iterations of test case execution&lt;br /&gt;
* '''Increase test coverage and accuracy'''&lt;br /&gt;
# Automated tests perform the exact same steps and records all details precisely&lt;br /&gt;
# They also increase the depth and scope of tests to improve the quality of the software&lt;br /&gt;
&lt;br /&gt;
=='''Brief History'''==&lt;br /&gt;
====Selenium====&lt;br /&gt;
&lt;br /&gt;
[[File: SE-logo.png|right|Selenium Logo|link=http://www.seleniumhq.org/images/big-logo.png]]&lt;br /&gt;
&lt;br /&gt;
''Selenium'' was developed in the year 2004 by Jason Huggins and has been continuously evolving ever since. Jason Huggins developed this as an internal tool for [http://en.wikipedia.org/wiki/ThoughtWorks ThoughtWorks] as a javascript library which came to be known as the Selenium core. Selenium core is now the basis of the Selenium Remote Control (the server) and Selenium IDE.&lt;br /&gt;
The year 2006 marked the beginning of the development of the WebDriver project which was what they believed ‘a tool of the future’. The WebDriver was initiated to solve the problems that were faced due to the fact that Selenium was a based on JavaScript and a lot of security limitations browsers apply to Javascript.&lt;br /&gt;
In 2008, both Selenium and WebDriver merged to provide a common set of features to all users which is called Selenium 2..&lt;br /&gt;
Simon Stewart, the creator of WebDriver, in a joint email to the WebDriver and Selenium community on August 6, 2009 said the following,&lt;br /&gt;
&lt;br /&gt;
“Why are the projects merging? Partly because webdriver addresses some shortcomings in selenium (by being able to bypass the JS sandbox, for example. And we’ve got a gorgeous API), partly because selenium addresses some shortcomings in webdriver (such as supporting a broader range of browsers) and partly because the main selenium contributors and I felt that it was the best way to offer users the best possible framework.”&amp;lt;ref name =&amp;quot;Introduction to Selenium&amp;quot;&amp;gt;[http://docs.seleniumhq.org/docs/01_introducing_selenium.jsp#selenium-history Introducing Selenium]. ''SeleniumHQ: Browser Automation''. Selenium Project, 4 Oct. 2014. Web. 06 Oct. 2014.&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Watir====&lt;br /&gt;
&lt;br /&gt;
''Watir'' started as a library to teach testers to write ruby code and grew to be an IE implementation which now supports IE, Firefox, Safari, Google Chrome and Opera.&lt;br /&gt;
Watir was primarily developed by Bret Pettichord and Paul Rogers. Watir has since then has a couple of stable releases for Watir classic as well as Watir WebDriver. The most recent releases being&amp;lt;ref&amp;gt;[http://watir.com/category/releases/ Watir Releases]. Watir: Web Application Testing in Ruby. 28 April, 2013&amp;lt;/ref&amp;gt;, &lt;br /&gt;
&lt;br /&gt;
[[File: Watir.gif|right|Watir logo|link=http://upload.wikimedia.org/wikipedia/commons/7/7e/Watir.gif]]&lt;br /&gt;
&lt;br /&gt;
* Watir-Classic	    &lt;br /&gt;
# 0.6.3 April 10, 2013 ([https://github.com/watir/watir-webdriver/blob/master/CHANGES.md#063 Release Notes]) &amp;lt;br /&amp;gt;&lt;br /&gt;
* Watir-WebDriver	    &lt;br /&gt;
# 3.6.0 March 16, 2013 ([https://groups.google.com/forum/#!msg/watir-general/MOOun5g3Hvg/JBVNy957lDYJ Release Notes]) &amp;lt;br /&amp;gt;&lt;br /&gt;
# 3.5.0 March 10, 2013 ([https://groups.google.com/forum/#!msg/watir-general/aeUqsglvK6k/Kq7FCBiERjYJ Release Notes]) &amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Watir has a google group ([https://groups.google.com/forum/#!forum/watir-general Watir General]) for its support and contribution while Selenium also has a [http://seleniumforum.forumotion.net/ Selenium forum] apart from its google group called [https://groups.google.com/forum/#!forum/selenium-users Selenium Users].&lt;br /&gt;
&lt;br /&gt;
=='''Comparison of Features, Functionality, and More'''==&lt;br /&gt;
Some features or functionality may be repeated here.  However, we will go into a bit more detail than previously mentioned.&lt;br /&gt;
===='''Open Source'''====&lt;br /&gt;
Both Selenium and Watir are [http://en.wikipedia.org/wiki/Open-source_software open source]!  This allows for greater extensibility and a deeper understanding of the inner workings of both of the frameworks, if the developer/tester chooses to delve into such details.  Additionally, the open source community allows for a more transparent, user-driven development and support cycle.  Users (the tester/developer) can choose to submit bug fixes or enhancements as patches, or they can choose to just use it “straight out of the box.”&lt;br /&gt;
&lt;br /&gt;
====Application Language Agnostic====&lt;br /&gt;
&lt;br /&gt;
Both Selenium and Watir are application language agnostic.  Because both Selenium and Watir test UI functionality in the browser, they can be used to test any web application.    &lt;br /&gt;
&lt;br /&gt;
====Language-specific Test Cases====&lt;br /&gt;
&lt;br /&gt;
Both Selenium and Watir require test cases to be written in some programming language.  Traditionally, both frameworks had limited choices in terms of language bindings.  However, with the advent of WebDriver, both became much more flexible.  WebDriver provided the bindings needed for many languages.  Today, the following are supported:&lt;br /&gt;
&lt;br /&gt;
'''Selenium*'''&lt;br /&gt;
&lt;br /&gt;
* Officially-supported: [http://en.wikipedia.org/wiki/Java_(programming_language) Java], [http://en.wikipedia.org/wiki/C_Sharp_(programming_language) C#], [http://en.wikipedia.org/wiki/Ruby_(programming_language) Ruby], [http://en.wikipedia.org/wiki/Python_(programming_language) Python], [http://en.wikipedia.org/wiki/Node.js Javascript/Node.js]&lt;br /&gt;
&lt;br /&gt;
* Unofficial/community-supported: [http://en.wikipedia.org/wiki/Perl Perl], [http://en.wikipedia.org/wiki/PHP PHP], [http://en.wikipedia.org/wiki/Haskell_(programming_language) Haskell], [http://en.wikipedia.org/wiki/Objective-C Objective-C], [http://en.wikipedia.org/wiki/R_(programming_language) R], [http://en.wikipedia.org/wiki/Dart_(programming_language) Dart], [http://en.wikipedia.org/wiki/Tcl Tcl]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;According to SeleniumHQ’s download page.&lt;br /&gt;
&lt;br /&gt;
'''Watir'''&lt;br /&gt;
&lt;br /&gt;
Unfortunately (or fortunately), Ruby is the only supported language for Watir.  After all, Watir does stand for “Web Application Testing in Ruby.” However, there are other frameworks which were inspired by Watir (but entirely separate) available in Java and C# - Watij and Watin,  respectively &amp;lt;ref&amp;gt;Djorgjievski, Darko. [http://www.sitepoint.com/watir-webdriver-control-browser/ Watir-WebDriver: Control the Browser]. ''SitePoint''. SitePoint Pty Ltd, 18 Apr. 2014. Web. 05 Oct. 2014.&amp;lt;/ref&amp;gt;.  There may be other similarly inspired frameworks available in other languages, but these are the most notable.&lt;br /&gt;
&lt;br /&gt;
====Cross-Browser and Headless Browser Support====&lt;br /&gt;
&lt;br /&gt;
[[File: watir_meet_webdriver.png | Watir Meets WebDriver |right|frame| link=http://yuml.me/diagram/scruffy/usecase/%5BTester%5D-%28Watir%20API%29,%20%28Watir%20API%29%3C%28FireWatir%29,%20%28Watir%20API%29%3C%28Watir%29,%20%28Watir%20API%29%3C%28SafariWatir%29,%20%28Watir%20API%29%3C%28Webdriver%29,%20%28Watir%20API%29%3C%28Celerity%29,%20%28Celerity%29-%28note:%20Celerity%20requires%20JRuby%29,%20%28Celerity%29-%28headless%29,%20%28Webdriver%29-%28Firefox%29,%20%28Webdriver%29-%28Chrome%29,%20%28Webdriver%29-%28IE%29,%20%28Webdriver%29-%28headless%29,%20%28FireWatir%29-%28Firefox%29,%20%28Watir%29-%28IE%29,%20%28SafariWatir%29-%28Safari%29.]]&lt;br /&gt;
&lt;br /&gt;
Traditionally, both Selenium and Watir were limited in the number of browsers they supported. Watir originally supported Internet Explorer and headless browsers exclusively.  Headless browsers were supported via the use of Celerity &amp;lt;ref&amp;gt;Scott, Alister. [http://watirmelon.com/2010/04/10/watir-selenium-webdriver/ Watir, Selenium &amp;amp; WebDriver]. ''Watirmelon''. Watirmelon, 10 Apr. 2010. Web. 05 Oct. 2014.&amp;lt;/ref&amp;gt;.  Selenium started out as a Javascript library, so naturally it supported more browsers such as IE, Firefox, Safari, etc &amp;lt;ref name = &amp;quot;Introduction to Selenium&amp;quot; /&amp;gt;.  However, it did not support headless browsers.&lt;br /&gt;
Today, browser support looks much better for both Selenium and Watir, largely due to the introduction of WebDriver.  With WebDriver in existence, support for most browsers was added to Watir via the gem &amp;quot;watir-webdriver.&amp;quot;  Similarly for Selenium, support for headless browsers was added, as well as making the API much simpler and more concise &amp;lt;ref&amp;gt;[http://docs.seleniumhq.org/projects/webdriver/ Selenium WebDriver]. ''SeleniumHQ: Browser Automation''. Selenium Project, n.d. Web. 06 Oct. 2014.&amp;lt;/ref&amp;gt;.  However, there is the obvious limitation that one can only test a browser which is supported on the running platform.  In other words, Safari and Internet explorer can only be tested on  OS X and Windows environments, respectively**.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;**&amp;lt;/nowiki&amp;gt; &amp;lt;span style=&amp;quot;font-size:88%&amp;quot;&amp;gt;Some work-arounds or programs may exist to allow these browsers to be tested on other platforms. Here, we are assuming no special additional configuration - just the base operating system and browsers.  With virtualization technologies such as [http://www.linux-kvm.org/page/Main_Page KVM], [https://www.virtualbox.org/ VirtualBox], and [http://en.wikipedia.org/wiki/Comparison_of_platform_virtualization_software others], this isn't a problem anyway.  [http://en.wikipedia.org/wiki/Virtual_machine Virtual machines] can be created with any operating system, as needed.&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Cross-Platform Support====&lt;br /&gt;
Both Watir and Selenium run on most popular distributions of Windows, Mac, and Linux.  Selenium doesn't have a list of officially supported operating system versions.  Instead they generally support any version that is currently popular.  Only a few versions are listed which they run test builds on.  These are versions which are officially known to work, but many more are supported as well.&lt;br /&gt;
&lt;br /&gt;
Because Watir is a collection of Ruby Gems, it runs on any platform that Ruby runs on.  Like Selenium, this includes nearly all popular platforms.&lt;br /&gt;
&lt;br /&gt;
=='''Getting started'''==&lt;br /&gt;
===Selenium WebDriver=== &lt;br /&gt;
----&lt;br /&gt;
====Install/Configure for Java====&lt;br /&gt;
Configuring Selenium requires you to download the binaries from [http://www.seleniumhq.org/download/ here]. &lt;br /&gt;
Once you have all your binaries in a directory, you can open any IDE of your choice and add this directory with all the .jar files to the CLASSPATH&lt;br /&gt;
*Example&lt;br /&gt;
This is how a typical Selenium code to find the term say, “Automation” on Google and display the results on the page would look like in Java using the [https://code.google.com/p/selenium/wiki/HtmlUnitDriver HtmlUnitDriver] would look like.&lt;br /&gt;
The HtmlUnitDriver is a pure Java driver that runs entirely in-memory. Because of this, you won't see a new browser window open &amp;lt;ref&amp;gt;[https://code.google.com/p/selenium/wiki/GettingStarted Getting started with Selenium]. Selenium: Browser Automation Framework. Google Code. 8 Feb, 2014.&amp;lt;/ref&amp;gt;,&lt;br /&gt;
&lt;br /&gt;
       package org.selenium.example;&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;
       import org.openqa.selenium.By;&lt;br /&gt;
       import org.openqa.selenium.WebDriver;&lt;br /&gt;
       import org.openqa.selenium.WebElement;&lt;br /&gt;
       import org.openqa.selenium.htmlunit.HtmlUnitDriver;&amp;lt;br /&amp;gt;&lt;br /&gt;
       public class Example  {&lt;br /&gt;
       public static void main(String[] args) {&lt;br /&gt;
        // Create a new instance of the html unit driver&lt;br /&gt;
        // Notice that the remainder of the code relies on the interface,&lt;br /&gt;
        // not the implementation.&lt;br /&gt;
        WebDriver driver = new HtmlUnitDriver();&amp;lt;br /&amp;gt;&lt;br /&gt;
        // And now use this to visit Google&lt;br /&gt;
        driver.get(&amp;quot;http://www.google.com&amp;quot;);&amp;lt;br /&amp;gt;&lt;br /&gt;
        // Find the text input element by its name&lt;br /&gt;
        WebElement element = driver.findElement(By.name(&amp;quot;q&amp;quot;));&amp;lt;br /&amp;gt;&lt;br /&gt;
        // Enter something to search for&lt;br /&gt;
        element.sendKeys(&amp;quot;Automation!&amp;quot;);&amp;lt;br /&amp;gt;&lt;br /&gt;
        // Now submit the form. WebDriver will find the form for us from the element&lt;br /&gt;
        element.submit();&amp;lt;br /&amp;gt;&lt;br /&gt;
        // Check the title of the page&lt;br /&gt;
        System.out.println(&amp;quot;Page title is: &amp;quot; + driver.getTitle());&lt;br /&gt;
        driver.quit();&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
If you compile and run it, you should see a line with the title of the Google search results as output. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Install/Configure for other languages====&lt;br /&gt;
Configuring Selenium for languages other than Java and for other development environments can be looked up [http://docs.seleniumhq.org/docs/03_webdriver.jsp#setting-up-a-selenium-webdriver-project here]. viz(C#, Ruby, Python, PHP, Perl, Javascript)&lt;br /&gt;
&lt;br /&gt;
===Watir===&lt;br /&gt;
----&lt;br /&gt;
====Install/Configure====&lt;br /&gt;
Drivers for Watir are installed as gems which are nothing but Ruby libraries which can be accessed over the internet.&lt;br /&gt;
All the instructions for installing Watir on various operating systems (viz. Windows, Mac OS, Linux) can be found [http://watir.com/installation/ here].&lt;br /&gt;
&lt;br /&gt;
*Example:&lt;br /&gt;
This is how a typical Watir code to find the term say, “Automation” on Google and display the results on the page would look like using Ruby&amp;lt;ref&amp;gt;Chernenko, Iryna. [http://blog.qatestlab.com/2011/02/23/automated-testing-with-watir-tutorial-for-begginers-part-1/ Watir Example]. QATestLab Blog: Automated Testing with Watir, 23 Feb 2011.&lt;br /&gt;
&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
        # Required in ruby 1.8.7&lt;br /&gt;
        require 'rubygems'&lt;br /&gt;
        # Watir IE driver&lt;br /&gt;
        require 'watir'&amp;lt;br /&amp;gt; &lt;br /&gt;
        ie = Watir::IE.new&amp;lt;br /&amp;gt; &lt;br /&gt;
        # text to show on console&lt;br /&gt;
        puts &amp;quot;Beginning of the test for Google search engine&amp;quot;&lt;br /&gt;
        puts &amp;quot;Step 1:  Go to the Google homepage&amp;quot;&lt;br /&gt;
        ie.goto &amp;quot;http://www.google.com&amp;quot;&amp;lt;br /&amp;gt;&lt;br /&gt;
        #set a variable&lt;br /&gt;
        search_text = &amp;quot;Automation&amp;quot;&lt;br /&gt;
        puts &amp;quot;Step 2: enter &amp;quot;+ search_text +&amp;quot; in the search text field.&amp;quot;&lt;br /&gt;
        ie.text_field(:name, &amp;quot;q&amp;quot;).set search_text   # &amp;quot;q&amp;quot; is the name of the search field&amp;lt;br /&amp;gt;&lt;br /&gt;
        puts &amp;quot; Step 3: click the 'Google Search' button.&amp;quot;&lt;br /&gt;
        ie.button(:name, &amp;quot;btnG&amp;quot;).click # &amp;quot;btnG&amp;quot; is the name of the Search button&amp;lt;br /&amp;gt;&lt;br /&gt;
        puts &amp;quot; Expected Result:&amp;quot;&lt;br /&gt;
        puts &amp;quot;  A Google page with results should be shown. 'Watir, pronounced water' should be high on the list.&amp;quot;&lt;br /&gt;
        puts &amp;quot; Actual Result:&amp;quot;&lt;br /&gt;
        if ie.text.include? &amp;quot;Watir, pronounced water&amp;quot;	&lt;br /&gt;
             puts &amp;quot;  Test Passed. Found the text string: 'Watir, pronounced water'. Actual Results match Expected Results.&amp;quot;&lt;br /&gt;
        else	&lt;br /&gt;
 	     puts &amp;quot;  Test Failed! Could not find text: 'Watir, pronounced water'.&amp;quot;&lt;br /&gt;
        end&lt;br /&gt;
        puts &amp;quot;End of test: Google search.&amp;quot;&lt;br /&gt;
        ie.close&lt;br /&gt;
&lt;br /&gt;
On compiling and running this and passing the test, you will see something like, &amp;lt;br /&amp;gt; &lt;br /&gt;
&lt;br /&gt;
        ''Output:''&lt;br /&gt;
        Beginning of the test for Google search engine &amp;lt;br /&amp;gt;&lt;br /&gt;
        Step 1:  Go to the Google homepage &amp;lt;br /&amp;gt;&lt;br /&gt;
        Step 2: enter Automation in the search text field. &amp;lt;br /&amp;gt;&lt;br /&gt;
        Step 3: click the 'Google Search' button. &amp;lt;br /&amp;gt;&lt;br /&gt;
        Expected Result: &amp;lt;br /&amp;gt;&lt;br /&gt;
        A Google page with results should be shown. 'Watir, pronounced water' should be high on the list. &amp;lt;br /&amp;gt;	&lt;br /&gt;
        Test Passed. Found the text string: 'Watir, pronounced water'. Actual Results match Expected Results. &amp;lt;br /&amp;gt;&lt;br /&gt;
        End of test: Google search. &amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Similar Tools==&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Sahi_(software) Sahi], uses the Sahi Scripting Language&amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Soatest SOATest], for testing and validating [http://en.wikipedia.org/wiki/Application_programming_interface API] driven applications &amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/TestComplete TestComplete], for Desktops, Web and Mobile&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
* [http://www.hiretheworld.com/blog/tech-blog/migrating-unit-tests-from-selenium-to-watir-webdriver Migrating unit tests from Selenium to Watir Web Driver] &amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://www.hiretheworld.com/blog/tech-blog/migrating-unit-tests-from-selenium-to-watir-webdriver Learning Selenium IDE] &amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/List_of_web_testing_tools List of web testing tools] &amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/List_of_web_testing_tools OWASP List of Acceptance Testing tools]&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
{{reflist}}&lt;br /&gt;
&amp;lt;references /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==External Links==&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Selenium_(software) Selenium Wiki Page] &amp;lt;br /&amp;gt;&lt;br /&gt;
* [https://github.com/SeleniumHQ/selenium Selenium Source Code] &amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Watir Watir Wiki Page] &amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Watir Watir Source Code] &amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Watir SauceLabs HomePage] &amp;lt;br /&amp;gt;&lt;/div&gt;</summary>
		<author><name>Jjbeaver</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/ch1b_27_js&amp;diff=89428</id>
		<title>CSC/ECE 517 Fall 2014/ch1b 27 js</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/ch1b_27_js&amp;diff=89428"/>
		<updated>2014-10-07T03:42:32Z</updated>

		<summary type="html">&lt;p&gt;Jjbeaver: /* Cross-Browser and Headless Browser Support */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;='''Selenium vs. Watir'''=&lt;br /&gt;
&lt;br /&gt;
Developing web applications is proving to be a challenging task with each passing day given the complex requirements and the demanding nature of the these applications. For the web applications to be robust we need to put in place some good testing strategies.&lt;br /&gt;
&lt;br /&gt;
'''''Selenium''''' is one of the most popularly used open source automation tools for web based applications. It is a JavaScript framework that runs in your web browser to interact with various elements in your browser. All in all, Selenium is a set of different software tools each with a different approach to supporting test automation. Selenium provides a rich set of testing functions that can be customized to suit the testing requirements.&lt;br /&gt;
 &lt;br /&gt;
'''''Watir''''', is another lightweight automation testing tool that is widely used for web app testing. It is an open-source ([http://en.wikipedia.org/wiki/BSD_licenses BSD])  family of Ruby libraries for automating web browsers. It allows you to write tests that are easy to read and maintain. Despite the fact that it is a set of Ruby libraries, it works perfectly, independent of the language that the web application is developed in. Watir as a tool is extremely simple and flexible.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=='''Motivation'''==&lt;br /&gt;
===Need for test automation===&lt;br /&gt;
With the majority of software applications today being implemented as [http://en.wikipedia.org/wiki/Web_application web applications] to be used over the internet, testing is becoming an indispensable part of the software development lifecycle ([http://en.wikipedia.org/wiki/Software_development_process SDLC]) of these applications. [http://en.wikipedia.org/wiki/Test_automation Test automation] is used where manual testing needs to be carried out repeatedly making it a cumbersome task. Test automation uses a software tool for this purpose on the application to be tested. It has proven to be highly efficient and critical in larger software development companies. Additionally, automation can be a valuable way to make Test Driven Development ([http://en.wikipedia.org/wiki/Test-driven_development TDD]) tasks an important part of the software development workflow.&lt;br /&gt;
 &lt;br /&gt;
Test Automation has a number of advantages mostly dealing with repetitiveness of the tests and the time taken,&lt;br /&gt;
* '''Covers cases that manual testing probably cannot'''&lt;br /&gt;
# Finds defects missed out my manual testing&lt;br /&gt;
# Automated testing can simulate numerous virtual users interacting with the web software/application&lt;br /&gt;
* '''Helps save time and money'''&lt;br /&gt;
# Once created, automated tests can be executed repeatedly at no additional   costs and at a much faster pace. Saving time directly translates into saving cost.&lt;br /&gt;
# Supports virtually unlimited iterations of test case execution&lt;br /&gt;
* '''Increase test coverage and accuracy'''&lt;br /&gt;
# Automated tests perform the exact same steps and records all details precisely&lt;br /&gt;
# They also increase the depth and scope of tests to improve the quality of the software&lt;br /&gt;
&lt;br /&gt;
=='''Brief History'''==&lt;br /&gt;
====Selenium====&lt;br /&gt;
&lt;br /&gt;
[[File: SE-logo.png|right|Selenium Logo|link=http://www.seleniumhq.org/images/big-logo.png]]&lt;br /&gt;
&lt;br /&gt;
''Selenium'' was developed in the year 2004 by Jason Huggins and has been continuously evolving ever since. Jason Huggins developed this as an internal tool for [http://en.wikipedia.org/wiki/ThoughtWorks ThoughtWorks] as a javascript library which came to be known as the Selenium core. Selenium core is now the basis of the Selenium Remote Control (the server) and Selenium IDE.&lt;br /&gt;
The year 2006 marked the beginning of the development of the WebDriver project which was what they believed ‘a tool of the future’. The WebDriver was initiated to solve the problems that were faced due to the fact that Selenium was a based on JavaScript and a lot of security limitations browsers apply to Javascript.&lt;br /&gt;
In 2008, both Selenium and WebDriver merged to provide a common set of features to all users which is called Selenium 2..&lt;br /&gt;
Simon Stewart, the creator of WebDriver, in a joint email to the WebDriver and Selenium community on August 6, 2009 said the following,&lt;br /&gt;
&lt;br /&gt;
“Why are the projects merging? Partly because webdriver addresses some shortcomings in selenium (by being able to bypass the JS sandbox, for example. And we’ve got a gorgeous API), partly because selenium addresses some shortcomings in webdriver (such as supporting a broader range of browsers) and partly because the main selenium contributors and I felt that it was the best way to offer users the best possible framework.”&amp;lt;ref name =&amp;quot;Introduction to Selenium&amp;quot;&amp;gt;[http://docs.seleniumhq.org/docs/01_introducing_selenium.jsp#selenium-history Introducing Selenium]. ''SeleniumHQ: Browser Automation''. Selenium Project, 4 Oct. 2014. Web. 06 Oct. 2014.&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Watir====&lt;br /&gt;
&lt;br /&gt;
''Watir'' started as a library to teach testers to write ruby code and grew to be an IE implementation which now supports IE, Firefox, Safari, Google Chrome and Opera.&lt;br /&gt;
Watir was primarily developed by Bret Pettichord and Paul Rogers. Watir has since then has a couple of stable releases for Watir classic as well as Watir WebDriver. The most recent releases being&amp;lt;ref&amp;gt;[http://watir.com/category/releases/ Watir Releases]. Watir: Web Application Testing in Ruby. 28 April, 2013&amp;lt;/ref&amp;gt;, &lt;br /&gt;
&lt;br /&gt;
[[File: Watir.gif|right|Watir logo|link=http://upload.wikimedia.org/wikipedia/commons/7/7e/Watir.gif]]&lt;br /&gt;
&lt;br /&gt;
* Watir-Classic	    &lt;br /&gt;
# 0.6.3 April 10, 2013 ([https://github.com/watir/watir-webdriver/blob/master/CHANGES.md#063 Release Notes]) &amp;lt;br /&amp;gt;&lt;br /&gt;
* Watir-WebDriver	    &lt;br /&gt;
# 3.6.0 March 16, 2013 ([https://groups.google.com/forum/#!msg/watir-general/MOOun5g3Hvg/JBVNy957lDYJ Release Notes]) &amp;lt;br /&amp;gt;&lt;br /&gt;
# 3.5.0 March 10, 2013 ([https://groups.google.com/forum/#!msg/watir-general/aeUqsglvK6k/Kq7FCBiERjYJ Release Notes]) &amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Watir has a google group ([https://groups.google.com/forum/#!forum/watir-general Watir General]) for its support and contribution while Selenium also has a [http://seleniumforum.forumotion.net/ Selenium forum] apart from its google group called [https://groups.google.com/forum/#!forum/selenium-users Selenium Users].&lt;br /&gt;
&lt;br /&gt;
=='''Comparison of Features, Functionality, and More'''==&lt;br /&gt;
Some features or functionality may be repeated here.  However, we will go into a bit more detail than previously mentioned.&lt;br /&gt;
===='''Open Source'''====&lt;br /&gt;
Both Selenium and Watir are [http://en.wikipedia.org/wiki/Open-source_software open source]!  This allows for greater extensibility and a deeper understanding of the inner workings of both of the frameworks, if the developer/tester chooses to delve into such details.  Additionally, the open source community allows for a more transparent, user-driven development and support cycle.  Users (the tester/developer) can choose to submit bug fixes or enhancements as patches, or they can choose to just use it “straight out of the box.”&lt;br /&gt;
&lt;br /&gt;
====Application Language Agnostic====&lt;br /&gt;
&lt;br /&gt;
Both Selenium and Watir are application language agnostic.  Because both Selenium and Watir test UI functionality in the browser, they can be used to test any web application.    &lt;br /&gt;
&lt;br /&gt;
====Language-specific Test Cases====&lt;br /&gt;
&lt;br /&gt;
Both Selenium and Watir require test cases to be written in some programming language.  Traditionally, both frameworks had limited choices in terms of language bindings.  However, with the advent of WebDriver, both became much more flexible.  WebDriver provided the bindings needed for many languages.  Today, the following are supported:&lt;br /&gt;
&lt;br /&gt;
'''Selenium*'''&lt;br /&gt;
&lt;br /&gt;
* Officially-supported: [http://en.wikipedia.org/wiki/Java_(programming_language) Java], [http://en.wikipedia.org/wiki/C_Sharp_(programming_language) C#], [http://en.wikipedia.org/wiki/Ruby_(programming_language) Ruby], [http://en.wikipedia.org/wiki/Python_(programming_language) Python], [http://en.wikipedia.org/wiki/Node.js Javascript/Node.js]&lt;br /&gt;
&lt;br /&gt;
* Unofficial/community-supported: [http://en.wikipedia.org/wiki/Perl Perl], [http://en.wikipedia.org/wiki/PHP PHP], [http://en.wikipedia.org/wiki/Haskell_(programming_language) Haskell], [http://en.wikipedia.org/wiki/Objective-C Objective-C], [http://en.wikipedia.org/wiki/R_(programming_language) R], [http://en.wikipedia.org/wiki/Dart_(programming_language) Dart], [http://en.wikipedia.org/wiki/Tcl Tcl]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;According to SeleniumHQ’s download page.&lt;br /&gt;
&lt;br /&gt;
'''Watir'''&lt;br /&gt;
&lt;br /&gt;
Unfortunately (or fortunately), Ruby is the only supported language for Watir.  After all, Watir does stand for “Web Application Testing in Ruby.” However, there are other frameworks which were inspired by Watir (but entirely separate) available in Java and C# - Watij and Watin,  respectively &amp;lt;ref&amp;gt;Djorgjievski, Darko. [http://www.sitepoint.com/watir-webdriver-control-browser/ Watir-WebDriver: Control the Browser]. ''SitePoint''. SitePoint Pty Ltd, 18 Apr. 2014. Web. 05 Oct. 2014.&amp;lt;/ref&amp;gt;.  There may be other similarly inspired frameworks available in other languages, but these are the most notable.&lt;br /&gt;
&lt;br /&gt;
====Cross-Platform Support====&lt;br /&gt;
Both Watir and Selenium run on most popular distributions of Windows, Mac, and Linux.  Selenium doesn't have a list of officially supported operating system versions.  Instead they generally support any version that is currently popular.  Only a few versions are listed which they run test builds on.  These are versions which are officially known to work, but many more are supported as well.&lt;br /&gt;
&lt;br /&gt;
Because Watir is a collection of Ruby Gems, it runs on any platform that Ruby runs on.  Like Selenium, this includes nearly all popular platforms.&lt;br /&gt;
&lt;br /&gt;
====Cross-Browser and Headless Browser Support====&lt;br /&gt;
&lt;br /&gt;
[[File: watir_meet_webdriver.png | Watir Meets WebDriver |right|frame| link=http://yuml.me/diagram/scruffy/usecase/%5BTester%5D-%28Watir%20API%29,%20%28Watir%20API%29%3C%28FireWatir%29,%20%28Watir%20API%29%3C%28Watir%29,%20%28Watir%20API%29%3C%28SafariWatir%29,%20%28Watir%20API%29%3C%28Webdriver%29,%20%28Watir%20API%29%3C%28Celerity%29,%20%28Celerity%29-%28note:%20Celerity%20requires%20JRuby%29,%20%28Celerity%29-%28headless%29,%20%28Webdriver%29-%28Firefox%29,%20%28Webdriver%29-%28Chrome%29,%20%28Webdriver%29-%28IE%29,%20%28Webdriver%29-%28headless%29,%20%28FireWatir%29-%28Firefox%29,%20%28Watir%29-%28IE%29,%20%28SafariWatir%29-%28Safari%29.]]&lt;br /&gt;
&lt;br /&gt;
Traditionally, both Selenium and Watir were limited in the number of browsers they supported. Watir originally supported Internet Explorer and headless browsers exclusively.  Headless browsers were supported via the use of Celerity &amp;lt;ref&amp;gt;Scott, Alister. [http://watirmelon.com/2010/04/10/watir-selenium-webdriver/ Watir, Selenium &amp;amp; WebDriver]. ''Watirmelon''. Watirmelon, 10 Apr. 2010. Web. 05 Oct. 2014.&amp;lt;/ref&amp;gt;.  Selenium started out as a Javascript library, so naturally it supported more browsers such as IE, Firefox, Safari, etc &amp;lt;ref name = &amp;quot;Introduction to Selenium&amp;quot; /&amp;gt;.  However, it did not support headless browsers.&lt;br /&gt;
Today, browser support looks much better for both Selenium and Watir, largely due to the introduction of WebDriver.  With WebDriver in existence, support for most browsers was added to Watir via the gem &amp;quot;watir-webdriver.&amp;quot;  Similarly for Selenium, support for headless browsers was added, as well as making the API much simpler and more concise &amp;lt;ref&amp;gt;[http://docs.seleniumhq.org/projects/webdriver/ Selenium WebDriver]. ''SeleniumHQ: Browser Automation''. Selenium Project, n.d. Web. 06 Oct. 2014.&amp;lt;/ref&amp;gt;.  However, there is the obvious limitation that one can only test a browser which is supported on the running platform.  In other words, Safari and Internet explorer can only be tested on  OS X and Windows environments, respectively**.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;**&amp;lt;/nowiki&amp;gt; &amp;lt;span style=&amp;quot;font-size:88%&amp;quot;&amp;gt;Some work-arounds or programs may exist to allow these browsers to be tested on other platforms. Here, we are assuming no special additional configuration - just the base operating system and browsers.  With virtualization technologies such as [http://www.linux-kvm.org/page/Main_Page KVM], [https://www.virtualbox.org/ VirtualBox], and [http://en.wikipedia.org/wiki/Comparison_of_platform_virtualization_software others], this isn't a problem anyway.  [http://en.wikipedia.org/wiki/Virtual_machine Virtual machines] can be created with any operating system, as needed.&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=='''Getting started'''==&lt;br /&gt;
===Selenium WebDriver=== &lt;br /&gt;
----&lt;br /&gt;
====Install/Configure for Java====&lt;br /&gt;
Configuring Selenium requires you to download the binaries from [http://www.seleniumhq.org/download/ here]. &lt;br /&gt;
Once you have all your binaries in a directory, you can open any IDE of your choice and add this directory with all the .jar files to the CLASSPATH&lt;br /&gt;
*Example&lt;br /&gt;
This is how a typical Selenium code to find the term say, “Automation” on Google and display the results on the page would look like in Java using the [https://code.google.com/p/selenium/wiki/HtmlUnitDriver HtmlUnitDriver] would look like.&lt;br /&gt;
The HtmlUnitDriver is a pure Java driver that runs entirely in-memory. Because of this, you won't see a new browser window open &amp;lt;ref&amp;gt;[https://code.google.com/p/selenium/wiki/GettingStarted Getting started with Selenium]. Selenium: Browser Automation Framework. Google Code. 8 Feb, 2014.&amp;lt;/ref&amp;gt;,&lt;br /&gt;
&lt;br /&gt;
       package org.selenium.example;&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;
       import org.openqa.selenium.By;&lt;br /&gt;
       import org.openqa.selenium.WebDriver;&lt;br /&gt;
       import org.openqa.selenium.WebElement;&lt;br /&gt;
       import org.openqa.selenium.htmlunit.HtmlUnitDriver;&amp;lt;br /&amp;gt;&lt;br /&gt;
       public class Example  {&lt;br /&gt;
       public static void main(String[] args) {&lt;br /&gt;
        // Create a new instance of the html unit driver&lt;br /&gt;
        // Notice that the remainder of the code relies on the interface,&lt;br /&gt;
        // not the implementation.&lt;br /&gt;
        WebDriver driver = new HtmlUnitDriver();&amp;lt;br /&amp;gt;&lt;br /&gt;
        // And now use this to visit Google&lt;br /&gt;
        driver.get(&amp;quot;http://www.google.com&amp;quot;);&amp;lt;br /&amp;gt;&lt;br /&gt;
        // Find the text input element by its name&lt;br /&gt;
        WebElement element = driver.findElement(By.name(&amp;quot;q&amp;quot;));&amp;lt;br /&amp;gt;&lt;br /&gt;
        // Enter something to search for&lt;br /&gt;
        element.sendKeys(&amp;quot;Automation!&amp;quot;);&amp;lt;br /&amp;gt;&lt;br /&gt;
        // Now submit the form. WebDriver will find the form for us from the element&lt;br /&gt;
        element.submit();&amp;lt;br /&amp;gt;&lt;br /&gt;
        // Check the title of the page&lt;br /&gt;
        System.out.println(&amp;quot;Page title is: &amp;quot; + driver.getTitle());&lt;br /&gt;
        driver.quit();&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
If you compile and run it, you should see a line with the title of the Google search results as output. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Install/Configure for other languages====&lt;br /&gt;
Configuring Selenium for languages other than Java and for other development environments can be looked up [http://docs.seleniumhq.org/docs/03_webdriver.jsp#setting-up-a-selenium-webdriver-project here]. viz(C#, Ruby, Python, PHP, Perl, Javascript)&lt;br /&gt;
&lt;br /&gt;
===Watir===&lt;br /&gt;
----&lt;br /&gt;
====Install/Configure====&lt;br /&gt;
Drivers for Watir are installed as gems which are nothing but Ruby libraries which can be accessed over the internet.&lt;br /&gt;
All the instructions for installing Watir on various operating systems (viz. Windows, Mac OS, Linux) can be found [http://watir.com/installation/ here].&lt;br /&gt;
&lt;br /&gt;
*Example:&lt;br /&gt;
This is how a typical Watir code to find the term say, “Automation” on Google and display the results on the page would look like using Ruby&amp;lt;ref&amp;gt;Chernenko, Iryna. [http://blog.qatestlab.com/2011/02/23/automated-testing-with-watir-tutorial-for-begginers-part-1/ Watir Example]. QATestLab Blog: Automated Testing with Watir, 23 Feb 2011.&lt;br /&gt;
&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
        # Required in ruby 1.8.7&lt;br /&gt;
        require 'rubygems'&lt;br /&gt;
        # Watir IE driver&lt;br /&gt;
        require 'watir'&amp;lt;br /&amp;gt; &lt;br /&gt;
        ie = Watir::IE.new&amp;lt;br /&amp;gt; &lt;br /&gt;
        # text to show on console&lt;br /&gt;
        puts &amp;quot;Beginning of the test for Google search engine&amp;quot;&lt;br /&gt;
        puts &amp;quot;Step 1:  Go to the Google homepage&amp;quot;&lt;br /&gt;
        ie.goto &amp;quot;http://www.google.com&amp;quot;&amp;lt;br /&amp;gt;&lt;br /&gt;
        #set a variable&lt;br /&gt;
        search_text = &amp;quot;Automation&amp;quot;&lt;br /&gt;
        puts &amp;quot;Step 2: enter &amp;quot;+ search_text +&amp;quot; in the search text field.&amp;quot;&lt;br /&gt;
        ie.text_field(:name, &amp;quot;q&amp;quot;).set search_text   # &amp;quot;q&amp;quot; is the name of the search field&amp;lt;br /&amp;gt;&lt;br /&gt;
        puts &amp;quot; Step 3: click the 'Google Search' button.&amp;quot;&lt;br /&gt;
        ie.button(:name, &amp;quot;btnG&amp;quot;).click # &amp;quot;btnG&amp;quot; is the name of the Search button&amp;lt;br /&amp;gt;&lt;br /&gt;
        puts &amp;quot; Expected Result:&amp;quot;&lt;br /&gt;
        puts &amp;quot;  A Google page with results should be shown. 'Watir, pronounced water' should be high on the list.&amp;quot;&lt;br /&gt;
        puts &amp;quot; Actual Result:&amp;quot;&lt;br /&gt;
        if ie.text.include? &amp;quot;Watir, pronounced water&amp;quot;	&lt;br /&gt;
             puts &amp;quot;  Test Passed. Found the text string: 'Watir, pronounced water'. Actual Results match Expected Results.&amp;quot;&lt;br /&gt;
        else	&lt;br /&gt;
 	     puts &amp;quot;  Test Failed! Could not find text: 'Watir, pronounced water'.&amp;quot;&lt;br /&gt;
        end&lt;br /&gt;
        puts &amp;quot;End of test: Google search.&amp;quot;&lt;br /&gt;
        ie.close&lt;br /&gt;
&lt;br /&gt;
On compiling and running this and passing the test, you will see something like, &amp;lt;br /&amp;gt; &lt;br /&gt;
&lt;br /&gt;
        ''Output:''&lt;br /&gt;
        Beginning of the test for Google search engine &amp;lt;br /&amp;gt;&lt;br /&gt;
        Step 1:  Go to the Google homepage &amp;lt;br /&amp;gt;&lt;br /&gt;
        Step 2: enter Automation in the search text field. &amp;lt;br /&amp;gt;&lt;br /&gt;
        Step 3: click the 'Google Search' button. &amp;lt;br /&amp;gt;&lt;br /&gt;
        Expected Result: &amp;lt;br /&amp;gt;&lt;br /&gt;
        A Google page with results should be shown. 'Watir, pronounced water' should be high on the list. &amp;lt;br /&amp;gt;	&lt;br /&gt;
        Test Passed. Found the text string: 'Watir, pronounced water'. Actual Results match Expected Results. &amp;lt;br /&amp;gt;&lt;br /&gt;
        End of test: Google search. &amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Similar Tools==&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Sahi_(software) Sahi], uses the Sahi Scripting Language&amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Soatest SOATest], for testing and validating [http://en.wikipedia.org/wiki/Application_programming_interface API] driven applications &amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/TestComplete TestComplete], for Desktops, Web and Mobile&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
* [http://www.hiretheworld.com/blog/tech-blog/migrating-unit-tests-from-selenium-to-watir-webdriver Migrating unit tests from Selenium to Watir Web Driver] &amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://www.hiretheworld.com/blog/tech-blog/migrating-unit-tests-from-selenium-to-watir-webdriver Learning Selenium IDE] &amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/List_of_web_testing_tools List of web testing tools] &amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/List_of_web_testing_tools OWASP List of Acceptance Testing tools]&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
{{reflist}}&lt;br /&gt;
&amp;lt;references /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==External Links==&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Selenium_(software) Selenium Wiki Page] &amp;lt;br /&amp;gt;&lt;br /&gt;
* [https://github.com/SeleniumHQ/selenium Selenium Source Code] &amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Watir Watir Wiki Page] &amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Watir Watir Source Code] &amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Watir SauceLabs HomePage] &amp;lt;br /&amp;gt;&lt;/div&gt;</summary>
		<author><name>Jjbeaver</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/ch1b_27_js&amp;diff=89427</id>
		<title>CSC/ECE 517 Fall 2014/ch1b 27 js</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/ch1b_27_js&amp;diff=89427"/>
		<updated>2014-10-07T03:42:10Z</updated>

		<summary type="html">&lt;p&gt;Jjbeaver: /* Cross-Browser and Headless Browser Support */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;='''Selenium vs. Watir'''=&lt;br /&gt;
&lt;br /&gt;
Developing web applications is proving to be a challenging task with each passing day given the complex requirements and the demanding nature of the these applications. For the web applications to be robust we need to put in place some good testing strategies.&lt;br /&gt;
&lt;br /&gt;
'''''Selenium''''' is one of the most popularly used open source automation tools for web based applications. It is a JavaScript framework that runs in your web browser to interact with various elements in your browser. All in all, Selenium is a set of different software tools each with a different approach to supporting test automation. Selenium provides a rich set of testing functions that can be customized to suit the testing requirements.&lt;br /&gt;
 &lt;br /&gt;
'''''Watir''''', is another lightweight automation testing tool that is widely used for web app testing. It is an open-source ([http://en.wikipedia.org/wiki/BSD_licenses BSD])  family of Ruby libraries for automating web browsers. It allows you to write tests that are easy to read and maintain. Despite the fact that it is a set of Ruby libraries, it works perfectly, independent of the language that the web application is developed in. Watir as a tool is extremely simple and flexible.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=='''Motivation'''==&lt;br /&gt;
===Need for test automation===&lt;br /&gt;
With the majority of software applications today being implemented as [http://en.wikipedia.org/wiki/Web_application web applications] to be used over the internet, testing is becoming an indispensable part of the software development lifecycle ([http://en.wikipedia.org/wiki/Software_development_process SDLC]) of these applications. [http://en.wikipedia.org/wiki/Test_automation Test automation] is used where manual testing needs to be carried out repeatedly making it a cumbersome task. Test automation uses a software tool for this purpose on the application to be tested. It has proven to be highly efficient and critical in larger software development companies. Additionally, automation can be a valuable way to make Test Driven Development ([http://en.wikipedia.org/wiki/Test-driven_development TDD]) tasks an important part of the software development workflow.&lt;br /&gt;
 &lt;br /&gt;
Test Automation has a number of advantages mostly dealing with repetitiveness of the tests and the time taken,&lt;br /&gt;
* '''Covers cases that manual testing probably cannot'''&lt;br /&gt;
# Finds defects missed out my manual testing&lt;br /&gt;
# Automated testing can simulate numerous virtual users interacting with the web software/application&lt;br /&gt;
* '''Helps save time and money'''&lt;br /&gt;
# Once created, automated tests can be executed repeatedly at no additional   costs and at a much faster pace. Saving time directly translates into saving cost.&lt;br /&gt;
# Supports virtually unlimited iterations of test case execution&lt;br /&gt;
* '''Increase test coverage and accuracy'''&lt;br /&gt;
# Automated tests perform the exact same steps and records all details precisely&lt;br /&gt;
# They also increase the depth and scope of tests to improve the quality of the software&lt;br /&gt;
&lt;br /&gt;
=='''Brief History'''==&lt;br /&gt;
====Selenium====&lt;br /&gt;
&lt;br /&gt;
[[File: SE-logo.png|right|Selenium Logo|link=http://www.seleniumhq.org/images/big-logo.png]]&lt;br /&gt;
&lt;br /&gt;
''Selenium'' was developed in the year 2004 by Jason Huggins and has been continuously evolving ever since. Jason Huggins developed this as an internal tool for [http://en.wikipedia.org/wiki/ThoughtWorks ThoughtWorks] as a javascript library which came to be known as the Selenium core. Selenium core is now the basis of the Selenium Remote Control (the server) and Selenium IDE.&lt;br /&gt;
The year 2006 marked the beginning of the development of the WebDriver project which was what they believed ‘a tool of the future’. The WebDriver was initiated to solve the problems that were faced due to the fact that Selenium was a based on JavaScript and a lot of security limitations browsers apply to Javascript.&lt;br /&gt;
In 2008, both Selenium and WebDriver merged to provide a common set of features to all users which is called Selenium 2..&lt;br /&gt;
Simon Stewart, the creator of WebDriver, in a joint email to the WebDriver and Selenium community on August 6, 2009 said the following,&lt;br /&gt;
&lt;br /&gt;
“Why are the projects merging? Partly because webdriver addresses some shortcomings in selenium (by being able to bypass the JS sandbox, for example. And we’ve got a gorgeous API), partly because selenium addresses some shortcomings in webdriver (such as supporting a broader range of browsers) and partly because the main selenium contributors and I felt that it was the best way to offer users the best possible framework.”&amp;lt;ref name =&amp;quot;Introduction to Selenium&amp;quot;&amp;gt;[http://docs.seleniumhq.org/docs/01_introducing_selenium.jsp#selenium-history Introducing Selenium]. ''SeleniumHQ: Browser Automation''. Selenium Project, 4 Oct. 2014. Web. 06 Oct. 2014.&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Watir====&lt;br /&gt;
&lt;br /&gt;
''Watir'' started as a library to teach testers to write ruby code and grew to be an IE implementation which now supports IE, Firefox, Safari, Google Chrome and Opera.&lt;br /&gt;
Watir was primarily developed by Bret Pettichord and Paul Rogers. Watir has since then has a couple of stable releases for Watir classic as well as Watir WebDriver. The most recent releases being&amp;lt;ref&amp;gt;[http://watir.com/category/releases/ Watir Releases]. Watir: Web Application Testing in Ruby. 28 April, 2013&amp;lt;/ref&amp;gt;, &lt;br /&gt;
&lt;br /&gt;
[[File: Watir.gif|right|Watir logo|link=http://upload.wikimedia.org/wikipedia/commons/7/7e/Watir.gif]]&lt;br /&gt;
&lt;br /&gt;
* Watir-Classic	    &lt;br /&gt;
# 0.6.3 April 10, 2013 ([https://github.com/watir/watir-webdriver/blob/master/CHANGES.md#063 Release Notes]) &amp;lt;br /&amp;gt;&lt;br /&gt;
* Watir-WebDriver	    &lt;br /&gt;
# 3.6.0 March 16, 2013 ([https://groups.google.com/forum/#!msg/watir-general/MOOun5g3Hvg/JBVNy957lDYJ Release Notes]) &amp;lt;br /&amp;gt;&lt;br /&gt;
# 3.5.0 March 10, 2013 ([https://groups.google.com/forum/#!msg/watir-general/aeUqsglvK6k/Kq7FCBiERjYJ Release Notes]) &amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Watir has a google group ([https://groups.google.com/forum/#!forum/watir-general Watir General]) for its support and contribution while Selenium also has a [http://seleniumforum.forumotion.net/ Selenium forum] apart from its google group called [https://groups.google.com/forum/#!forum/selenium-users Selenium Users].&lt;br /&gt;
&lt;br /&gt;
=='''Comparison of Features, Functionality, and More'''==&lt;br /&gt;
Some features or functionality may be repeated here.  However, we will go into a bit more detail than previously mentioned.&lt;br /&gt;
===='''Open Source'''====&lt;br /&gt;
Both Selenium and Watir are [http://en.wikipedia.org/wiki/Open-source_software open source]!  This allows for greater extensibility and a deeper understanding of the inner workings of both of the frameworks, if the developer/tester chooses to delve into such details.  Additionally, the open source community allows for a more transparent, user-driven development and support cycle.  Users (the tester/developer) can choose to submit bug fixes or enhancements as patches, or they can choose to just use it “straight out of the box.”&lt;br /&gt;
&lt;br /&gt;
====Application Language Agnostic====&lt;br /&gt;
&lt;br /&gt;
Both Selenium and Watir are application language agnostic.  Because both Selenium and Watir test UI functionality in the browser, they can be used to test any web application.    &lt;br /&gt;
&lt;br /&gt;
====Language-specific Test Cases====&lt;br /&gt;
&lt;br /&gt;
Both Selenium and Watir require test cases to be written in some programming language.  Traditionally, both frameworks had limited choices in terms of language bindings.  However, with the advent of WebDriver, both became much more flexible.  WebDriver provided the bindings needed for many languages.  Today, the following are supported:&lt;br /&gt;
&lt;br /&gt;
'''Selenium*'''&lt;br /&gt;
&lt;br /&gt;
* Officially-supported: [http://en.wikipedia.org/wiki/Java_(programming_language) Java], [http://en.wikipedia.org/wiki/C_Sharp_(programming_language) C#], [http://en.wikipedia.org/wiki/Ruby_(programming_language) Ruby], [http://en.wikipedia.org/wiki/Python_(programming_language) Python], [http://en.wikipedia.org/wiki/Node.js Javascript/Node.js]&lt;br /&gt;
&lt;br /&gt;
* Unofficial/community-supported: [http://en.wikipedia.org/wiki/Perl Perl], [http://en.wikipedia.org/wiki/PHP PHP], [http://en.wikipedia.org/wiki/Haskell_(programming_language) Haskell], [http://en.wikipedia.org/wiki/Objective-C Objective-C], [http://en.wikipedia.org/wiki/R_(programming_language) R], [http://en.wikipedia.org/wiki/Dart_(programming_language) Dart], [http://en.wikipedia.org/wiki/Tcl Tcl]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;According to SeleniumHQ’s download page.&lt;br /&gt;
&lt;br /&gt;
'''Watir'''&lt;br /&gt;
&lt;br /&gt;
Unfortunately (or fortunately), Ruby is the only supported language for Watir.  After all, Watir does stand for “Web Application Testing in Ruby.” However, there are other frameworks which were inspired by Watir (but entirely separate) available in Java and C# - Watij and Watin,  respectively &amp;lt;ref&amp;gt;Djorgjievski, Darko. [http://www.sitepoint.com/watir-webdriver-control-browser/ Watir-WebDriver: Control the Browser]. ''SitePoint''. SitePoint Pty Ltd, 18 Apr. 2014. Web. 05 Oct. 2014.&amp;lt;/ref&amp;gt;.  There may be other similarly inspired frameworks available in other languages, but these are the most notable.&lt;br /&gt;
&lt;br /&gt;
====Cross-Platform Support====&lt;br /&gt;
Both Watir and Selenium run on most popular distributions of Windows, Mac, and Linux.  Selenium doesn't have a list of officially supported operating system versions.  Instead they generally support any version that is currently popular.  Only a few versions are listed which they run test builds on.  These are versions which are officially known to work, but many more are supported as well.&lt;br /&gt;
&lt;br /&gt;
Because Watir is a collection of Ruby Gems, it runs on any platform that Ruby runs on.  Like Selenium, this includes nearly all popular platforms.&lt;br /&gt;
&lt;br /&gt;
====Cross-Browser and Headless Browser Support====&lt;br /&gt;
&lt;br /&gt;
[[File: watir_meet_webdriver.png | Watir Meets WebDriver |right| link=http://yuml.me/diagram/scruffy/usecase/%5BTester%5D-%28Watir%20API%29,%20%28Watir%20API%29%3C%28FireWatir%29,%20%28Watir%20API%29%3C%28Watir%29,%20%28Watir%20API%29%3C%28SafariWatir%29,%20%28Watir%20API%29%3C%28Webdriver%29,%20%28Watir%20API%29%3C%28Celerity%29,%20%28Celerity%29-%28note:%20Celerity%20requires%20JRuby%29,%20%28Celerity%29-%28headless%29,%20%28Webdriver%29-%28Firefox%29,%20%28Webdriver%29-%28Chrome%29,%20%28Webdriver%29-%28IE%29,%20%28Webdriver%29-%28headless%29,%20%28FireWatir%29-%28Firefox%29,%20%28Watir%29-%28IE%29,%20%28SafariWatir%29-%28Safari%29.]]&lt;br /&gt;
&lt;br /&gt;
Traditionally, both Selenium and Watir were limited in the number of browsers they supported. Watir originally supported Internet Explorer and headless browsers exclusively.  Headless browsers were supported via the use of Celerity &amp;lt;ref&amp;gt;Scott, Alister. [http://watirmelon.com/2010/04/10/watir-selenium-webdriver/ Watir, Selenium &amp;amp; WebDriver]. ''Watirmelon''. Watirmelon, 10 Apr. 2010. Web. 05 Oct. 2014.&amp;lt;/ref&amp;gt;.  Selenium started out as a Javascript library, so naturally it supported more browsers such as IE, Firefox, Safari, etc &amp;lt;ref name = &amp;quot;Introduction to Selenium&amp;quot; /&amp;gt;.  However, it did not support headless browsers.&lt;br /&gt;
Today, browser support looks much better for both Selenium and Watir, largely due to the introduction of WebDriver.  With WebDriver in existence, support for most browsers was added to Watir via the gem &amp;quot;watir-webdriver.&amp;quot;  Similarly for Selenium, support for headless browsers was added, as well as making the API much simpler and more concise &amp;lt;ref&amp;gt;[http://docs.seleniumhq.org/projects/webdriver/ Selenium WebDriver]. ''SeleniumHQ: Browser Automation''. Selenium Project, n.d. Web. 06 Oct. 2014.&amp;lt;/ref&amp;gt;.  However, there is the obvious limitation that one can only test a browser which is supported on the running platform.  In other words, Safari and Internet explorer can only be tested on  OS X and Windows environments, respectively**.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;**&amp;lt;/nowiki&amp;gt; &amp;lt;span style=&amp;quot;font-size:88%&amp;quot;&amp;gt;Some work-arounds or programs may exist to allow these browsers to be tested on other platforms. Here, we are assuming no special additional configuration - just the base operating system and browsers.  With virtualization technologies such as [http://www.linux-kvm.org/page/Main_Page KVM], [https://www.virtualbox.org/ VirtualBox], and [http://en.wikipedia.org/wiki/Comparison_of_platform_virtualization_software others], this isn't a problem anyway.  [http://en.wikipedia.org/wiki/Virtual_machine Virtual machines] can be created with any operating system, as needed.&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=='''Getting started'''==&lt;br /&gt;
===Selenium WebDriver=== &lt;br /&gt;
----&lt;br /&gt;
====Install/Configure for Java====&lt;br /&gt;
Configuring Selenium requires you to download the binaries from [http://www.seleniumhq.org/download/ here]. &lt;br /&gt;
Once you have all your binaries in a directory, you can open any IDE of your choice and add this directory with all the .jar files to the CLASSPATH&lt;br /&gt;
*Example&lt;br /&gt;
This is how a typical Selenium code to find the term say, “Automation” on Google and display the results on the page would look like in Java using the [https://code.google.com/p/selenium/wiki/HtmlUnitDriver HtmlUnitDriver] would look like.&lt;br /&gt;
The HtmlUnitDriver is a pure Java driver that runs entirely in-memory. Because of this, you won't see a new browser window open &amp;lt;ref&amp;gt;[https://code.google.com/p/selenium/wiki/GettingStarted Getting started with Selenium]. Selenium: Browser Automation Framework. Google Code. 8 Feb, 2014.&amp;lt;/ref&amp;gt;,&lt;br /&gt;
&lt;br /&gt;
       package org.selenium.example;&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;
       import org.openqa.selenium.By;&lt;br /&gt;
       import org.openqa.selenium.WebDriver;&lt;br /&gt;
       import org.openqa.selenium.WebElement;&lt;br /&gt;
       import org.openqa.selenium.htmlunit.HtmlUnitDriver;&amp;lt;br /&amp;gt;&lt;br /&gt;
       public class Example  {&lt;br /&gt;
       public static void main(String[] args) {&lt;br /&gt;
        // Create a new instance of the html unit driver&lt;br /&gt;
        // Notice that the remainder of the code relies on the interface,&lt;br /&gt;
        // not the implementation.&lt;br /&gt;
        WebDriver driver = new HtmlUnitDriver();&amp;lt;br /&amp;gt;&lt;br /&gt;
        // And now use this to visit Google&lt;br /&gt;
        driver.get(&amp;quot;http://www.google.com&amp;quot;);&amp;lt;br /&amp;gt;&lt;br /&gt;
        // Find the text input element by its name&lt;br /&gt;
        WebElement element = driver.findElement(By.name(&amp;quot;q&amp;quot;));&amp;lt;br /&amp;gt;&lt;br /&gt;
        // Enter something to search for&lt;br /&gt;
        element.sendKeys(&amp;quot;Automation!&amp;quot;);&amp;lt;br /&amp;gt;&lt;br /&gt;
        // Now submit the form. WebDriver will find the form for us from the element&lt;br /&gt;
        element.submit();&amp;lt;br /&amp;gt;&lt;br /&gt;
        // Check the title of the page&lt;br /&gt;
        System.out.println(&amp;quot;Page title is: &amp;quot; + driver.getTitle());&lt;br /&gt;
        driver.quit();&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
If you compile and run it, you should see a line with the title of the Google search results as output. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Install/Configure for other languages====&lt;br /&gt;
Configuring Selenium for languages other than Java and for other development environments can be looked up [http://docs.seleniumhq.org/docs/03_webdriver.jsp#setting-up-a-selenium-webdriver-project here]. viz(C#, Ruby, Python, PHP, Perl, Javascript)&lt;br /&gt;
&lt;br /&gt;
===Watir===&lt;br /&gt;
----&lt;br /&gt;
====Install/Configure====&lt;br /&gt;
Drivers for Watir are installed as gems which are nothing but Ruby libraries which can be accessed over the internet.&lt;br /&gt;
All the instructions for installing Watir on various operating systems (viz. Windows, Mac OS, Linux) can be found [http://watir.com/installation/ here].&lt;br /&gt;
&lt;br /&gt;
*Example:&lt;br /&gt;
This is how a typical Watir code to find the term say, “Automation” on Google and display the results on the page would look like using Ruby&amp;lt;ref&amp;gt;Chernenko, Iryna. [http://blog.qatestlab.com/2011/02/23/automated-testing-with-watir-tutorial-for-begginers-part-1/ Watir Example]. QATestLab Blog: Automated Testing with Watir, 23 Feb 2011.&lt;br /&gt;
&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
        # Required in ruby 1.8.7&lt;br /&gt;
        require 'rubygems'&lt;br /&gt;
        # Watir IE driver&lt;br /&gt;
        require 'watir'&amp;lt;br /&amp;gt; &lt;br /&gt;
        ie = Watir::IE.new&amp;lt;br /&amp;gt; &lt;br /&gt;
        # text to show on console&lt;br /&gt;
        puts &amp;quot;Beginning of the test for Google search engine&amp;quot;&lt;br /&gt;
        puts &amp;quot;Step 1:  Go to the Google homepage&amp;quot;&lt;br /&gt;
        ie.goto &amp;quot;http://www.google.com&amp;quot;&amp;lt;br /&amp;gt;&lt;br /&gt;
        #set a variable&lt;br /&gt;
        search_text = &amp;quot;Automation&amp;quot;&lt;br /&gt;
        puts &amp;quot;Step 2: enter &amp;quot;+ search_text +&amp;quot; in the search text field.&amp;quot;&lt;br /&gt;
        ie.text_field(:name, &amp;quot;q&amp;quot;).set search_text   # &amp;quot;q&amp;quot; is the name of the search field&amp;lt;br /&amp;gt;&lt;br /&gt;
        puts &amp;quot; Step 3: click the 'Google Search' button.&amp;quot;&lt;br /&gt;
        ie.button(:name, &amp;quot;btnG&amp;quot;).click # &amp;quot;btnG&amp;quot; is the name of the Search button&amp;lt;br /&amp;gt;&lt;br /&gt;
        puts &amp;quot; Expected Result:&amp;quot;&lt;br /&gt;
        puts &amp;quot;  A Google page with results should be shown. 'Watir, pronounced water' should be high on the list.&amp;quot;&lt;br /&gt;
        puts &amp;quot; Actual Result:&amp;quot;&lt;br /&gt;
        if ie.text.include? &amp;quot;Watir, pronounced water&amp;quot;	&lt;br /&gt;
             puts &amp;quot;  Test Passed. Found the text string: 'Watir, pronounced water'. Actual Results match Expected Results.&amp;quot;&lt;br /&gt;
        else	&lt;br /&gt;
 	     puts &amp;quot;  Test Failed! Could not find text: 'Watir, pronounced water'.&amp;quot;&lt;br /&gt;
        end&lt;br /&gt;
        puts &amp;quot;End of test: Google search.&amp;quot;&lt;br /&gt;
        ie.close&lt;br /&gt;
&lt;br /&gt;
On compiling and running this and passing the test, you will see something like, &amp;lt;br /&amp;gt; &lt;br /&gt;
&lt;br /&gt;
        ''Output:''&lt;br /&gt;
        Beginning of the test for Google search engine &amp;lt;br /&amp;gt;&lt;br /&gt;
        Step 1:  Go to the Google homepage &amp;lt;br /&amp;gt;&lt;br /&gt;
        Step 2: enter Automation in the search text field. &amp;lt;br /&amp;gt;&lt;br /&gt;
        Step 3: click the 'Google Search' button. &amp;lt;br /&amp;gt;&lt;br /&gt;
        Expected Result: &amp;lt;br /&amp;gt;&lt;br /&gt;
        A Google page with results should be shown. 'Watir, pronounced water' should be high on the list. &amp;lt;br /&amp;gt;	&lt;br /&gt;
        Test Passed. Found the text string: 'Watir, pronounced water'. Actual Results match Expected Results. &amp;lt;br /&amp;gt;&lt;br /&gt;
        End of test: Google search. &amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Similar Tools==&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Sahi_(software) Sahi], uses the Sahi Scripting Language&amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Soatest SOATest], for testing and validating [http://en.wikipedia.org/wiki/Application_programming_interface API] driven applications &amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/TestComplete TestComplete], for Desktops, Web and Mobile&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
* [http://www.hiretheworld.com/blog/tech-blog/migrating-unit-tests-from-selenium-to-watir-webdriver Migrating unit tests from Selenium to Watir Web Driver] &amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://www.hiretheworld.com/blog/tech-blog/migrating-unit-tests-from-selenium-to-watir-webdriver Learning Selenium IDE] &amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/List_of_web_testing_tools List of web testing tools] &amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/List_of_web_testing_tools OWASP List of Acceptance Testing tools]&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
{{reflist}}&lt;br /&gt;
&amp;lt;references /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==External Links==&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Selenium_(software) Selenium Wiki Page] &amp;lt;br /&amp;gt;&lt;br /&gt;
* [https://github.com/SeleniumHQ/selenium Selenium Source Code] &amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Watir Watir Wiki Page] &amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Watir Watir Source Code] &amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Watir SauceLabs HomePage] &amp;lt;br /&amp;gt;&lt;/div&gt;</summary>
		<author><name>Jjbeaver</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Watir_meet_webdriver.png&amp;diff=89426</id>
		<title>File:Watir meet webdriver.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Watir_meet_webdriver.png&amp;diff=89426"/>
		<updated>2014-10-07T03:41:23Z</updated>

		<summary type="html">&lt;p&gt;Jjbeaver: uploaded a new version of &amp;amp;quot;File:Watir meet webdriver.png&amp;amp;quot;: Smaller image size because this wiki doesn't allow shrinking/thumbnails.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Evolution of Watir - Addition of WebDriver: http://yuml.me/diagram/scruffy/usecase/%5BTester%5D-%28Watir%20API%29,%20%28Watir%20API%29%3C%28FireWatir%29,%20%28Watir%20API%29%3C%28Watir%29,%20%28Watir%20API%29%3C%28SafariWatir%29,%20%28Watir%20API%29%3C%28Webdriver%29,%20%28Watir%20API%29%3C%28Celerity%29,%20%28Celerity%29-%28note:%20Celerity%20requires%20JRuby%29,%20%28Celerity%29-%28headless%29,%20%28Webdriver%29-%28Firefox%29,%20%28Webdriver%29-%28Chrome%29,%20%28Webdriver%29-%28IE%29,%20%28Webdriver%29-%28headless%29,%20%28FireWatir%29-%28Firefox%29,%20%28Watir%29-%28IE%29,%20%28SafariWatir%29-%28Safari%29.&lt;/div&gt;</summary>
		<author><name>Jjbeaver</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Watir_meet_webdriver.png&amp;diff=89423</id>
		<title>File:Watir meet webdriver.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Watir_meet_webdriver.png&amp;diff=89423"/>
		<updated>2014-10-07T03:36:25Z</updated>

		<summary type="html">&lt;p&gt;Jjbeaver: Evolution of Watir - Addition of WebDriver: http://yuml.me/diagram/scruffy/usecase/%5BTester%5D-%28Watir%20API%29,%20%28Watir%20API%29%3C%28FireWatir%29,%20%28Watir%20API%29%3C%28Watir%29,%20%28Watir%20API%29%3C%28SafariWatir%29,%20%28Watir%20API%29%3C%28&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Evolution of Watir - Addition of WebDriver: http://yuml.me/diagram/scruffy/usecase/%5BTester%5D-%28Watir%20API%29,%20%28Watir%20API%29%3C%28FireWatir%29,%20%28Watir%20API%29%3C%28Watir%29,%20%28Watir%20API%29%3C%28SafariWatir%29,%20%28Watir%20API%29%3C%28Webdriver%29,%20%28Watir%20API%29%3C%28Celerity%29,%20%28Celerity%29-%28note:%20Celerity%20requires%20JRuby%29,%20%28Celerity%29-%28headless%29,%20%28Webdriver%29-%28Firefox%29,%20%28Webdriver%29-%28Chrome%29,%20%28Webdriver%29-%28IE%29,%20%28Webdriver%29-%28headless%29,%20%28FireWatir%29-%28Firefox%29,%20%28Watir%29-%28IE%29,%20%28SafariWatir%29-%28Safari%29.&lt;/div&gt;</summary>
		<author><name>Jjbeaver</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/ch1b_27_js&amp;diff=89422</id>
		<title>CSC/ECE 517 Fall 2014/ch1b 27 js</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/ch1b_27_js&amp;diff=89422"/>
		<updated>2014-10-07T03:35:49Z</updated>

		<summary type="html">&lt;p&gt;Jjbeaver: /* Cross-Browser and Headless Browser Support */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;='''Selenium vs. Watir'''=&lt;br /&gt;
&lt;br /&gt;
Developing web applications is proving to be a challenging task with each passing day given the complex requirements and the demanding nature of the these applications. For the web applications to be robust we need to put in place some good testing strategies.&lt;br /&gt;
&lt;br /&gt;
'''''Selenium''''' is one of the most popularly used open source automation tools for web based applications. It is a JavaScript framework that runs in your web browser to interact with various elements in your browser. All in all, Selenium is a set of different software tools each with a different approach to supporting test automation. Selenium provides a rich set of testing functions that can be customized to suit the testing requirements.&lt;br /&gt;
 &lt;br /&gt;
'''''Watir''''', is another lightweight automation testing tool that is widely used for web app testing. It is an open-source ([http://en.wikipedia.org/wiki/BSD_licenses BSD])  family of Ruby libraries for automating web browsers. It allows you to write tests that are easy to read and maintain. Despite the fact that it is a set of Ruby libraries, it works perfectly, independent of the language that the web application is developed in. Watir as a tool is extremely simple and flexible.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=='''Motivation'''==&lt;br /&gt;
===Need for test automation===&lt;br /&gt;
With the majority of software applications today being implemented as [http://en.wikipedia.org/wiki/Web_application web applications] to be used over the internet, testing is becoming an indispensable part of the software development lifecycle ([http://en.wikipedia.org/wiki/Software_development_process SDLC]) of these applications. [http://en.wikipedia.org/wiki/Test_automation Test automation] is used where manual testing needs to be carried out repeatedly making it a cumbersome task. Test automation uses a software tool for this purpose on the application to be tested. It has proven to be highly efficient and critical in larger software development companies. Additionally, automation can be a valuable way to make Test Driven Development ([http://en.wikipedia.org/wiki/Test-driven_development TDD]) tasks an important part of the software development workflow.&lt;br /&gt;
 &lt;br /&gt;
Test Automation has a number of advantages mostly dealing with repetitiveness of the tests and the time taken,&lt;br /&gt;
* '''Covers cases that manual testing probably cannot'''&lt;br /&gt;
# Finds defects missed out my manual testing&lt;br /&gt;
# Automated testing can simulate numerous virtual users interacting with the web software/application&lt;br /&gt;
* '''Helps save time and money'''&lt;br /&gt;
# Once created, automated tests can be executed repeatedly at no additional   costs and at a much faster pace. Saving time directly translates into saving cost.&lt;br /&gt;
# Supports virtually unlimited iterations of test case execution&lt;br /&gt;
* '''Increase test coverage and accuracy'''&lt;br /&gt;
# Automated tests perform the exact same steps and records all details precisely&lt;br /&gt;
# They also increase the depth and scope of tests to improve the quality of the software&lt;br /&gt;
&lt;br /&gt;
=='''Brief History'''==&lt;br /&gt;
====Selenium====&lt;br /&gt;
&lt;br /&gt;
[[File: SE-logo.png|right|Selenium Logo|link=http://www.seleniumhq.org/images/big-logo.png]]&lt;br /&gt;
&lt;br /&gt;
''Selenium'' was developed in the year 2004 by Jason Huggins and has been continuously evolving ever since. Jason Huggins developed this as an internal tool for [http://en.wikipedia.org/wiki/ThoughtWorks ThoughtWorks] as a javascript library which came to be known as the Selenium core. Selenium core is now the basis of the Selenium Remote Control (the server) and Selenium IDE.&lt;br /&gt;
The year 2006 marked the beginning of the development of the WebDriver project which was what they believed ‘a tool of the future’. The WebDriver was initiated to solve the problems that were faced due to the fact that Selenium was a based on JavaScript and a lot of security limitations browsers apply to Javascript.&lt;br /&gt;
In 2008, both Selenium and WebDriver merged to provide a common set of features to all users which is called Selenium 2..&lt;br /&gt;
Simon Stewart, the creator of WebDriver, in a joint email to the WebDriver and Selenium community on August 6, 2009 said the following,&lt;br /&gt;
&lt;br /&gt;
“Why are the projects merging? Partly because webdriver addresses some shortcomings in selenium (by being able to bypass the JS sandbox, for example. And we’ve got a gorgeous API), partly because selenium addresses some shortcomings in webdriver (such as supporting a broader range of browsers) and partly because the main selenium contributors and I felt that it was the best way to offer users the best possible framework.”&amp;lt;ref name =&amp;quot;Introduction to Selenium&amp;quot;&amp;gt;[http://docs.seleniumhq.org/docs/01_introducing_selenium.jsp#selenium-history Introducing Selenium]. ''SeleniumHQ: Browser Automation''. Selenium Project, 4 Oct. 2014. Web. 06 Oct. 2014.&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Watir====&lt;br /&gt;
&lt;br /&gt;
''Watir'' started as a library to teach testers to write ruby code and grew to be an IE implementation which now supports IE, Firefox, Safari, Google Chrome and Opera.&lt;br /&gt;
Watir was primarily developed by Bret Pettichord and Paul Rogers. Watir has since then has a couple of stable releases for Watir classic as well as Watir WebDriver. The most recent releases being&amp;lt;ref&amp;gt;[http://watir.com/category/releases/ Watir Releases]. Watir: Web Application Testing in Ruby. 28 April, 2013&amp;lt;/ref&amp;gt;, &lt;br /&gt;
&lt;br /&gt;
[[File: Watir.gif|right|Watir logo|link=http://upload.wikimedia.org/wikipedia/commons/7/7e/Watir.gif]]&lt;br /&gt;
&lt;br /&gt;
* Watir-Classic	    &lt;br /&gt;
# 0.6.3 April 10, 2013 ([https://github.com/watir/watir-webdriver/blob/master/CHANGES.md#063 Release Notes]) &amp;lt;br /&amp;gt;&lt;br /&gt;
* Watir-WebDriver	    &lt;br /&gt;
# 3.6.0 March 16, 2013 ([https://groups.google.com/forum/#!msg/watir-general/MOOun5g3Hvg/JBVNy957lDYJ Release Notes]) &amp;lt;br /&amp;gt;&lt;br /&gt;
# 3.5.0 March 10, 2013 ([https://groups.google.com/forum/#!msg/watir-general/aeUqsglvK6k/Kq7FCBiERjYJ Release Notes]) &amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Watir has a google group ([https://groups.google.com/forum/#!forum/watir-general Watir General]) for its support and contribution while Selenium also has a [http://seleniumforum.forumotion.net/ Selenium forum] apart from its google group called [https://groups.google.com/forum/#!forum/selenium-users Selenium Users].&lt;br /&gt;
&lt;br /&gt;
=='''Comparison of Features, Functionality, and More'''==&lt;br /&gt;
Some features or functionality may be repeated here.  However, we will go into a bit more detail than previously mentioned.&lt;br /&gt;
===='''Open Source'''====&lt;br /&gt;
Both Selenium and Watir are [http://en.wikipedia.org/wiki/Open-source_software open source]!  This allows for greater extensibility and a deeper understanding of the inner workings of both of the frameworks, if the developer/tester chooses to delve into such details.  Additionally, the open source community allows for a more transparent, user-driven development and support cycle.  Users (the tester/developer) can choose to submit bug fixes or enhancements as patches, or they can choose to just use it “straight out of the box.”&lt;br /&gt;
&lt;br /&gt;
====Application Language Agnostic====&lt;br /&gt;
&lt;br /&gt;
Both Selenium and Watir are application language agnostic.  Because both Selenium and Watir test UI functionality in the browser, they can be used to test any web application.    &lt;br /&gt;
&lt;br /&gt;
====Language-specific Test Cases====&lt;br /&gt;
&lt;br /&gt;
Both Selenium and Watir require test cases to be written in some programming language.  Traditionally, both frameworks had limited choices in terms of language bindings.  However, with the advent of WebDriver, both became much more flexible.  WebDriver provided the bindings needed for many languages.  Today, the following are supported:&lt;br /&gt;
&lt;br /&gt;
'''Selenium*'''&lt;br /&gt;
&lt;br /&gt;
* Officially-supported: [http://en.wikipedia.org/wiki/Java_(programming_language) Java], [http://en.wikipedia.org/wiki/C_Sharp_(programming_language) C#], [http://en.wikipedia.org/wiki/Ruby_(programming_language) Ruby], [http://en.wikipedia.org/wiki/Python_(programming_language) Python], [http://en.wikipedia.org/wiki/Node.js Javascript/Node.js]&lt;br /&gt;
&lt;br /&gt;
* Unofficial/community-supported: [http://en.wikipedia.org/wiki/Perl Perl], [http://en.wikipedia.org/wiki/PHP PHP], [http://en.wikipedia.org/wiki/Haskell_(programming_language) Haskell], [http://en.wikipedia.org/wiki/Objective-C Objective-C], [http://en.wikipedia.org/wiki/R_(programming_language) R], [http://en.wikipedia.org/wiki/Dart_(programming_language) Dart], [http://en.wikipedia.org/wiki/Tcl Tcl]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;According to SeleniumHQ’s download page.&lt;br /&gt;
&lt;br /&gt;
'''Watir'''&lt;br /&gt;
&lt;br /&gt;
Unfortunately (or fortunately), Ruby is the only supported language for Watir.  After all, Watir does stand for “Web Application Testing in Ruby.” However, there are other frameworks which were inspired by Watir (but entirely separate) available in Java and C# - Watij and Watin,  respectively &amp;lt;ref&amp;gt;Djorgjievski, Darko. [http://www.sitepoint.com/watir-webdriver-control-browser/ Watir-WebDriver: Control the Browser]. ''SitePoint''. SitePoint Pty Ltd, 18 Apr. 2014. Web. 05 Oct. 2014.&amp;lt;/ref&amp;gt;.  There may be other similarly inspired frameworks available in other languages, but these are the most notable.&lt;br /&gt;
&lt;br /&gt;
====Cross-Platform Support====&lt;br /&gt;
Both Watir and Selenium run on most popular distributions of Windows, Mac, and Linux.  Selenium doesn't have a list of officially supported operating system versions.  Instead they generally support any version that is currently popular.  Only a few versions are listed which they run test builds on.  These are versions which are officially known to work, but many more are supported as well.&lt;br /&gt;
&lt;br /&gt;
Because Watir is a collection of Ruby Gems, it runs on any platform that Ruby runs on.  Like Selenium, this includes nearly all popular platforms.&lt;br /&gt;
&lt;br /&gt;
====Cross-Browser and Headless Browser Support====&lt;br /&gt;
&lt;br /&gt;
[[File: watir_meet_webdriver.png | Watir Meets WebDriver | link=http://yuml.me/diagram/scruffy/usecase/%5BTester%5D-%28Watir%20API%29,%20%28Watir%20API%29%3C%28FireWatir%29,%20%28Watir%20API%29%3C%28Watir%29,%20%28Watir%20API%29%3C%28SafariWatir%29,%20%28Watir%20API%29%3C%28Webdriver%29,%20%28Watir%20API%29%3C%28Celerity%29,%20%28Celerity%29-%28note:%20Celerity%20requires%20JRuby%29,%20%28Celerity%29-%28headless%29,%20%28Webdriver%29-%28Firefox%29,%20%28Webdriver%29-%28Chrome%29,%20%28Webdriver%29-%28IE%29,%20%28Webdriver%29-%28headless%29,%20%28FireWatir%29-%28Firefox%29,%20%28Watir%29-%28IE%29,%20%28SafariWatir%29-%28Safari%29.]]&lt;br /&gt;
&lt;br /&gt;
Traditionally, both Selenium and Watir were limited in the number of browsers they supported. Watir originally supported Internet Explorer and headless browsers exclusively.  Headless browsers were supported via the use of Celerity &amp;lt;ref&amp;gt;Scott, Alister. [http://watirmelon.com/2010/04/10/watir-selenium-webdriver/ Watir, Selenium &amp;amp; WebDriver]. ''Watirmelon''. Watirmelon, 10 Apr. 2010. Web. 05 Oct. 2014.&amp;lt;/ref&amp;gt;.  Selenium started out as a Javascript library, so naturally it supported more browsers such as IE, Firefox, Safari, etc &amp;lt;ref name = &amp;quot;Introduction to Selenium&amp;quot; /&amp;gt;.  However, it did not support headless browsers.&lt;br /&gt;
Today, browser support looks much better for both Selenium and Watir, largely due to the introduction of WebDriver.  With WebDriver in existence, support for most browsers was added to Watir via the gem &amp;quot;watir-webdriver.&amp;quot;  Similarly for Selenium, support for headless browsers was added, as well as making the API much simpler and more concise &amp;lt;ref&amp;gt;[http://docs.seleniumhq.org/projects/webdriver/ Selenium WebDriver]. ''SeleniumHQ: Browser Automation''. Selenium Project, n.d. Web. 06 Oct. 2014.&amp;lt;/ref&amp;gt;.  However, there is the obvious limitation that one can only test a browser which is supported on the running platform.  In other words, Safari and Internet explorer can only be tested on  OS X and Windows environments, respectively**.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;**&amp;lt;/nowiki&amp;gt; &amp;lt;span style=&amp;quot;font-size:88%&amp;quot;&amp;gt;Some work-arounds or programs may exist to allow these browsers to be tested on other platforms. Here, we are assuming no special additional configuration - just the base operating system and browsers.  With virtualization technologies such as [http://www.linux-kvm.org/page/Main_Page KVM], [https://www.virtualbox.org/ VirtualBox], and [http://en.wikipedia.org/wiki/Comparison_of_platform_virtualization_software others], this isn't a problem anyway.  [http://en.wikipedia.org/wiki/Virtual_machine Virtual machines] can be created with any operating system, as needed.&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=='''Getting started'''==&lt;br /&gt;
===Selenium WebDriver=== &lt;br /&gt;
----&lt;br /&gt;
====Install/Configure for Java====&lt;br /&gt;
Configuring Selenium requires you to download the binaries from [http://www.seleniumhq.org/download/ here]. &lt;br /&gt;
Once you have all your binaries in a directory, you can open any IDE of your choice and add this directory with all the .jar files to the CLASSPATH&lt;br /&gt;
*Example&lt;br /&gt;
This is how a typical Selenium code to find the term say, “Automation” on Google and display the results on the page would look like in Java using the [https://code.google.com/p/selenium/wiki/HtmlUnitDriver HtmlUnitDriver] would look like.&lt;br /&gt;
The HtmlUnitDriver is a pure Java driver that runs entirely in-memory. Because of this, you won't see a new browser window open &amp;lt;ref&amp;gt;[https://code.google.com/p/selenium/wiki/GettingStarted Getting started with Selenium]. Selenium: Browser Automation Framework. Google Code. 8 Feb, 2014.&amp;lt;/ref&amp;gt;,&lt;br /&gt;
&lt;br /&gt;
       package org.selenium.example;&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;
       import org.openqa.selenium.By;&lt;br /&gt;
       import org.openqa.selenium.WebDriver;&lt;br /&gt;
       import org.openqa.selenium.WebElement;&lt;br /&gt;
       import org.openqa.selenium.htmlunit.HtmlUnitDriver;&amp;lt;br /&amp;gt;&lt;br /&gt;
       public class Example  {&lt;br /&gt;
       public static void main(String[] args) {&lt;br /&gt;
        // Create a new instance of the html unit driver&lt;br /&gt;
        // Notice that the remainder of the code relies on the interface,&lt;br /&gt;
        // not the implementation.&lt;br /&gt;
        WebDriver driver = new HtmlUnitDriver();&amp;lt;br /&amp;gt;&lt;br /&gt;
        // And now use this to visit Google&lt;br /&gt;
        driver.get(&amp;quot;http://www.google.com&amp;quot;);&amp;lt;br /&amp;gt;&lt;br /&gt;
        // Find the text input element by its name&lt;br /&gt;
        WebElement element = driver.findElement(By.name(&amp;quot;q&amp;quot;));&amp;lt;br /&amp;gt;&lt;br /&gt;
        // Enter something to search for&lt;br /&gt;
        element.sendKeys(&amp;quot;Automation!&amp;quot;);&amp;lt;br /&amp;gt;&lt;br /&gt;
        // Now submit the form. WebDriver will find the form for us from the element&lt;br /&gt;
        element.submit();&amp;lt;br /&amp;gt;&lt;br /&gt;
        // Check the title of the page&lt;br /&gt;
        System.out.println(&amp;quot;Page title is: &amp;quot; + driver.getTitle());&lt;br /&gt;
        driver.quit();&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
If you compile and run it, you should see a line with the title of the Google search results as output. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Install/Configure for other languages====&lt;br /&gt;
Configuring Selenium for languages other than Java and for other development environments can be looked up [http://docs.seleniumhq.org/docs/03_webdriver.jsp#setting-up-a-selenium-webdriver-project here]. viz(C#, Ruby, Python, PHP, Perl, Javascript)&lt;br /&gt;
&lt;br /&gt;
===Watir===&lt;br /&gt;
----&lt;br /&gt;
====Install/Configure====&lt;br /&gt;
Drivers for Watir are installed as gems which are nothing but Ruby libraries which can be accessed over the internet.&lt;br /&gt;
All the instructions for installing Watir on various operating systems (viz. Windows, Mac OS, Linux) can be found [http://watir.com/installation/ here].&lt;br /&gt;
&lt;br /&gt;
*Example:&lt;br /&gt;
This is how a typical Watir code to find the term say, “Automation” on Google and display the results on the page would look like using Ruby&amp;lt;ref&amp;gt;Chernenko, Iryna. [http://blog.qatestlab.com/2011/02/23/automated-testing-with-watir-tutorial-for-begginers-part-1/ Watir Example]. QATestLab Blog: Automated Testing with Watir, 23 Feb 2011.&lt;br /&gt;
&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
        # Required in ruby 1.8.7&lt;br /&gt;
        require 'rubygems'&lt;br /&gt;
        # Watir IE driver&lt;br /&gt;
        require 'watir'&amp;lt;br /&amp;gt; &lt;br /&gt;
        ie = Watir::IE.new&amp;lt;br /&amp;gt; &lt;br /&gt;
        # text to show on console&lt;br /&gt;
        puts &amp;quot;Beginning of the test for Google search engine&amp;quot;&lt;br /&gt;
        puts &amp;quot;Step 1:  Go to the Google homepage&amp;quot;&lt;br /&gt;
        ie.goto &amp;quot;http://www.google.com&amp;quot;&amp;lt;br /&amp;gt;&lt;br /&gt;
        #set a variable&lt;br /&gt;
        search_text = &amp;quot;Automation&amp;quot;&lt;br /&gt;
        puts &amp;quot;Step 2: enter &amp;quot;+ search_text +&amp;quot; in the search text field.&amp;quot;&lt;br /&gt;
        ie.text_field(:name, &amp;quot;q&amp;quot;).set search_text   # &amp;quot;q&amp;quot; is the name of the search field&amp;lt;br /&amp;gt;&lt;br /&gt;
        puts &amp;quot; Step 3: click the 'Google Search' button.&amp;quot;&lt;br /&gt;
        ie.button(:name, &amp;quot;btnG&amp;quot;).click # &amp;quot;btnG&amp;quot; is the name of the Search button&amp;lt;br /&amp;gt;&lt;br /&gt;
        puts &amp;quot; Expected Result:&amp;quot;&lt;br /&gt;
        puts &amp;quot;  A Google page with results should be shown. 'Watir, pronounced water' should be high on the list.&amp;quot;&lt;br /&gt;
        puts &amp;quot; Actual Result:&amp;quot;&lt;br /&gt;
        if ie.text.include? &amp;quot;Watir, pronounced water&amp;quot;	&lt;br /&gt;
             puts &amp;quot;  Test Passed. Found the text string: 'Watir, pronounced water'. Actual Results match Expected Results.&amp;quot;&lt;br /&gt;
        else	&lt;br /&gt;
 	     puts &amp;quot;  Test Failed! Could not find text: 'Watir, pronounced water'.&amp;quot;&lt;br /&gt;
        end&lt;br /&gt;
        puts &amp;quot;End of test: Google search.&amp;quot;&lt;br /&gt;
        ie.close&lt;br /&gt;
&lt;br /&gt;
On compiling and running this and passing the test, you will see something like, &amp;lt;br /&amp;gt; &lt;br /&gt;
&lt;br /&gt;
        ''Output:''&lt;br /&gt;
        Beginning of the test for Google search engine &amp;lt;br /&amp;gt;&lt;br /&gt;
        Step 1:  Go to the Google homepage &amp;lt;br /&amp;gt;&lt;br /&gt;
        Step 2: enter Automation in the search text field. &amp;lt;br /&amp;gt;&lt;br /&gt;
        Step 3: click the 'Google Search' button. &amp;lt;br /&amp;gt;&lt;br /&gt;
        Expected Result: &amp;lt;br /&amp;gt;&lt;br /&gt;
        A Google page with results should be shown. 'Watir, pronounced water' should be high on the list. &amp;lt;br /&amp;gt;	&lt;br /&gt;
        Test Passed. Found the text string: 'Watir, pronounced water'. Actual Results match Expected Results. &amp;lt;br /&amp;gt;&lt;br /&gt;
        End of test: Google search. &amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Similar Tools==&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Sahi_(software) Sahi], uses the Sahi Scripting Language&amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Soatest SOATest], for testing and validating [http://en.wikipedia.org/wiki/Application_programming_interface API] driven applications &amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/TestComplete TestComplete], for Desktops, Web and Mobile&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
* [http://www.hiretheworld.com/blog/tech-blog/migrating-unit-tests-from-selenium-to-watir-webdriver Migrating unit tests from Selenium to Watir Web Driver] &amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://www.hiretheworld.com/blog/tech-blog/migrating-unit-tests-from-selenium-to-watir-webdriver Learning Selenium IDE] &amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/List_of_web_testing_tools List of web testing tools] &amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/List_of_web_testing_tools OWASP List of Acceptance Testing tools]&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
{{reflist}}&lt;br /&gt;
&amp;lt;references /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==External Links==&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Selenium_(software) Selenium Wiki Page] &amp;lt;br /&amp;gt;&lt;br /&gt;
* [https://github.com/SeleniumHQ/selenium Selenium Source Code] &amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Watir Watir Wiki Page] &amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Watir Watir Source Code] &amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Watir SauceLabs HomePage] &amp;lt;br /&amp;gt;&lt;/div&gt;</summary>
		<author><name>Jjbeaver</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/ch1b_27_js&amp;diff=89421</id>
		<title>CSC/ECE 517 Fall 2014/ch1b 27 js</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/ch1b_27_js&amp;diff=89421"/>
		<updated>2014-10-07T03:35:05Z</updated>

		<summary type="html">&lt;p&gt;Jjbeaver: /* Comparison of Features, Functionality, and More */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;='''Selenium vs. Watir'''=&lt;br /&gt;
&lt;br /&gt;
Developing web applications is proving to be a challenging task with each passing day given the complex requirements and the demanding nature of the these applications. For the web applications to be robust we need to put in place some good testing strategies.&lt;br /&gt;
&lt;br /&gt;
'''''Selenium''''' is one of the most popularly used open source automation tools for web based applications. It is a JavaScript framework that runs in your web browser to interact with various elements in your browser. All in all, Selenium is a set of different software tools each with a different approach to supporting test automation. Selenium provides a rich set of testing functions that can be customized to suit the testing requirements.&lt;br /&gt;
 &lt;br /&gt;
'''''Watir''''', is another lightweight automation testing tool that is widely used for web app testing. It is an open-source ([http://en.wikipedia.org/wiki/BSD_licenses BSD])  family of Ruby libraries for automating web browsers. It allows you to write tests that are easy to read and maintain. Despite the fact that it is a set of Ruby libraries, it works perfectly, independent of the language that the web application is developed in. Watir as a tool is extremely simple and flexible.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=='''Motivation'''==&lt;br /&gt;
===Need for test automation===&lt;br /&gt;
With the majority of software applications today being implemented as [http://en.wikipedia.org/wiki/Web_application web applications] to be used over the internet, testing is becoming an indispensable part of the software development lifecycle ([http://en.wikipedia.org/wiki/Software_development_process SDLC]) of these applications. [http://en.wikipedia.org/wiki/Test_automation Test automation] is used where manual testing needs to be carried out repeatedly making it a cumbersome task. Test automation uses a software tool for this purpose on the application to be tested. It has proven to be highly efficient and critical in larger software development companies. Additionally, automation can be a valuable way to make Test Driven Development ([http://en.wikipedia.org/wiki/Test-driven_development TDD]) tasks an important part of the software development workflow.&lt;br /&gt;
 &lt;br /&gt;
Test Automation has a number of advantages mostly dealing with repetitiveness of the tests and the time taken,&lt;br /&gt;
* '''Covers cases that manual testing probably cannot'''&lt;br /&gt;
# Finds defects missed out my manual testing&lt;br /&gt;
# Automated testing can simulate numerous virtual users interacting with the web software/application&lt;br /&gt;
* '''Helps save time and money'''&lt;br /&gt;
# Once created, automated tests can be executed repeatedly at no additional   costs and at a much faster pace. Saving time directly translates into saving cost.&lt;br /&gt;
# Supports virtually unlimited iterations of test case execution&lt;br /&gt;
* '''Increase test coverage and accuracy'''&lt;br /&gt;
# Automated tests perform the exact same steps and records all details precisely&lt;br /&gt;
# They also increase the depth and scope of tests to improve the quality of the software&lt;br /&gt;
&lt;br /&gt;
=='''Brief History'''==&lt;br /&gt;
====Selenium====&lt;br /&gt;
&lt;br /&gt;
[[File: SE-logo.png|right|Selenium Logo|link=http://www.seleniumhq.org/images/big-logo.png]]&lt;br /&gt;
&lt;br /&gt;
''Selenium'' was developed in the year 2004 by Jason Huggins and has been continuously evolving ever since. Jason Huggins developed this as an internal tool for [http://en.wikipedia.org/wiki/ThoughtWorks ThoughtWorks] as a javascript library which came to be known as the Selenium core. Selenium core is now the basis of the Selenium Remote Control (the server) and Selenium IDE.&lt;br /&gt;
The year 2006 marked the beginning of the development of the WebDriver project which was what they believed ‘a tool of the future’. The WebDriver was initiated to solve the problems that were faced due to the fact that Selenium was a based on JavaScript and a lot of security limitations browsers apply to Javascript.&lt;br /&gt;
In 2008, both Selenium and WebDriver merged to provide a common set of features to all users which is called Selenium 2..&lt;br /&gt;
Simon Stewart, the creator of WebDriver, in a joint email to the WebDriver and Selenium community on August 6, 2009 said the following,&lt;br /&gt;
&lt;br /&gt;
“Why are the projects merging? Partly because webdriver addresses some shortcomings in selenium (by being able to bypass the JS sandbox, for example. And we’ve got a gorgeous API), partly because selenium addresses some shortcomings in webdriver (such as supporting a broader range of browsers) and partly because the main selenium contributors and I felt that it was the best way to offer users the best possible framework.”&amp;lt;ref name =&amp;quot;Introduction to Selenium&amp;quot;&amp;gt;[http://docs.seleniumhq.org/docs/01_introducing_selenium.jsp#selenium-history Introducing Selenium]. ''SeleniumHQ: Browser Automation''. Selenium Project, 4 Oct. 2014. Web. 06 Oct. 2014.&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Watir====&lt;br /&gt;
&lt;br /&gt;
''Watir'' started as a library to teach testers to write ruby code and grew to be an IE implementation which now supports IE, Firefox, Safari, Google Chrome and Opera.&lt;br /&gt;
Watir was primarily developed by Bret Pettichord and Paul Rogers. Watir has since then has a couple of stable releases for Watir classic as well as Watir WebDriver. The most recent releases being&amp;lt;ref&amp;gt;[http://watir.com/category/releases/ Watir Releases]. Watir: Web Application Testing in Ruby. 28 April, 2013&amp;lt;/ref&amp;gt;, &lt;br /&gt;
&lt;br /&gt;
[[File: Watir.gif|right|Watir logo|link=http://upload.wikimedia.org/wikipedia/commons/7/7e/Watir.gif]]&lt;br /&gt;
&lt;br /&gt;
* Watir-Classic	    &lt;br /&gt;
# 0.6.3 April 10, 2013 ([https://github.com/watir/watir-webdriver/blob/master/CHANGES.md#063 Release Notes]) &amp;lt;br /&amp;gt;&lt;br /&gt;
* Watir-WebDriver	    &lt;br /&gt;
# 3.6.0 March 16, 2013 ([https://groups.google.com/forum/#!msg/watir-general/MOOun5g3Hvg/JBVNy957lDYJ Release Notes]) &amp;lt;br /&amp;gt;&lt;br /&gt;
# 3.5.0 March 10, 2013 ([https://groups.google.com/forum/#!msg/watir-general/aeUqsglvK6k/Kq7FCBiERjYJ Release Notes]) &amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Watir has a google group ([https://groups.google.com/forum/#!forum/watir-general Watir General]) for its support and contribution while Selenium also has a [http://seleniumforum.forumotion.net/ Selenium forum] apart from its google group called [https://groups.google.com/forum/#!forum/selenium-users Selenium Users].&lt;br /&gt;
&lt;br /&gt;
=='''Comparison of Features, Functionality, and More'''==&lt;br /&gt;
Some features or functionality may be repeated here.  However, we will go into a bit more detail than previously mentioned.&lt;br /&gt;
===='''Open Source'''====&lt;br /&gt;
Both Selenium and Watir are [http://en.wikipedia.org/wiki/Open-source_software open source]!  This allows for greater extensibility and a deeper understanding of the inner workings of both of the frameworks, if the developer/tester chooses to delve into such details.  Additionally, the open source community allows for a more transparent, user-driven development and support cycle.  Users (the tester/developer) can choose to submit bug fixes or enhancements as patches, or they can choose to just use it “straight out of the box.”&lt;br /&gt;
&lt;br /&gt;
====Application Language Agnostic====&lt;br /&gt;
&lt;br /&gt;
Both Selenium and Watir are application language agnostic.  Because both Selenium and Watir test UI functionality in the browser, they can be used to test any web application.    &lt;br /&gt;
&lt;br /&gt;
====Language-specific Test Cases====&lt;br /&gt;
&lt;br /&gt;
Both Selenium and Watir require test cases to be written in some programming language.  Traditionally, both frameworks had limited choices in terms of language bindings.  However, with the advent of WebDriver, both became much more flexible.  WebDriver provided the bindings needed for many languages.  Today, the following are supported:&lt;br /&gt;
&lt;br /&gt;
'''Selenium*'''&lt;br /&gt;
&lt;br /&gt;
* Officially-supported: [http://en.wikipedia.org/wiki/Java_(programming_language) Java], [http://en.wikipedia.org/wiki/C_Sharp_(programming_language) C#], [http://en.wikipedia.org/wiki/Ruby_(programming_language) Ruby], [http://en.wikipedia.org/wiki/Python_(programming_language) Python], [http://en.wikipedia.org/wiki/Node.js Javascript/Node.js]&lt;br /&gt;
&lt;br /&gt;
* Unofficial/community-supported: [http://en.wikipedia.org/wiki/Perl Perl], [http://en.wikipedia.org/wiki/PHP PHP], [http://en.wikipedia.org/wiki/Haskell_(programming_language) Haskell], [http://en.wikipedia.org/wiki/Objective-C Objective-C], [http://en.wikipedia.org/wiki/R_(programming_language) R], [http://en.wikipedia.org/wiki/Dart_(programming_language) Dart], [http://en.wikipedia.org/wiki/Tcl Tcl]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;According to SeleniumHQ’s download page.&lt;br /&gt;
&lt;br /&gt;
'''Watir'''&lt;br /&gt;
&lt;br /&gt;
Unfortunately (or fortunately), Ruby is the only supported language for Watir.  After all, Watir does stand for “Web Application Testing in Ruby.” However, there are other frameworks which were inspired by Watir (but entirely separate) available in Java and C# - Watij and Watin,  respectively &amp;lt;ref&amp;gt;Djorgjievski, Darko. [http://www.sitepoint.com/watir-webdriver-control-browser/ Watir-WebDriver: Control the Browser]. ''SitePoint''. SitePoint Pty Ltd, 18 Apr. 2014. Web. 05 Oct. 2014.&amp;lt;/ref&amp;gt;.  There may be other similarly inspired frameworks available in other languages, but these are the most notable.&lt;br /&gt;
&lt;br /&gt;
====Cross-Platform Support====&lt;br /&gt;
Both Watir and Selenium run on most popular distributions of Windows, Mac, and Linux.  Selenium doesn't have a list of officially supported operating system versions.  Instead they generally support any version that is currently popular.  Only a few versions are listed which they run test builds on.  These are versions which are officially known to work, but many more are supported as well.&lt;br /&gt;
&lt;br /&gt;
Because Watir is a collection of Ruby Gems, it runs on any platform that Ruby runs on.  Like Selenium, this includes nearly all popular platforms.&lt;br /&gt;
&lt;br /&gt;
====Cross-Browser and Headless Browser Support====&lt;br /&gt;
&lt;br /&gt;
[[File: watir_meet_webdriver.png | Watir Meets WebDriver]]&lt;br /&gt;
&lt;br /&gt;
Traditionally, both Selenium and Watir were limited in the number of browsers they supported. Watir originally supported Internet Explorer and headless browsers exclusively.  Headless browsers were supported via the use of Celerity &amp;lt;ref&amp;gt;Scott, Alister. [http://watirmelon.com/2010/04/10/watir-selenium-webdriver/ Watir, Selenium &amp;amp; WebDriver]. ''Watirmelon''. Watirmelon, 10 Apr. 2010. Web. 05 Oct. 2014.&amp;lt;/ref&amp;gt;.  Selenium started out as a Javascript library, so naturally it supported more browsers such as IE, Firefox, Safari, etc &amp;lt;ref name = &amp;quot;Introduction to Selenium&amp;quot; /&amp;gt;.  However, it did not support headless browsers.&lt;br /&gt;
Today, browser support looks much better for both Selenium and Watir, largely due to the introduction of WebDriver.  With WebDriver in existence, support for most browsers was added to Watir via the gem &amp;quot;watir-webdriver.&amp;quot;  Similarly for Selenium, support for headless browsers was added, as well as making the API much simpler and more concise &amp;lt;ref&amp;gt;[http://docs.seleniumhq.org/projects/webdriver/ Selenium WebDriver]. ''SeleniumHQ: Browser Automation''. Selenium Project, n.d. Web. 06 Oct. 2014.&amp;lt;/ref&amp;gt;.  However, there is the obvious limitation that one can only test a browser which is supported on the running platform.  In other words, Safari and Internet explorer can only be tested on  OS X and Windows environments, respectively**.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;**&amp;lt;/nowiki&amp;gt; &amp;lt;span style=&amp;quot;font-size:88%&amp;quot;&amp;gt;Some work-arounds or programs may exist to allow these browsers to be tested on other platforms. Here, we are assuming no special additional configuration - just the base operating system and browsers.  With virtualization technologies such as [http://www.linux-kvm.org/page/Main_Page KVM], [https://www.virtualbox.org/ VirtualBox], and [http://en.wikipedia.org/wiki/Comparison_of_platform_virtualization_software others], this isn't a problem anyway.  [http://en.wikipedia.org/wiki/Virtual_machine Virtual machines] can be created with any operating system, as needed.&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=='''Getting started'''==&lt;br /&gt;
===Selenium WebDriver=== &lt;br /&gt;
----&lt;br /&gt;
====Install/Configure for Java====&lt;br /&gt;
Configuring Selenium requires you to download the binaries from [http://www.seleniumhq.org/download/ here]. &lt;br /&gt;
Once you have all your binaries in a directory, you can open any IDE of your choice and add this directory with all the .jar files to the CLASSPATH&lt;br /&gt;
*Example&lt;br /&gt;
This is how a typical Selenium code to find the term say, “Automation” on Google and display the results on the page would look like in Java using the [https://code.google.com/p/selenium/wiki/HtmlUnitDriver HtmlUnitDriver] would look like.&lt;br /&gt;
The HtmlUnitDriver is a pure Java driver that runs entirely in-memory. Because of this, you won't see a new browser window open &amp;lt;ref&amp;gt;[https://code.google.com/p/selenium/wiki/GettingStarted Getting started with Selenium]. Selenium: Browser Automation Framework. Google Code. 8 Feb, 2014.&amp;lt;/ref&amp;gt;,&lt;br /&gt;
&lt;br /&gt;
       package org.selenium.example;&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;
       import org.openqa.selenium.By;&lt;br /&gt;
       import org.openqa.selenium.WebDriver;&lt;br /&gt;
       import org.openqa.selenium.WebElement;&lt;br /&gt;
       import org.openqa.selenium.htmlunit.HtmlUnitDriver;&amp;lt;br /&amp;gt;&lt;br /&gt;
       public class Example  {&lt;br /&gt;
       public static void main(String[] args) {&lt;br /&gt;
        // Create a new instance of the html unit driver&lt;br /&gt;
        // Notice that the remainder of the code relies on the interface,&lt;br /&gt;
        // not the implementation.&lt;br /&gt;
        WebDriver driver = new HtmlUnitDriver();&amp;lt;br /&amp;gt;&lt;br /&gt;
        // And now use this to visit Google&lt;br /&gt;
        driver.get(&amp;quot;http://www.google.com&amp;quot;);&amp;lt;br /&amp;gt;&lt;br /&gt;
        // Find the text input element by its name&lt;br /&gt;
        WebElement element = driver.findElement(By.name(&amp;quot;q&amp;quot;));&amp;lt;br /&amp;gt;&lt;br /&gt;
        // Enter something to search for&lt;br /&gt;
        element.sendKeys(&amp;quot;Automation!&amp;quot;);&amp;lt;br /&amp;gt;&lt;br /&gt;
        // Now submit the form. WebDriver will find the form for us from the element&lt;br /&gt;
        element.submit();&amp;lt;br /&amp;gt;&lt;br /&gt;
        // Check the title of the page&lt;br /&gt;
        System.out.println(&amp;quot;Page title is: &amp;quot; + driver.getTitle());&lt;br /&gt;
        driver.quit();&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
If you compile and run it, you should see a line with the title of the Google search results as output. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Install/Configure for other languages====&lt;br /&gt;
Configuring Selenium for languages other than Java and for other development environments can be looked up [http://docs.seleniumhq.org/docs/03_webdriver.jsp#setting-up-a-selenium-webdriver-project here]. viz(C#, Ruby, Python, PHP, Perl, Javascript)&lt;br /&gt;
&lt;br /&gt;
===Watir===&lt;br /&gt;
----&lt;br /&gt;
====Install/Configure====&lt;br /&gt;
Drivers for Watir are installed as gems which are nothing but Ruby libraries which can be accessed over the internet.&lt;br /&gt;
All the instructions for installing Watir on various operating systems (viz. Windows, Mac OS, Linux) can be found [http://watir.com/installation/ here].&lt;br /&gt;
&lt;br /&gt;
*Example:&lt;br /&gt;
This is how a typical Watir code to find the term say, “Automation” on Google and display the results on the page would look like using Ruby&amp;lt;ref&amp;gt;Chernenko, Iryna. [http://blog.qatestlab.com/2011/02/23/automated-testing-with-watir-tutorial-for-begginers-part-1/ Watir Example]. QATestLab Blog: Automated Testing with Watir, 23 Feb 2011.&lt;br /&gt;
&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
        # Required in ruby 1.8.7&lt;br /&gt;
        require 'rubygems'&lt;br /&gt;
        # Watir IE driver&lt;br /&gt;
        require 'watir'&amp;lt;br /&amp;gt; &lt;br /&gt;
        ie = Watir::IE.new&amp;lt;br /&amp;gt; &lt;br /&gt;
        # text to show on console&lt;br /&gt;
        puts &amp;quot;Beginning of the test for Google search engine&amp;quot;&lt;br /&gt;
        puts &amp;quot;Step 1:  Go to the Google homepage&amp;quot;&lt;br /&gt;
        ie.goto &amp;quot;http://www.google.com&amp;quot;&amp;lt;br /&amp;gt;&lt;br /&gt;
        #set a variable&lt;br /&gt;
        search_text = &amp;quot;Automation&amp;quot;&lt;br /&gt;
        puts &amp;quot;Step 2: enter &amp;quot;+ search_text +&amp;quot; in the search text field.&amp;quot;&lt;br /&gt;
        ie.text_field(:name, &amp;quot;q&amp;quot;).set search_text   # &amp;quot;q&amp;quot; is the name of the search field&amp;lt;br /&amp;gt;&lt;br /&gt;
        puts &amp;quot; Step 3: click the 'Google Search' button.&amp;quot;&lt;br /&gt;
        ie.button(:name, &amp;quot;btnG&amp;quot;).click # &amp;quot;btnG&amp;quot; is the name of the Search button&amp;lt;br /&amp;gt;&lt;br /&gt;
        puts &amp;quot; Expected Result:&amp;quot;&lt;br /&gt;
        puts &amp;quot;  A Google page with results should be shown. 'Watir, pronounced water' should be high on the list.&amp;quot;&lt;br /&gt;
        puts &amp;quot; Actual Result:&amp;quot;&lt;br /&gt;
        if ie.text.include? &amp;quot;Watir, pronounced water&amp;quot;	&lt;br /&gt;
             puts &amp;quot;  Test Passed. Found the text string: 'Watir, pronounced water'. Actual Results match Expected Results.&amp;quot;&lt;br /&gt;
        else	&lt;br /&gt;
 	     puts &amp;quot;  Test Failed! Could not find text: 'Watir, pronounced water'.&amp;quot;&lt;br /&gt;
        end&lt;br /&gt;
        puts &amp;quot;End of test: Google search.&amp;quot;&lt;br /&gt;
        ie.close&lt;br /&gt;
&lt;br /&gt;
On compiling and running this and passing the test, you will see something like, &amp;lt;br /&amp;gt; &lt;br /&gt;
&lt;br /&gt;
        ''Output:''&lt;br /&gt;
        Beginning of the test for Google search engine &amp;lt;br /&amp;gt;&lt;br /&gt;
        Step 1:  Go to the Google homepage &amp;lt;br /&amp;gt;&lt;br /&gt;
        Step 2: enter Automation in the search text field. &amp;lt;br /&amp;gt;&lt;br /&gt;
        Step 3: click the 'Google Search' button. &amp;lt;br /&amp;gt;&lt;br /&gt;
        Expected Result: &amp;lt;br /&amp;gt;&lt;br /&gt;
        A Google page with results should be shown. 'Watir, pronounced water' should be high on the list. &amp;lt;br /&amp;gt;	&lt;br /&gt;
        Test Passed. Found the text string: 'Watir, pronounced water'. Actual Results match Expected Results. &amp;lt;br /&amp;gt;&lt;br /&gt;
        End of test: Google search. &amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Similar Tools==&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Sahi_(software) Sahi], uses the Sahi Scripting Language&amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Soatest SOATest], for testing and validating [http://en.wikipedia.org/wiki/Application_programming_interface API] driven applications &amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/TestComplete TestComplete], for Desktops, Web and Mobile&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
* [http://www.hiretheworld.com/blog/tech-blog/migrating-unit-tests-from-selenium-to-watir-webdriver Migrating unit tests from Selenium to Watir Web Driver] &amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://www.hiretheworld.com/blog/tech-blog/migrating-unit-tests-from-selenium-to-watir-webdriver Learning Selenium IDE] &amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/List_of_web_testing_tools List of web testing tools] &amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/List_of_web_testing_tools OWASP List of Acceptance Testing tools]&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
{{reflist}}&lt;br /&gt;
&amp;lt;references /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==External Links==&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Selenium_(software) Selenium Wiki Page] &amp;lt;br /&amp;gt;&lt;br /&gt;
* [https://github.com/SeleniumHQ/selenium Selenium Source Code] &amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Watir Watir Wiki Page] &amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Watir Watir Source Code] &amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Watir SauceLabs HomePage] &amp;lt;br /&amp;gt;&lt;/div&gt;</summary>
		<author><name>Jjbeaver</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/ch1b_27_js&amp;diff=89420</id>
		<title>CSC/ECE 517 Fall 2014/ch1b 27 js</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/ch1b_27_js&amp;diff=89420"/>
		<updated>2014-10-07T03:31:28Z</updated>

		<summary type="html">&lt;p&gt;Jjbeaver: /* Comparison of Features, Functionality, and More */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;='''Selenium vs. Watir'''=&lt;br /&gt;
&lt;br /&gt;
Developing web applications is proving to be a challenging task with each passing day given the complex requirements and the demanding nature of the these applications. For the web applications to be robust we need to put in place some good testing strategies.&lt;br /&gt;
&lt;br /&gt;
'''''Selenium''''' is one of the most popularly used open source automation tools for web based applications. It is a JavaScript framework that runs in your web browser to interact with various elements in your browser. All in all, Selenium is a set of different software tools each with a different approach to supporting test automation. Selenium provides a rich set of testing functions that can be customized to suit the testing requirements.&lt;br /&gt;
 &lt;br /&gt;
'''''Watir''''', is another lightweight automation testing tool that is widely used for web app testing. It is an open-source ([http://en.wikipedia.org/wiki/BSD_licenses BSD])  family of Ruby libraries for automating web browsers. It allows you to write tests that are easy to read and maintain. Despite the fact that it is a set of Ruby libraries, it works perfectly, independent of the language that the web application is developed in. Watir as a tool is extremely simple and flexible.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=='''Motivation'''==&lt;br /&gt;
===Need for test automation===&lt;br /&gt;
With the majority of software applications today being implemented as [http://en.wikipedia.org/wiki/Web_application web applications] to be used over the internet, testing is becoming an indispensable part of the software development lifecycle ([http://en.wikipedia.org/wiki/Software_development_process SDLC]) of these applications. [http://en.wikipedia.org/wiki/Test_automation Test automation] is used where manual testing needs to be carried out repeatedly making it a cumbersome task. Test automation uses a software tool for this purpose on the application to be tested. It has proven to be highly efficient and critical in larger software development companies. Additionally, automation can be a valuable way to make Test Driven Development ([http://en.wikipedia.org/wiki/Test-driven_development TDD]) tasks an important part of the software development workflow.&lt;br /&gt;
 &lt;br /&gt;
Test Automation has a number of advantages mostly dealing with repetitiveness of the tests and the time taken,&lt;br /&gt;
* '''Covers cases that manual testing probably cannot'''&lt;br /&gt;
# Finds defects missed out my manual testing&lt;br /&gt;
# Automated testing can simulate numerous virtual users interacting with the web software/application&lt;br /&gt;
* '''Helps save time and money'''&lt;br /&gt;
# Once created, automated tests can be executed repeatedly at no additional   costs and at a much faster pace. Saving time directly translates into saving cost.&lt;br /&gt;
# Supports virtually unlimited iterations of test case execution&lt;br /&gt;
* '''Increase test coverage and accuracy'''&lt;br /&gt;
# Automated tests perform the exact same steps and records all details precisely&lt;br /&gt;
# They also increase the depth and scope of tests to improve the quality of the software&lt;br /&gt;
&lt;br /&gt;
=='''Brief History'''==&lt;br /&gt;
====Selenium====&lt;br /&gt;
&lt;br /&gt;
[[File: SE-logo.png|right|Selenium Logo|link=http://www.seleniumhq.org/images/big-logo.png]]&lt;br /&gt;
&lt;br /&gt;
''Selenium'' was developed in the year 2004 by Jason Huggins and has been continuously evolving ever since. Jason Huggins developed this as an internal tool for [http://en.wikipedia.org/wiki/ThoughtWorks ThoughtWorks] as a javascript library which came to be known as the Selenium core. Selenium core is now the basis of the Selenium Remote Control (the server) and Selenium IDE.&lt;br /&gt;
The year 2006 marked the beginning of the development of the WebDriver project which was what they believed ‘a tool of the future’. The WebDriver was initiated to solve the problems that were faced due to the fact that Selenium was a based on JavaScript and a lot of security limitations browsers apply to Javascript.&lt;br /&gt;
In 2008, both Selenium and WebDriver merged to provide a common set of features to all users which is called Selenium 2..&lt;br /&gt;
Simon Stewart, the creator of WebDriver, in a joint email to the WebDriver and Selenium community on August 6, 2009 said the following,&lt;br /&gt;
&lt;br /&gt;
“Why are the projects merging? Partly because webdriver addresses some shortcomings in selenium (by being able to bypass the JS sandbox, for example. And we’ve got a gorgeous API), partly because selenium addresses some shortcomings in webdriver (such as supporting a broader range of browsers) and partly because the main selenium contributors and I felt that it was the best way to offer users the best possible framework.”&amp;lt;ref name =&amp;quot;Introduction to Selenium&amp;quot;&amp;gt;[http://docs.seleniumhq.org/docs/01_introducing_selenium.jsp#selenium-history Introducing Selenium]. ''SeleniumHQ: Browser Automation''. Selenium Project, 4 Oct. 2014. Web. 06 Oct. 2014.&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Watir====&lt;br /&gt;
&lt;br /&gt;
''Watir'' started as a library to teach testers to write ruby code and grew to be an IE implementation which now supports IE, Firefox, Safari, Google Chrome and Opera.&lt;br /&gt;
Watir was primarily developed by Bret Pettichord and Paul Rogers. Watir has since then has a couple of stable releases for Watir classic as well as Watir WebDriver. The most recent releases being&amp;lt;ref&amp;gt;[http://watir.com/category/releases/ Watir Releases]. Watir: Web Application Testing in Ruby. 28 April, 2013&amp;lt;/ref&amp;gt;, &lt;br /&gt;
&lt;br /&gt;
[[File: Watir.gif|right|Watir logo|link=http://upload.wikimedia.org/wikipedia/commons/7/7e/Watir.gif]]&lt;br /&gt;
&lt;br /&gt;
* Watir-Classic	    &lt;br /&gt;
# 0.6.3 April 10, 2013 ([https://github.com/watir/watir-webdriver/blob/master/CHANGES.md#063 Release Notes]) &amp;lt;br /&amp;gt;&lt;br /&gt;
* Watir-WebDriver	    &lt;br /&gt;
# 3.6.0 March 16, 2013 ([https://groups.google.com/forum/#!msg/watir-general/MOOun5g3Hvg/JBVNy957lDYJ Release Notes]) &amp;lt;br /&amp;gt;&lt;br /&gt;
# 3.5.0 March 10, 2013 ([https://groups.google.com/forum/#!msg/watir-general/aeUqsglvK6k/Kq7FCBiERjYJ Release Notes]) &amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Watir has a google group ([https://groups.google.com/forum/#!forum/watir-general Watir General]) for its support and contribution while Selenium also has a [http://seleniumforum.forumotion.net/ Selenium forum] apart from its google group called [https://groups.google.com/forum/#!forum/selenium-users Selenium Users].&lt;br /&gt;
&lt;br /&gt;
=='''Comparison of Features, Functionality, and More'''==&lt;br /&gt;
Some features or functionality may be repeated here.  However, we will go into a bit more detail than previously mentioned.&lt;br /&gt;
===='''Open Source'''====&lt;br /&gt;
Both Selenium and Watir are [http://en.wikipedia.org/wiki/Open-source_software open source]!  This allows for greater extensibility and a deeper understanding of the inner workings of both of the frameworks, if the developer/tester chooses to delve into such details.  Additionally, the open source community allows for a more transparent, user-driven development and support cycle.  Users (the tester/developer) can choose to submit bug fixes or enhancements as patches, or they can choose to just use it “straight out of the box.”&lt;br /&gt;
&lt;br /&gt;
====Application Language Agnostic====&lt;br /&gt;
&lt;br /&gt;
Both Selenium and Watir are application language agnostic.  Because both Selenium and Watir test UI functionality in the browser, they can be used to test any web application.    &lt;br /&gt;
&lt;br /&gt;
====Language-specific Test Cases====&lt;br /&gt;
&lt;br /&gt;
Both Selenium and Watir require test cases to be written in some programming language.  Traditionally, both frameworks had limited choices in terms of language bindings.  However, with the advent of WebDriver, both became much more flexible.  WebDriver provided the bindings needed for many languages.  Today, the following are supported:&lt;br /&gt;
&lt;br /&gt;
'''Selenium*'''&lt;br /&gt;
&lt;br /&gt;
* Officially-supported: [http://en.wikipedia.org/wiki/Java_(programming_language) Java], [http://en.wikipedia.org/wiki/C_Sharp_(programming_language) C#], [http://en.wikipedia.org/wiki/Ruby_(programming_language) Ruby], [http://en.wikipedia.org/wiki/Python_(programming_language) Python], [http://en.wikipedia.org/wiki/Node.js Javascript/Node.js]&lt;br /&gt;
&lt;br /&gt;
* Unofficial/community-supported: [http://en.wikipedia.org/wiki/Perl Perl], [http://en.wikipedia.org/wiki/PHP PHP], [http://en.wikipedia.org/wiki/Haskell_(programming_language) Haskell], [http://en.wikipedia.org/wiki/Objective-C Objective-C], [http://en.wikipedia.org/wiki/R_(programming_language) R], [http://en.wikipedia.org/wiki/Dart_(programming_language) Dart], [http://en.wikipedia.org/wiki/Tcl Tcl]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;According to SeleniumHQ’s download page.&lt;br /&gt;
&lt;br /&gt;
'''Watir'''&lt;br /&gt;
&lt;br /&gt;
Unfortunately (or fortunately), Ruby is the only supported language for Watir.  After all, Watir does stand for “Web Application Testing in Ruby.” However, there are other frameworks which were inspired by Watir (but entirely separate) available in Java and C# - Watij and Watin,  respectively &amp;lt;ref&amp;gt;Djorgjievski, Darko. [http://www.sitepoint.com/watir-webdriver-control-browser/ Watir-WebDriver: Control the Browser]. ''SitePoint''. SitePoint Pty Ltd, 18 Apr. 2014. Web. 05 Oct. 2014.&amp;lt;/ref&amp;gt;.  There may be other similarly inspired frameworks available in other languages, but these are the most notable.&lt;br /&gt;
&lt;br /&gt;
====Cross-Platform Support====&lt;br /&gt;
Both Watir and Selenium run on most popular distributions of Windows, Mac, and Linux.  Selenium doesn't have a list of officially supported operating system versions.  Instead they generally support any version that is currently popular.  Only a few versions are listed which they run test builds on.  These are versions which are officially known to work, but many more are supported as well.&lt;br /&gt;
&lt;br /&gt;
Because Watir is a collection of Ruby Gems, it runs on any platform that Ruby runs on.  Like Selenium, this includes nearly all popular platforms.&lt;br /&gt;
&lt;br /&gt;
====Cross-Browser and Headless Browser Support====&lt;br /&gt;
&lt;br /&gt;
Traditionally, both Selenium and Watir were limited in the number of browsers they supported. Watir originally supported Internet Explorer and headless browsers exclusively.  Headless browsers were supported via the use of Celerity &amp;lt;ref&amp;gt;Scott, Alister. [http://watirmelon.com/2010/04/10/watir-selenium-webdriver/ Watir, Selenium &amp;amp; WebDriver]. ''Watirmelon''. Watirmelon, 10 Apr. 2010. Web. 05 Oct. 2014.&amp;lt;/ref&amp;gt;.  Selenium started out as a Javascript library, so naturally it supported more browsers such as IE, Firefox, Safari, etc &amp;lt;ref name = &amp;quot;Introduction to Selenium&amp;quot; /&amp;gt;.  However, it did not support headless browsers.&lt;br /&gt;
Today, browser support looks much better for both Selenium and Watir, largely due to the introduction of WebDriver.  With WebDriver in existence, support for most browsers was added to Watir via the gem &amp;quot;watir-webdriver.&amp;quot;  Similarly for Selenium, support for headless browsers was added, as well as making the API much simpler and more concise &amp;lt;ref&amp;gt;[http://docs.seleniumhq.org/projects/webdriver/ Selenium WebDriver]. ''SeleniumHQ: Browser Automation''. Selenium Project, n.d. Web. 06 Oct. 2014.&amp;lt;/ref&amp;gt;.  However, there is the obvious limitation that one can only test a browser which is supported on the running platform.  In other words, Safari and Internet explorer can only be tested on  OS X and Windows environments, respectively**.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;**&amp;lt;/nowiki&amp;gt; &amp;lt;span style=&amp;quot;font-size:88%&amp;quot;&amp;gt;Some work-arounds or programs may exist to allow these browsers to be tested on other platforms. Here, we are assuming no special additional configuration - just the base operating system and browsers.  With virtualization technologies such as [http://www.linux-kvm.org/page/Main_Page KVM], [https://www.virtualbox.org/ VirtualBox], and [http://en.wikipedia.org/wiki/Comparison_of_platform_virtualization_software others], this isn't a problem anyway.  [http://en.wikipedia.org/wiki/Virtual_machine Virtual machines] can be created with any operating system, as needed.&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=='''Getting started'''==&lt;br /&gt;
===Selenium WebDriver=== &lt;br /&gt;
----&lt;br /&gt;
====Install/Configure for Java====&lt;br /&gt;
Configuring Selenium requires you to download the binaries from [http://www.seleniumhq.org/download/ here]. &lt;br /&gt;
Once you have all your binaries in a directory, you can open any IDE of your choice and add this directory with all the .jar files to the CLASSPATH&lt;br /&gt;
*Example&lt;br /&gt;
This is how a typical Selenium code to find the term say, “Automation” on Google and display the results on the page would look like in Java using the [https://code.google.com/p/selenium/wiki/HtmlUnitDriver HtmlUnitDriver] would look like.&lt;br /&gt;
The HtmlUnitDriver is a pure Java driver that runs entirely in-memory. Because of this, you won't see a new browser window open &amp;lt;ref&amp;gt;[https://code.google.com/p/selenium/wiki/GettingStarted Getting started with Selenium]. Selenium: Browser Automation Framework. Google Code. 8 Feb, 2014.&amp;lt;/ref&amp;gt;,&lt;br /&gt;
&lt;br /&gt;
       package org.selenium.example;&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;
       import org.openqa.selenium.By;&lt;br /&gt;
       import org.openqa.selenium.WebDriver;&lt;br /&gt;
       import org.openqa.selenium.WebElement;&lt;br /&gt;
       import org.openqa.selenium.htmlunit.HtmlUnitDriver;&amp;lt;br /&amp;gt;&lt;br /&gt;
       public class Example  {&lt;br /&gt;
       public static void main(String[] args) {&lt;br /&gt;
        // Create a new instance of the html unit driver&lt;br /&gt;
        // Notice that the remainder of the code relies on the interface,&lt;br /&gt;
        // not the implementation.&lt;br /&gt;
        WebDriver driver = new HtmlUnitDriver();&amp;lt;br /&amp;gt;&lt;br /&gt;
        // And now use this to visit Google&lt;br /&gt;
        driver.get(&amp;quot;http://www.google.com&amp;quot;);&amp;lt;br /&amp;gt;&lt;br /&gt;
        // Find the text input element by its name&lt;br /&gt;
        WebElement element = driver.findElement(By.name(&amp;quot;q&amp;quot;));&amp;lt;br /&amp;gt;&lt;br /&gt;
        // Enter something to search for&lt;br /&gt;
        element.sendKeys(&amp;quot;Automation!&amp;quot;);&amp;lt;br /&amp;gt;&lt;br /&gt;
        // Now submit the form. WebDriver will find the form for us from the element&lt;br /&gt;
        element.submit();&amp;lt;br /&amp;gt;&lt;br /&gt;
        // Check the title of the page&lt;br /&gt;
        System.out.println(&amp;quot;Page title is: &amp;quot; + driver.getTitle());&lt;br /&gt;
        driver.quit();&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
If you compile and run it, you should see a line with the title of the Google search results as output. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Install/Configure for other languages====&lt;br /&gt;
Configuring Selenium for languages other than Java and for other development environments can be looked up [http://docs.seleniumhq.org/docs/03_webdriver.jsp#setting-up-a-selenium-webdriver-project here]. viz(C#, Ruby, Python, PHP, Perl, Javascript)&lt;br /&gt;
&lt;br /&gt;
===Watir===&lt;br /&gt;
----&lt;br /&gt;
====Install/Configure====&lt;br /&gt;
Drivers for Watir are installed as gems which are nothing but Ruby libraries which can be accessed over the internet.&lt;br /&gt;
All the instructions for installing Watir on various operating systems (viz. Windows, Mac OS, Linux) can be found [http://watir.com/installation/ here].&lt;br /&gt;
&lt;br /&gt;
*Example:&lt;br /&gt;
This is how a typical Watir code to find the term say, “Automation” on Google and display the results on the page would look like using Ruby&amp;lt;ref&amp;gt;Chernenko, Iryna. [http://blog.qatestlab.com/2011/02/23/automated-testing-with-watir-tutorial-for-begginers-part-1/ Watir Example]. QATestLab Blog: Automated Testing with Watir, 23 Feb 2011.&lt;br /&gt;
&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
        # Required in ruby 1.8.7&lt;br /&gt;
        require 'rubygems'&lt;br /&gt;
        # Watir IE driver&lt;br /&gt;
        require 'watir'&amp;lt;br /&amp;gt; &lt;br /&gt;
        ie = Watir::IE.new&amp;lt;br /&amp;gt; &lt;br /&gt;
        # text to show on console&lt;br /&gt;
        puts &amp;quot;Beginning of the test for Google search engine&amp;quot;&lt;br /&gt;
        puts &amp;quot;Step 1:  Go to the Google homepage&amp;quot;&lt;br /&gt;
        ie.goto &amp;quot;http://www.google.com&amp;quot;&amp;lt;br /&amp;gt;&lt;br /&gt;
        #set a variable&lt;br /&gt;
        search_text = &amp;quot;Automation&amp;quot;&lt;br /&gt;
        puts &amp;quot;Step 2: enter &amp;quot;+ search_text +&amp;quot; in the search text field.&amp;quot;&lt;br /&gt;
        ie.text_field(:name, &amp;quot;q&amp;quot;).set search_text   # &amp;quot;q&amp;quot; is the name of the search field&amp;lt;br /&amp;gt;&lt;br /&gt;
        puts &amp;quot; Step 3: click the 'Google Search' button.&amp;quot;&lt;br /&gt;
        ie.button(:name, &amp;quot;btnG&amp;quot;).click # &amp;quot;btnG&amp;quot; is the name of the Search button&amp;lt;br /&amp;gt;&lt;br /&gt;
        puts &amp;quot; Expected Result:&amp;quot;&lt;br /&gt;
        puts &amp;quot;  A Google page with results should be shown. 'Watir, pronounced water' should be high on the list.&amp;quot;&lt;br /&gt;
        puts &amp;quot; Actual Result:&amp;quot;&lt;br /&gt;
        if ie.text.include? &amp;quot;Watir, pronounced water&amp;quot;	&lt;br /&gt;
             puts &amp;quot;  Test Passed. Found the text string: 'Watir, pronounced water'. Actual Results match Expected Results.&amp;quot;&lt;br /&gt;
        else	&lt;br /&gt;
 	     puts &amp;quot;  Test Failed! Could not find text: 'Watir, pronounced water'.&amp;quot;&lt;br /&gt;
        end&lt;br /&gt;
        puts &amp;quot;End of test: Google search.&amp;quot;&lt;br /&gt;
        ie.close&lt;br /&gt;
&lt;br /&gt;
On compiling and running this and passing the test, you will see something like, &amp;lt;br /&amp;gt; &lt;br /&gt;
&lt;br /&gt;
        ''Output:''&lt;br /&gt;
        Beginning of the test for Google search engine &amp;lt;br /&amp;gt;&lt;br /&gt;
        Step 1:  Go to the Google homepage &amp;lt;br /&amp;gt;&lt;br /&gt;
        Step 2: enter Automation in the search text field. &amp;lt;br /&amp;gt;&lt;br /&gt;
        Step 3: click the 'Google Search' button. &amp;lt;br /&amp;gt;&lt;br /&gt;
        Expected Result: &amp;lt;br /&amp;gt;&lt;br /&gt;
        A Google page with results should be shown. 'Watir, pronounced water' should be high on the list. &amp;lt;br /&amp;gt;	&lt;br /&gt;
        Test Passed. Found the text string: 'Watir, pronounced water'. Actual Results match Expected Results. &amp;lt;br /&amp;gt;&lt;br /&gt;
        End of test: Google search. &amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Similar Tools==&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Sahi_(software) Sahi], uses the Sahi Scripting Language&amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Soatest SOATest], for testing and validating [http://en.wikipedia.org/wiki/Application_programming_interface API] driven applications &amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/TestComplete TestComplete], for Desktops, Web and Mobile&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
* [http://www.hiretheworld.com/blog/tech-blog/migrating-unit-tests-from-selenium-to-watir-webdriver Migrating unit tests from Selenium to Watir Web Driver] &amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://www.hiretheworld.com/blog/tech-blog/migrating-unit-tests-from-selenium-to-watir-webdriver Learning Selenium IDE] &amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/List_of_web_testing_tools List of web testing tools] &amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/List_of_web_testing_tools OWASP List of Acceptance Testing tools]&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
{{reflist}}&lt;br /&gt;
&amp;lt;references /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==External Links==&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Selenium_(software) Selenium Wiki Page] &amp;lt;br /&amp;gt;&lt;br /&gt;
* [https://github.com/SeleniumHQ/selenium Selenium Source Code] &amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Watir Watir Wiki Page] &amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Watir Watir Source Code] &amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Watir SauceLabs HomePage] &amp;lt;br /&amp;gt;&lt;/div&gt;</summary>
		<author><name>Jjbeaver</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/ch1b_27_js&amp;diff=89419</id>
		<title>CSC/ECE 517 Fall 2014/ch1b 27 js</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/ch1b_27_js&amp;diff=89419"/>
		<updated>2014-10-07T03:26:40Z</updated>

		<summary type="html">&lt;p&gt;Jjbeaver: /* Cross-Browser and Headless Browser Support */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;='''Selenium vs. Watir'''=&lt;br /&gt;
&lt;br /&gt;
Developing web applications is proving to be a challenging task with each passing day given the complex requirements and the demanding nature of the these applications. For the web applications to be robust we need to put in place some good testing strategies.&lt;br /&gt;
&lt;br /&gt;
'''''Selenium''''' is one of the most popularly used open source automation tools for web based applications. It is a JavaScript framework that runs in your web browser to interact with various elements in your browser. All in all, Selenium is a set of different software tools each with a different approach to supporting test automation. Selenium provides a rich set of testing functions that can be customized to suit the testing requirements.&lt;br /&gt;
 &lt;br /&gt;
'''''Watir''''', is another lightweight automation testing tool that is widely used for web app testing. It is an open-source ([http://en.wikipedia.org/wiki/BSD_licenses BSD])  family of Ruby libraries for automating web browsers. It allows you to write tests that are easy to read and maintain. Despite the fact that it is a set of Ruby libraries, it works perfectly, independent of the language that the web application is developed in. Watir as a tool is extremely simple and flexible.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=='''Motivation'''==&lt;br /&gt;
===Need for test automation===&lt;br /&gt;
With the majority of software applications today being implemented as [http://en.wikipedia.org/wiki/Web_application web applications] to be used over the internet, testing is becoming an indispensable part of the software development lifecycle ([http://en.wikipedia.org/wiki/Software_development_process SDLC]) of these applications. [http://en.wikipedia.org/wiki/Test_automation Test automation] is used where manual testing needs to be carried out repeatedly making it a cumbersome task. Test automation uses a software tool for this purpose on the application to be tested. It has proven to be highly efficient and critical in larger software development companies. Additionally, automation can be a valuable way to make Test Driven Development ([http://en.wikipedia.org/wiki/Test-driven_development TDD]) tasks an important part of the software development workflow.&lt;br /&gt;
 &lt;br /&gt;
Test Automation has a number of advantages mostly dealing with repetitiveness of the tests and the time taken,&lt;br /&gt;
* '''Covers cases that manual testing probably cannot'''&lt;br /&gt;
# Finds defects missed out my manual testing&lt;br /&gt;
# Automated testing can simulate numerous virtual users interacting with the web software/application&lt;br /&gt;
* '''Helps save time and money'''&lt;br /&gt;
# Once created, automated tests can be executed repeatedly at no additional   costs and at a much faster pace. Saving time directly translates into saving cost.&lt;br /&gt;
# Supports virtually unlimited iterations of test case execution&lt;br /&gt;
* '''Increase test coverage and accuracy'''&lt;br /&gt;
# Automated tests perform the exact same steps and records all details precisely&lt;br /&gt;
# They also increase the depth and scope of tests to improve the quality of the software&lt;br /&gt;
&lt;br /&gt;
=='''Brief History'''==&lt;br /&gt;
====Selenium====&lt;br /&gt;
&lt;br /&gt;
[[File: SE-logo.png|right|Selenium Logo|link=http://www.seleniumhq.org/images/big-logo.png]]&lt;br /&gt;
&lt;br /&gt;
''Selenium'' was developed in the year 2004 by Jason Huggins and has been continuously evolving ever since. Jason Huggins developed this as an internal tool for [http://en.wikipedia.org/wiki/ThoughtWorks ThoughtWorks] as a javascript library which came to be known as the Selenium core. Selenium core is now the basis of the Selenium Remote Control (the server) and Selenium IDE.&lt;br /&gt;
The year 2006 marked the beginning of the development of the WebDriver project which was what they believed ‘a tool of the future’. The WebDriver was initiated to solve the problems that were faced due to the fact that Selenium was a based on JavaScript and a lot of security limitations browsers apply to Javascript.&lt;br /&gt;
In 2008, both Selenium and WebDriver merged to provide a common set of features to all users which is called Selenium 2..&lt;br /&gt;
Simon Stewart, the creator of WebDriver, in a joint email to the WebDriver and Selenium community on August 6, 2009 said the following,&lt;br /&gt;
&lt;br /&gt;
“Why are the projects merging? Partly because webdriver addresses some shortcomings in selenium (by being able to bypass the JS sandbox, for example. And we’ve got a gorgeous API), partly because selenium addresses some shortcomings in webdriver (such as supporting a broader range of browsers) and partly because the main selenium contributors and I felt that it was the best way to offer users the best possible framework.”&amp;lt;ref name =&amp;quot;Introduction to Selenium&amp;quot;&amp;gt;[http://docs.seleniumhq.org/docs/01_introducing_selenium.jsp#selenium-history Introducing Selenium]. ''SeleniumHQ: Browser Automation''. Selenium Project, 4 Oct. 2014. Web. 06 Oct. 2014.&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Watir====&lt;br /&gt;
&lt;br /&gt;
''Watir'' started as a library to teach testers to write ruby code and grew to be an IE implementation which now supports IE, Firefox, Safari, Google Chrome and Opera.&lt;br /&gt;
Watir was primarily developed by Bret Pettichord and Paul Rogers. Watir has since then has a couple of stable releases for Watir classic as well as Watir WebDriver. The most recent releases being&amp;lt;ref&amp;gt;[http://watir.com/category/releases/ Watir Releases]. Watir: Web Application Testing in Ruby. 28 April, 2013&amp;lt;/ref&amp;gt;, &lt;br /&gt;
&lt;br /&gt;
[[File: Watir.gif|right|Watir logo|link=http://upload.wikimedia.org/wikipedia/commons/7/7e/Watir.gif]]&lt;br /&gt;
&lt;br /&gt;
* Watir-Classic	    &lt;br /&gt;
# 0.6.3 April 10, 2013 ([https://github.com/watir/watir-webdriver/blob/master/CHANGES.md#063 Release Notes]) &amp;lt;br /&amp;gt;&lt;br /&gt;
* Watir-WebDriver	    &lt;br /&gt;
# 3.6.0 March 16, 2013 ([https://groups.google.com/forum/#!msg/watir-general/MOOun5g3Hvg/JBVNy957lDYJ Release Notes]) &amp;lt;br /&amp;gt;&lt;br /&gt;
# 3.5.0 March 10, 2013 ([https://groups.google.com/forum/#!msg/watir-general/aeUqsglvK6k/Kq7FCBiERjYJ Release Notes]) &amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Watir has a google group ([https://groups.google.com/forum/#!forum/watir-general Watir General]) for its support and contribution while Selenium also has a [http://seleniumforum.forumotion.net/ Selenium forum] apart from its google group called [https://groups.google.com/forum/#!forum/selenium-users Selenium Users].&lt;br /&gt;
&lt;br /&gt;
=='''Comparison of Features, Functionality, and More'''==&lt;br /&gt;
Some features or functionality may be repeated here.  However, we will go into a bit more detail than previously mentioned.&lt;br /&gt;
===='''Open Source'''====&lt;br /&gt;
Both Selenium and Watir are open source!  This allows for greater extensibility and a deeper understanding of the inner workings of both of the frameworks, if the developer/tester chooses to delve into such details.  Additionally, the open source community allows for a more transparent, user-driven development and support cycle.  Users (the tester/developer) can choose to submit bug fixes or enhancements as patches, or they can choose to just use it “straight out of the box.”&lt;br /&gt;
&lt;br /&gt;
====Application Language Agnostic====&lt;br /&gt;
&lt;br /&gt;
Both Selenium and Watir are application language agnostic.  Because both Selenium and Watir test UI functionality in the browser, they can be used to test any web application.    &lt;br /&gt;
&lt;br /&gt;
====Language-specific Test Cases====&lt;br /&gt;
&lt;br /&gt;
Both Selenium and Watir require test cases to be written in some programming language.  Traditionally, both frameworks had limited choices in terms of language bindings.  However, with the advent of WebDriver, both became much more flexible.  WebDriver provided the bindings needed for many languages.  Today, the following are supported:&lt;br /&gt;
&lt;br /&gt;
'''Selenium*'''&lt;br /&gt;
&lt;br /&gt;
* Officially-supported: [http://en.wikipedia.org/wiki/Java_(programming_language) Java], [http://en.wikipedia.org/wiki/C_Sharp_(programming_language) C#], [http://en.wikipedia.org/wiki/Ruby_(programming_language) Ruby], [http://en.wikipedia.org/wiki/Python_(programming_language) Python], [http://en.wikipedia.org/wiki/Node.js Javascript/Node.js]&lt;br /&gt;
&lt;br /&gt;
* Unofficial/community-supported: [http://en.wikipedia.org/wiki/Perl Perl], [http://en.wikipedia.org/wiki/PHP PHP], [http://en.wikipedia.org/wiki/Haskell_(programming_language) Haskell], [http://en.wikipedia.org/wiki/Objective-C Objective-C], [http://en.wikipedia.org/wiki/R_(programming_language) R], [http://en.wikipedia.org/wiki/Dart_(programming_language) Dart], [http://en.wikipedia.org/wiki/Tcl Tcl]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;According to SeleniumHQ’s download page.&lt;br /&gt;
&lt;br /&gt;
'''Watir'''&lt;br /&gt;
&lt;br /&gt;
Unfortunately (or fortunately), Ruby is the only supported language for Watir.  After all, Watir does stand for “Web Application Testing in Ruby.” However, there are other frameworks which were inspired by Watir (but entirely separate) available in Java and C# - Watij and Watin,  respectively &amp;lt;ref&amp;gt;Djorgjievski, Darko. [http://www.sitepoint.com/watir-webdriver-control-browser/ Watir-WebDriver: Control the Browser]. ''SitePoint''. SitePoint Pty Ltd, 18 Apr. 2014. Web. 05 Oct. 2014.&amp;lt;/ref&amp;gt;.  There may be other similarly inspired frameworks available in other languages, but these are the most notable.&lt;br /&gt;
&lt;br /&gt;
====Cross-Platform Support====&lt;br /&gt;
Both Watir and Selenium run on most popular distributions of Windows, Mac, and Linux.  Selenium doesn't have a list of officially supported operating system versions.  Instead they generally support any version that is currently popular.  Only a few versions are listed which they run test builds on.  These are versions which are officially known to work, but many more are supported as well.&lt;br /&gt;
&lt;br /&gt;
Because Watir is a collection of Ruby Gems, it runs on any platform that Ruby runs on.  Like Selenium, this includes nearly all popular platforms.&lt;br /&gt;
&lt;br /&gt;
====Cross-Browser and Headless Browser Support====&lt;br /&gt;
&lt;br /&gt;
Traditionally, both Selenium and Watir were limited in the number of browsers they supported. Watir originally supported Internet Explorer and headless browsers exclusively.  Headless browsers were supported via the use of Celerity &amp;lt;ref&amp;gt;Scott, Alister. [http://watirmelon.com/2010/04/10/watir-selenium-webdriver/ Watir, Selenium &amp;amp; WebDriver]. ''Watirmelon''. Watirmelon, 10 Apr. 2010. Web. 05 Oct. 2014.&amp;lt;/ref&amp;gt;.  Selenium started out as a Javascript library, so naturally it supported more browsers such as IE, Firefox, Safari, etc &amp;lt;ref name = &amp;quot;Introduction to Selenium&amp;quot; /&amp;gt;.  However, it did not support headless browsers.&lt;br /&gt;
Today, browser support looks much better for both Selenium and Watir, largely due to the introduction of WebDriver.  With WebDriver in existence, support for most browsers was added to Watir via the gem &amp;quot;watir-webdriver.&amp;quot;  Similarly for Selenium, support for headless browsers was added, as well as making the API much simpler and more concise &amp;lt;ref&amp;gt;[http://docs.seleniumhq.org/projects/webdriver/ Selenium WebDriver]. ''SeleniumHQ: Browser Automation''. Selenium Project, n.d. Web. 06 Oct. 2014.&amp;lt;/ref&amp;gt;.  However, there is the obvious limitation that one can only test a browser which is supported on the running platform.  In other words, Safari and Internet explorer can only be tested on  OS X and Windows environments, respectively**.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;**&amp;lt;/nowiki&amp;gt; &amp;lt;span style=&amp;quot;font-size:88%&amp;quot;&amp;gt;Some work-arounds or programs may exist to allow these browsers to be tested on other platforms. Here, we are assuming no special additional configuration - just the base operating system and browsers.  With virtualization technologies such as [http://www.linux-kvm.org/page/Main_Page KVM], [https://www.virtualbox.org/ VirtualBox], and [http://en.wikipedia.org/wiki/Comparison_of_platform_virtualization_software others], this isn't a problem anyway.  [http://en.wikipedia.org/wiki/Virtual_machine Virtual machines] can be created with any operating system, as needed.&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=='''Getting started'''==&lt;br /&gt;
===Selenium WebDriver=== &lt;br /&gt;
----&lt;br /&gt;
====Install/Configure for Java====&lt;br /&gt;
Configuring Selenium requires you to download the binaries from [http://www.seleniumhq.org/download/ here]. &lt;br /&gt;
Once you have all your binaries in a directory, you can open any IDE of your choice and add this directory with all the .jar files to the CLASSPATH&lt;br /&gt;
*Example&lt;br /&gt;
This is how a typical Selenium code to find the term say, “Automation” on Google and display the results on the page would look like in Java using the [https://code.google.com/p/selenium/wiki/HtmlUnitDriver HtmlUnitDriver] would look like.&lt;br /&gt;
The HtmlUnitDriver is a pure Java driver that runs entirely in-memory. Because of this, you won't see a new browser window open &amp;lt;ref&amp;gt;[https://code.google.com/p/selenium/wiki/GettingStarted Getting started with Selenium]. Selenium: Browser Automation Framework. Google Code. 8 Feb, 2014.&amp;lt;/ref&amp;gt;,&lt;br /&gt;
&lt;br /&gt;
       package org.selenium.example;&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;
       import org.openqa.selenium.By;&lt;br /&gt;
       import org.openqa.selenium.WebDriver;&lt;br /&gt;
       import org.openqa.selenium.WebElement;&lt;br /&gt;
       import org.openqa.selenium.htmlunit.HtmlUnitDriver;&amp;lt;br /&amp;gt;&lt;br /&gt;
       public class Example  {&lt;br /&gt;
       public static void main(String[] args) {&lt;br /&gt;
        // Create a new instance of the html unit driver&lt;br /&gt;
        // Notice that the remainder of the code relies on the interface,&lt;br /&gt;
        // not the implementation.&lt;br /&gt;
        WebDriver driver = new HtmlUnitDriver();&amp;lt;br /&amp;gt;&lt;br /&gt;
        // And now use this to visit Google&lt;br /&gt;
        driver.get(&amp;quot;http://www.google.com&amp;quot;);&amp;lt;br /&amp;gt;&lt;br /&gt;
        // Find the text input element by its name&lt;br /&gt;
        WebElement element = driver.findElement(By.name(&amp;quot;q&amp;quot;));&amp;lt;br /&amp;gt;&lt;br /&gt;
        // Enter something to search for&lt;br /&gt;
        element.sendKeys(&amp;quot;Automation!&amp;quot;);&amp;lt;br /&amp;gt;&lt;br /&gt;
        // Now submit the form. WebDriver will find the form for us from the element&lt;br /&gt;
        element.submit();&amp;lt;br /&amp;gt;&lt;br /&gt;
        // Check the title of the page&lt;br /&gt;
        System.out.println(&amp;quot;Page title is: &amp;quot; + driver.getTitle());&lt;br /&gt;
        driver.quit();&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
If you compile and run it, you should see a line with the title of the Google search results as output. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Install/Configure for other languages====&lt;br /&gt;
Configuring Selenium for languages other than Java and for other development environments can be looked up [http://docs.seleniumhq.org/docs/03_webdriver.jsp#setting-up-a-selenium-webdriver-project here]. viz(C#, Ruby, Python, PHP, Perl, Javascript)&lt;br /&gt;
&lt;br /&gt;
===Watir===&lt;br /&gt;
----&lt;br /&gt;
====Install/Configure====&lt;br /&gt;
Drivers for Watir are installed as gems which are nothing but Ruby libraries which can be accessed over the internet.&lt;br /&gt;
All the instructions for installing Watir on various operating systems (viz. Windows, Mac OS, Linux) can be found [http://watir.com/installation/ here].&lt;br /&gt;
&lt;br /&gt;
*Example:&lt;br /&gt;
This is how a typical Watir code to find the term say, “Automation” on Google and display the results on the page would look like using Ruby&amp;lt;ref&amp;gt;Chernenko, Iryna. [http://blog.qatestlab.com/2011/02/23/automated-testing-with-watir-tutorial-for-begginers-part-1/ Watir Example]. QATestLab Blog: Automated Testing with Watir, 23 Feb 2011.&lt;br /&gt;
&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
        # Required in ruby 1.8.7&lt;br /&gt;
        require 'rubygems'&lt;br /&gt;
        # Watir IE driver&lt;br /&gt;
        require 'watir'&amp;lt;br /&amp;gt; &lt;br /&gt;
        ie = Watir::IE.new&amp;lt;br /&amp;gt; &lt;br /&gt;
        # text to show on console&lt;br /&gt;
        puts &amp;quot;Beginning of the test for Google search engine&amp;quot;&lt;br /&gt;
        puts &amp;quot;Step 1:  Go to the Google homepage&amp;quot;&lt;br /&gt;
        ie.goto &amp;quot;http://www.google.com&amp;quot;&amp;lt;br /&amp;gt;&lt;br /&gt;
        #set a variable&lt;br /&gt;
        search_text = &amp;quot;Automation&amp;quot;&lt;br /&gt;
        puts &amp;quot;Step 2: enter &amp;quot;+ search_text +&amp;quot; in the search text field.&amp;quot;&lt;br /&gt;
        ie.text_field(:name, &amp;quot;q&amp;quot;).set search_text   # &amp;quot;q&amp;quot; is the name of the search field&amp;lt;br /&amp;gt;&lt;br /&gt;
        puts &amp;quot; Step 3: click the 'Google Search' button.&amp;quot;&lt;br /&gt;
        ie.button(:name, &amp;quot;btnG&amp;quot;).click # &amp;quot;btnG&amp;quot; is the name of the Search button&amp;lt;br /&amp;gt;&lt;br /&gt;
        puts &amp;quot; Expected Result:&amp;quot;&lt;br /&gt;
        puts &amp;quot;  A Google page with results should be shown. 'Watir, pronounced water' should be high on the list.&amp;quot;&lt;br /&gt;
        puts &amp;quot; Actual Result:&amp;quot;&lt;br /&gt;
        if ie.text.include? &amp;quot;Watir, pronounced water&amp;quot;	&lt;br /&gt;
             puts &amp;quot;  Test Passed. Found the text string: 'Watir, pronounced water'. Actual Results match Expected Results.&amp;quot;&lt;br /&gt;
        else	&lt;br /&gt;
 	     puts &amp;quot;  Test Failed! Could not find text: 'Watir, pronounced water'.&amp;quot;&lt;br /&gt;
        end&lt;br /&gt;
        puts &amp;quot;End of test: Google search.&amp;quot;&lt;br /&gt;
        ie.close&lt;br /&gt;
&lt;br /&gt;
On compiling and running this and passing the test, you will see something like, &amp;lt;br /&amp;gt; &lt;br /&gt;
&lt;br /&gt;
        ''Output:''&lt;br /&gt;
        Beginning of the test for Google search engine &amp;lt;br /&amp;gt;&lt;br /&gt;
        Step 1:  Go to the Google homepage &amp;lt;br /&amp;gt;&lt;br /&gt;
        Step 2: enter Automation in the search text field. &amp;lt;br /&amp;gt;&lt;br /&gt;
        Step 3: click the 'Google Search' button. &amp;lt;br /&amp;gt;&lt;br /&gt;
        Expected Result: &amp;lt;br /&amp;gt;&lt;br /&gt;
        A Google page with results should be shown. 'Watir, pronounced water' should be high on the list. &amp;lt;br /&amp;gt;	&lt;br /&gt;
        Test Passed. Found the text string: 'Watir, pronounced water'. Actual Results match Expected Results. &amp;lt;br /&amp;gt;&lt;br /&gt;
        End of test: Google search. &amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Similar Tools==&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Sahi_(software) Sahi], uses the Sahi Scripting Language&amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Soatest SOATest], for testing and validating [http://en.wikipedia.org/wiki/Application_programming_interface API] driven applications &amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/TestComplete TestComplete], for Desktops, Web and Mobile&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
* [http://www.hiretheworld.com/blog/tech-blog/migrating-unit-tests-from-selenium-to-watir-webdriver Migrating unit tests from Selenium to Watir Web Driver] &amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://www.hiretheworld.com/blog/tech-blog/migrating-unit-tests-from-selenium-to-watir-webdriver Learning Selenium IDE] &amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/List_of_web_testing_tools List of web testing tools] &amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/List_of_web_testing_tools OWASP List of Acceptance Testing tools]&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
{{reflist}}&lt;br /&gt;
&amp;lt;references /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==External Links==&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Selenium_(software) Selenium Wiki Page] &amp;lt;br /&amp;gt;&lt;br /&gt;
* [https://github.com/SeleniumHQ/selenium Selenium Source Code] &amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Watir Watir Wiki Page] &amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Watir Watir Source Code] &amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Watir SauceLabs HomePage] &amp;lt;br /&amp;gt;&lt;/div&gt;</summary>
		<author><name>Jjbeaver</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/ch1b_27_js&amp;diff=89418</id>
		<title>CSC/ECE 517 Fall 2014/ch1b 27 js</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/ch1b_27_js&amp;diff=89418"/>
		<updated>2014-10-07T03:24:53Z</updated>

		<summary type="html">&lt;p&gt;Jjbeaver: /* Cross-Browser and Headless Browser Support */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;='''Selenium vs. Watir'''=&lt;br /&gt;
&lt;br /&gt;
Developing web applications is proving to be a challenging task with each passing day given the complex requirements and the demanding nature of the these applications. For the web applications to be robust we need to put in place some good testing strategies.&lt;br /&gt;
&lt;br /&gt;
'''''Selenium''''' is one of the most popularly used open source automation tools for web based applications. It is a JavaScript framework that runs in your web browser to interact with various elements in your browser. All in all, Selenium is a set of different software tools each with a different approach to supporting test automation. Selenium provides a rich set of testing functions that can be customized to suit the testing requirements.&lt;br /&gt;
 &lt;br /&gt;
'''''Watir''''', is another lightweight automation testing tool that is widely used for web app testing. It is an open-source ([http://en.wikipedia.org/wiki/BSD_licenses BSD])  family of Ruby libraries for automating web browsers. It allows you to write tests that are easy to read and maintain. Despite the fact that it is a set of Ruby libraries, it works perfectly, independent of the language that the web application is developed in. Watir as a tool is extremely simple and flexible.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=='''Motivation'''==&lt;br /&gt;
===Need for test automation===&lt;br /&gt;
With the majority of software applications today being implemented as [http://en.wikipedia.org/wiki/Web_application web applications] to be used over the internet, testing is becoming an indispensable part of the software development lifecycle ([http://en.wikipedia.org/wiki/Software_development_process SDLC]) of these applications. [http://en.wikipedia.org/wiki/Test_automation Test automation] is used where manual testing needs to be carried out repeatedly making it a cumbersome task. Test automation uses a software tool for this purpose on the application to be tested. It has proven to be highly efficient and critical in larger software development companies. Additionally, automation can be a valuable way to make Test Driven Development ([http://en.wikipedia.org/wiki/Test-driven_development TDD]) tasks an important part of the software development workflow.&lt;br /&gt;
 &lt;br /&gt;
Test Automation has a number of advantages mostly dealing with repetitiveness of the tests and the time taken,&lt;br /&gt;
* '''Covers cases that manual testing probably cannot'''&lt;br /&gt;
# Finds defects missed out my manual testing&lt;br /&gt;
# Automated testing can simulate numerous virtual users interacting with the web software/application&lt;br /&gt;
* '''Helps save time and money'''&lt;br /&gt;
# Once created, automated tests can be executed repeatedly at no additional   costs and at a much faster pace. Saving time directly translates into saving cost.&lt;br /&gt;
# Supports virtually unlimited iterations of test case execution&lt;br /&gt;
* '''Increase test coverage and accuracy'''&lt;br /&gt;
# Automated tests perform the exact same steps and records all details precisely&lt;br /&gt;
# They also increase the depth and scope of tests to improve the quality of the software&lt;br /&gt;
&lt;br /&gt;
=='''Brief History'''==&lt;br /&gt;
====Selenium====&lt;br /&gt;
&lt;br /&gt;
[[File: SE-logo.png|right|Selenium Logo|link=http://www.seleniumhq.org/images/big-logo.png]]&lt;br /&gt;
&lt;br /&gt;
''Selenium'' was developed in the year 2004 by Jason Huggins and has been continuously evolving ever since. Jason Huggins developed this as an internal tool for [http://en.wikipedia.org/wiki/ThoughtWorks ThoughtWorks] as a javascript library which came to be known as the Selenium core. Selenium core is now the basis of the Selenium Remote Control (the server) and Selenium IDE.&lt;br /&gt;
The year 2006 marked the beginning of the development of the WebDriver project which was what they believed ‘a tool of the future’. The WebDriver was initiated to solve the problems that were faced due to the fact that Selenium was a based on JavaScript and a lot of security limitations browsers apply to Javascript.&lt;br /&gt;
In 2008, both Selenium and WebDriver merged to provide a common set of features to all users which is called Selenium 2..&lt;br /&gt;
Simon Stewart, the creator of WebDriver, in a joint email to the WebDriver and Selenium community on August 6, 2009 said the following,&lt;br /&gt;
&lt;br /&gt;
“Why are the projects merging? Partly because webdriver addresses some shortcomings in selenium (by being able to bypass the JS sandbox, for example. And we’ve got a gorgeous API), partly because selenium addresses some shortcomings in webdriver (such as supporting a broader range of browsers) and partly because the main selenium contributors and I felt that it was the best way to offer users the best possible framework.”&amp;lt;ref name =&amp;quot;Introduction to Selenium&amp;quot;&amp;gt;[http://docs.seleniumhq.org/docs/01_introducing_selenium.jsp#selenium-history Introducing Selenium]. ''SeleniumHQ: Browser Automation''. Selenium Project, 4 Oct. 2014. Web. 06 Oct. 2014.&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Watir====&lt;br /&gt;
&lt;br /&gt;
''Watir'' started as a library to teach testers to write ruby code and grew to be an IE implementation which now supports IE, Firefox, Safari, Google Chrome and Opera.&lt;br /&gt;
Watir was primarily developed by Bret Pettichord and Paul Rogers. Watir has since then has a couple of stable releases for Watir classic as well as Watir WebDriver. The most recent releases being&amp;lt;ref&amp;gt;[http://watir.com/category/releases/ Watir Releases]. Watir: Web Application Testing in Ruby. 28 April, 2013&amp;lt;/ref&amp;gt;, &lt;br /&gt;
&lt;br /&gt;
[[File: Watir.gif|right|Watir logo|link=http://upload.wikimedia.org/wikipedia/commons/7/7e/Watir.gif]]&lt;br /&gt;
&lt;br /&gt;
* Watir-Classic	    &lt;br /&gt;
# 0.6.3 April 10, 2013 ([https://github.com/watir/watir-webdriver/blob/master/CHANGES.md#063 Release Notes]) &amp;lt;br /&amp;gt;&lt;br /&gt;
* Watir-WebDriver	    &lt;br /&gt;
# 3.6.0 March 16, 2013 ([https://groups.google.com/forum/#!msg/watir-general/MOOun5g3Hvg/JBVNy957lDYJ Release Notes]) &amp;lt;br /&amp;gt;&lt;br /&gt;
# 3.5.0 March 10, 2013 ([https://groups.google.com/forum/#!msg/watir-general/aeUqsglvK6k/Kq7FCBiERjYJ Release Notes]) &amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Watir has a google group ([https://groups.google.com/forum/#!forum/watir-general Watir General]) for its support and contribution while Selenium also has a [http://seleniumforum.forumotion.net/ Selenium forum] apart from its google group called [https://groups.google.com/forum/#!forum/selenium-users Selenium Users].&lt;br /&gt;
&lt;br /&gt;
=='''Comparison of Features, Functionality, and More'''==&lt;br /&gt;
Some features or functionality may be repeated here.  However, we will go into a bit more detail than previously mentioned.&lt;br /&gt;
===='''Open Source'''====&lt;br /&gt;
Both Selenium and Watir are open source!  This allows for greater extensibility and a deeper understanding of the inner workings of both of the frameworks, if the developer/tester chooses to delve into such details.  Additionally, the open source community allows for a more transparent, user-driven development and support cycle.  Users (the tester/developer) can choose to submit bug fixes or enhancements as patches, or they can choose to just use it “straight out of the box.”&lt;br /&gt;
&lt;br /&gt;
====Application Language Agnostic====&lt;br /&gt;
&lt;br /&gt;
Both Selenium and Watir are application language agnostic.  Because both Selenium and Watir test UI functionality in the browser, they can be used to test any web application.    &lt;br /&gt;
&lt;br /&gt;
====Language-specific Test Cases====&lt;br /&gt;
&lt;br /&gt;
Both Selenium and Watir require test cases to be written in some programming language.  Traditionally, both frameworks had limited choices in terms of language bindings.  However, with the advent of WebDriver, both became much more flexible.  WebDriver provided the bindings needed for many languages.  Today, the following are supported:&lt;br /&gt;
&lt;br /&gt;
'''Selenium*'''&lt;br /&gt;
&lt;br /&gt;
* Officially-supported: [http://en.wikipedia.org/wiki/Java_(programming_language) Java], [http://en.wikipedia.org/wiki/C_Sharp_(programming_language) C#], [http://en.wikipedia.org/wiki/Ruby_(programming_language) Ruby], [http://en.wikipedia.org/wiki/Python_(programming_language) Python], [http://en.wikipedia.org/wiki/Node.js Javascript/Node.js]&lt;br /&gt;
&lt;br /&gt;
* Unofficial/community-supported: [http://en.wikipedia.org/wiki/Perl Perl], [http://en.wikipedia.org/wiki/PHP PHP], [http://en.wikipedia.org/wiki/Haskell_(programming_language) Haskell], [http://en.wikipedia.org/wiki/Objective-C Objective-C], [http://en.wikipedia.org/wiki/R_(programming_language) R], [http://en.wikipedia.org/wiki/Dart_(programming_language) Dart], [http://en.wikipedia.org/wiki/Tcl Tcl]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;According to SeleniumHQ’s download page.&lt;br /&gt;
&lt;br /&gt;
'''Watir'''&lt;br /&gt;
&lt;br /&gt;
Unfortunately (or fortunately), Ruby is the only supported language for Watir.  After all, Watir does stand for “Web Application Testing in Ruby.” However, there are other frameworks which were inspired by Watir (but entirely separate) available in Java and C# - Watij and Watin,  respectively &amp;lt;ref&amp;gt;Djorgjievski, Darko. [http://www.sitepoint.com/watir-webdriver-control-browser/ Watir-WebDriver: Control the Browser]. ''SitePoint''. SitePoint Pty Ltd, 18 Apr. 2014. Web. 05 Oct. 2014.&amp;lt;/ref&amp;gt;.  There may be other similarly inspired frameworks available in other languages, but these are the most notable.&lt;br /&gt;
&lt;br /&gt;
====Cross-Platform Support====&lt;br /&gt;
Both Watir and Selenium run on most popular distributions of Windows, Mac, and Linux.  Selenium doesn't have a list of officially supported operating system versions.  Instead they generally support any version that is currently popular.  Only a few versions are listed which they run test builds on.  These are versions which are officially known to work, but many more are supported as well.&lt;br /&gt;
&lt;br /&gt;
Because Watir is a collection of Ruby Gems, it runs on any platform that Ruby runs on.  Like Selenium, this includes nearly all popular platforms.&lt;br /&gt;
&lt;br /&gt;
====Cross-Browser and Headless Browser Support====&lt;br /&gt;
&lt;br /&gt;
Traditionally, both Selenium and Watir were limited in the number of browsers they supported. Watir originally supported Internet Explorer and headless browsers exclusively.  Headless browsers were supported via the use of Celerity &amp;lt;ref&amp;gt;Scott, Alister. [http://watirmelon.com/2010/04/10/watir-selenium-webdriver/ Watir, Selenium &amp;amp; WebDriver]. ''Watirmelon''. Watirmelon, 10 Apr. 2010. Web. 05 Oct. 2014.&amp;lt;/ref&amp;gt;.  Selenium started out as a Javascript library, so naturally it supported more browsers such as IE, Firefox, Safari, etc &amp;lt;ref name = &amp;quot;Introduction to Selenium&amp;quot; /&amp;gt;.  However, it did not support headless browsers.&lt;br /&gt;
Today, browser support looks much better for both Selenium and Watir, largely due to the introduction of WebDriver.  With WebDriver in existence, support for most browsers was added to Watir via the gem &amp;quot;watir-webdriver.&amp;quot;  Similarly for Selenium, support for headless browsers was added, as well as making the API much simpler and more concise &amp;lt;ref&amp;gt;[http://docs.seleniumhq.org/projects/webdriver/ Selenium WebDriver]. ''SeleniumHQ: Browser Automation''. Selenium Project, n.d. Web. 06 Oct. 2014.&amp;lt;/ref&amp;gt;.  However, there is the obvious limitation that one can only test a browser which is supported on the running platform.  In other words, Safari and Internet explorer can only be tested on  OS X and Windows environments, respectively**.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;**&amp;lt;/nowiki&amp;gt;Some work-arounds or programs may exist to allow these browsers to be tested on other platforms. Here, we are assuming no special additional configuration - just the base operating system and browsers.  With virtualization technologies such as [http://www.linux-kvm.org/page/Main_Page KVM], [https://www.virtualbox.org/ VirtualBox], and [http://en.wikipedia.org/wiki/Comparison_of_platform_virtualization_software others], this isn't a problem anyway.  [http://en.wikipedia.org/wiki/Virtual_machine Virtual machines] can be created with any operating system, as needed.&lt;br /&gt;
&lt;br /&gt;
=='''Getting started'''==&lt;br /&gt;
===Selenium WebDriver=== &lt;br /&gt;
----&lt;br /&gt;
====Install/Configure for Java====&lt;br /&gt;
Configuring Selenium requires you to download the binaries from [http://www.seleniumhq.org/download/ here]. &lt;br /&gt;
Once you have all your binaries in a directory, you can open any IDE of your choice and add this directory with all the .jar files to the CLASSPATH&lt;br /&gt;
*Example&lt;br /&gt;
This is how a typical Selenium code to find the term say, “Automation” on Google and display the results on the page would look like in Java using the [https://code.google.com/p/selenium/wiki/HtmlUnitDriver HtmlUnitDriver] would look like.&lt;br /&gt;
The HtmlUnitDriver is a pure Java driver that runs entirely in-memory. Because of this, you won't see a new browser window open &amp;lt;ref&amp;gt;[https://code.google.com/p/selenium/wiki/GettingStarted Getting started with Selenium]. Selenium: Browser Automation Framework. Google Code. 8 Feb, 2014.&amp;lt;/ref&amp;gt;,&lt;br /&gt;
&lt;br /&gt;
       package org.selenium.example;&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;
       import org.openqa.selenium.By;&lt;br /&gt;
       import org.openqa.selenium.WebDriver;&lt;br /&gt;
       import org.openqa.selenium.WebElement;&lt;br /&gt;
       import org.openqa.selenium.htmlunit.HtmlUnitDriver;&amp;lt;br /&amp;gt;&lt;br /&gt;
       public class Example  {&lt;br /&gt;
       public static void main(String[] args) {&lt;br /&gt;
        // Create a new instance of the html unit driver&lt;br /&gt;
        // Notice that the remainder of the code relies on the interface,&lt;br /&gt;
        // not the implementation.&lt;br /&gt;
        WebDriver driver = new HtmlUnitDriver();&amp;lt;br /&amp;gt;&lt;br /&gt;
        // And now use this to visit Google&lt;br /&gt;
        driver.get(&amp;quot;http://www.google.com&amp;quot;);&amp;lt;br /&amp;gt;&lt;br /&gt;
        // Find the text input element by its name&lt;br /&gt;
        WebElement element = driver.findElement(By.name(&amp;quot;q&amp;quot;));&amp;lt;br /&amp;gt;&lt;br /&gt;
        // Enter something to search for&lt;br /&gt;
        element.sendKeys(&amp;quot;Automation!&amp;quot;);&amp;lt;br /&amp;gt;&lt;br /&gt;
        // Now submit the form. WebDriver will find the form for us from the element&lt;br /&gt;
        element.submit();&amp;lt;br /&amp;gt;&lt;br /&gt;
        // Check the title of the page&lt;br /&gt;
        System.out.println(&amp;quot;Page title is: &amp;quot; + driver.getTitle());&lt;br /&gt;
        driver.quit();&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
If you compile and run it, you should see a line with the title of the Google search results as output. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Install/Configure for other languages====&lt;br /&gt;
Configuring Selenium for languages other than Java and for other development environments can be looked up [http://docs.seleniumhq.org/docs/03_webdriver.jsp#setting-up-a-selenium-webdriver-project here]. viz(C#, Ruby, Python, PHP, Perl, Javascript)&lt;br /&gt;
&lt;br /&gt;
===Watir===&lt;br /&gt;
----&lt;br /&gt;
====Install/Configure====&lt;br /&gt;
Drivers for Watir are installed as gems which are nothing but Ruby libraries which can be accessed over the internet.&lt;br /&gt;
All the instructions for installing Watir on various operating systems (viz. Windows, Mac OS, Linux) can be found [http://watir.com/installation/ here].&lt;br /&gt;
&lt;br /&gt;
*Example:&lt;br /&gt;
This is how a typical Watir code to find the term say, “Automation” on Google and display the results on the page would look like using Ruby&amp;lt;ref&amp;gt;Chernenko, Iryna. [http://blog.qatestlab.com/2011/02/23/automated-testing-with-watir-tutorial-for-begginers-part-1/ Watir Example]. QATestLab Blog: Automated Testing with Watir, 23 Feb 2011.&lt;br /&gt;
&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
        # Required in ruby 1.8.7&lt;br /&gt;
        require 'rubygems'&lt;br /&gt;
        # Watir IE driver&lt;br /&gt;
        require 'watir'&amp;lt;br /&amp;gt; &lt;br /&gt;
        ie = Watir::IE.new&amp;lt;br /&amp;gt; &lt;br /&gt;
        # text to show on console&lt;br /&gt;
        puts &amp;quot;Beginning of the test for Google search engine&amp;quot;&lt;br /&gt;
        puts &amp;quot;Step 1:  Go to the Google homepage&amp;quot;&lt;br /&gt;
        ie.goto &amp;quot;http://www.google.com&amp;quot;&amp;lt;br /&amp;gt;&lt;br /&gt;
        #set a variable&lt;br /&gt;
        search_text = &amp;quot;Automation&amp;quot;&lt;br /&gt;
        puts &amp;quot;Step 2: enter &amp;quot;+ search_text +&amp;quot; in the search text field.&amp;quot;&lt;br /&gt;
        ie.text_field(:name, &amp;quot;q&amp;quot;).set search_text   # &amp;quot;q&amp;quot; is the name of the search field&amp;lt;br /&amp;gt;&lt;br /&gt;
        puts &amp;quot; Step 3: click the 'Google Search' button.&amp;quot;&lt;br /&gt;
        ie.button(:name, &amp;quot;btnG&amp;quot;).click # &amp;quot;btnG&amp;quot; is the name of the Search button&amp;lt;br /&amp;gt;&lt;br /&gt;
        puts &amp;quot; Expected Result:&amp;quot;&lt;br /&gt;
        puts &amp;quot;  A Google page with results should be shown. 'Watir, pronounced water' should be high on the list.&amp;quot;&lt;br /&gt;
        puts &amp;quot; Actual Result:&amp;quot;&lt;br /&gt;
        if ie.text.include? &amp;quot;Watir, pronounced water&amp;quot;	&lt;br /&gt;
             puts &amp;quot;  Test Passed. Found the text string: 'Watir, pronounced water'. Actual Results match Expected Results.&amp;quot;&lt;br /&gt;
        else	&lt;br /&gt;
 	     puts &amp;quot;  Test Failed! Could not find text: 'Watir, pronounced water'.&amp;quot;&lt;br /&gt;
        end&lt;br /&gt;
        puts &amp;quot;End of test: Google search.&amp;quot;&lt;br /&gt;
        ie.close&lt;br /&gt;
&lt;br /&gt;
On compiling and running this and passing the test, you will see something like, &amp;lt;br /&amp;gt; &lt;br /&gt;
&lt;br /&gt;
        ''Output:''&lt;br /&gt;
        Beginning of the test for Google search engine &amp;lt;br /&amp;gt;&lt;br /&gt;
        Step 1:  Go to the Google homepage &amp;lt;br /&amp;gt;&lt;br /&gt;
        Step 2: enter Automation in the search text field. &amp;lt;br /&amp;gt;&lt;br /&gt;
        Step 3: click the 'Google Search' button. &amp;lt;br /&amp;gt;&lt;br /&gt;
        Expected Result: &amp;lt;br /&amp;gt;&lt;br /&gt;
        A Google page with results should be shown. 'Watir, pronounced water' should be high on the list. &amp;lt;br /&amp;gt;	&lt;br /&gt;
        Test Passed. Found the text string: 'Watir, pronounced water'. Actual Results match Expected Results. &amp;lt;br /&amp;gt;&lt;br /&gt;
        End of test: Google search. &amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Similar Tools==&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Sahi_(software) Sahi], uses the Sahi Scripting Language&amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Soatest SOATest], for testing and validating [http://en.wikipedia.org/wiki/Application_programming_interface API] driven applications &amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/TestComplete TestComplete], for Desktops, Web and Mobile&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
* [http://www.hiretheworld.com/blog/tech-blog/migrating-unit-tests-from-selenium-to-watir-webdriver Migrating unit tests from Selenium to Watir Web Driver] &amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://www.hiretheworld.com/blog/tech-blog/migrating-unit-tests-from-selenium-to-watir-webdriver Learning Selenium IDE] &amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/List_of_web_testing_tools List of web testing tools] &amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/List_of_web_testing_tools OWASP List of Acceptance Testing tools]&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
{{reflist}}&lt;br /&gt;
&amp;lt;references /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==External Links==&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Selenium_(software) Selenium Wiki Page] &amp;lt;br /&amp;gt;&lt;br /&gt;
* [https://github.com/SeleniumHQ/selenium Selenium Source Code] &amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Watir Watir Wiki Page] &amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Watir Watir Source Code] &amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Watir SauceLabs HomePage] &amp;lt;br /&amp;gt;&lt;/div&gt;</summary>
		<author><name>Jjbeaver</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/ch1b_27_js&amp;diff=89416</id>
		<title>CSC/ECE 517 Fall 2014/ch1b 27 js</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/ch1b_27_js&amp;diff=89416"/>
		<updated>2014-10-07T03:15:53Z</updated>

		<summary type="html">&lt;p&gt;Jjbeaver: /* Comparison of Features, Functionality, and More */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;='''Selenium vs. Watir'''=&lt;br /&gt;
&lt;br /&gt;
Developing web applications is proving to be a challenging task with each passing day given the complex requirements and the demanding nature of the these applications. For the web applications to be robust we need to put in place some good testing strategies.&lt;br /&gt;
&lt;br /&gt;
'''''Selenium''''' is one of the most popularly used open source automation tools for web based applications. It is a JavaScript framework that runs in your web browser to interact with various elements in your browser. All in all, Selenium is a set of different software tools each with a different approach to supporting test automation. Selenium provides a rich set of testing functions that can be customized to suit the testing requirements.https://code.google.com/p/selenium/wiki/GettingStarted&lt;br /&gt;
 &lt;br /&gt;
'''''Watir''''', is another lightweight automation testing tool that is widely used for web app testing. It is an open-source ([http://en.wikipedia.org/wiki/BSD_licenses BSD])  family of Ruby libraries for automating web browsers. It allows you to write tests that are easy to read and maintain. Despite the fact that it is a set of Ruby libraries, it works perfectly, independent of the language that the web application is developed in. Watir as a tool is extremely simple and flexible.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=='''Motivation'''==&lt;br /&gt;
===Need for test automation===&lt;br /&gt;
With the majority of software applications today being implemented as [http://en.wikipedia.org/wiki/Web_application web applications] to be used over the internet, testing is becoming an indispensable part of the software development lifecycle ([http://en.wikipedia.org/wiki/Software_development_process SDLC]) of these applications. [http://en.wikipedia.org/wiki/Test_automation Test automation] is used where manual testing needs to be carried out repeatedly making it a cumbersome task. Test automation uses a software tool for this purpose on the application to be tested. It has proven to be highly efficient and critical in larger software development companies. Additionally, automation can be a valuable way to make Test Driven Development ([http://en.wikipedia.org/wiki/Test-driven_development TDD]) tasks an important part of the software development workflow.&lt;br /&gt;
 &lt;br /&gt;
Test Automation has a number of advantages mostly dealing with repetitiveness of the tests and the time taken,&lt;br /&gt;
* '''Covers cases that manual testing probably cannot'''&lt;br /&gt;
# Finds defects missed out my manual testing&lt;br /&gt;
# Automated testing can simulate numerous virtual users interacting with the web software/application&lt;br /&gt;
* '''Helps save time and money'''&lt;br /&gt;
# Once created, automated tests can be executed repeatedly at no additional   costs and at a much faster pace. Saving time directly translates into saving cost.&lt;br /&gt;
# Supports virtually unlimited iterations of test case execution&lt;br /&gt;
* '''Increase test coverage and accuracy'''&lt;br /&gt;
# Automated tests perform the exact same steps and records all details precisely&lt;br /&gt;
# They also increase the depth and scope of tests to improve the quality of the software&lt;br /&gt;
&lt;br /&gt;
=='''Brief History'''==&lt;br /&gt;
====Selenium====&lt;br /&gt;
&lt;br /&gt;
[[File: SE-logo.png|right|Selenium Logo|link=http://www.seleniumhq.org/images/big-logo.png]]&lt;br /&gt;
&lt;br /&gt;
''Selenium'' was developed in the year 2004 by Jason Huggins and has been continuously evolving ever since. Jason Huggins developed this as an internal tool for [http://en.wikipedia.org/wiki/ThoughtWorks ThoughtWorks] as a javascript library which came to be known as the Selenium core. Selenium core is now the basis of the Selenium Remote Control (the server) and Selenium IDE.&lt;br /&gt;
The year 2006 marked the beginning of the development of the WebDriver project which was what they believed ‘a tool of the future’. The WebDriver was initiated to solve the problems that were faced due to the fact that Selenium was a based on JavaScript and a lot of security limitations browsers apply to Javascript.&lt;br /&gt;
In 2008, both Selenium and WebDriver merged to provide a common set of features to all users which is called Selenium 2..&lt;br /&gt;
Simon Stewart, the creator of WebDriver, in a joint email to the WebDriver and Selenium community on August 6, 2009 said the following,&lt;br /&gt;
&lt;br /&gt;
“Why are the projects merging? Partly because webdriver addresses some shortcomings in selenium (by being able to bypass the JS sandbox, for example. And we’ve got a gorgeous API), partly because selenium addresses some shortcomings in webdriver (such as supporting a broader range of browsers) and partly because the main selenium contributors and I felt that it was the best way to offer users the best possible framework.”&amp;lt;ref name =&amp;quot;Introduction to Selenium&amp;quot;&amp;gt;[http://docs.seleniumhq.org/docs/01_introducing_selenium.jsp#selenium-history Introducing Selenium]. ''SeleniumHQ: Browser Automation''. Selenium Project, 4 Oct. 2014. Web. 06 Oct. 2014.&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Watir====&lt;br /&gt;
&lt;br /&gt;
''Watir'' started as a library to teach testers to write ruby code and grew to be an IE implementation which now supports IE, Firefox, Safari, Google Chrome and Opera.&lt;br /&gt;
Watir was primarily developed by Bret Pettichord and Paul Rogers. Watir has since then has a couple of stable releases for Watir classic as well as Watir WebDriver. The most recent releases being&amp;lt;ref&amp;gt;[http://watir.com/category/releases/ Watir Releases]. Watir: Web Application Testing in Ruby. 28 April, 2013&amp;lt;/ref&amp;gt;, &lt;br /&gt;
&lt;br /&gt;
[[File: Watir.gif|right|Watir logo|link=http://upload.wikimedia.org/wikipedia/commons/7/7e/Watir.gif]]&lt;br /&gt;
&lt;br /&gt;
* Watir-Classic	    &lt;br /&gt;
# 0.6.3 April 10, 2013 ([https://github.com/watir/watir-webdriver/blob/master/CHANGES.md#063 Release Notes]) &amp;lt;br /&amp;gt;&lt;br /&gt;
* Watir-WebDriver	    &lt;br /&gt;
# 3.6.0 March 16, 2013 ([https://groups.google.com/forum/#!msg/watir-general/MOOun5g3Hvg/JBVNy957lDYJ Release Notes]) &amp;lt;br /&amp;gt;&lt;br /&gt;
# 3.5.0 March 10, 2013 ([https://groups.google.com/forum/#!msg/watir-general/aeUqsglvK6k/Kq7FCBiERjYJ Release Notes]) &amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Watir has a google group ([https://groups.google.com/forum/#!forum/watir-general Watir General]) for its support and contribution while Selenium also has a [http://seleniumforum.forumotion.net/ Selenium forum] apart from its google group called [https://groups.google.com/forum/#!forum/selenium-users Selenium Users].&lt;br /&gt;
&lt;br /&gt;
=='''Comparison of Features, Functionality, and More'''==&lt;br /&gt;
Some features or functionality may be repeated here.  However, we will go into a bit more detail than previously mentioned.&lt;br /&gt;
===='''Open Source'''====&lt;br /&gt;
Both Selenium and Watir are open source!  This allows for greater extensibility and a deeper understanding of the inner workings of both of the frameworks, if the developer/tester chooses to delve into such details.  Additionally, the open source community allows for a more transparent, user-driven development and support cycle.  Users (the tester/developer) can choose to submit bug fixes or enhancements as patches, or they can choose to just use it “straight out of the box.”&lt;br /&gt;
&lt;br /&gt;
====Application Language Agnostic====&lt;br /&gt;
&lt;br /&gt;
Both Selenium and Watir are application language agnostic.  Because both Selenium and Watir test UI functionality in the browser, they can be used to test any web application.    &lt;br /&gt;
&lt;br /&gt;
====Language-specific Test Cases====&lt;br /&gt;
&lt;br /&gt;
Both Selenium and Watir require test cases to be written in some programming language.  Traditionally, both frameworks had limited choices in terms of language bindings.  However, with the advent of WebDriver, both became much more flexible.  WebDriver provided the bindings needed for many languages.  Today, the following are supported:&lt;br /&gt;
&lt;br /&gt;
'''Selenium*'''&lt;br /&gt;
&lt;br /&gt;
* Officially-supported: [http://en.wikipedia.org/wiki/Java_(programming_language) Java], [http://en.wikipedia.org/wiki/C_Sharp_(programming_language) C#], [http://en.wikipedia.org/wiki/Ruby_(programming_language) Ruby], [http://en.wikipedia.org/wiki/Python_(programming_language) Python], [http://en.wikipedia.org/wiki/Node.js Javascript/Node.js]&lt;br /&gt;
&lt;br /&gt;
* Unofficial/community-supported: [http://en.wikipedia.org/wiki/Perl Perl], [http://en.wikipedia.org/wiki/PHP PHP], [http://en.wikipedia.org/wiki/Haskell_(programming_language) Haskell], [http://en.wikipedia.org/wiki/Objective-C Objective-C], [http://en.wikipedia.org/wiki/R_(programming_language) R], [http://en.wikipedia.org/wiki/Dart_(programming_language) Dart], [http://en.wikipedia.org/wiki/Tcl Tcl]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;According to SeleniumHQ’s download page.&lt;br /&gt;
&lt;br /&gt;
'''Watir'''&lt;br /&gt;
&lt;br /&gt;
Unfortunately (or fortunately), Ruby is the only supported language for Watir.  After all, Watir does stand for “Web Application Testing in Ruby.” However, there are other frameworks which were inspired by Watir (but entirely separate) available in Java and C# - Watij and Watin,  respectively &amp;lt;ref&amp;gt;Djorgjievski, Darko. [http://www.sitepoint.com/watir-webdriver-control-browser/ Watir-WebDriver: Control the Browser]. ''SitePoint''. SitePoint Pty Ltd, 18 Apr. 2014. Web. 05 Oct. 2014.&amp;lt;/ref&amp;gt;.  There may be other similarly inspired frameworks available in other languages, but these are the most notable.&lt;br /&gt;
&lt;br /&gt;
====Cross-Platform Support====&lt;br /&gt;
Both Watir and Selenium run on most popular distributions of Windows, Mac, and Linux.  Selenium doesn't have a list of officially supported operating system versions.  Instead they generally support any version that is currently popular.  Only a few versions are listed which they run test builds on.  These are versions which are officially known to work, but many more are supported as well.&lt;br /&gt;
&lt;br /&gt;
Because Watir is a collection of Ruby Gems, it runs on any platform that Ruby runs on.  Like Selenium, this includes nearly all popular platforms.&lt;br /&gt;
&lt;br /&gt;
====Cross-Browser and Headless Browser Support====&lt;br /&gt;
&lt;br /&gt;
Traditionally, both Selenium and Watir were limited in the number of browsers they supported. Watir originally supported Internet Explorer and headless browsers exclusively.  Headless browsers were supported via the use of Celerity &amp;lt;ref&amp;gt;Scott, Alister. [http://watirmelon.com/2010/04/10/watir-selenium-webdriver/ Watir, Selenium &amp;amp; WebDriver]. ''Watirmelon''. Watirmelon, 10 Apr. 2010. Web. 05 Oct. 2014.&amp;lt;/ref&amp;gt;.  Selenium started out as a Javascript library, so naturally it supported more browsers such as IE, Firefox, Safari, etc &amp;lt;ref name = &amp;quot;Introduction to Selenium&amp;quot; /&amp;gt;.  However, it did not support headless browsers.&lt;br /&gt;
Today, browser support looks much better for both Selenium and Watir, largely due to the introduction of WebDriver.  With WebDriver in existence, support for most browsers was added to Watir via the gem &amp;quot;watir-webdriver.&amp;quot;  Similarly for Selenium, support for headless browsers was added, as well as making the API much simpler and more concise &amp;lt;ref&amp;gt;[http://docs.seleniumhq.org/projects/webdriver/ Selenium WebDriver]. ''SeleniumHQ: Browser Automation''. Selenium Project, n.d. Web. 06 Oct. 2014.&amp;lt;/ref&amp;gt;.  However, there is the obvious limitation that one can only test a browser which is supported on the running platform.  In other words, Safari and Internet explorer can only be tested on  OS X and Windows environments, respectively**.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;**&amp;lt;/nowiki&amp;gt;Some work-arounds or programs exist to allow these browsers to be tested on other platforms. Here, we are assuming no special additional configuration - just the base operating system and browsers.&lt;br /&gt;
&lt;br /&gt;
=='''Getting started'''==&lt;br /&gt;
===Selenium WebDriver=== &lt;br /&gt;
----&lt;br /&gt;
====Install/Configure for Java====&lt;br /&gt;
Configuring Selenium requires you to download the binaries from [http://www.seleniumhq.org/download/ here]. &lt;br /&gt;
Once you have all your binaries in a directory, you can open any IDE of your choice and add this directory with all the .jar files to the CLASSPATH&lt;br /&gt;
*Example&lt;br /&gt;
This is how a typical Selenium code to find the term say, “Automation” on Google and display the results on the page would look like in Java using the [https://code.google.com/p/selenium/wiki/HtmlUnitDriver HtmlUnitDriver] would look like.&lt;br /&gt;
The HtmlUnitDriver is a pure Java driver that runs entirely in-memory. Because of this, you won't see a new browser window open &amp;lt;ref&amp;gt;[https://code.google.com/p/selenium/wiki/GettingStarted Getting started with Selenium]. Selenium: Browser Automation Framework. Google Code. 8 Feb, 2014.&amp;lt;/ref&amp;gt;,&lt;br /&gt;
&lt;br /&gt;
       package org.selenium.example;&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;
       import org.openqa.selenium.By;&lt;br /&gt;
       import org.openqa.selenium.WebDriver;&lt;br /&gt;
       import org.openqa.selenium.WebElement;&lt;br /&gt;
       import org.openqa.selenium.htmlunit.HtmlUnitDriver;&amp;lt;br /&amp;gt;&lt;br /&gt;
       public class Example  {&lt;br /&gt;
       public static void main(String[] args) {&lt;br /&gt;
        // Create a new instance of the html unit driver&lt;br /&gt;
        // Notice that the remainder of the code relies on the interface,&lt;br /&gt;
        // not the implementation.&lt;br /&gt;
        WebDriver driver = new HtmlUnitDriver();&amp;lt;br /&amp;gt;&lt;br /&gt;
        // And now use this to visit Google&lt;br /&gt;
        driver.get(&amp;quot;http://www.google.com&amp;quot;);&amp;lt;br /&amp;gt;&lt;br /&gt;
        // Find the text input element by its name&lt;br /&gt;
        WebElement element = driver.findElement(By.name(&amp;quot;q&amp;quot;));&amp;lt;br /&amp;gt;&lt;br /&gt;
        // Enter something to search for&lt;br /&gt;
        element.sendKeys(&amp;quot;Automation!&amp;quot;);&amp;lt;br /&amp;gt;&lt;br /&gt;
        // Now submit the form. WebDriver will find the form for us from the element&lt;br /&gt;
        element.submit();&amp;lt;br /&amp;gt;&lt;br /&gt;
        // Check the title of the page&lt;br /&gt;
        System.out.println(&amp;quot;Page title is: &amp;quot; + driver.getTitle());&lt;br /&gt;
        driver.quit();&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
If you compile and run it, you should see a line with the title of the Google search results as output. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Install/Configure for other languages====&lt;br /&gt;
Configuring Selenium for languages other than Java and for other development environments can be looked up [http://docs.seleniumhq.org/docs/03_webdriver.jsp#setting-up-a-selenium-webdriver-project here]. viz(C#, Ruby, Python, PHP, Perl, Javascript)&lt;br /&gt;
&lt;br /&gt;
===Watir===&lt;br /&gt;
----&lt;br /&gt;
====Install/Configure====&lt;br /&gt;
Drivers for Watir are installed as gems which are nothing but Ruby libraries which can be accessed over the internet.&lt;br /&gt;
All the instructions for installing Watir on various operating systems (viz. Windows, Mac OS, Linux) can be found [http://watir.com/installation/ here].&lt;br /&gt;
&lt;br /&gt;
*Example:&lt;br /&gt;
This is how a typical Watir code to find the term say, “Automation” on Google and display the results on the page would look like using Ruby&amp;lt;ref&amp;gt;Chernenko, Iryna. [http://blog.qatestlab.com/2011/02/23/automated-testing-with-watir-tutorial-for-begginers-part-1/ Watir Example]. QATestLab Blog: Automated Testing with Watir, 23 Feb 2011.&lt;br /&gt;
&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
        # Required in ruby 1.8.7&lt;br /&gt;
        require 'rubygems'&lt;br /&gt;
        # Watir IE driver&lt;br /&gt;
        require 'watir'&amp;lt;br /&amp;gt; &lt;br /&gt;
        ie = Watir::IE.new&amp;lt;br /&amp;gt; &lt;br /&gt;
        # text to show on console&lt;br /&gt;
        puts &amp;quot;Beginning of the test for Google search engine&amp;quot;&lt;br /&gt;
        puts &amp;quot;Step 1:  Go to the Google homepage&amp;quot;&lt;br /&gt;
        ie.goto &amp;quot;http://www.google.com&amp;quot;&amp;lt;br /&amp;gt;&lt;br /&gt;
        #set a variable&lt;br /&gt;
        search_text = &amp;quot;Automation&amp;quot;&lt;br /&gt;
        puts &amp;quot;Step 2: enter &amp;quot;+ search_text +&amp;quot; in the search text field.&amp;quot;&lt;br /&gt;
        ie.text_field(:name, &amp;quot;q&amp;quot;).set search_text   # &amp;quot;q&amp;quot; is the name of the search field&amp;lt;br /&amp;gt;&lt;br /&gt;
        puts &amp;quot; Step 3: click the 'Google Search' button.&amp;quot;&lt;br /&gt;
        ie.button(:name, &amp;quot;btnG&amp;quot;).click # &amp;quot;btnG&amp;quot; is the name of the Search button&amp;lt;br /&amp;gt;&lt;br /&gt;
        puts &amp;quot; Expected Result:&amp;quot;&lt;br /&gt;
        puts &amp;quot;  A Google page with results should be shown. 'Watir, pronounced water' should be high on the list.&amp;quot;&lt;br /&gt;
        puts &amp;quot; Actual Result:&amp;quot;&lt;br /&gt;
        if ie.text.include? &amp;quot;Watir, pronounced water&amp;quot;	&lt;br /&gt;
             puts &amp;quot;  Test Passed. Found the text string: 'Watir, pronounced water'. Actual Results match Expected Results.&amp;quot;&lt;br /&gt;
        else	&lt;br /&gt;
 	     puts &amp;quot;  Test Failed! Could not find text: 'Watir, pronounced water'.&amp;quot;&lt;br /&gt;
        end&lt;br /&gt;
        puts &amp;quot;End of test: Google search.&amp;quot;&lt;br /&gt;
        ie.close&lt;br /&gt;
&lt;br /&gt;
On compiling and running this and passing the test, you will see something like, &amp;lt;br /&amp;gt; &lt;br /&gt;
&lt;br /&gt;
        ''Output:''&lt;br /&gt;
        Beginning of the test for Google search engine &amp;lt;br /&amp;gt;&lt;br /&gt;
        Step 1:  Go to the Google homepage &amp;lt;br /&amp;gt;&lt;br /&gt;
        Step 2: enter Automation in the search text field. &amp;lt;br /&amp;gt;&lt;br /&gt;
        Step 3: click the 'Google Search' button. &amp;lt;br /&amp;gt;&lt;br /&gt;
        Expected Result: &amp;lt;br /&amp;gt;&lt;br /&gt;
        A Google page with results should be shown. 'Watir, pronounced water' should be high on the list. &amp;lt;br /&amp;gt;	&lt;br /&gt;
        Test Passed. Found the text string: 'Watir, pronounced water'. Actual Results match Expected Results. &amp;lt;br /&amp;gt;&lt;br /&gt;
        End of test: Google search. &amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Similar Tools==&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Sahi_(software) Sahi], uses the Sahi Scripting Language&amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Soatest SOATest], for testing and validating [http://en.wikipedia.org/wiki/Application_programming_interface API] driven applications &amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/TestComplete TestComplete], for Desktops, Web and Mobile&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
* [http://www.hiretheworld.com/blog/tech-blog/migrating-unit-tests-from-selenium-to-watir-webdriver Migrating unit tests from Selenium to Watir Web Driver] &amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://www.hiretheworld.com/blog/tech-blog/migrating-unit-tests-from-selenium-to-watir-webdriver Learning Selenium IDE] &amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/List_of_web_testing_tools List of web testing tools] &amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/List_of_web_testing_tools OWASP List of Acceptance Testing tools]&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
{{reflist}}&lt;br /&gt;
&amp;lt;references /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==External Links==&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Selenium_(software) Selenium Wiki Page] &amp;lt;br /&amp;gt;&lt;br /&gt;
* [https://github.com/SeleniumHQ/selenium Selenium Source Code] &amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Watir Watir Wiki Page] &amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Watir Watir Source Code] &amp;lt;br /&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Watir SauceLabs HomePage] &amp;lt;br /&amp;gt;&lt;/div&gt;</summary>
		<author><name>Jjbeaver</name></author>
	</entry>
</feed>