jarib-celerity 0.0.6.7 → 0.0.6.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.txt +4 -0
- data/lib/celerity/browser.rb +36 -21
- data/lib/celerity/clickable_element.rb +16 -1
- data/lib/celerity/collections.rb +2 -2
- data/lib/celerity/default_viewer.rb +1 -1
- data/lib/celerity/disabled_element.rb +5 -5
- data/lib/celerity/element.rb +25 -21
- data/lib/celerity/element_collection.rb +14 -14
- data/lib/celerity/element_locator.rb +9 -9
- data/lib/celerity/elements/button.rb +9 -9
- data/lib/celerity/elements/file_field.rb +3 -3
- data/lib/celerity/elements/form.rb +5 -5
- data/lib/celerity/elements/frame.rb +2 -2
- data/lib/celerity/elements/image.rb +2 -2
- data/lib/celerity/elements/label.rb +1 -1
- data/lib/celerity/elements/link.rb +4 -4
- data/lib/celerity/elements/non_control_elements.rb +3 -3
- data/lib/celerity/elements/option.rb +5 -5
- data/lib/celerity/elements/radio_check.rb +16 -16
- data/lib/celerity/elements/select_list.rb +16 -16
- data/lib/celerity/elements/table.rb +15 -12
- data/lib/celerity/elements/table_row.rb +3 -3
- data/lib/celerity/elements/text_field.rb +22 -25
- data/lib/celerity/exception.rb +5 -5
- data/lib/celerity/htmlunit.rb +8 -2
- data/lib/celerity/htmlunit/htmlunit-2.6-SNAPSHOT.jar +0 -0
- data/lib/celerity/htmlunit/{nekohtml-1.9.12.jar → nekohtml-1.9.13-20090507.082850-2.jar} +0 -0
- data/lib/celerity/listener.rb +17 -17
- data/lib/celerity/util.rb +1 -1
- data/lib/celerity/version.rb +2 -2
- data/lib/celerity/watir_compatibility.rb +2 -2
- metadata +7 -9
- data/lib/celerity/extra/method_generator.rb +0 -170
- data/lib/celerity/htmlunit/htmlunit-2.5.jar +0 -0
data/lib/celerity/util.rb
CHANGED
data/lib/celerity/version.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
module Celerity
|
2
2
|
class Browser
|
3
3
|
class << self
|
4
|
-
|
4
|
+
|
5
5
|
# Added for Watir compatibility - not in use by Celerity
|
6
6
|
attr_accessor :speed, :attach_timeout, :visible
|
7
7
|
# Added for Watir compatibility - not in use by Celerity
|
@@ -78,7 +78,7 @@ module Celerity
|
|
78
78
|
alias_method :dragContentsTo, :drag_contents_to
|
79
79
|
alias_method :getContents, :value
|
80
80
|
alias_method :get_contents, :value
|
81
|
-
|
81
|
+
|
82
82
|
def requires_typing; end
|
83
83
|
end
|
84
84
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jarib-celerity
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.6.
|
4
|
+
version: 0.0.6.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jari Bakken
|
@@ -11,7 +11,7 @@ autorequire:
|
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
13
|
|
14
|
-
date: 2009-04
|
14
|
+
date: 2009-06-04 00:00:00 -07:00
|
15
15
|
default_executable:
|
16
16
|
dependencies:
|
17
17
|
- !ruby/object:Gem::Dependency
|
@@ -22,7 +22,7 @@ dependencies:
|
|
22
22
|
requirements:
|
23
23
|
- - ">="
|
24
24
|
- !ruby/object:Gem::Version
|
25
|
-
version:
|
25
|
+
version: 2.0.0
|
26
26
|
version:
|
27
27
|
description: "Celerity is a JRuby wrapper around HtmlUnit \xE2\x80\x93 a headless Java browser with JavaScript support. It provides a simple API for programmatic navigation through web applications. Celerity aims at being API compatible with Watir."
|
28
28
|
email: jari.bakken@finn.no
|
@@ -66,8 +66,6 @@ files:
|
|
66
66
|
- lib/celerity/elements/table_row.rb
|
67
67
|
- lib/celerity/elements/text_field.rb
|
68
68
|
- lib/celerity/exception.rb
|
69
|
-
- lib/celerity/extra
|
70
|
-
- lib/celerity/extra/method_generator.rb
|
71
69
|
- lib/celerity/htmlunit
|
72
70
|
- lib/celerity/htmlunit/commons-codec-1.3.jar
|
73
71
|
- lib/celerity/htmlunit/commons-collections-3.2.1.jar
|
@@ -76,9 +74,9 @@ files:
|
|
76
74
|
- lib/celerity/htmlunit/commons-lang-2.4.jar
|
77
75
|
- lib/celerity/htmlunit/commons-logging-1.1.1.jar
|
78
76
|
- lib/celerity/htmlunit/cssparser-0.9.5.jar
|
79
|
-
- lib/celerity/htmlunit/htmlunit-2.
|
77
|
+
- lib/celerity/htmlunit/htmlunit-2.6-SNAPSHOT.jar
|
80
78
|
- lib/celerity/htmlunit/htmlunit-core-js-2.5.jar
|
81
|
-
- lib/celerity/htmlunit/nekohtml-1.9.
|
79
|
+
- lib/celerity/htmlunit/nekohtml-1.9.13-20090507.082850-2.jar
|
82
80
|
- lib/celerity/htmlunit/sac-1.3.jar
|
83
81
|
- lib/celerity/htmlunit/serializer-2.7.1.jar
|
84
82
|
- lib/celerity/htmlunit/xalan-2.7.1.jar
|
@@ -101,7 +99,7 @@ files:
|
|
101
99
|
- tasks
|
102
100
|
- tasks/jar.rake
|
103
101
|
- tasks/rdoc.rake
|
104
|
-
has_rdoc:
|
102
|
+
has_rdoc: false
|
105
103
|
homepage: http://celerity.rubyforge.org
|
106
104
|
post_install_message:
|
107
105
|
rdoc_options:
|
@@ -126,7 +124,7 @@ requirements: []
|
|
126
124
|
rubyforge_project: celerity
|
127
125
|
rubygems_version: 1.2.0
|
128
126
|
signing_key:
|
129
|
-
specification_version:
|
127
|
+
specification_version: 3
|
130
128
|
summary: Celerity is a JRuby library for easy and fast functional test automation for web applications
|
131
129
|
test_files: []
|
132
130
|
|
@@ -1,170 +0,0 @@
|
|
1
|
-
require "rubygems"
|
2
|
-
require "uri"
|
3
|
-
require "active_support"
|
4
|
-
|
5
|
-
#--
|
6
|
-
# http://api.rubyonrails.com/classes/Inflector.html#M001621
|
7
|
-
#++
|
8
|
-
class String # :nodoc:
|
9
|
-
def underscore
|
10
|
-
gsub(/::/, '/').
|
11
|
-
gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2').
|
12
|
-
gsub(/([a-z\d])([A-Z])/,'\1_\2').
|
13
|
-
tr("-", "_").
|
14
|
-
downcase
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
module Celerity
|
19
|
-
|
20
|
-
#
|
21
|
-
# Experimental - generate a method definition for accessing elements on the current page.
|
22
|
-
#
|
23
|
-
# Usage:
|
24
|
-
#
|
25
|
-
# MethodGenerator.new(browser, opts).parse
|
26
|
-
#
|
27
|
-
#
|
28
|
-
class MethodGenerator
|
29
|
-
|
30
|
-
ELEMENTS = %w[text_field select_list radio checkbox button].map { |e| e.to_sym }
|
31
|
-
BUGGY_ELEMENTS = %w[radio checkbox].map { |e| e.to_sym }
|
32
|
-
|
33
|
-
def initialize(ie, opts = {})
|
34
|
-
@ie = ie
|
35
|
-
@opts = opts
|
36
|
-
@browser = @opts[:browser] || '@ie'
|
37
|
-
|
38
|
-
@docs = " # Fills in the page at #{@ie.url}\n #\n"
|
39
|
-
@docs << " # Parameters:\n #\n"
|
40
|
-
@doc_elements = []
|
41
|
-
|
42
|
-
@method = " def #{@opts[:method_name] || 'generated_method'}(opts = {})\n\n"
|
43
|
-
end
|
44
|
-
|
45
|
-
def parse
|
46
|
-
ELEMENTS.each do |elem|
|
47
|
-
@method << " # buggy!\n" if BUGGY_ELEMENTS.include?(elem)
|
48
|
-
add_elements(elem)
|
49
|
-
end
|
50
|
-
add_elements(:link) if @opts[:include_links]
|
51
|
-
@method << " end\n\n"
|
52
|
-
|
53
|
-
# fix docs
|
54
|
-
max = @doc_elements.map { |symbol, _| symbol.to_s.size }.max
|
55
|
-
@doc_elements.each do |sym, desc|
|
56
|
-
@docs << " # #{sym.to_s.ljust(max)} => #{desc}\n"
|
57
|
-
end
|
58
|
-
@docs << " #\n"*2
|
59
|
-
@docs + @method
|
60
|
-
end
|
61
|
-
|
62
|
-
private
|
63
|
-
|
64
|
-
def add_elements(symbol)
|
65
|
-
symbol = symbol.to_sym
|
66
|
-
symbol_pluralized = symbol.to_s.pluralize.to_sym
|
67
|
-
@ie.send(symbol_pluralized).each_with_index do |elem, idx|
|
68
|
-
self.send("add_#{symbol}".to_sym, elem, idx)
|
69
|
-
end
|
70
|
-
|
71
|
-
@method << "\n"
|
72
|
-
end
|
73
|
-
|
74
|
-
def add_text_field(elem, idx)
|
75
|
-
how, what = find_identifier(elem) || [:index, (idx + 1).to_s]
|
76
|
-
@method << " #{@browser}.text_field(#{how.inspect}, #{what.inspect}).value = "
|
77
|
-
symbol = (how == :index) ? ":text_field_#{what.underscore}" : ":#{what.underscore}"
|
78
|
-
@method << "opts[#{symbol}]\n"
|
79
|
-
@doc_elements << [symbol, "value for text field #{what.inspect}"]
|
80
|
-
end
|
81
|
-
|
82
|
-
def add_select_list(elem, idx)
|
83
|
-
how, what = find_identifier(elem) || [:index, (idx + 1).to_s]
|
84
|
-
@method << " #{@browser}.select_list(#{how.inspect}, #{what.inspect}).select("
|
85
|
-
symbol = (how == :index) ? ":select_list_#{what.underscore}" : ":#{what.underscore}"
|
86
|
-
@method << "opts[#{symbol}])\n"
|
87
|
-
@doc_elements << [symbol, "option to select for select list #{what.inspect}"]
|
88
|
-
end
|
89
|
-
|
90
|
-
def add_radio(elem, idx)
|
91
|
-
how, what = find_identifier(elem) || [:index, (idx + 1).to_s]
|
92
|
-
@method << " #{@browser}.radio(#{how.inspect}, #{what.inspect}, "
|
93
|
-
|
94
|
-
if (value = elem.value).empty?
|
95
|
-
symbol = (how == :index) ? ":radio_#{what.underscore}" : ":#{what.underscore}"
|
96
|
-
else
|
97
|
-
symbol = ":#{what.underscore}_#{value.underscore}"
|
98
|
-
@method << "#{value.inspect}).set if opts[#{symbol}]\n"
|
99
|
-
end
|
100
|
-
|
101
|
-
@doc_elements << [symbol, "set the radio with id/value #{what.inspect}"]
|
102
|
-
end
|
103
|
-
|
104
|
-
def add_checkbox(elem, idx)
|
105
|
-
how, what = find_identifier(elem) || [:index, (idx + 1).to_s]
|
106
|
-
@method << " #{@browser}.checkbox(#{how.inspect}, #{what.inspect}, "
|
107
|
-
symbol = (how == :index) ? ":checkbox_#{what.underscore}" : ":#{what.underscore}"
|
108
|
-
@method << "#{elem.value.inspect}).set if opts[#{symbol}]\n"
|
109
|
-
|
110
|
-
@doc_elements << [symbol, "set the checkbox with id/value #{what.inspect}"]
|
111
|
-
end
|
112
|
-
|
113
|
-
def add_button(elem, idx)
|
114
|
-
how, what = find_identifier(elem) || [:index, (idx + 1).to_s]
|
115
|
-
@method << " #{@browser}.button(#{how.inspect}, #{what.inspect}).click\n"
|
116
|
-
end
|
117
|
-
|
118
|
-
def add_link(elem, idx)
|
119
|
-
if (href = elem.href) =~ /javascript/
|
120
|
-
how, what = :index, (idx + 1).to_s
|
121
|
-
else
|
122
|
-
how = :url
|
123
|
-
|
124
|
-
begin
|
125
|
-
uri = URI.parse(href)
|
126
|
-
what = Regexp.new(Regexp.escape(uri.to_s.sub(/.*#{uri.host}\//, '')))
|
127
|
-
rescue URI::InvalidURIError
|
128
|
-
what = href
|
129
|
-
end
|
130
|
-
end
|
131
|
-
@method << " #{@browser}.link(#{how.inspect}, #{what.inspect}).click\n"
|
132
|
-
end
|
133
|
-
|
134
|
-
def find_identifier(element)
|
135
|
-
# could use ATTRIBUTES if they were 'weighted' somehow?
|
136
|
-
attrs = element.class::ATTRIBUTES
|
137
|
-
[:id, :name].each do |attribute|
|
138
|
-
return [attribute, element.send(attribute)] if attrs.include?(attribute) && !element.send(attribute).empty?
|
139
|
-
end
|
140
|
-
nil
|
141
|
-
end
|
142
|
-
|
143
|
-
end # MethodGenerator
|
144
|
-
|
145
|
-
class Browser
|
146
|
-
|
147
|
-
#
|
148
|
-
# Experimental - generate a method definition for accessing elements on the current page
|
149
|
-
# Not loaded by default - need to require 'celerity/extra/method_generator'
|
150
|
-
#
|
151
|
-
|
152
|
-
def generate_method(opts = {})
|
153
|
-
MethodGenerator.new(self, opts).parse
|
154
|
-
end
|
155
|
-
|
156
|
-
end # Browser
|
157
|
-
end # Celerity
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
# if __FILE__ == $0
|
162
|
-
# require File.dirname(__FILE__) + "/../spec/spec_helper"
|
163
|
-
# $stdout.sync = true
|
164
|
-
# @ie = Browser.new
|
165
|
-
# @ie.goto(HTML_DIR + "/forms_with_input_elements.html")
|
166
|
-
#
|
167
|
-
# puts MethodGenerator.new(@ie).parse
|
168
|
-
# @ie.goto(HTML_DIR + "/forms3.html")
|
169
|
-
# puts MethodGenerator.new(@ie).parse
|
170
|
-
# end
|
Binary file
|