tracks/vendor/plugins/selenium-on-rails/doc/files
2009-12-16 16:44:49 -05:00
..
lib Update selenium on rails using 'official' git repo 2008-12-02 10:05:41 +01:00
CHANGELOG.html Update selenium on rails using 'official' git repo 2008-12-02 10:05:41 +01:00
README.html Upgrade Selenium on Rails to r140 2009-12-16 16:44:49 -05:00

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html 
     PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
  <title>File: README</title>
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  <meta http-equiv="Content-Script-Type" content="text/javascript" />
  <link rel="stylesheet" href=".././rdoc-style.css" type="text/css" media="screen" />
  <script type="text/javascript">
  // <![CDATA[

  function popupCode( url ) {
    window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
  }

  function toggleCode( id ) {
    if ( document.getElementById )
      elem = document.getElementById( id );
    else if ( document.all )
      elem = eval( "document.all." + id );
    else
      return false;

    elemStyle = elem.style;
    
    if ( elemStyle.display != "block" ) {
      elemStyle.display = "block"
    } else {
      elemStyle.display = "none"
    }

    return true;
  }
  
  // Make codeblocks hidden by default
  document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
  
  // ]]>
  </script>

</head>
<body>



  <div id="fileHeader">
    <h1>README</h1>
    <table class="header-table">
    <tr class="top-aligned-row">
      <td><strong>Path:</strong></td>
      <td>README
      </td>
    </tr>
    <tr class="top-aligned-row">
      <td><strong>Last Update:</strong></td>
      <td>Sat Feb 03 22:54:11 +0100 2007</td>
    </tr>
    </table>
  </div>
  <!-- banner header -->

  <div id="bodyContent">



  <div id="contextContent">

