jarib-celerity 0.0.6.17 → 0.0.6.18
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 +1 -1
- data/lib/celerity/element_locator.rb +1 -1
- data/lib/celerity/elements/select_list.rb +25 -4
- data/lib/celerity/htmlunit/commons-codec-1.4.jar +0 -0
- data/lib/celerity/htmlunit/htmlunit-2.6-SNAPSHOT.jar +0 -0
- data/lib/celerity/htmlunit/{nekohtml-1.9.13-20090812.213532-11.jar → nekohtml-1.9.13-20090820.100833-15.jar} +0 -0
- data/lib/celerity/htmlunit/{xercesImpl-2.8.1.jar → xercesImpl-2.9.1.jar} +0 -0
- data/lib/celerity/version.rb +1 -1
- data/lib/celerity/viewer_connection.rb +30 -5
- data/lib/celerity/watir_compatibility.rb +0 -1
- metadata +22 -18
- data/lib/celerity/htmlunit/commons-codec-1.3.jar +0 -0
data/lib/celerity/browser.rb
CHANGED
@@ -58,7 +58,7 @@ module Celerity
|
|
58
58
|
raise TypeError, "wrong argument type #{opts.class}, expected Hash"
|
59
59
|
end
|
60
60
|
|
61
|
-
unless (render_types = [:html, :xml, nil]).include?(opts[:render])
|
61
|
+
unless (render_types = [:html, :xml, nil, 'html', 'xml']).include?(opts[:render])
|
62
62
|
raise ArgumentError, "expected one of #{render_types.inspect} for key :render"
|
63
63
|
end
|
64
64
|
|
@@ -34,31 +34,52 @@ module Celerity
|
|
34
34
|
end
|
35
35
|
|
36
36
|
#
|
37
|
-
# Select the option(s)
|
37
|
+
# Select the option(s) whose text or label matches the given string.
|
38
38
|
# If several options match the value given, all will be selected.
|
39
39
|
#
|
40
40
|
# @param [String, Regexp] value A value.
|
41
41
|
# @raise [Celerity::Exception::NoValueFoundException] if the value does not exist.
|
42
|
-
# @return [String
|
42
|
+
# @return [String] The option selected. If multiple options match, returns the first match
|
43
43
|
#
|
44
44
|
#
|
45
45
|
|
46
46
|
def select(value)
|
47
47
|
assert_exists
|
48
|
-
raise NoValueFoundException, "unknown option with value #{value.inspect} for select_list #{@conditions.inspect}" unless include?(value)
|
49
48
|
|
50
49
|
selected = nil
|
51
|
-
|
50
|
+
@object.getOptions.select do |option|
|
52
51
|
next unless matches_option?(option, value)
|
53
52
|
|
54
53
|
selected ||= option.asText
|
55
54
|
option.click
|
56
55
|
end
|
57
56
|
|
57
|
+
unless selected
|
58
|
+
raise NoValueFoundException, "unknown option with value #{value.inspect} for select_list #{@conditions.inspect}"
|
59
|
+
end
|
60
|
+
|
58
61
|
selected
|
59
62
|
end
|
60
63
|
alias_method :set, :select
|
61
64
|
|
65
|
+
#
|
66
|
+
# Selects the option(s) whose value attribute matches the given string.
|
67
|
+
# @param [String, Regexp] value A value.
|
68
|
+
# @raise [Celerity::Exception::NoValueFoundException] if the value does not exist.
|
69
|
+
# @return [String] The option selected. If multiple options match, returns the first match
|
70
|
+
#
|
71
|
+
|
72
|
+
def select_value(value)
|
73
|
+
assert_exists
|
74
|
+
selected = @object.getOptions.map { |e| e.click if matches?(e.getValueAttribute, value) }.compact.first
|
75
|
+
|
76
|
+
unless selected
|
77
|
+
raise NoValueFoundException, "unknown option with value #{value.inspect} for select_list #{@conditions.inspect}"
|
78
|
+
end
|
79
|
+
|
80
|
+
selected.asText
|
81
|
+
end
|
82
|
+
|
62
83
|
#
|
63
84
|
# Returns true if the select list has one or more options matching the given value.
|
64
85
|
#
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
data/lib/celerity/version.rb
CHANGED
@@ -21,7 +21,7 @@ module Celerity
|
|
21
21
|
#
|
22
22
|
|
23
23
|
def render_html(html, url)
|
24
|
-
send_data(
|
24
|
+
send_data('method' => 'page_changed', 'html' => html, 'url' => url)
|
25
25
|
end
|
26
26
|
|
27
27
|
#
|
@@ -30,16 +30,28 @@ module Celerity
|
|
30
30
|
#
|
31
31
|
|
32
32
|
def save(path)
|
33
|
-
send_data(
|
33
|
+
send_data('method' => 'save', 'path' => path)
|
34
34
|
end
|
35
35
|
|
36
|
+
|
36
37
|
#
|
37
38
|
# Tells the viewer to dump the render tree to the given path.
|
38
|
-
# Only available
|
39
|
+
# Only available in the Qt viewer.
|
39
40
|
#
|
40
41
|
|
41
42
|
def save_render_tree(path)
|
42
|
-
send_data(
|
43
|
+
send_data('method' => 'save_render_tree', 'path' => path)
|
44
|
+
end
|
45
|
+
|
46
|
+
#
|
47
|
+
# Get the currently rendered page as a Base64-encoded PNG image.
|
48
|
+
# Only available in the Qt viewer.
|
49
|
+
#
|
50
|
+
|
51
|
+
def image_data
|
52
|
+
send_data('method' => 'image_data')
|
53
|
+
data = read_data
|
54
|
+
data['image'] || data['error']
|
43
55
|
end
|
44
56
|
|
45
57
|
#
|
@@ -52,7 +64,8 @@ module Celerity
|
|
52
64
|
|
53
65
|
private
|
54
66
|
|
55
|
-
def send_data(
|
67
|
+
def send_data(msg)
|
68
|
+
json = msg.to_json
|
56
69
|
data = "Content-Length: #{json.size}\n\n#{json}"
|
57
70
|
@socket.write data
|
58
71
|
@socket.flush
|
@@ -60,5 +73,17 @@ module Celerity
|
|
60
73
|
nil
|
61
74
|
end
|
62
75
|
|
76
|
+
def read_data
|
77
|
+
buf = ''
|
78
|
+
until buf =~ /\n\n\z/ || @socket.eof? || @socket.closed?
|
79
|
+
buf << @socket.read(1).to_s
|
80
|
+
end
|
81
|
+
|
82
|
+
return if buf.empty?
|
83
|
+
|
84
|
+
length = buf[/Content-Length: (\d+)/, 1].to_i
|
85
|
+
JSON.parse @socket.read(length)
|
86
|
+
end
|
87
|
+
|
63
88
|
end
|
64
89
|
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.18
|
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-08-
|
14
|
+
date: 2009-08-25 00:00:00 -07:00
|
15
15
|
default_executable:
|
16
16
|
dependencies:
|
17
17
|
- !ruby/object:Gem::Dependency
|
@@ -32,7 +32,7 @@ dependencies:
|
|
32
32
|
requirements:
|
33
33
|
- - ">="
|
34
34
|
- !ruby/object:Gem::Version
|
35
|
-
version: 2.
|
35
|
+
version: 2.3.2
|
36
36
|
version:
|
37
37
|
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."
|
38
38
|
email: jari.bakken@finn.no
|
@@ -46,6 +46,7 @@ extra_rdoc_files:
|
|
46
46
|
files:
|
47
47
|
- History.txt
|
48
48
|
- lib
|
49
|
+
- lib/celerity
|
49
50
|
- lib/celerity/browser.rb
|
50
51
|
- lib/celerity/clickable_element.rb
|
51
52
|
- lib/celerity/collections.rb
|
@@ -55,6 +56,7 @@ files:
|
|
55
56
|
- lib/celerity/element.rb
|
56
57
|
- lib/celerity/element_collection.rb
|
57
58
|
- lib/celerity/element_locator.rb
|
59
|
+
- lib/celerity/elements
|
58
60
|
- lib/celerity/elements/button.rb
|
59
61
|
- lib/celerity/elements/file_field.rb
|
60
62
|
- lib/celerity/elements/form.rb
|
@@ -73,19 +75,8 @@ files:
|
|
73
75
|
- lib/celerity/elements/table_row.rb
|
74
76
|
- lib/celerity/elements/text_field.rb
|
75
77
|
- lib/celerity/exception.rb
|
76
|
-
- lib/celerity/htmlunit
|
77
|
-
- lib/celerity/
|
78
|
-
- lib/celerity/ignoring_web_connection.rb
|
79
|
-
- lib/celerity/input_element.rb
|
80
|
-
- lib/celerity/listener.rb
|
81
|
-
- lib/celerity/short_inspect.rb
|
82
|
-
- lib/celerity/util.rb
|
83
|
-
- lib/celerity/version.rb
|
84
|
-
- lib/celerity/viewer_connection.rb
|
85
|
-
- lib/celerity/watir_compatibility.rb
|
86
|
-
- lib/celerity/xpath_support.rb
|
87
|
-
- lib/celerity.rb
|
88
|
-
- lib/celerity/htmlunit/commons-codec-1.3.jar
|
78
|
+
- lib/celerity/htmlunit
|
79
|
+
- lib/celerity/htmlunit/commons-codec-1.4.jar
|
89
80
|
- lib/celerity/htmlunit/commons-collections-3.2.1.jar
|
90
81
|
- lib/celerity/htmlunit/commons-httpclient-3.1.jar
|
91
82
|
- lib/celerity/htmlunit/commons-io-1.4.jar
|
@@ -94,13 +85,26 @@ files:
|
|
94
85
|
- lib/celerity/htmlunit/cssparser-0.9.5.jar
|
95
86
|
- lib/celerity/htmlunit/htmlunit-2.6-SNAPSHOT.jar
|
96
87
|
- lib/celerity/htmlunit/htmlunit-core-js-2.6-SNAPSHOT.jar
|
97
|
-
- lib/celerity/htmlunit/nekohtml-1.9.13-
|
88
|
+
- lib/celerity/htmlunit/nekohtml-1.9.13-20090820.100833-15.jar
|
98
89
|
- lib/celerity/htmlunit/sac-1.3.jar
|
99
90
|
- lib/celerity/htmlunit/serializer-2.7.1.jar
|
100
91
|
- lib/celerity/htmlunit/xalan-2.7.1.jar
|
101
|
-
- lib/celerity/htmlunit/xercesImpl-2.
|
92
|
+
- lib/celerity/htmlunit/xercesImpl-2.9.1.jar
|
102
93
|
- lib/celerity/htmlunit/xml-apis-1.3.04.jar
|
94
|
+
- lib/celerity/htmlunit.rb
|
95
|
+
- lib/celerity/identifier.rb
|
96
|
+
- lib/celerity/ignoring_web_connection.rb
|
97
|
+
- lib/celerity/input_element.rb
|
98
|
+
- lib/celerity/listener.rb
|
99
|
+
- lib/celerity/resources
|
103
100
|
- lib/celerity/resources/no_viewer.png
|
101
|
+
- lib/celerity/short_inspect.rb
|
102
|
+
- lib/celerity/util.rb
|
103
|
+
- lib/celerity/version.rb
|
104
|
+
- lib/celerity/viewer_connection.rb
|
105
|
+
- lib/celerity/watir_compatibility.rb
|
106
|
+
- lib/celerity/xpath_support.rb
|
107
|
+
- lib/celerity.rb
|
104
108
|
- License.txt
|
105
109
|
- Rakefile
|
106
110
|
- README.markdown
|
Binary file
|