diff --git a/tracks/vendor/plugins/selenium-on-rails/LICENSE-2.0.txt b/tracks/vendor/plugins/selenium-on-rails/LICENSE-2.0.txt new file mode 100644 index 00000000..d6456956 --- /dev/null +++ b/tracks/vendor/plugins/selenium-on-rails/LICENSE-2.0.txt @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/tracks/vendor/plugins/selenium-on-rails/README b/tracks/vendor/plugins/selenium-on-rails/README new file mode 100644 index 00000000..75a43918 --- /dev/null +++ b/tracks/vendor/plugins/selenium-on-rails/README @@ -0,0 +1,192 @@ += Selenium on Rails + +== Overview + +Selenium on Rails provides an easy way to test Rails application with +SeleniumCore[http://www.openqa.org/selenium-core/]. + +This plugin does four things: +1. The Selenium Core files don't have to pollute /public, they can stay in the Selenium gem or in /vendor/selenium. +2. No need to create suite files, they are generated on the fly -- one suite per directory in /test/selenium (suites can be nested). +3. Instead of writing the test cases in HTML you can use a number of better formats (see Formats). +4. Loading of fixtures and wiping of session (/selenium/setup). + +== Installation + +1. Selenium Core needs to be available. It could either be installed as a gem (gem install selenium) or in /vendor/selenium/. +2. Install Selenium on Rails: script/plugin install http://svn.openqa.org/svn/selenium-on-rails/selenium-on-rails +3. If RedCloth is available the Selenese test cases can use it for better markup. +4. Run the Rakefile in the plugin's directory to run the tests in order to see that everything works. (If RedCloth isn't installed a few tests will fail since they assume RedCloth is installed.) +5. Create a test case: script/generate selenium login +6. Start the server: script/server -e test +7. Point your browser to http://localhost:3000/selenium +8. 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. + +=== win32-open3 + +win32-open3[http://raa.ruby-lang.org/project/win32-open3/] is needed if you're +on Windows and want to run your tests as a Rake task +(see test:acceptance), i.e. you don't have to install it but it's +recommended. + +You can build it from source or install the binary: + +1. Download the latest version of win32-open3, open3-0.2.2.so[http://rubyforge.org/frs/download.php/8515/open3-0.2.2.so] at the time of this writing. +2. Open up irb and run this snippet: require 'rbconfig'; include Config; puts CONFIG['sitearchdir'] +3. Create a win32 directory under the directory you got, e.g. c:\ruby\lib\ruby\site_ruby\1.8\i386-msvcrt +4. Rename the .so file to open3.so and put it in the win32 directory. +5. Profit! (unless you get an error when doing require 'win32/open3') + +== Formats + +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. + +=== Selenese, .sel + +Selenese is the dumbest format (in a good way). You just write your commands +delimited by | characters. + + |open|/selenium/setup| + |open|/| + |goBack| + +If you don't want to write Selenese tests by hand you can use +SeleniumIDE[http://www.openqa.org/selenium-ide/] which has +support[http://wiki.openqa.org/display/SIDE/SeleniumOnRails] for Selenese. + +SeleniumIDE makes it super easy to record test and edit them. + +=== RSelenese, .rsel + +RSelenese enable you to write your tests in Ruby. + + setup :fixtures => :all + open '/' + assert_title 'Home' + ('a'..'z').each {|c| open :controller => 'user', :action => 'create', :name => c } + +See SeleniumOnRails::TestBuilder for available commands. + +=== HTML/RHTML + +You can write your tests in HTML/RHTML but that's mostly useful if you have +existing tests you want to reuse. + +=== Partial test cases + +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. + +A partial test case is just like a normal test case besides that its filename +has to start with _: + + #_login.rsel + open '/login' + type 'name', name + type 'password', password + click 'submit', :wait=>true + +To include a partial test case you write like this in a Selenese test case: + + |includePartial|login|name=John Doe|password=eoD nhoJ| + +in a RSelenese test case: + + include_partial 'login', :name => 'Jane Doe', :password => 'Jane Doe'.reverse + +and in a RHTML test case: + + <%= render :partial => 'login', :locals => {:name = 'Joe Schmo', :password => 'Joe Schmo'.reverse} %> + +== Configuration + +There are a number of settings available. You make them by renaming +config.yml.example to config.yml and make your changes in that +file. + +=== Environments + +Per default this plugin is only available in test environment. You can change +this by setting environments, such as: + + #config.yml + environments: + - test + - development + +== test:acceptance + +You can run all your Selenium tests as a Rake task. + +First, if you're on Windows, you have to make sure win32-open3 is installed. +Then you have to configure which browsers you want to run, like this: + + #config.yml + browsers: + firefox: 'c:\Program Files\Mozilla Firefox\firefox.exe' + ie: 'c:\Program Files\Internet Explorer\iexplore.exe' + +Now you're all set. First start a server: + + script/server -e test + +Then run the tests: + + rake test:acceptance + +Now it should work, otherwise let me know! + +=== Store results + +If you want to store the results from a test:acceptance you just need +to set in which directory they should be stored: + + #config.yml + result_dir: 'c:\result' + +So when you run rake test:acceptance the tables with the results will +be stored as .html files in that directory. + +This can be useful especially for continous integration. + +== Todo + +=== Standalone mode + +More work is needed on test:acceptance on Windows to be able to start +the server when needed. + +=== user_extension.js + +Selenium has support for user_extension.js which is a way to extend the +functionality of Selenium Core. However there is currently no easy way to add +such a file in Selenium on Rails. + +=== More setup/teardown support? + +Currently there is only support to load fixtures and to wipe the session in +/selenium/setup. Is there a need for more kinds of setups or teardowns? + +=== More documentation + + +== Not todo + +=== 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 +the Selenese format. + +== Credits + +* Jon Tirsen, http://jutopia.tirsen.com -- initial inspiration[http://wiki.rubyonrails.com/rails/pages/SeleniumIntegration] +* Eric Kidd, http://www.randomhacks.net -- contribution of RSelenese + +== Information + +For more information, check out the website[http://www.openqa.org/selenium-on-rails/]. diff --git a/tracks/vendor/plugins/selenium-on-rails/Rakefile b/tracks/vendor/plugins/selenium-on-rails/Rakefile new file mode 100644 index 00000000..fbd733d9 --- /dev/null +++ b/tracks/vendor/plugins/selenium-on-rails/Rakefile @@ -0,0 +1,27 @@ +require 'rake' +require 'rake/testtask' +require 'rdoc/rdoc' + +desc 'Default: run unit tests.' +task :default => :test + +desc 'Test the Selenium on Rails plugin.' +Rake::TestTask.new(:test) do |t| + t.libs << 'lib' + t.pattern = 'test/**/*_test.rb' + t.verbose = true +end + +desc 'Generate documentation for the Selenium on Rails plugin.' +task :rdoc do + rm_rf 'doc' + RDoc::RDoc.new.document(%w(--line-numbers --inline-source --title SeleniumOnRails README lib)) +end + +begin + require 'rcov/rcovtask' + Rcov::RcovTask.new do |t| + t.test_files = FileList['test/*_test.rb'] + end +rescue LoadError #if rcov isn't available, ignore +end diff --git a/tracks/vendor/plugins/selenium-on-rails/config.yml b/tracks/vendor/plugins/selenium-on-rails/config.yml new file mode 100644 index 00000000..17746296 --- /dev/null +++ b/tracks/vendor/plugins/selenium-on-rails/config.yml @@ -0,0 +1,27 @@ +# Rename this file to config.yml in order to configure the plugin + +# +# General settings +# + +environments: + - test +# - development # Uncomment this line to enable in development environment. N.B. your development database will likely be altered/destroyed/abducted + +#selenium_path: 'c:\selenium' #path to selenium installation. only needed when selenium isn't installed in /vendor/selenium or as a gem + +# +# rake test:acceptance settings +# + +browsers: + firefox: 'c:\Program Files\Mozilla Firefox\firefox.exe' + ie: 'c:\Program Files\Internet Explorer\iexplore.exe' + +#host: 'localhost' +#port_start: 3000 +#port_end: 3005 +#max_browser_duration: 120 +#multi_window: false + +#result_dir: 'c:\result' # the directory where the results will be stored after a test:acceptance run diff --git a/tracks/vendor/plugins/selenium-on-rails/config.yml.example b/tracks/vendor/plugins/selenium-on-rails/config.yml.example new file mode 100644 index 00000000..17746296 --- /dev/null +++ b/tracks/vendor/plugins/selenium-on-rails/config.yml.example @@ -0,0 +1,27 @@ +# Rename this file to config.yml in order to configure the plugin + +# +# General settings +# + +environments: + - test +# - development # Uncomment this line to enable in development environment. N.B. your development database will likely be altered/destroyed/abducted + +#selenium_path: 'c:\selenium' #path to selenium installation. only needed when selenium isn't installed in /vendor/selenium or as a gem + +# +# rake test:acceptance settings +# + +browsers: + firefox: 'c:\Program Files\Mozilla Firefox\firefox.exe' + ie: 'c:\Program Files\Internet Explorer\iexplore.exe' + +#host: 'localhost' +#port_start: 3000 +#port_end: 3005 +#max_browser_duration: 120 +#multi_window: false + +#result_dir: 'c:\result' # the directory where the results will be stored after a test:acceptance run diff --git a/tracks/vendor/plugins/selenium-on-rails/doc/classes/SeleniumController.html b/tracks/vendor/plugins/selenium-on-rails/doc/classes/SeleniumController.html new file mode 100644 index 00000000..c8bcc34d --- /dev/null +++ b/tracks/vendor/plugins/selenium-on-rails/doc/classes/SeleniumController.html @@ -0,0 +1,265 @@ + + + + +
+| Class | +SeleniumController | +
| In: | +
+
+ lib/controllers/selenium_controller.rb
+
+ + |
+
| Parent: | ++ ActionController::Base + | +
+ # File lib/controllers/selenium_controller.rb, line 50 +50: def record +51: dir = record_table +52: +53: @result = {'resultDir' => dir} +54: for p in ['result', 'numTestFailures', 'numTestPasses', 'numCommandFailures', 'numCommandPasses', 'numCommandErrors', 'totalTime'] +55: @result[p] = params[p] +56: end +57: File.open(log_path(params[:logFile] || 'default.yml'), 'w') {|f| YAML.dump(@result, f)} +58: +59: render :file => view_path('record.rhtml'), :layout => layout_path +60: end ++
+ # File lib/controllers/selenium_controller.rb, line 7 + 7: def setup + 8: unless params.has_key? :keep_session + 9: reset_session +10: @session_wiped = true +11: end +12: @cleared_tables = clear_tables params[:clear_tables].to_s +13: @loaded_fixtures = load_fixtures params[:fixtures].to_s +14: render :file => view_path('setup.rhtml'), :layout => layout_path +15: end ++
+ # File lib/controllers/selenium_controller.rb, line 34 +34: def support_file +35: if params[:filename].empty? +36: redirect_to :filename => 'TestRunner.html', :test => 'tests' +37: return +38: end +39: +40: filename = File.join selenium_path, params[:filename] +41: if File.file? filename +42: type = WEBrick::HTTPUtils::DefaultMimeTypes[$1.downcase] if filename =~ /\.(\w+)$/ +43: type ||= 'text/html' +44: send_file filename, :type => type, :disposition => 'inline', :stream => false +45: else +46: render :text => 'Not found', :status => 404 +47: end +48: end ++
+ # File lib/controllers/selenium_controller.rb, line 17 +17: def test_file +18: params[:testname] = '' if params[:testname].to_s == 'TestSuite.html' +19: filename = File.join selenium_tests_path, params[:testname] +20: if File.directory? filename +21: @suite_path = filename +22: render :file => view_path('test_suite.rhtml'), :layout => layout_path +23: elsif File.readable? filename +24: render_test_case filename +25: else +26: if File.directory? selenium_tests_path +27: render :text => 'Not found', :status => 404 +28: else +29: render :text => "Did not find the Selenium tests path (#{selenium_tests_path}). Run script/generate selenium", :status => 404 +30: end +31: end +32: end ++
| Module | +SeleniumHelper | +
| In: | +
+
+ lib/selenium_helper.rb
+
+ + |
+
| Module | +SeleniumOnRails | +
| In: | +
+
+ lib/selenium_on_rails/paths.rb
+
+ + + lib/selenium_on_rails.rb + + + |
+
| Module | +SeleniumOnRails::FixtureLoader | +
| In: | +
+
+ lib/selenium_on_rails/fixture_loader.rb
+
+ + |
+
+ # File lib/selenium_on_rails/fixture_loader.rb, line 6 + 6: def available_fixtures + 7: fixtures = {} + 8: path = fixtures_path + '/' + 9: files = Dir["#{path}**/*.{yml,csv}"] +10: files.each do |file| +11: rel_path = file.sub(path, '') +12: next if skip_file? rel_path +13: fixture_set = File.dirname(rel_path) +14: fixture_set = '' if fixture_set == '.' +15: fixture = rel_path.sub /\.[^.]*$/, '' +16: fixtures[fixture_set] ||= [] +17: fixtures[fixture_set] << fixture +18: end +19: +20: fixtures +21: end ++
+ # File lib/selenium_on_rails/fixture_loader.rb, line 45 +45: def clear_tables tables +46: table_names = tables.split /\s*,\s*/ +47: connection = ActiveRecord::Base.connection +48: table_names.each do |table| +49: connection.execute "DELETE FROM #{table}" +50: end +51: table_names +52: end ++
+ # File lib/selenium_on_rails/fixture_loader.rb, line 23 +23: def load_fixtures fixtures_param +24: available = nil +25: fixtures = fixtures_param.split(/\s*,\s*/).collect do |f| +26: fixture_set = File.dirname f +27: fixture_set = '' if fixture_set == '.' +28: fixture = File.basename f +29: if fixture == 'all' +30: available ||= available_fixtures +31: available[fixture_set] +32: else +33: f +34: end +35: end +36: fixtures.flatten! +37: fixtures.reject! {|f| f.blank? } +38: +39: if fixtures.any? +40: Fixtures.create_fixtures fixtures_path, fixtures +41: end +42: fixtures +43: end ++
| Module | +SeleniumOnRails::PartialsSupport | +
| In: | +
+
+ lib/selenium_on_rails/partials_support.rb
+
+ + |
+
+Provides partials support to test cases so they can include other partial +test cases. +
++The partial’s commands are returned as html table rows. +
+ ++Extracts the commands from a partial. The partial must contain a html table +and the first row is ignored since it cannot contain a command. +
+ ++ # File lib/selenium_on_rails/partials_support.rb, line 19 +19: def extract_commands_from_partial partial +20: partial = partial.match(/.*<table>.*?<tr>.*?<\/tr>(.*?)<\/table>/im)[1] +21: raise "Partial '#{name}' doesn't contain any table" unless partial +22: partial +23: end ++
+Overrides where the partial is searched for, and returns only the command +table rows. +
+ ++ # File lib/selenium_on_rails/partials_support.rb, line 9 + 9: def render_partial partial_path = default_template_name, object = nil, local_assigns = nil, status = nil +10: pattern = partial_pattern partial_path +11: filename = Dir[pattern].first +12: raise "Partial '#{partial_path}' cannot be found! (Looking for file: '#{pattern}')" unless filename +13: partial = render :file => filename, :use_full_path => false, :locals => local_assigns +14: extract_commands_from_partial partial +15: end ++
| Module | +SeleniumOnRails::Paths | +
| In: | +
+
+ lib/selenium_on_rails/paths.rb
+
+ + |
+
+ # File lib/selenium_on_rails/paths.rb, line 25 +25: def fixtures_path +26: File.expand_path File.join(RAILS_ROOT, 'test/fixtures') +27: end ++
+Returns the path to the layout template. The path is relative in relation +to the app/views/ directory since Rails doesn’t support absolute +paths to layout templates. +
+ ++ # File lib/selenium_on_rails/paths.rb, line 19 +19: def layout_path +20: rails_root = Pathname.new File.expand_path(File.join(RAILS_ROOT, 'app/views')) +21: view_path = Pathname.new view_path('layout') +22: view_path.relative_path_from(rails_root).to_s +23: end ++
+ # File lib/selenium_on_rails/paths.rb, line 29 +29: def log_path log_file +30: File.expand_path(File.dirname(__FILE__) + '/../../log/' + log_file) +31: end ++
+ # File lib/selenium_on_rails/paths.rb, line 3 +3: def selenium_path +4: @@selenium_path ||= find_selenium_path +5: @@selenium_path +6: end ++
+ # File lib/selenium_on_rails/paths.rb, line 8 + 8: def selenium_tests_path + 9: File.expand_path(File.join(RAILS_ROOT, 'test/selenium')) +10: end ++
+ # File lib/selenium_on_rails/paths.rb, line 33 +33: def skip_file? file +34: file.split('/').each do |f| +35: return true if f.upcase == 'CVS' or f.starts_with?('.') or f.ends_with?('~') or f.starts_with?('_') +36: end +37: false +38: end ++
| Class | +SeleniumOnRails::RSelenese | +
| In: | +
+
+ lib/selenium_on_rails/rselenese.rb
+
+ + |
+
| Parent: | ++ + SeleniumOnRails::TestBuilder + + | +
+Renders Selenium test templates in a fashion analogous to rxml and +rjs templates. +
++ setup + open :controller => 'customer', :action => 'list' + assert_title 'Customers' ++
+See SeleniumOnRails::TestBuilder for a list +of available commands. +
+ +| view | +[RW] | ++ |
+Render template using local_assigns. +
+ ++ # File lib/selenium_on_rails/rselenese.rb, line 23 +23: def render template, local_assigns +24: title = (@view.assigns['page_title'] or local_assigns['page_title']) +25: table(title) do +26: test = self #to enable test.command +27: +28: assign_locals_code = '' +29: local_assigns.each_key {|key| assign_locals_code << "#{key} = local_assigns[#{key.inspect}];"} +30: +31: eval assign_locals_code + "\n" + template +32: end +33: end ++
| Module | +SeleniumOnRails::Renderer | +
| In: | +
+
+ lib/selenium_on_rails/renderer.rb
+
+ + |
+
+ # File lib/selenium_on_rails/renderer.rb, line 5 + 5: def render_test_case filename + 6: @template.extend SeleniumOnRails::PartialsSupport + 7: @page_title = test_case_name filename + 8: output = render_to_string :file => filename + 9: layout = (output =~ /<html>/i ? false : layout_path) +10: render :text => output, :layout => layout +11: +12: headers['Cache-control'] = 'no-cache' +13: headers['Pragma'] = 'no-cache' +14: headers['Expires'] = '-1' +15: end ++
| Class | +SeleniumOnRails::Selenese | +
| In: | +
+
+ lib/selenium_on_rails/selenese.rb
+
+ + |
+
| Parent: | ++ Object + | +
+ # File lib/selenium_on_rails/selenese.rb, line 7 +7: def initialize view +8: @view = view +9: end ++
+ # File lib/selenium_on_rails/selenese.rb, line 11 +11: def render template, local_assigns +12: name = (@view.assigns['page_title'] or local_assigns['page_title']) +13: lines = template.strip.split "\n" +14: html = '' +15: html << extract_comments(lines) +16: html << extract_commands(lines, name) +17: html << extract_comments(lines) +18: raise 'You cannot have comments in the middle of commands!' if next_line lines, :any +19: html +20: end ++
| Module | +SeleniumOnRails::SuiteRenderer | +
| In: | +
+
+ lib/selenium_on_rails/suite_renderer.rb
+
+ + |
+
+ # File lib/selenium_on_rails/suite_renderer.rb, line 24 +24: def link_to_test_case suite_name, filename +25: name = suite_name + test_case_name(filename) +26: link_to name, :action => :test_file, :testname => path_to_relative_url(filename).sub(/^\//,'') +27: end ++
+ # File lib/selenium_on_rails/suite_renderer.rb, line 18 +18: def test_cases path +19: tests = [] +20: visit_all_tests path, '', nil, Proc.new {|n, p| tests << [n,p]} +21: tests +22: end ++
+ # File lib/selenium_on_rails/suite_renderer.rb, line 2 +2: def test_suite_name path +3: return 'All test cases' if [nil, '/'].include? path_to_relative_url(path) +4: File.split(path)[-1].humanize +5: end ++
+ # File lib/selenium_on_rails/suite_renderer.rb, line 7 + 7: def test_suites path + 8: suites = [] + 9: +10: parent_path = File.join(File.split(path).slice(0..-2)) #all but last +11: parent_path = path_to_relative_url parent_path +12: suites << ['..', parent_path] unless parent_path.nil? +13: +14: visit_all_tests path, '', Proc.new {|n, p| suites << [n,path_to_relative_url(p)]}, nil +15: suites +16: end ++
| Class | +SeleniumOnRails::TestBuilder | +
| In: | +
+
+ lib/selenium_on_rails/test_builder.rb
+
+ + |
+
| Parent: | ++ Object + | +
+Builds Selenium test table using a high-level Ruby interface. Normally +invoked through SeleniumOnRails::RSelenese. +
++See SeleniumOnRails::TestBuilderActions for +the available actions and SeleniumOnRails::TestBuilderAccessors +for the available checks. +
++For more information on the commands supported by TestBuilder, see the Selenium Commands +Documentation at release.openqa.org/selenium-core/nightly/reference.html. +
+ ++Create a new TestBuilder for view. +
+ ++ # File lib/selenium_on_rails/test_builder.rb, line 26 +26: def initialize view +27: @view = view +28: @output = '' +29: @xml = Builder::XmlMarkup.new :indent => 2, :target => @output +30: end ++
+Convert str to a Selenium command name. +
+ ++ # File lib/selenium_on_rails/test_builder.rb, line 15 +15: def self.selenize str +16: str.camelize.gsub(/^[A-Z]/) {|s| s.downcase } +17: end ++
+Add a new test command using cmd, target and +value. +
+ ++ # File lib/selenium_on_rails/test_builder.rb, line 41 +41: def command cmd, target=nil, value=nil +42: @xml.tr do +43: _tdata cmd +44: _tdata target +45: _tdata value +46: end +47: end ++
+Same as command but add AndWait to the name of +cmd. +
+ ++ # File lib/selenium_on_rails/test_builder.rb, line 52 +52: def command_and_wait cmd, target=nil, value=nil +53: command_verbatim cmd.to_s + 'AndWait', target, value +54: end ++
+Prepends pattern with ‘exact:’ if it would be +considered containing string-match pattern otherwise. +
+ ++ # File lib/selenium_on_rails/test_builder.rb, line 21 +21: def exactize pattern +22: pattern.include?(':') ? "exact:#{pattern}" : pattern +23: end ++
+Re routes commands in the provided block to command_and_wait instead of command. +
+ ++ # File lib/selenium_on_rails/test_builder.rb, line 58 +58: def make_command_waiting +59: self.class.send :alias_method, :command, :command_and_wait +60: yield +61: self.class.send :alias_method, :command, :command_verbatim +62: end ++
| Module | +SeleniumOnRails::TestBuilderAccessors | +
| In: | +
+
+ lib/selenium_on_rails/test_builder_accessors.rb
+
+ + |
+
+The accessors available for SeleniumOnRails::TestBuilder tests. +
++For each store_foo there’s assert_foo, +assert_not_foo, verify_foo, verify_not_foo, +wait_for_foo, wait_for_not_foo. +
+ ++Gets the absolute URL of the current page. +
++Related Assertions, automatically generated: +
++ # File lib/selenium_on_rails/test_builder_accessors.rb, line 129 +129: def store_absolute_location variable_name +130: command 'storeAbsoluteLocation', variable_name +131: end ++
+Retrieves the message of a JavaScript alert generated during the previous +action, or fail if there were no alerts. +
++Getting an alert has the same effect as manually clicking OK. If an alert +is generated but you do not get/verify it, the next Selenium action will +fail. +
++NOTE: under Selenium, JavaScript alerts will NOT pop up a visible alert +dialog. +
++NOTE: Selenium does NOT support JavaScript alerts that are generated in a +page’s onload() event handler. In this case a visible dialog +WILL be generated and Selenium will hang until someone manually clicks OK. +
++Related Assertions, automatically generated: +
++ # File lib/selenium_on_rails/test_builder_accessors.rb, line 66 +66: def store_alert variable_name +67: command 'storeAlert', variable_name +68: end ++
+Has an alert occurred? +
++Related Assertions, automatically generated: +
++ # File lib/selenium_on_rails/test_builder_accessors.rb, line 15 +15: def store_alert_present variable_name +16: command 'storeAlertPresent', variable_name +17: end ++
+Returns the IDs of all buttons on the page. +
++If a given button has no ID, it will appear as "" in this array. +
++The pattern for the automatically generated assertions can either +take an array or a pattern. +
++ assert_all_buttons ['but1', 'but2'] + assert_all_buttons 'but?,but?*' ++
+Related Assertions, automatically generated: +
++ # File lib/selenium_on_rails/test_builder_accessors.rb, line 400 +400: def store_all_buttons variable_name +401: command 'storeAllButtons', variable_name +402: end ++
+Returns the IDs of all input fields on the page. +
++If a given field has no ID, it will appear as "" in this array. +
++The pattern for the automatically generated assertions can either +take an array or a pattern. +
++ assert_all_fields ['field1', 'field2'] + assert_all_fields 'field?,field?*' ++
+Related Assertions, automatically generated: +
++ # File lib/selenium_on_rails/test_builder_accessors.rb, line 440 +440: def store_all_fields variable_name +441: command 'storeAllFields', variable_name +442: end ++
+Returns the IDs of all links on the page. +
++If a given link has no ID, it will appear as "" in this array. +
++The pattern for the automatically generated assertions can either +take an array or a pattern. +
++ assert_all_links ['link1', 'link2'] + assert_all_links 'link?,link?*' ++
+Related Assertions, automatically generated: +
++ # File lib/selenium_on_rails/test_builder_accessors.rb, line 420 +420: def store_all_links variable_name +421: command 'storeAllLinks', variable_name +422: end ++
+Gets the value of an element attribute. +
++Related Assertions, automatically generated: +
++ # File lib/selenium_on_rails/test_builder_accessors.rb, line 322 +322: def store_attribute locator, attribute_name, variable_name +323: command 'storeAttribute', "#{locator}@#{attribute_name}", variable_name +324: end ++
+Gets the entire text of the page. +
++Related Assertions, automatically generated: +
++ # File lib/selenium_on_rails/test_builder_accessors.rb, line 169 +169: def store_body_text variable_name +170: command 'storeBodyText', variable_name +171: end ++
+Gets whether a toggle-button (checkbox/radio) is checked. Fails if the +specified element doesn’t exist or isn’t a toggle-button. +
++Related Assertions, automatically generated: +
++ # File lib/selenium_on_rails/test_builder_accessors.rb, line 239 +239: def store_checked locator, variable_name +240: command 'storeChecked', locator, variable_name +241: end ++
+Retrieves the message of a JavaScript confirmation dialog generated during +the previous action. +
++By default, the confirm function will return true, having the same +effect as manually clicking OK. This can be changed by prior execution of +the choose_cancel_on_next_confirmation command. If a confirmation +is generated but you do not get/verify it, the next Selenium action will +fail. +
++NOTE: under Selenium, JavaScript confirmations will NOT pop up a visible +dialog. +
++NOTE: Selenium does NOT support JavaScript confirmations that are generated +in a page’s onload() event handler. In this case a visible +dialog WILL be generated and Selenium will hang until you manually click +OK. +
++Related Assertions, automatically generated: +
++ # File lib/selenium_on_rails/test_builder_accessors.rb, line 92 +92: def store_confirmation variable_name +93: command 'storeConfirmation', variable_name +94: end ++
+Has confirm() been called? +
++Related Assertions, automatically generated: +
++ # File lib/selenium_on_rails/test_builder_accessors.rb, line 41 +41: def store_confirmation_present variable_name +42: command 'storeConfirmationPresent', variable_name +43: end ++
+Determines whether the specified input element is editable, i.e. +hasn’t been disabled. This method will fail if the specified element +isn’t an input element. +
++Related Assertions, automatically generated: +
++ # File lib/selenium_on_rails/test_builder_accessors.rb, line 380 +380: def store_editable locator, variable_name +381: command 'storeEditable', locator, variable_name +382: end ++
+Verifies that the specified element is somewhere on the page. +
++Related Assertions, automatically generated: +
++ # File lib/selenium_on_rails/test_builder_accessors.rb, line 349 +349: def store_element_present locator, variable_name +350: command 'storeElementPresent', locator, variable_name +351: end ++
+Gets the result of evaluating the specified JavaScript snippet. The snippet +may have multiple lines, but only the result of the last line will be +returned. +
++Note that, by default, the snippet will run in the context of the +"selenium" object itself, so this will refer to the +Selenium object, and window will refer to the top-level runner +test window, not the window of your application. +
++If you need a reference to the window of your application, you can refer to +this.browserbot.getCurrentWindow() and if you need to use a +locator to refer to a single element in your application page, you can use +this.page().findElement("foo") where +"foo" is your locator. +
++Related Assertions, automatically generated: +
++ # File lib/selenium_on_rails/test_builder_accessors.rb, line 225 +225: def store_eval script, variable_name +226: command 'storeEval', script, variable_name +227: end ++
+Returns the specified expression. +
++This is useful because of JavaScript preprocessing. +
++Related Assertions, automatically generated: +
++ # File lib/selenium_on_rails/test_builder_accessors.rb, line 468 +468: def store_expression expression, variable_name +469: command 'storeExpression', expression, variable_name +470: end ++
+Returns the entire HTML source between the opening and closing +"html" tags. +
++Related Assertions, automatically generated: +
++ # File lib/selenium_on_rails/test_builder_accessors.rb, line 453 +453: def store_html_source variable_name +454: command 'storeHtmlSource', variable_name +455: end ++
+Verify the location of the current page ends with the expected location. If +an URL querystring is provided, this is checked as well. +
++Related Assertions, automatically generated: +
++ # File lib/selenium_on_rails/test_builder_accessors.rb, line 143 +143: def store_location expected_location, variable_name +144: command 'storeLocation', expected_location, variable_name +145: end ++
+Retrieves the message of a JavaScript question prompt dialog generated +during the previous action. +
++Successful handling of the prompt requires prior execution of the +answer_on_next_prompt command. If a prompt is generated but you do +not get/verify it, the next Selenium action will fail. +
++NOTE: under Selenium, JavaScript prompts will NOT pop up a visible dialog. +
++NOTE: Selenium does NOT support JavaScript prompts that are generated in a +page’s onload() event handler. In this case a visible dialog +WILL be generated and Selenium will hang until someone manually clicks OK. +
++Related Assertions, automatically generated: +
++ # File lib/selenium_on_rails/test_builder_accessors.rb, line 116 +116: def store_prompt variable_name +117: command 'storePrompt', variable_name +118: end ++
+Has a prompt occurred? +
++Related Assertions, automatically generated: +
++ # File lib/selenium_on_rails/test_builder_accessors.rb, line 28 +28: def store_prompt_present variable_name +29: command 'storePromptPresent', variable_name +30: end ++
+Gets all option labels in the specified select drop-down. +
++The pattern for the automatically generated assertions can either +take an array or a pattern. +
++ assert_select_options 'fruits', ['apple', 'pear'] + assert_select_options 'fruits', 'a*,p*' ++
+Related Assertions, automatically generated: +
++ # File lib/selenium_on_rails/test_builder_accessors.rb, line 309 +309: def store_select_options locator, variable_name +310: command 'storeSelectOptions', locator, variable_name +311: end ++
+Verifies that the selected option of a drop-down satisfies the +option_locator. +
++option_locator is typically just an option label (e.g. "John +Smith"). +
++See the select command for more information about option locators. +
++NOTE: store_selected is +currently not supported by Selenium Core. +
++Related Assertions, automatically generated: +
++ # File lib/selenium_on_rails/test_builder_accessors.rb, line 272 +272: def store_selected locator, option_locator, variable_name +273: raise 'Not supported in Selenium Core at the moment' +274: end ++
+Gets all option labels for selected options in the specified select or +multi-select element. +
++The pattern for the automatically generated assertions can either +take an array or a pattern. +
++ assert_selected_options 'fruits', ['apple', 'pear'] + assert_selected_options 'fruits', 'a*,p*' ++
+Related Assertions, automatically generated: +
++ # File lib/selenium_on_rails/test_builder_accessors.rb, line 291 +291: def store_selected_options locator, variable_name +292: command 'storeSelectedOptions', locator, variable_name +293: end ++
+Gets the text from a cell of a table. +
++Related Assertions, automatically generated: +
++ # File lib/selenium_on_rails/test_builder_accessors.rb, line 252 +252: def store_table locator, row, column, variable_name +253: command 'storeTable', "#{locator}.#{row}.#{column}", variable_name +254: end ++
+Gets the text of an element. This works for any element that contains text. +This command uses either the textContent (Mozilla-like browsers) +or the innerText (IE-like browsers) of the element, which is the +rendered text shown to the user. +
++Related Assertions, automatically generated: +
++ # File lib/selenium_on_rails/test_builder_accessors.rb, line 200 +200: def store_text locator, variable_name +201: command 'storeText', locator, variable_name +202: end ++
+Verifies that the specified text pattern appears somewhere on the rendered +page shown to the user. +
++Related Assertions, automatically generated: +
++ # File lib/selenium_on_rails/test_builder_accessors.rb, line 336 +336: def store_text_present pattern, variable_name +337: command 'storeTextPresent', pattern, variable_name +338: end ++
+Gets the title of the current page. +
++Related Assertions, automatically generated: +
++ # File lib/selenium_on_rails/test_builder_accessors.rb, line 156 +156: def store_title variable_name +157: command 'storeTitle', variable_name +158: end ++
+Gets the (whitespace-trimmed) value of an input field (or anything else +with a value parameter). For checkbox/radio elements, the value will be +"on" or "off" depending on whether the element is +checked or not. +
++Related Assertions, automatically generated: +
++ # File lib/selenium_on_rails/test_builder_accessors.rb, line 184 +184: def store_value locator, variable_name +185: command 'storeValue', locator, variable_name +186: end ++
+Determines if the specified element is visible. An element can be rendered +invisible by setting the CSS "visibility" property to +"hidden", or the "display" property to +"none", either for the element itself or one if its ancestors. +This method will fail if the element is not present. +
++Related Assertions, automatically generated: +
++ # File lib/selenium_on_rails/test_builder_accessors.rb, line 365 +365: def store_visible locator, variable_name +366: command 'storeVisible', locator, variable_name +367: end ++
| Module | +SeleniumOnRails::TestBuilderActions | +
| In: | +
+
+ lib/selenium_on_rails/test_builder_actions.rb
+
+ + |
+
+The actions available for SeleniumOnRails::TestBuilder tests. +
++For each action foo there’s also an action +foo_and_wait. +
+ ++Add a selection to the set of selected options in a multi-select element +using an option locator. +
++See the select +command for more information about option locators. +
+ ++ # File lib/selenium_on_rails/test_builder_actions.rb, line 142 +142: def add_selection locator, option_locator +143: command 'addSelection', locator, option_locator +144: end ++
+Instructs Selenium to return the specified answer string in response to the +next JavaScript prompt (window.prompt()). +
+ ++ # File lib/selenium_on_rails/test_builder_actions.rb, line 193 +193: def answer_on_next_prompt answer +194: command 'answerOnNextPrompt', answer +195: end ++
+Check a toggle-button (checkbox/radio). +
+ ++ # File lib/selenium_on_rails/test_builder_actions.rb, line 102 +102: def check locator +103: command 'check', locator +104: end ++
+By default, Selenium’s overridden window.confirm() function +will return true, as if the user had manually clicked OK. After +running this command, the next call to confirm() will return +false, as if the user had clicked Cancel. +
+ ++ # File lib/selenium_on_rails/test_builder_actions.rb, line 187 +187: def choose_cancel_on_next_confirmation +188: command 'chooseCancelOnNextConfirmation' +189: end ++
+Clicks on a link, button, checkbox or radio button. If the click action +causes a new page to load (like a link usually does), call wait_for_page_to_load. +
+ ++ # File lib/selenium_on_rails/test_builder_actions.rb, line 47 +47: def click locator +48: command 'click', locator +49: end ++
+Simulates the user clicking the "close" button in the titlebar of +a popup window or tab. +
+ ++ # File lib/selenium_on_rails/test_builder_actions.rb, line 209 +209: def close +210: command 'close' +211: end ++
+Explicitly simulate an event (e.g. "focus", +"blur"), to trigger the corresponding +"on_event_" handler. +
+ ++ # File lib/selenium_on_rails/test_builder_actions.rb, line 53 +53: def fire_event locator, event_name +54: command 'fireEvent', locator, event_name +55: end ++
+Simulates the user clicking the "back" button on their browser. +
+ ++ # File lib/selenium_on_rails/test_builder_actions.rb, line 198 +198: def go_back +199: command 'goBack' +200: end ++
+Includes a partial. The path is relative to the Selenium tests root. The +starting _ and the file extension don’t have to be specified. +
++ #include test/selenium/_partial.* + include_partial 'partial' + #include test/selenium/suite/_partial.* + include_partial 'suite/partial' + #include test/selenium/suite/_partial.* and provide local assigns + include_partial 'suite/partial', :foo => bar ++ +
+ # File lib/selenium_on_rails/test_builder_actions.rb, line 39 +39: def include_partial path, local_assigns = {} +40: partial = @view.render :partial => path, :locals => local_assigns +41: @output << partial +42: end ++
+Simulates a user pressing a key (without releasing it yet). +
++keycode is the numeric keycode of the key to be pressed, normally +the ASCII value of that key. +
+ ++ # File lib/selenium_on_rails/test_builder_actions.rb, line 69 +69: def key_down locator, keycode +70: command 'keyDown', locator, keycode +71: end ++
+Simulates a user pressing and releasing a key. +
++keycode is the numeric keycode of the key to be pressed, normally +the ASCII value of that key. +
+ ++ # File lib/selenium_on_rails/test_builder_actions.rb, line 61 +61: def key_press locator, keycode +62: command 'keyPress', locator, keycode +63: end ++
+Simulates a user releasing a key. +
++keycode is the numeric keycode of the key to be released, normally +the ASCII value of that key. +
+ ++ # File lib/selenium_on_rails/test_builder_actions.rb, line 77 +77: def key_up locator, keycode +78: command 'keyUp', locator, keycode +79: end ++
+Simulates a user pressing the mouse button (without releasing it yet) on +the specified element. +
+ ++ # File lib/selenium_on_rails/test_builder_actions.rb, line 88 +88: def mouse_down locator +89: command 'mouseDown', locator +90: end ++
+Simulates a user hovering a mouse over the specified element. +
+ ++ # File lib/selenium_on_rails/test_builder_actions.rb, line 82 +82: def mouse_over locator +83: command 'mouseOver', locator +84: end ++
+Opens an URL in the test frame. This accepts both relative and absolute +URLs. The open command waits for the page to load before +proceeding, i.e. you don’t have to call wait_for_page_to_load. +
++Note: The URL must be on the same domain as the runner HTML due to security +restrictions in the browser (Same Origin Policy). +
+ ++ # File lib/selenium_on_rails/test_builder_actions.rb, line 166 +166: def open url +167: command 'open', url_arg(url) +168: end ++
+Simulates the user clicking the "Refresh" button on their +browser. +
+ ++ # File lib/selenium_on_rails/test_builder_actions.rb, line 203 +203: def refresh +204: command 'refresh' +205: end ++
+Remove a selection from the set of selected options in a multi-select +element using an option locator. +
++See the select command for more information about option locators. +
+ ++ # File lib/selenium_on_rails/test_builder_actions.rb, line 150 +150: def remove_selection locator, option_locator +151: command 'removeSelection', locator, option_locator +152: end ++
+Select an option from a drop-down using an option locator. +
++Option locators provide different ways of specifying options of an HTML +Select element (e.g. for selecting a specific option, or for asserting that +the selected option satisfies a specification). There are several forms of +Select Option Locator. +
++ label=regexp:^[Oo]ther ++
+ value=other ++
+ id=option1 ++
+ index=2 ++
+If no option locator prefix is provided, the default behaviour is to match +on label. +
+ ++ # File lib/selenium_on_rails/test_builder_actions.rb, line 134 +134: def select locator, option_locator +135: command 'select', locator, option_locator +136: end ++
+Selects a popup window; once a popup window has been selected, all commands +go to that window. To select the main window again, use nil as the +target. +
+ ++ # File lib/selenium_on_rails/test_builder_actions.rb, line 172 +172: def select_window window_id +173: command 'selectWindow', window_id||'null' +174: end ++
+Writes a message to the status bar and adds a note to the browser-side log. +
++context is the message sent to the browser. +
++log_level_threshold can be nil, :debug, +:info, :warn or :error. +
+ ++ # File lib/selenium_on_rails/test_builder_actions.rb, line 219 +219: def set_context context, log_level_threshold = nil +220: if log_level_threshold +221: command 'setContext', context, log_level_threshold.to_s +222: else +223: command 'setContext', context +224: end +225: end ++
+Specifies the amount of time that Selenium will wait for actions to +complete. +
++Actions that require waiting include open and the +wait_for* actions. +
++The default timeout is 30 seconds. +
++timeout is specified in milliseconds. +
+ ++ # File lib/selenium_on_rails/test_builder_actions.rb, line 251 +251: def set_timeout timeout +252: command 'setTimeout', timeout +253: end ++
+Tell Selenium on Rails to clear the session and load any fixtures. DO NOT +CALL THIS AGAINST NON-TEST DATABASES. The supported options are +:keep_session, :fixtures and :clear_tables +
++ setup + setup :keep_session + setup :fixtures => :all + setup :keep_session, :fixtures => [:foo, :bar] + setup :clear_tables => [:foo, :bar] ++ +
+ # File lib/selenium_on_rails/test_builder_actions.rb, line 14 +14: def setup options = {} +15: options = {options => nil} unless options.is_a? Hash +16: +17: opts = {:controller => 'selenium', :action => 'setup'} +18: opts[:keep_session] = true if options.has_key? :keep_session +19: +20: [:fixtures, :clear_tables].each do |key| +21: if (f = options[key]) +22: f = [f] unless f.is_a? Array +23: opts[key] = f.join ',' +24: end +25: end +26: +27: open opts +28: end ++
+Submit the specified form. This is particularly useful for forms without +submit buttons, e.g. single-input "Search" forms. +
+ ++ # File lib/selenium_on_rails/test_builder_actions.rb, line 156 +156: def submit locator +157: command 'submit', locator +158: end ++
+Sets the value of an input field, as though you typed it in. +
++Can also be used to set the value of combo boxes, check boxes, etc. In +these cases, value should be the value of the option selected, not +the visible text. +
+ ++ # File lib/selenium_on_rails/test_builder_actions.rb, line 97 +97: def type locator, value +98: command 'type', locator, value +99: end ++
+Uncheck a toggle-button (checkbox/radio). +
+ ++ # File lib/selenium_on_rails/test_builder_actions.rb, line 107 +107: def uncheck locator +108: command 'uncheck', locator +109: end ++
+Runs the specified JavaScript snippet repeatedly until it evaluates to +true. The snippet may have multiple lines, but only the result of +the last line will be considered. +
++Note that, by default, the snippet will be run in the runner’s test +window, not in the window of your application. To get the window of your +application, you can use the JavaScript snippet +selenium.browserbot.getCurrentWindow(), and then run your +JavaScript in there. +
++timeout is specified in milliseconds. +
+ ++ # File lib/selenium_on_rails/test_builder_actions.rb, line 238 +238: def wait_for_condition script, timeout +239: command 'waitForCondition', script, timeout +240: end ++
+Waits for a new page to load. +
++You can use this command instead of the and_wait suffixes, +click_and_wait, select_and_wait, type_and_wait +etc. (which are only available in the JS API). +
++Selenium constantly keeps track of new pages loading, and sets a +newPageLoaded flag when it first notices a page load. Running any +other Selenium command after turns the flag to false. Hence, if +you want to wait for a page to load, you must wait immediately after a +Selenium command that caused a page-load. +
++timeout is specified in milliseconds. +
+ ++ # File lib/selenium_on_rails/test_builder_actions.rb, line 268 +268: def wait_for_page_to_load timeout +269: command 'waitForPageToLoad', timeout +270: end ++
| Class | +SeleniumOnRailsConfig | +
| In: | +
+
+ lib/selenium_on_rails_config.rb
+
+ + |
+
| Parent: | ++ Object + | +
| Path: | +README + | +
| Last Update: | +Fri Dec 08 00:50:30 GMT Standard Time 2006 | +
+Selenium on Rails provides an easy way to test Rails application with Selenium Core. +
++This plugin does four things: +
++win32-open3 is +needed if you’re on Windows and want to run your tests as a Rake task +(see test:acceptance), i.e. you don’t have to install it but +it’s recommended. +
++You can build it from source or install the binary: +
++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. +
++Selenese is the dumbest format (in a good way). You just write your +commands delimited by | characters. +
++ |open|/selenium/setup| + |open|/| + |goBack| ++
+If you don’t want to write Selenese tests by hand you can use SeleniumIDE which has support for +Selenese. +
++SeleniumIDE makes it super easy to record test and edit them. +
++RSelenese enable you to write your tests in Ruby. +
+
+ setup :fixtures => :all
+ open '/'
+ assert_title 'Home'
+ ('a'..'z').each {|c| open :controller => 'user', :action => 'create', :name => c }
+
++See SeleniumOnRails::TestBuilder +for available commands. +
++You can write your tests in HTML/RHTML but that’s mostly useful if +you have existing tests you want to reuse. +
++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. +
++A partial test case is just like a normal test case besides that its +filename has to start with _: +
++ #_login.rsel + open '/login' + type 'name', name + type 'password', password + click 'submit', :wait=>true ++
+To include a partial test case you write like this in a Selenese test case: +
++ |includePartial|login|name=John Doe|password=eoD nhoJ| ++
+in a RSelenese test case: +
++ include_partial 'login', :name => 'Jane Doe', :password => 'Jane Doe'.reverse ++
+and in a RHTML test case: +
+
+ <%= render :partial => 'login', :locals => {:name = 'Joe Schmo', :password => 'Joe Schmo'.reverse} %>
+
++There are a number of settings available. You make them by renaming +config.yml.example to config.yml and make your changes in +that file. +
++Per default this plugin is only available in test environment. You can +change this by setting environments, such as: +
++ #config.yml + environments: + - test + - development ++
+You can run all your Selenium tests as a Rake task. +
++First, if you’re on Windows, you have to make sure win32-open3 is +installed. Then you have to configure which browsers you want to run, like +this: +
++ #config.yml + browsers: + firefox: 'c:\Program Files\Mozilla Firefox\firefox.exe' + ie: 'c:\Program Files\Internet Explorer\iexplore.exe' ++
+Now you’re all set. First start a server: +
++ script/server -e test ++
+Then run the tests: +
++ rake test:acceptance ++
+Now it should work, otherwise let me know! +
++If you want to store the results from a test:acceptance you just +need to set in which directory they should be stored: +
++ #config.yml + result_dir: 'c:\result' ++
+So when you run rake test:acceptance the tables with the results +will be stored as .html files in that directory. +
++This can be useful especially for continous integration. +
++More work is needed on test:acceptance on Windows to be able to +start the server when needed. +
++Selenium has support for user_extension.js which is a way to +extend the functionality of Selenium Core. However there is currently no +easy way to add such a file in Selenium on Rails. +
++Currently there is only support to load fixtures and to wipe the session in +/selenium/setup. Is there a need for more kinds of setups or +teardowns? +
++Creating an editor for the test cases is currently considered out of scope +for this plugin. SeleniumIDE does such a good +job and has support for +the Selenese format. +
++For more information, check out the website. +
+ +| Path: | +lib/controllers/selenium_controller.rb + | +
| Last Update: | +Fri Dec 08 00:52:51 GMT Standard Time 2006 | +
| Path: | +lib/selenium_helper.rb + | +
| Last Update: | +Sun Feb 05 01:02:10 W. Europe Standard Time 2006 | +
| Path: | +lib/selenium_on_rails/acceptance_test_runner.rb + | +
| Last Update: | +Fri Dec 08 00:16:44 GMT Standard Time 2006 | +
| BROWSERS | += | +c :browsers, {} | +
| REUSE_EXISTING_SERVER | += | +c :reuse_existing_server, true | +
| START_SERVER | += | +c :start_server, false | +
| PORTS | += | +c(:port_start, 3000)..c(:port_end, 3005) | +
| TEST_RUNNER_URL | += | +c :test_runner_url, '/selenium/TestRunner.html' | +
| MAX_BROWSER_DURATION | += | +c :max_browser_duration, 2*60 | +
| SERVER_COMMAND | += | +c_b :server_command do server_path = File.expand_path(File.dirname(__FILE__) + '/../../../../../script/server') | +
+ # File lib/selenium_on_rails/acceptance_test_runner.rb, line 7 +7: def c(var, default = nil) SeleniumOnRailsConfig.get var, default end ++
| Path: | +lib/selenium_on_rails/fixture_loader.rb + | +
| Last Update: | +Sun Feb 05 00:59:28 W. Europe Standard Time 2006 | +
| Path: | +lib/selenium_on_rails/partials_support.rb + | +
| Last Update: | +Tue May 02 00:43:37 W. Europe Daylight Time 2006 | +
+Provides partials support to test cases so they can include other partial +test cases. +
++The partial’s commands are returned as html table rows. +
+ +| Path: | +lib/selenium_on_rails/paths.rb + | +
| Last Update: | +Sun Feb 05 00:59:28 W. Europe Standard Time 2006 | +
| Path: | +lib/selenium_on_rails/renderer.rb + | +
| Last Update: | +Sun Feb 05 00:59:29 W. Europe Standard Time 2006 | +
| Path: | +lib/selenium_on_rails/rselenese.rb + | +
| Last Update: | +Sun Feb 19 12:59:40 W. Europe Standard Time 2006 | +
+Renders Selenium test templates in a fashion analogous to rxml and +rjs templates. +
++ setup + open :controller => 'customer', :action => 'list' + assert_title 'Customers' ++
+See SeleniumOnRails::TestBuilder +for a list of available commands. +
+ +| Path: | +lib/selenium_on_rails/selenese.rb + | +
| Last Update: | +Sun Feb 05 00:56:55 W. Europe Standard Time 2006 | +
| Path: | +lib/selenium_on_rails/suite_renderer.rb + | +
| Last Update: | +Sun Feb 05 04:12:56 W. Europe Standard Time 2006 | +
| Path: | +lib/selenium_on_rails/test_builder_accessors.rb + | +
| Last Update: | +Tue Jun 06 03:01:29 W. Europe Daylight Time 2006 | +
+The accessors available for SeleniumOnRails::TestBuilder +tests. +
++For each store_foo there’s assert_foo, +assert_not_foo, verify_foo, verify_not_foo, +wait_for_foo, wait_for_not_foo. +
+ +| Path: | +lib/selenium_on_rails/test_builder_actions.rb + | +
| Last Update: | +Tue Jun 06 03:12:04 W. Europe Daylight Time 2006 | +
+The actions available for SeleniumOnRails::TestBuilder +tests. +
++For each action foo there’s also an action +foo_and_wait. +
+ +| Path: | +lib/selenium_on_rails/test_builder.rb + | +
| Last Update: | +Tue Jun 06 02:47:24 W. Europe Daylight Time 2006 | +
+Builds Selenium test table using a high-level Ruby interface. Normally +invoked through SeleniumOnRails::RSelenese. +
++See SeleniumOnRails::TestBuilderActions +for the available actions and SeleniumOnRails::TestBuilderAccessors +for the available checks. +
++For more information on the commands supported by TestBuilder, see the +Selenium Commands Documentation at release.openqa.org/selenium-core/nightly/reference.html. +
+ +| Path: | +lib/selenium_on_rails_config.rb + | +
| Last Update: | +Mon Feb 20 21:58:17 W. Europe Standard Time 2006 | +
| Path: | +lib/selenium_on_rails.rb + | +
| Last Update: | +Thu May 04 01:18:20 W. Europe Daylight Time 2006 | +
It's often a good idea to start the test with opening /selenium/setup (see <%%= link_to 'here', :controller => 'selenium', :action => 'setup' %> for more info).
+ +| <%%= @page_title %> | ||
|---|---|---|
| open | /selenium/setup | |
| open | <%%= page %> | |
| assertTitle | Home | |
More information about the commands is available here.
+ +You can write comments above and below the commands, but you can only have one set of commands, i.e. one table, per test.
+ +Point the browser to <%= testcase_link %> to see how this test is rendered, or to <%= suite_link %> to run the suite.
diff --git a/tracks/vendor/plugins/selenium-on-rails/generators/selenium/templates/rselenese.rhtml b/tracks/vendor/plugins/selenium-on-rails/generators/selenium/templates/rselenese.rhtml new file mode 100644 index 00000000..419eb368 --- /dev/null +++ b/tracks/vendor/plugins/selenium-on-rails/generators/selenium/templates/rselenese.rhtml @@ -0,0 +1,14 @@ +# It's often a good idea to start the test with 'setup'. +# See /selenium/setup for more info. + +setup +open '/' +assert_title 'Home' + +# More information about the commands is available at: +# http://release.openqa.org/selenium-core/nightly/reference.html +# See also the RDoc for SeleniumOnRails::TestBuilder. +# +# Point the browser to <%= testcase_link %> to see +# how this test is rendered, or to <%= suite_link %> to +# run the suite. diff --git a/tracks/vendor/plugins/selenium-on-rails/generators/selenium/templates/selenese.rhtml b/tracks/vendor/plugins/selenium-on-rails/generators/selenium/templates/selenese.rhtml new file mode 100644 index 00000000..f4ccb8a9 --- /dev/null +++ b/tracks/vendor/plugins/selenium-on-rails/generators/selenium/templates/selenese.rhtml @@ -0,0 +1,11 @@ +It's often a good idea to start the test with opening /selenium/setup (see "here":/selenium/setup for more info). + +|open|/selenium/setup| +|open|/| +|assertTitle|Home| + +More information about the commands is available "here":http://release.openqa.org/selenium-core/nightly/reference.html. + +You can write comments above and below the commands, but you can only have one set of commands, i.e. one table, per test. "RedCloth":http://www.whytheluckystiff.net/ruby/redcloth/ is used for formatting if installed. + +Point the browser to "<%= testcase_link %>":<%= testcase_link %> to see how this test is rendered, or to "<%= suite_link %>":<%= suite_link %> to run the suite. diff --git a/tracks/vendor/plugins/selenium-on-rails/init.rb b/tracks/vendor/plugins/selenium-on-rails/init.rb new file mode 100644 index 00000000..05d43a8c --- /dev/null +++ b/tracks/vendor/plugins/selenium-on-rails/init.rb @@ -0,0 +1,19 @@ +require 'selenium_on_rails_config' +envs = SeleniumOnRailsConfig.get :environments + +if envs.include? RAILS_ENV + #initialize the plugin + $LOAD_PATH << File.dirname(__FILE__) + "/lib/controllers" + require 'selenium_controller' + require File.dirname(__FILE__) + '/routes' + +else + #erase all traces + $LOAD_PATH.delete lib_path + + #but help user figure out what to do + unless RAILS_ENV == 'production' # don't pollute production + require File.dirname(__FILE__) + '/switch_environment/init' + end +end + diff --git a/tracks/vendor/plugins/selenium-on-rails/lib/controllers/selenium_controller.rb b/tracks/vendor/plugins/selenium-on-rails/lib/controllers/selenium_controller.rb new file mode 100644 index 00000000..f6e328c8 --- /dev/null +++ b/tracks/vendor/plugins/selenium-on-rails/lib/controllers/selenium_controller.rb @@ -0,0 +1,119 @@ +require 'webrick/httputils' + +class SeleniumController < ActionController::Base + include SeleniumOnRails::FixtureLoader + include SeleniumOnRails::Renderer + + def setup + unless params.has_key? :keep_session + reset_session + @session_wiped = true + end + @cleared_tables = clear_tables params[:clear_tables].to_s + @loaded_fixtures = load_fixtures params[:fixtures].to_s + render :file => view_path('setup.rhtml'), :layout => layout_path + end + + def test_file + params[:testname] = '' if params[:testname].to_s == 'TestSuite.html' + filename = File.join selenium_tests_path, params[:testname] + if File.directory? filename + @suite_path = filename + render :file => view_path('test_suite.rhtml'), :layout => layout_path + elsif File.readable? filename + render_test_case filename + else + if File.directory? selenium_tests_path + render :text => 'Not found', :status => 404 + else + render :text => "Did not find the Selenium tests path (#{selenium_tests_path}). Run script/generate selenium", :status => 404 + end + end + end + + def support_file + if params[:filename].empty? + redirect_to :filename => 'TestRunner.html', :test => 'tests' + return + end + + filename = File.join selenium_path, params[:filename] + if File.file? filename + type = WEBrick::HTTPUtils::DefaultMimeTypes[$1.downcase] if filename =~ /\.(\w+)$/ + type ||= 'text/html' + send_file filename, :type => type, :disposition => 'inline', :stream => false + else + render :text => 'Not found', :status => 404 + end + end + + def record + dir = record_table + + @result = {'resultDir' => dir} + for p in ['result', 'numTestFailures', 'numTestPasses', 'numCommandFailures', 'numCommandPasses', 'numCommandErrors', 'totalTime'] + @result[p] = params[p] + end + File.open(log_path(params[:logFile] || 'default.yml'), 'w') {|f| YAML.dump(@result, f)} + + render :file => view_path('record.rhtml'), :layout => layout_path + end + + def record_table + return nil unless result_dir = SeleniumOnRailsConfig.get(:result_dir) + + cur_result_dir = File.join(result_dir, (params[:logFile] || "default").sub(/\.yml$/, '')) + FileUtils.mkdir_p(cur_result_dir) + File.open("#{cur_result_dir}/index.html", "wb") do |f| + f.write <