<div id="description">
	<p>Welcome to the Selenium on Rails README.  Exciting isn&#8217;t it?</p>

	<h1 id="selenium_on_rails">Selenium on Rails</h1>

	<h2 id="overview">Overview</h2>

	<p>Selenium on Rails provides an easy way to test Rails application with 
	SeleniumCore[http://www.openqa.org/selenium-core/].</p>

	<p>This plugin does four things:</p>

	<ol>
	<li>The Selenium Core files don&#8217;t have to pollute <tt>/public</tt>.</li>
	<li>No need to create suite files, they are generated on the fly &#8212; one suite per directory in <tt>/test/selenium</tt> (suites can be nested).</li>
	<li>Instead of writing the test cases in HTML you can use a number of better formats (see <tt>Formats</tt>).</li>
	<li>Loading of fixtures and wiping of session (<tt>/selenium/setup</tt>).</li>
	</ol>

	<h2 id="installation">Installation</h2>

	<p>Rails periodically changes the way that it renders pages, which unfortunately breaks backwards versions of Selenium on Rails.  Therefore there are different
	installation locations depending on your version of Rails:</p>

	<p><em>Rails 2.2 and up:</em></p>

	<pre><code>http://svn.openqa.org/svn/selenium-on-rails/stable/selenium-on-rails
	</code></pre>

	<p><em>Rails 2.1:</em></p>

	<pre><code>http://svn.openqa.org/svn/selenium-on-rails/tags/rails_2_1/selenium-on-rails
	</code></pre>

	<p><em>Before Rails 2.1:</em></p>

	<pre><code>http://svn.openqa.org/svn/selenium-on-rails/tags/pre-rails-2-1/selenium-on-rails
	</code></pre>

	<p>The latest release is always kept on GitHub at </p>

	<pre><code>git clone git://github.com/paytonrules/selenium-on-rails.git
	</code></pre>

	<p>To install:</p>

	<ol>
	<li>Install Selenium on Rails: script/plugin install <URL></li>
	<li>If youre on Windows, gem install win32-open3</li>
	<li>If the RedCloth gem is available the Selenese test cases can use it for better markup.</li>
	<li>Run the Rakefile in the plugins directory to run the tests in order to see that everything works. (If RedCloth isnt installed a few tests will fail since they assume RedCloth is installed.)</li>
	<li>Create a test case: script/generate selenium <TestName></li>
	<li>Start the server: script/server -e test</li>
	<li>Point your browser to localhost:3000/selenium</li>
	<li>If everything works as expected you should see the Selenium test runner. The north east frame contains all your test cases (just one for now), and the north frame contains your test case.</li>
	</ol>

	<h2 id="formats">Formats</h2>

	<p>The test cases can be written in a number of formats. Which one you choose is a matter of taste. You can generate your test files by running script/generate selenium or by creating them manually in your /test/selenium directory.</p>

	<h2 id="rselenese_rsel">RSelenese, .rsel</h2>

	<p>RSelenese lets you write your tests in Ruby. This is my favorite format.</p>

	<pre><code>setup :fixtures =&gt; :all
	open '/'
	assert_title 'Home'
	('a'..'z').each {|c| open :controller =&gt; 'user', :action =&gt; 'create', :name =&gt; c }
	</code></pre>

	<p>See SeleniumOnRails::TestBuilder for available commands. <em>IMPORTANT NOTE:</em> RSelenese generates the HTML tables for Selenium behind the scenes when the page is loaded - ONCE. That means code like this:</p>

	<pre><code>(1..10).each do |index|
	    do something
	end
	</code></pre>

	<p>Will only be executed when the test is loaded, not when the test is run. This is a common error and leads to tests that work the first time and fail the second time.</p>

	<h2 id="selenese_sel">Selenese, .sel</h2>

	<p>Selenese is the dumbest format (in a good way). You just write your commands delimited by | characters.</p>

	<pre><code>|open|/selenium/setup|
	|open|/|
	|goBack|
	</code></pre>

	<p>If you dont want to write Selenese tests by hand you can use SeleniumIDE which has support for Selenese.</p>

	<h2 id="html_rhtml">HTML/RHTML</h2>

	<p>You can write your tests in HTML/RHTML but thats mostly useful if you have existing tests you want to reuse.</p>

	<h2 id="partial_test_cases">Partial test cases</h2>

	<p>If you have some common actions you want to do in several test cases you can put them in a separate partial test case and include them in your other test cases. This is highly recommended, just as small functions would be recommended in structured programming.</p>

	<p>A partial test case is just like a normal test case besides that its filename has to start with _:</p>

	<pre><code>#_login.rsel
	open '/login'
	type 'name', name
	type 'password', password
	click 'submit', :wait=&gt;true
	</code></pre>

	<p>To include a partial test case in a RSelenese test case:</p>

	<pre><code>include_partial 'login', :name =&gt; 'Jane Doe', :password =&gt; 'Jane Doe'.reverse
	</code></pre>

	<p>in a Selenese test case:</p>

	<pre><code>|includePartial|login|name=John Doe|password=eoD nhoJ|
	</code></pre>

	<p>and in a RHTML test case:</p>

	<pre><code>&lt;%= render :partial =&gt; 'login', :locals =&gt; {:name = 'Joe Schmo', :password =&gt; 'Joe Schmo'.reverse} %&gt;
	</code></pre>

	<h2 id="configuration">Configuration</h2>

	<p>There are a number of settings available. You make them by renaming selenium.yml.example to selenium.yml and placing it in your rails app&#8217;s config 
	file.  Make your changes in that file.</p>

	<h2 id="environments">Environments</h2>

	<p>Per default this plugin is only available in test environment. You can change this by setting environments, such as:</p>

	<pre><code>#selenium.yml
	environments:
	    - test
	    - development
	</code></pre>

	<h2 id="selenium_core_path">Selenium Core path</h2>

	<p>If you dont want to use the bundled Selenium Core version you can set selenium_path to the directory where Selenium Core is stored.</p>

	<pre><code>#config.yml
	selenium_path: 'c:\selenium'
	</code></pre>

	<h2 id="rake_task">Rake Task</h2>

	<p>You can run all your Selenium tests as a Rake task. If you&#8217;re using a continuous builder this is a great way to integrate selenium into your build process.  First, if youre on Windows, you have to make sure win32-open3 is installed. Then you have to configure which browsers you want to run, like this:</p>

	<pre><code>#config.yml
	browsers:
	    firefox: 'c:\Program Files\Mozilla Firefox\firefox.exe'
	    ie: 'c:\Program Files\Internet Explorer\iexplore.exe'
	</code></pre>

	<p>Now youre all set. First start a server:</p>

	<pre><code>script/server -e test
	</code></pre>

	<p>Then run the tests:</p>

	<pre><code>rake test:acceptance
	</code></pre>

	<p>Now it should work, otherwise let me know!</p>

	<h2 id="store_results">Store results</h2>

	<p>If you want to store the results from a test:acceptance you just need to set in which directory they should be stored:</p>

	<pre><code>#config.yml
	result_dir: 'c:\result'
	</code></pre>

	<p>So when you run rake test:acceptance the tables with the results will be stored as .html files in that directory.</p>

	<h2 id="user_extensionjs">user_extension.js</h2>

	<p>Selenium has support for user_extension.js which is a way to extend the functionality of Selenium Core. Selenium on Rails now provides the means for you to extend it&#8217;s functionality to match.</p>

	<p>To get you started, we&#8217;ve included the example files lib/test_builder_user_accessors.rb.example and lib/test_builder_user_actions.rb.example that replicate the sample extensions in Selenium Core&#8217;s user-extensions.js.sample.</p>

	<p>To get these examples running, simply remove the .example and .sample extensions 
	from the files and restart your server.</p>

	<h2 id="todo">Todo</h2>

	<ul>
	<li><p>Standalone mode
	More work is needed on test:acceptance&lt; on Windows to be able to start the server when needed.</p></li>
	<li><p>Documentation update</p></li>
	</ul>

	<h2 id="not_todo">Not todo</h2>

	<ul>
	<li>Editor
	Creating an editor for the test cases is currently considered out of scope for this plugin. SeleniumIDE[http://www.openqa.org/selenium-ide/] does such a good  job and has support[http://wiki.openqa.org/display/SIDE/SeleniumOnRails] for both the Selenese and RSelenese formats.</li>
	</ul>

	<h2 id="credits">Credits</h2>

	<ul>
	<li>Jonas Bengston &#8212; original creator</li>
	<li>Eric Smith, http://blog.8thlight.com/eric &#8212; Current Maintainer</li>
	<li>Jon Tirsen, http://jutopia.tirsen.com &#8212; initial inspiration[http://wiki.rubyonrails.com/rails/pages/SeleniumIntegration]</li>
	<li>Eric Kidd, http://www.randomhacks.net &#8212; contribution of RSelenese</li>
	<li>Marcos Tapajós http://www.improveit.com.br/en/company/tapajos &#8212; Several useful features, current committer</li>
	<li>Ryan Bates, http://railscasts.com &#8212; Fixes for Rails 2.1</li>
	<li>Nando Vieira, http://simplesideias.com.br</li>
	<li>Gordon McCreight, a neat script that lists any unsupported methods</li>
	</ul>

	<h2 id="contributing_">Contributing ##</h2>

	<p>Contributing is simple.  Fork this repo, make your changes, then issue a pull request.  <em>IMPORTANT</em> I will not take forks that do not have associated unit tests.  There must be tests, and they must pass, so I can bring the changes in.</p>

	<h2 id="information">Information</h2>

	<p>For more information, check out the <a href="http://seleniumhq.org/projects/on-rails/">website</a>.</p>



  </div>


    <!-- if includes -->

    <div id="section">





      


    <!-- if method_list -->


  </div>


<div id="validator-badges">
  <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
</div>

</body>
</html>