jarib-celerity 0.0.5.11 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
data/History.txt CHANGED
@@ -1,3 +1,36 @@
1
+ == 0.0.6 2009-03-19
2
+ * Support for meta, strong, dl, dt, dd, and em HTML elements.
3
+ * Update to HtmlUnit 2.5-SNAPSHOT.
4
+ * New options for Browser#new: :proxy, :charset, :render, :log_level
5
+ * Methods added:
6
+ - Browser#add_cookie
7
+ - Browser#asynchronized
8
+ - Browser#add_listener
9
+ - Browser#content_type
10
+ - Browser#cookies
11
+ - Browser#debug_web_connection
12
+ - Browser#focused_element
13
+ - Browser#io
14
+ - Browser#remove_cookie
15
+ - Browser#response_headers
16
+ - Browser#wait
17
+ - Browser#xml
18
+ - Browser#{element,elements}_by_xpath
19
+ - ClickableElement#{double,right}_click
20
+ - ElementCollection#{first,last}
21
+ * Methods removed:
22
+ - Browser#show_*
23
+ * Methods renamed:
24
+ - SelectList#get_all_contents => SelectList#options
25
+ - SelectList#get_selected_items => selected_options
26
+ - SelectList#clear_selection => SelectList#clear
27
+ * Add support for finding elements by their corresponding <label>.
28
+ * Recognize buttons of type image, reset, submit.
29
+ * Proxy support (see Browser.new)
30
+ * Lots of refactorings, bug fixes and minor enhancements.
31
+
32
+ Thanks to Hirobumi Hama, Kamal Fariz Mahyuddin and Thomas Marek for contributions in this release.
33
+
1
34
  == 0.0.4 2008-08-18
2
35
  * Minor enhancements
3
36
  * Update HtmlUnit to 2.2
data/README.txt CHANGED
@@ -18,7 +18,7 @@ web applications. Celerity aims at being API compatible with Watir.
18
18
 
19
19
  == REQUIREMENTS:
20
20
 
21
- * JRuby 1.1.5 or higher
21
+ * JRuby 1.2.0 or higher
22
22
  * Java 6
23
23
 
24
24
  == INSTALL:
@@ -231,7 +231,7 @@ module Celerity
231
231
  # Get all the elements matching the given XPath.
232
232
  #
233
233
  # @param [String] xpath
234
- # @retrun [Array<Celerity::Element>] array of elements
234
+ # @return [Array<Celerity::Element>] array of elements
235
235
  #
236
236
 
237
237
  def elements_by_xpath(xpath)
@@ -288,17 +288,60 @@ module Celerity
288
288
  #
289
289
  # Get the cookies for this session. (Celerity only)
290
290
  #
291
+ # @return [Hash<domain, Hash<name, value>>]
292
+ #
291
293
 
292
294
  def cookies
293
- result = {}
295
+ result = Hash.new { |hash, key| hash[key] = {} }
294
296
 
295
- cookies = @webclient.getCookieManager.getCookies.to_a
297
+ cookies = @webclient.getCookieManager.getCookies
296
298
  cookies.each do |cookie|
297
- result[cookie.getName] = cookie.getValue
299
+ result[cookie.getDomain][cookie.getName] = cookie.getValue
298
300
  end
299
301
 
300
302
  result
301
303
  end
304
+
305
+ #
306
+ # Add a cookie with the given parameters (Celerity only)
307
+ #
308
+ # @param [String] domain
309
+ # @param [String] name
310
+ # @param [String] value
311
+ #
312
+ # @option opts :path [String] ("/") A path
313
+ # @option opts :max_age [Fixnum] (??) A max age
314
+ # @option opts :secure [Boolean] (false)
315
+ #
316
+
317
+ def add_cookie(domain, name, value, opts = {})
318
+ path = opts.delete(:path) || "/"
319
+ max_age = opts.delete(:max_age) || (Time.now + 60*60*24) # not sure if this is correct
320
+ secure = opts.delete(:secure) || false
321
+
322
+ raise "unknown option: #{opts.inspect}" unless opts.empty?
323
+
324
+ cookie = Cookie.new(domain, name, value, path, max_age, secure)
325
+ @webclient.getCookieManager.addCookie(cookie)
326
+ end
327
+
328
+ #
329
+ # Remove the cookie with the given domain and name (Celerity only)
330
+ #
331
+ # @param [String] domain
332
+ # @param [String] name
333
+ #
334
+
335
+ def remove_cookie(domain, name)
336
+ cm = @webclient.getCookieManager
337
+ cookie = cm.getCookies.find { |c| c.getDomain == domain && c.getName == name }
338
+
339
+ if cookie.nil?
340
+ raise "no cookie with domain #{domain.inspect} and name #{name.inspect}"
341
+ end
342
+
343
+ cm.removeCookie(cookie)
344
+ end
302
345
 
303
346
  #
304
347
  # Execute the given JavaScript on the current page.
@@ -310,7 +353,7 @@ module Celerity
310
353
  @page.executeJavaScript(source.to_s).getJavaScriptResult
311
354
  end
312
355
 
313
- # experimental
356
+ # experimental - should be removed?
314
357
  def send_keys(keys)
315
358
  keys = keys.gsub(/\s*/, '').scan(/((?:\{[A-Z]+?\})|.)/u).flatten
316
359
  keys.each do |key|
@@ -40,7 +40,7 @@ module Celerity
40
40
  when :xpath
41
41
  return find_by_xpath(what)
42
42
  when :label
43
- return find_by_label(what)
43
+ return find_by_label(what) unless @attributes.include?(:label)
44
44
  when :class_name
45
45
  how = :class
46
46
  when :url
@@ -22,5 +22,11 @@ module Celerity
22
22
  assert_exists
23
23
  @object.isSelected
24
24
  end
25
+
26
+ def label
27
+ # overrides Container#label
28
+ assert_exists
29
+ @object.getAttribute("label")
30
+ end
25
31
  end
26
32
  end
@@ -1,8 +1,11 @@
1
1
  module Celerity
2
2
  Jars = Dir[File.dirname(__FILE__) + '/htmlunit/*.jar']
3
+ Jars.each { |jar| require(jar) }
4
+
5
+ include_class org.apache.commons.httpclient.Cookie
3
6
  end
4
7
 
5
- Celerity::Jars.each { |jar| require(jar) }
8
+
6
9
 
7
10
  module HtmlUnit
8
11
  include_package 'com.gargoylesoftware.htmlunit'
@@ -2,8 +2,8 @@ module Celerity #:nodoc:
2
2
  module VERSION #:nodoc:
3
3
  MAJOR = 0
4
4
  MINOR = 0
5
- TINY = 5
6
- PATCH = 11 # Set to nil for official release
5
+ TINY = 6
6
+ PATCH = nil # Set to nil for official release
7
7
 
8
8
  STRING = [MAJOR, MINOR, TINY, PATCH].compact.join('.')
9
9
  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.5.11
4
+ version: 0.0.6
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-03-11 00:00:00 -07:00
14
+ date: 2009-03-19 00:00:00 -07:00
15
15
  default_executable:
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency