jarib-celerity 0.0.5.4 → 0.0.5.5
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/lib/celerity/browser.rb +19 -7
- data/lib/celerity/clickable_element.rb +34 -7
- data/lib/celerity/element_collections.rb +14 -0
- data/lib/celerity/elements/label.rb +2 -0
- data/lib/celerity/elements/table.rb +1 -0
- data/lib/celerity/elements/table_cell.rb +1 -0
- data/lib/celerity/elements/table_elements.rb +1 -0
- data/lib/celerity/elements/table_row.rb +1 -0
- data/lib/celerity/util.rb +43 -40
- data/lib/celerity/version.rb +1 -1
- data/lib/celerity/watir_compatibility.rb +0 -2
- metadata +3 -3
data/lib/celerity/browser.rb
CHANGED
@@ -179,10 +179,10 @@ module Celerity
|
|
179
179
|
goto(@last_url) if @last_url
|
180
180
|
end
|
181
181
|
|
182
|
-
# Wait for
|
183
|
-
def
|
182
|
+
# Wait for javascript jobs to finish
|
183
|
+
def wait
|
184
184
|
assert_exists
|
185
|
-
@page.getEnclosingWindow.
|
185
|
+
@page.getEnclosingWindow.getJobManager.waitForAllJobsToFinish(10000)
|
186
186
|
end
|
187
187
|
|
188
188
|
# Refresh the current page
|
@@ -191,12 +191,24 @@ module Celerity
|
|
191
191
|
self.page = @page.refresh
|
192
192
|
end
|
193
193
|
|
194
|
-
# Clears all cookies. (Celerity
|
194
|
+
# Clears all cookies. (Celerity only)
|
195
195
|
def clear_cookies
|
196
196
|
@webclient.getCookieManager.clearCookies
|
197
197
|
end
|
198
198
|
|
199
|
-
#
|
199
|
+
# Get the cookies for this session. (Celerity only)
|
200
|
+
def cookies
|
201
|
+
result = {}
|
202
|
+
|
203
|
+
cookies = @webclient.getCookieManager.getCookies.to_a
|
204
|
+
cookies.each do |cookie|
|
205
|
+
result[cookie.getName] = cookie.getValue
|
206
|
+
end
|
207
|
+
|
208
|
+
result
|
209
|
+
end
|
210
|
+
|
211
|
+
# Execute the given JavaScript on the current page. (Celerity only)
|
200
212
|
# @return [Object] The resulting Object
|
201
213
|
def execute_script(source)
|
202
214
|
assert_exists
|
@@ -219,7 +231,7 @@ module Celerity
|
|
219
231
|
end
|
220
232
|
end
|
221
233
|
|
222
|
-
# Wait until the given block evaluates to true (Celerity
|
234
|
+
# Wait until the given block evaluates to true (Celerity only)
|
223
235
|
#
|
224
236
|
# @param [Fixnum] timeout Number of seconds to wait before timing out (default: 30).
|
225
237
|
# @yieldparam [Celerity::Browser] browser The browser instance.
|
@@ -233,7 +245,7 @@ module Celerity
|
|
233
245
|
end
|
234
246
|
end
|
235
247
|
|
236
|
-
# Wait while the given block evaluates to true (Celerity
|
248
|
+
# Wait while the given block evaluates to true (Celerity only)
|
237
249
|
#
|
238
250
|
# @param [Fixnum] timeout Number of seconds to wait before timing out (default: 30).
|
239
251
|
# @yieldparam [Celerity::Browser] browser The browser instance.
|
@@ -1,26 +1,53 @@
|
|
1
1
|
module Celerity
|
2
2
|
module ClickableElement
|
3
3
|
|
4
|
-
#
|
5
|
-
|
6
|
-
|
7
|
-
assert_enabled if respond_to?(:assert_enabled)
|
4
|
+
#
|
5
|
+
# click the element
|
6
|
+
#
|
8
7
|
|
8
|
+
def click
|
9
|
+
assert_exists_and_enabled
|
9
10
|
@container.update_page(@object.click)
|
10
11
|
end
|
11
12
|
|
13
|
+
#
|
14
|
+
# double click the element (Celerity only)
|
15
|
+
#
|
16
|
+
|
17
|
+
def double_click
|
18
|
+
assert_exists_and_enabled
|
19
|
+
@container.update_page(@object.dblClick)
|
20
|
+
end
|
21
|
+
|
22
|
+
#
|
23
|
+
# right click the element (Celerity only)
|
24
|
+
#
|
25
|
+
|
26
|
+
def right_click
|
27
|
+
assert_exists_and_enabled
|
28
|
+
@container.update_page(@object.rightClick)
|
29
|
+
end
|
30
|
+
|
31
|
+
#
|
12
32
|
# Click the element and return a new Browser instance with the resulting page.
|
13
33
|
# This is useful for elements that trigger popups when clicked.
|
14
34
|
#
|
15
35
|
# @return [Celerity::Browser]
|
16
|
-
|
17
|
-
assert_exists
|
18
|
-
assert_enabled if respond_to?(:assert_enabled)
|
36
|
+
#
|
19
37
|
|
38
|
+
def click_and_attach
|
39
|
+
assert_exists_and_enabled
|
20
40
|
browser = Browser.new(:log_level => @browser.log_level)
|
21
41
|
browser.update_page(@object.click)
|
22
42
|
|
23
43
|
browser
|
24
44
|
end
|
45
|
+
|
46
|
+
private
|
47
|
+
|
48
|
+
def assert_exists_and_enabled
|
49
|
+
assert_exists
|
50
|
+
assert_enabled if respond_to?(:assert_enabled)
|
51
|
+
end
|
25
52
|
end
|
26
53
|
end
|
@@ -49,6 +49,20 @@ module Celerity
|
|
49
49
|
end
|
50
50
|
end
|
51
51
|
|
52
|
+
# Get the first element in this collection. (Celerity-specific)
|
53
|
+
#
|
54
|
+
# @return [Celerity::Element] Returns a subclass of Celerity::Element
|
55
|
+
def first
|
56
|
+
self[INDEX_OFFSET]
|
57
|
+
end
|
58
|
+
|
59
|
+
# Get the last element in this collection. (Celerity-specific)
|
60
|
+
#
|
61
|
+
# @return [Celerity::Element] Returns a subclass of Celerity::Element
|
62
|
+
def last
|
63
|
+
self[INDEX_OFFSET - 1]
|
64
|
+
end
|
65
|
+
|
52
66
|
# Note: This can be quite useful in irb:
|
53
67
|
#
|
54
68
|
# puts browser.text_fields
|
data/lib/celerity/util.rb
CHANGED
@@ -3,45 +3,48 @@ module Celerity
|
|
3
3
|
module_function
|
4
4
|
|
5
5
|
HtmlUnit2CelerityElement = {
|
6
|
-
HtmlUnit::Html::HtmlAnchor
|
7
|
-
HtmlUnit::Html::HtmlArea
|
8
|
-
HtmlUnit::Html::HtmlButton
|
9
|
-
HtmlUnit::Html::HtmlButtonInput
|
10
|
-
HtmlUnit::Html::HtmlCaption
|
11
|
-
HtmlUnit::Html::HtmlCheckBoxInput
|
12
|
-
HtmlUnit::Html::
|
13
|
-
HtmlUnit::Html::
|
14
|
-
HtmlUnit::Html::
|
15
|
-
HtmlUnit::Html::
|
16
|
-
HtmlUnit::Html::
|
17
|
-
HtmlUnit::Html::
|
18
|
-
HtmlUnit::Html::
|
19
|
-
HtmlUnit::Html::
|
20
|
-
HtmlUnit::Html::
|
21
|
-
HtmlUnit::Html::
|
22
|
-
HtmlUnit::Html::
|
23
|
-
HtmlUnit::Html::
|
24
|
-
HtmlUnit::Html::
|
25
|
-
HtmlUnit::Html::
|
26
|
-
HtmlUnit::Html::
|
27
|
-
HtmlUnit::Html::
|
28
|
-
HtmlUnit::Html::
|
29
|
-
HtmlUnit::Html::
|
30
|
-
HtmlUnit::Html::
|
31
|
-
HtmlUnit::Html::
|
32
|
-
HtmlUnit::Html::
|
33
|
-
HtmlUnit::Html::
|
34
|
-
HtmlUnit::Html::
|
35
|
-
HtmlUnit::Html::
|
36
|
-
HtmlUnit::Html::
|
37
|
-
HtmlUnit::Html::
|
38
|
-
HtmlUnit::Html::
|
39
|
-
HtmlUnit::Html::
|
40
|
-
HtmlUnit::Html::
|
41
|
-
HtmlUnit::Html::
|
42
|
-
HtmlUnit::Html::
|
43
|
-
HtmlUnit::Html::
|
44
|
-
HtmlUnit::Html::
|
6
|
+
HtmlUnit::Html::HtmlAnchor => Celerity::Link,
|
7
|
+
HtmlUnit::Html::HtmlArea => Celerity::Area,
|
8
|
+
HtmlUnit::Html::HtmlButton => Celerity::Button,
|
9
|
+
HtmlUnit::Html::HtmlButtonInput => Celerity::Button,
|
10
|
+
HtmlUnit::Html::HtmlCaption => Celerity::Button, # ?
|
11
|
+
HtmlUnit::Html::HtmlCheckBoxInput => Celerity::CheckBox,
|
12
|
+
HtmlUnit::Html::HtmlDefinitionDescription => Celerity::Dd,
|
13
|
+
HtmlUnit::Html::HtmlDefinitionList => Celerity::Dl,
|
14
|
+
HtmlUnit::Html::HtmlDefinitionTerm => Celerity::Dt,
|
15
|
+
HtmlUnit::Html::HtmlDivision => Celerity::Div,
|
16
|
+
HtmlUnit::Html::HtmlFileInput => Celerity::FileField,
|
17
|
+
HtmlUnit::Html::HtmlForm => Celerity::Form,
|
18
|
+
HtmlUnit::Html::HtmlFrame => Celerity::Frame,
|
19
|
+
HtmlUnit::Html::HtmlHeading1 => Celerity::H1,
|
20
|
+
HtmlUnit::Html::HtmlHeading2 => Celerity::H2,
|
21
|
+
HtmlUnit::Html::HtmlHeading3 => Celerity::H3,
|
22
|
+
HtmlUnit::Html::HtmlHeading4 => Celerity::H4,
|
23
|
+
HtmlUnit::Html::HtmlHeading5 => Celerity::H5,
|
24
|
+
HtmlUnit::Html::HtmlHeading6 => Celerity::H6,
|
25
|
+
HtmlUnit::Html::HtmlHiddenInput => Celerity::Hidden,
|
26
|
+
HtmlUnit::Html::HtmlImage => Celerity::Image,
|
27
|
+
HtmlUnit::Html::HtmlLabel => Celerity::Label,
|
28
|
+
HtmlUnit::Html::HtmlLink => Celerity::Link,
|
29
|
+
HtmlUnit::Html::HtmlListItem => Celerity::Li,
|
30
|
+
HtmlUnit::Html::HtmlMap => Celerity::Map,
|
31
|
+
HtmlUnit::Html::HtmlOption => Celerity::Option,
|
32
|
+
HtmlUnit::Html::HtmlOrderedList => Celerity::Ol,
|
33
|
+
HtmlUnit::Html::HtmlParagraph => Celerity::P,
|
34
|
+
HtmlUnit::Html::HtmlPasswordInput => Celerity::TextField,
|
35
|
+
HtmlUnit::Html::HtmlPreformattedText => Celerity::Pre,
|
36
|
+
HtmlUnit::Html::HtmlRadioButtonInput => Celerity::Radio,
|
37
|
+
HtmlUnit::Html::HtmlSelect => Celerity::SelectList,
|
38
|
+
HtmlUnit::Html::HtmlSpan => Celerity::Span,
|
39
|
+
HtmlUnit::Html::HtmlTable => Celerity::Table,
|
40
|
+
HtmlUnit::Html::HtmlTableBody => Celerity::TableBody,
|
41
|
+
HtmlUnit::Html::HtmlTableCell => Celerity::TableCell,
|
42
|
+
HtmlUnit::Html::HtmlTableFooter => Celerity::TableFooter,
|
43
|
+
HtmlUnit::Html::HtmlTableHeader => Celerity::TableHeader,
|
44
|
+
HtmlUnit::Html::HtmlTableRow => Celerity::TableRow,
|
45
|
+
HtmlUnit::Html::HtmlTextArea => Celerity::TextField,
|
46
|
+
HtmlUnit::Html::HtmlTextInput => Celerity::TextField,
|
47
|
+
HtmlUnit::Html::HtmlUnorderedList => Celerity::Ul
|
45
48
|
}
|
46
49
|
|
47
50
|
def htmlunit2celerity(klass)
|
@@ -71,7 +74,7 @@ module Celerity
|
|
71
74
|
|
72
75
|
def normalize_text(string)
|
73
76
|
string.gsub("\302\240", ' '). # non-breaking space 00A0
|
74
|
-
gsub(/\n|\t/, ''
|
77
|
+
gsub(/\n|\t/, ''). # get rid of newlines/tabs
|
75
78
|
strip
|
76
79
|
end
|
77
80
|
|
data/lib/celerity/version.rb
CHANGED
@@ -25,8 +25,6 @@ module Celerity
|
|
25
25
|
# Added for Watir compatability - not in use by Celerity
|
26
26
|
def speed=(s); s end
|
27
27
|
# Added for Watir compatability - not in use by Celerity
|
28
|
-
def wait; end
|
29
|
-
# Added for Watir compatability - not in use by Celerity
|
30
28
|
def status; '' end
|
31
29
|
end
|
32
30
|
|
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.5.
|
4
|
+
version: 0.0.5.5
|
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-02-
|
14
|
+
date: 2009-02-10 00:00:00 -08:00
|
15
15
|
default_executable:
|
16
16
|
dependencies:
|
17
17
|
- !ruby/object:Gem::Dependency
|
@@ -21,7 +21,7 @@ dependencies:
|
|
21
21
|
requirements:
|
22
22
|
- - ">="
|
23
23
|
- !ruby/object:Gem::Version
|
24
|
-
version: 1.8.
|
24
|
+
version: 1.8.2
|
25
25
|
version:
|
26
26
|
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."
|
27
27
|
email: jari.bakken@finn.no
|