celerity 0.9.0 → 0.9.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (56) hide show
  1. data/.document +5 -0
  2. data/.gitignore +9 -0
  3. data/.gitmodules +3 -0
  4. data/.travis.yml +4 -0
  5. data/Gemfile +3 -0
  6. data/LICENSE +253 -596
  7. data/README.rdoc +8 -4
  8. data/Rakefile +5 -1
  9. data/benchmark/bm_2000_spans.rb +48 -0
  10. data/benchmark/bm_digg.rb +26 -0
  11. data/benchmark/bm_google_images.rb +36 -0
  12. data/benchmark/bm_input_locator.rb +69 -0
  13. data/benchmark/bm_text_input.rb +19 -0
  14. data/benchmark/loader.rb +14 -0
  15. data/celerity.gemspec +18 -114
  16. data/lib/celerity.rb +1 -3
  17. data/lib/celerity/htmlunit/commons-lang3-3.0.1.jar +0 -0
  18. data/lib/celerity/htmlunit/cssparser-0.9.6-20110829.205617-3.jar +0 -0
  19. data/lib/celerity/htmlunit/{htmlunit-2.9.jar → htmlunit-2.10-SNAPSHOT.jar} +0 -0
  20. data/lib/celerity/version.rb +1 -1
  21. data/spec/browser_authentication_spec.rb +16 -0
  22. data/spec/browser_spec.rb +428 -0
  23. data/spec/button_spec.rb +24 -0
  24. data/spec/clickable_element_spec.rb +39 -0
  25. data/spec/default_viewer_spec.rb +23 -0
  26. data/spec/element_spec.rb +77 -0
  27. data/spec/filefield_spec.rb +18 -0
  28. data/spec/htmlunit_spec.rb +63 -0
  29. data/spec/implementation.rb +7 -0
  30. data/spec/index_offset_spec.rb +24 -0
  31. data/spec/link_spec.rb +16 -0
  32. data/spec/listener_spec.rb +142 -0
  33. data/spec/spec_helper.rb +6 -0
  34. data/spec/table_spec.rb +41 -0
  35. data/spec/watir_compatibility_spec.rb +32 -0
  36. data/tasks/snapshot.rake +1 -1
  37. data/website/benchmarks.html +237 -0
  38. data/website/css/color.css +153 -0
  39. data/website/css/hacks.css +3 -0
  40. data/website/css/layout.css +179 -0
  41. data/website/css/screen.css +5 -0
  42. data/website/css/textmate.css +226 -0
  43. data/website/css/typography.css +72 -0
  44. data/website/gfx/body_bg.gif +0 -0
  45. data/website/gfx/button_bg.jpg +0 -0
  46. data/website/gfx/header_bg.jpg +0 -0
  47. data/website/gfx/header_left.jpg +0 -0
  48. data/website/gfx/header_right.jpg +0 -0
  49. data/website/gfx/nav_bg.jpg +0 -0
  50. data/website/index.html +125 -0
  51. data/website/yard/index.html +1 -0
  52. metadata +69 -22
  53. data/VERSION.yml +0 -5
  54. data/lib/celerity/htmlunit/commons-lang-2.6.jar +0 -0
  55. data/lib/celerity/htmlunit/cssparser-0.9.5.jar +0 -0
  56. data/tasks/jeweler.rake +0 -28
@@ -2,6 +2,9 @@
2
2
 
3
3
  * http://celerity.rubyforge.org/
4
4
 
5
+ {<img src="http://travis-ci.org/jarib/celerity.png" />}[http://travis-ci.org/jarib/celerity]
6
+
7
+
5
8
  == Description
6
9
 
7
10
  Celerity is a JRuby library for easy and fast functional test automation for web applications.
@@ -66,9 +69,9 @@ The source code is available on [GitHub](http://github.com/jarib/celerity/tree/m
66
69
  Celerity - JRuby wrapper for HtmlUnit
67
70
  Copyright (c) 2008-2011 FINN.no AS
68
71
 
69
- This program is free software: you can redistribute it and/or modify
72
+ This program is free software; you can redistribute it and/or modify
70
73
  it under the terms of the GNU General Public License as published by
71
- the Free Software Foundation, either version 3 of the License, or
74
+ the Free Software Foundation; either version 2 of the License, or
72
75
  (at your option) any later version.
73
76
 
74
77
  This program is distributed in the hope that it will be useful,
@@ -76,5 +79,6 @@ but WITHOUT ANY WARRANTY; without even the implied warranty of
76
79
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
77
80
  GNU General Public License for more details.
78
81
 
79
- You should have received a copy of the GNU General Public License
80
- along with this program. If not, see <http://www.gnu.org/licenses/>.
82
+ You should have received a copy of the GNU General Public License along
83
+ with this program; if not, write to the Free Software Foundation, Inc.,
84
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
data/Rakefile CHANGED
@@ -1,6 +1,10 @@
1
1
  require 'rubygems'
2
2
  require 'rake'
3
- require File.expand_path("lib/celerity/version", File.dirname(__FILE__))
3
+
4
+ include Rake::DSL
5
+
6
+ require 'bundler'
7
+ Bundler::GemHelper.install_tasks
4
8
 
5
9
  Dir['tasks/**/*.rake'].each do |rake|
6
10
  begin
@@ -0,0 +1,48 @@
1
+ require File.dirname(__FILE__) + "/loader"
2
+
3
+ # Create browser object
4
+ browser = create_browser
5
+ browser.goto(HTML_DIR + "/2000_spans.html")
6
+
7
+ TESTS = 100
8
+ res = Benchmark.bmbm do |results|
9
+ results.report("Loop through all spans (n = 1)") do
10
+ 1.times do # Hard coded 1 run
11
+ browser.spans.each do |span|
12
+ span.text
13
+ end
14
+ end
15
+ end
16
+
17
+ # results.report("Loop through all spans (raw)") do
18
+ # TESTS.times do
19
+ # if RUBY_PLATFORM =~ /java/
20
+ # browser.document.getHtmlElementsByTagName("span").each do |span|
21
+ # span.asText
22
+ # end
23
+ # else
24
+ # browser.document.getElementsByTagName("span").each do |span|
25
+ # span.innerText
26
+ # end
27
+ # end
28
+ # end
29
+ # end
30
+
31
+ results.report("Last span by id (String)") do
32
+ TESTS.times do
33
+ browser.span(:id, "id_2000").exists?
34
+ end
35
+ end
36
+
37
+ results.report("Last span by id (Regexp)") do
38
+ TESTS.times do
39
+ browser.span(:id, "/2000/").exists?
40
+ end
41
+ end
42
+
43
+ end
44
+
45
+ puts
46
+ total = res.inject(0.0) { |mem, bm| mem + bm.real }
47
+ puts "total : " + total.to_s
48
+ puts "average: " + (total/res.size.to_f).to_s
@@ -0,0 +1,26 @@
1
+ require File.dirname(__FILE__) + "/loader"
2
+
3
+ TESTS = 5
4
+ res = Benchmark.bmbm do |results|
5
+ results.report("Diggs on front page") do
6
+ TESTS.times do
7
+ # Create browser object
8
+ browser = create_browser
9
+
10
+ # Go to digg.com
11
+ browser.goto('http://digg.com/')
12
+
13
+ # Gather statistics
14
+ total_diggs = 0
15
+ digg_number_elements = browser.links.select { |link| link.id =~ /diggs/ }
16
+ digg_numbers = digg_number_elements.collect { |digg_number_element| digg_number_element.text }
17
+ digg_numbers.each { |digg_number| total_diggs += digg_number.to_i }
18
+ #puts "Found #{digg_numbers.size} stories, with a total of #{total_diggs} diggs."
19
+ end
20
+ end
21
+ end
22
+
23
+ puts
24
+ total = res.inject(0.0) { |mem, bm| mem + bm.real }
25
+ puts "total : " + total.to_s
26
+ puts "average: " + (total/res.size.to_f).to_s
@@ -0,0 +1,36 @@
1
+ require File.dirname(__FILE__) + "/loader"
2
+
3
+ TESTS = 5
4
+ res = Benchmark.bmbm do |results|
5
+ results.report("Google image search results") do
6
+ TESTS.times do
7
+ # Create browser object
8
+ browser = create_browser
9
+
10
+ # Goto images.google.com
11
+ browser.goto('http://images.google.com/ncr')
12
+
13
+ # Search for Watir
14
+ browser.text_field(:name, 'q').set('Watir')
15
+ browser.button(:value, 'Search Images').click
16
+
17
+ src_pool = []
18
+ pages = 1
19
+ # Gather statistics and click Next if there are more results
20
+ while browser.link(:text, 'Next').exists?
21
+ pages += 1
22
+ browser.link(:text, 'Next').click unless src_pool.empty?
23
+ table_cells = browser.cells.select { |cell| cell.id =~ /tDataImage\d+/ }
24
+ table_cells.each do |cell|
25
+ src_pool << cell.images.first.src if cell.images.first.exists?
26
+ end
27
+ end
28
+ #puts "Looked at #{pages} pages of image search results. Got #{src_pool.size} images."
29
+ end
30
+ end
31
+ end
32
+
33
+ puts
34
+ total = res.inject(0.0) { |mem, bm| mem + bm.real }
35
+ puts "total : " + total.to_s
36
+ puts "average: " + (total/res.size.to_f).to_s
@@ -0,0 +1,69 @@
1
+ require File.dirname(__FILE__) + "/loader"
2
+
3
+ browser = create_browser
4
+ browser.goto(HTML_DIR + "/forms_with_input_elements.html")
5
+
6
+ TESTS = 1000
7
+ res = Benchmark.bmbm do |results|
8
+ results.report("text input by id (String)") do
9
+ TESTS.times { browser.text_field(:id, "new_user_first_name").exists? }
10
+ end
11
+ results.report("text input by id (Regexp)") do
12
+ TESTS.times { browser.text_field(:id, /first_name/).exists? }
13
+ end
14
+ results.report("text input by name (String)") do
15
+ TESTS.times { browser.text_field(:name, "new_user_email").exists? }
16
+ end
17
+ results.report("text input by name (Regexp)") do
18
+ TESTS.times { browser.text_field(:name, /user_email/).exists? }
19
+ end
20
+
21
+ results.report("select list by id (String)") do
22
+ TESTS.times { browser.select_list(:id, 'new_user_country').exists? }
23
+ end
24
+ results.report("select list by id (Regexp)") do
25
+ TESTS.times { browser.select_list(:id, /user_country/).exists? }
26
+ end
27
+ results.report("select list by name (String)") do
28
+ TESTS.times { browser.select_list(:name, 'new_user_country').exists? }
29
+ end
30
+ results.report("select list by name (Regexp)") do
31
+ TESTS.times { browser.select_list(:name, /user_country/).exists? }
32
+ end
33
+
34
+ results.report("checkbox by id (String)") do
35
+ TESTS.times { browser.checkbox(:id, 'new_user_interests_books').exists? }
36
+ end
37
+ results.report("checkbox by id (Regexp)") do
38
+ TESTS.times { browser.checkbox(:id, /interests_books/).exists? }
39
+ end
40
+
41
+ results.report("checkbox by name (String)") do
42
+ TESTS.times { browser.checkbox(:name, 'new_user_interests').exists? }
43
+ end
44
+ results.report("checkbox by name (Regexp)") do
45
+ TESTS.times { browser.checkbox(:name, /user_interests/).exists? }
46
+ end
47
+
48
+ results.report("checkbox by id (String) and value (String)") do
49
+ TESTS.times { browser.checkbox(:id, 'new_user_interests_books', 'cars').exists? }
50
+ end
51
+ results.report("checkbox by id (Regexp) and value (Regexp)") do
52
+ TESTS.times { browser.checkbox(:id, /interests_books/, /car/).exists? }
53
+ end
54
+
55
+ results.report("checkbox by name (String) and value (String)") do
56
+ TESTS.times { browser.checkbox(:name, 'new_user_interests', 'dancing').exists? }
57
+ end
58
+ results.report("checkbox by name (Regexp) and value (Regexp)") do
59
+ TESTS.times { browser.checkbox(:name, /user_interests/, /danc/).exists? }
60
+ end
61
+
62
+
63
+
64
+ end
65
+
66
+ puts
67
+ total = res.inject(0.0) { |mem, bm| mem + bm.real }
68
+ puts "total : " + total.to_s
69
+ puts "average: " + (total/res.size.to_f).to_s
@@ -0,0 +1,19 @@
1
+ require File.dirname(__FILE__) + "/loader"
2
+
3
+ browser = create_browser
4
+ browser.goto(HTML_DIR + "/forms_with_input_elements.html")
5
+
6
+ TESTS = 10000
7
+ res = Benchmark.bmbm do |results|
8
+ results.report("TextField#set") do
9
+ TESTS.times { browser.text_field(:id, "new_user_first_name").set("1234567890") }
10
+ end
11
+ results.report("TextField#value=") do
12
+ TESTS.times { browser.text_field(:id, "new_user_first_name").value = "1234567890" }
13
+ end
14
+ end
15
+
16
+ puts
17
+ total = res.inject(0.0) { |mem, bm| mem + bm.real }
18
+ puts "total : " + total.to_s
19
+ puts "average: " + (total/res.size.to_f).to_s
@@ -0,0 +1,14 @@
1
+ require 'benchmark'
2
+ require File.dirname(__FILE__) + "/../spec/spec_helper"
3
+
4
+
5
+ def create_browser
6
+ if RUBY_PLATFORM =~ /java/
7
+ browser = Celerity::Browser.new(:log_level => :off)
8
+ else
9
+ require 'watir'
10
+ browser = Watir::IE.new
11
+ end
12
+
13
+ browser
14
+ end
@@ -1,122 +1,26 @@
1
- # Generated by jeweler
2
- # DO NOT EDIT THIS FILE DIRECTLY
3
- # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
1
  # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require 'celerity/version'
5
4
 
6
5
  Gem::Specification.new do |s|
7
- s.name = %q{celerity}
8
- s.version = "0.9.0"
9
-
10
- s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
- s.authors = ["Jari Bakken", "T. Alexander Lystad", "Knut Johannes Dahle"]
12
- s.date = %q{2011-08-18}
13
- s.description = %q{Celerity is a JRuby wrapper around HtmlUnit – a headless Java browser with JavaScript support. It provides a simple API for programmatic navigation through web applications. Celerity provides a superset of Watir's API.}
14
- s.email = %q{jari.bakken@gmail.com}
15
- s.extra_rdoc_files = [
16
- "LICENSE",
17
- "README.rdoc"
18
- ]
19
- s.files = [
20
- "LICENSE",
21
- "README.rdoc",
22
- "Rakefile",
23
- "VERSION.yml",
24
- "celerity.gemspec",
25
- "lib/celerity.rb",
26
- "lib/celerity/browser.rb",
27
- "lib/celerity/clickable_element.rb",
28
- "lib/celerity/collections.rb",
29
- "lib/celerity/container.rb",
30
- "lib/celerity/default_viewer.rb",
31
- "lib/celerity/disabled_element.rb",
32
- "lib/celerity/element.rb",
33
- "lib/celerity/element_collection.rb",
34
- "lib/celerity/element_locator.rb",
35
- "lib/celerity/elements/button.rb",
36
- "lib/celerity/elements/file_field.rb",
37
- "lib/celerity/elements/form.rb",
38
- "lib/celerity/elements/frame.rb",
39
- "lib/celerity/elements/image.rb",
40
- "lib/celerity/elements/label.rb",
41
- "lib/celerity/elements/link.rb",
42
- "lib/celerity/elements/meta.rb",
43
- "lib/celerity/elements/non_control_elements.rb",
44
- "lib/celerity/elements/option.rb",
45
- "lib/celerity/elements/radio_check.rb",
46
- "lib/celerity/elements/select_list.rb",
47
- "lib/celerity/elements/table.rb",
48
- "lib/celerity/elements/table_cell.rb",
49
- "lib/celerity/elements/table_elements.rb",
50
- "lib/celerity/elements/table_row.rb",
51
- "lib/celerity/elements/text_field.rb",
52
- "lib/celerity/exception.rb",
53
- "lib/celerity/htmlunit.rb",
54
- "lib/celerity/htmlunit/commons-codec-1.4.jar",
55
- "lib/celerity/htmlunit/commons-collections-3.2.1.jar",
56
- "lib/celerity/htmlunit/commons-io-2.0.1.jar",
57
- "lib/celerity/htmlunit/commons-lang-2.6.jar",
58
- "lib/celerity/htmlunit/commons-logging-1.1.1.jar",
59
- "lib/celerity/htmlunit/cssparser-0.9.5.jar",
60
- "lib/celerity/htmlunit/htmlunit-2.9.jar",
61
- "lib/celerity/htmlunit/htmlunit-core-js-2.9.jar",
62
- "lib/celerity/htmlunit/httpclient-4.1.2.jar",
63
- "lib/celerity/htmlunit/httpcore-4.1.2.jar",
64
- "lib/celerity/htmlunit/httpmime-4.1.2.jar",
65
- "lib/celerity/htmlunit/nekohtml-1.9.15.jar",
66
- "lib/celerity/htmlunit/sac-1.3.jar",
67
- "lib/celerity/htmlunit/serializer-2.7.1.jar",
68
- "lib/celerity/htmlunit/xalan-2.7.1.jar",
69
- "lib/celerity/htmlunit/xercesImpl-2.9.1.jar",
70
- "lib/celerity/htmlunit/xml-apis-1.3.04.jar",
71
- "lib/celerity/identifier.rb",
72
- "lib/celerity/ignoring_web_connection.rb",
73
- "lib/celerity/input_element.rb",
74
- "lib/celerity/javascript_debugger.rb",
75
- "lib/celerity/listener.rb",
76
- "lib/celerity/resources/no_viewer.png",
77
- "lib/celerity/short_inspect.rb",
78
- "lib/celerity/util.rb",
79
- "lib/celerity/version.rb",
80
- "lib/celerity/viewer_connection.rb",
81
- "lib/celerity/watir_compatibility.rb",
82
- "lib/celerity/xpath_support.rb",
83
- "tasks/benchmark.rake",
84
- "tasks/check.rake",
85
- "tasks/clean.rake",
86
- "tasks/fix.rake",
87
- "tasks/jar.rake",
88
- "tasks/jeweler.rake",
89
- "tasks/rdoc.rake",
90
- "tasks/snapshot.rake",
91
- "tasks/spec.rake",
92
- "tasks/website.rake",
93
- "tasks/yard.rake"
94
- ]
95
- s.homepage = %q{http://github.com/jarib/celerity}
96
- s.require_paths = ["lib"]
6
+ s.name = %q{celerity}
7
+ s.version = Celerity::VERSION
8
+ s.authors = ["Jari Bakken", "T. Alexander Lystad", "Knut Johannes Dahle"]
9
+ s.description = "Celerity is a JRuby wrapper around HtmlUnit – a headless Java browser with JavaScript support. It provides a simple API for programmatic navigation through web applications. Celerity provides a superset of Watir's API."
10
+ s.summary = %q{Celerity is a JRuby library for easy and fast functional test automation for web applications.}
11
+ s.email = %q{jari.bakken@gmail.com}
12
+ s.homepage = %q{http://github.com/jarib/celerity}
13
+ s.require_paths = ["lib"]
97
14
  s.rubyforge_project = %q{celerity}
98
- s.rubygems_version = %q{1.5.1}
99
- s.summary = %q{Celerity is a JRuby library for easy and fast functional test automation for web applications.}
100
15
 
101
- if s.respond_to? :specification_version then
102
- s.specification_version = 3
16
+ s.add_development_dependency "rake", "~> 0.9.2"
17
+ s.add_development_dependency "rspec", "~> 2.0.0"
18
+ s.add_development_dependency "yard", ">= 0"
19
+ s.add_development_dependency "sinatra", "~> 1.0"
20
+ s.add_development_dependency "mongrel", ">= 0"
103
21
 
104
- if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
105
- s.add_development_dependency(%q<rspec>, ["~> 2.0.0"])
106
- s.add_development_dependency(%q<yard>, [">= 0"])
107
- s.add_development_dependency(%q<sinatra>, [">= 1.0"])
108
- s.add_development_dependency(%q<mongrel>, [">= 0"])
109
- else
110
- s.add_dependency(%q<rspec>, ["~> 2.0.0"])
111
- s.add_dependency(%q<yard>, [">= 0"])
112
- s.add_dependency(%q<sinatra>, [">= 1.0"])
113
- s.add_dependency(%q<mongrel>, [">= 0"])
114
- end
115
- else
116
- s.add_dependency(%q<rspec>, ["~> 2.0.0"])
117
- s.add_dependency(%q<yard>, [">= 0"])
118
- s.add_dependency(%q<sinatra>, [">= 1.0"])
119
- s.add_dependency(%q<mongrel>, [">= 0"])
120
- end
22
+ s.files = `git ls-files`.split("\n")
23
+ s.test_files = []
24
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
121
25
  end
122
26
 
@@ -1,5 +1,3 @@
1
- $:.unshift(File.dirname(__FILE__)) unless $:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
2
-
3
1
  raise "Celerity only works on JRuby at the moment." unless RUBY_PLATFORM =~ /java/
4
2
 
5
3
  require "java"
@@ -29,7 +27,7 @@ module Celerity
29
27
  attr_accessor :index_offset
30
28
  end
31
29
 
32
- DIR = File.expand_path(File.dirname(__FILE__) + "/celerity")
30
+ DIR = File.expand_path("../celerity", __FILE__)
33
31
  end
34
32
 
35
33
  require "celerity/version"
@@ -1,3 +1,3 @@
1
1
  module Celerity
2
- VERSION = "0.9.0"
2
+ VERSION = "0.9.1"
3
3
  end
@@ -0,0 +1,16 @@
1
+ require File.expand_path("../watirspec/spec_helper", __FILE__)
2
+
3
+ describe "Browser" do
4
+
5
+ describe "#credentials=" do
6
+ it "sets the basic authentication credentials" do
7
+ browser.goto(WatirSpec.host + "/authentication")
8
+ browser.text.should_not include("ok")
9
+
10
+ browser.credentials = "foo:bar"
11
+
12
+ browser.goto(WatirSpec.host + "/authentication")
13
+ browser.text.should include("ok")
14
+ end
15
+ end
16
+ end