jarib-celerity 0.0.6 → 0.0.6.1
Sign up to get free protection for your applications and to get access to all the features.
data/lib/celerity/browser.rb
CHANGED
@@ -89,7 +89,9 @@ module Celerity
|
|
89
89
|
request = HtmlUnit::WebRequestSettings.new(::Java::JavaNet::URL.new(uri))
|
90
90
|
request.setCharset(@charset)
|
91
91
|
|
92
|
-
|
92
|
+
rescue_status_code_exception do
|
93
|
+
self.page = @webclient.getPage(request)
|
94
|
+
end
|
93
95
|
|
94
96
|
url()
|
95
97
|
end
|
@@ -180,6 +182,14 @@ module Celerity
|
|
180
182
|
|
181
183
|
Hash[*@page.getWebResponse.getResponseHeaders.map { |obj| [obj.name, obj.value] }.flatten]
|
182
184
|
end
|
185
|
+
|
186
|
+
#
|
187
|
+
# @return [Fixnum] status code of the last request
|
188
|
+
#
|
189
|
+
|
190
|
+
def status_code
|
191
|
+
@page.getWebResponse.getStatusCode
|
192
|
+
end
|
183
193
|
|
184
194
|
#
|
185
195
|
# @return [String] content-type as in 'text/html'
|
@@ -190,7 +200,7 @@ module Celerity
|
|
190
200
|
|
191
201
|
@page.getWebResponse.getContentType
|
192
202
|
end
|
193
|
-
|
203
|
+
|
194
204
|
#
|
195
205
|
# @return [IO, nil] page contents as an IO, returns nil if no page is loaded.
|
196
206
|
#
|
@@ -265,7 +275,7 @@ module Celerity
|
|
265
275
|
|
266
276
|
def wait
|
267
277
|
assert_exists
|
268
|
-
@page.getEnclosingWindow.getJobManager.
|
278
|
+
@page.getEnclosingWindow.getJobManager.waitForJobs(10000)
|
269
279
|
end
|
270
280
|
|
271
281
|
#
|
@@ -535,6 +545,36 @@ module Celerity
|
|
535
545
|
!!@page
|
536
546
|
end
|
537
547
|
alias_method :exists?, :exist?
|
548
|
+
|
549
|
+
#
|
550
|
+
# Turn on/off javascript exceptions
|
551
|
+
#
|
552
|
+
# @param [Bool]
|
553
|
+
#
|
554
|
+
|
555
|
+
def javascript_exceptions=(bool)
|
556
|
+
@webclient.throwExceptionOnScriptError = bool
|
557
|
+
end
|
558
|
+
|
559
|
+
def javascript_exceptions
|
560
|
+
@webclient.throwExceptionOnScriptError
|
561
|
+
end
|
562
|
+
|
563
|
+
#
|
564
|
+
# Turn on/off status code exceptions
|
565
|
+
#
|
566
|
+
# @param [Bool]
|
567
|
+
#
|
568
|
+
|
569
|
+
def status_code_exceptions=(bool)
|
570
|
+
@webclient.throwExceptionOnFailingStatusCode = bool
|
571
|
+
end
|
572
|
+
|
573
|
+
def status_code_exceptions
|
574
|
+
@webclient.throwExceptionOnFailingStatusCode
|
575
|
+
end
|
576
|
+
|
577
|
+
|
538
578
|
|
539
579
|
#
|
540
580
|
# Sets the current page object for the browser
|
@@ -615,13 +655,13 @@ module Celerity
|
|
615
655
|
@webclient = ::HtmlUnit::WebClient.new(browser_version)
|
616
656
|
end
|
617
657
|
|
618
|
-
|
619
|
-
|
620
|
-
@webclient.cssEnabled
|
621
|
-
@webclient.useInsecureSSL
|
658
|
+
self.javascript_exceptions = false unless opts.delete(:javascript_exceptions)
|
659
|
+
self.status_code_exceptions = false unless opts.delete(:status_code_exceptions)
|
660
|
+
@webclient.cssEnabled = false unless opts.delete(:css)
|
661
|
+
@webclient.useInsecureSSL = opts.delete(:secure_ssl) == false
|
622
662
|
@webclient.setAjaxController(::HtmlUnit::NicelyResynchronizingAjaxController.new) if opts.delete(:resynchronize)
|
623
663
|
end
|
624
|
-
|
664
|
+
|
625
665
|
#
|
626
666
|
# This *should* be unneccessary, but sometimes the page we get from the
|
627
667
|
# window is different (ie. a different object) from our current @page
|
@@ -7,7 +7,7 @@ module Celerity
|
|
7
7
|
|
8
8
|
def click
|
9
9
|
assert_exists_and_enabled
|
10
|
-
@container.update_page(@object.click)
|
10
|
+
rescue_status_code_exception { @container.update_page(@object.click) }
|
11
11
|
end
|
12
12
|
|
13
13
|
#
|
@@ -16,7 +16,7 @@ module Celerity
|
|
16
16
|
|
17
17
|
def double_click
|
18
18
|
assert_exists_and_enabled
|
19
|
-
@container.update_page(@object.dblClick)
|
19
|
+
rescue_status_code_exception { @container.update_page(@object.dblClick) }
|
20
20
|
end
|
21
21
|
|
22
22
|
#
|
@@ -25,7 +25,7 @@ module Celerity
|
|
25
25
|
|
26
26
|
def right_click
|
27
27
|
assert_exists_and_enabled
|
28
|
-
@container.update_page(@object.rightClick)
|
28
|
+
rescue_status_code_exception { @container.update_page(@object.rightClick) }
|
29
29
|
end
|
30
30
|
|
31
31
|
#
|
@@ -38,7 +38,7 @@ module Celerity
|
|
38
38
|
def click_and_attach
|
39
39
|
assert_exists_and_enabled
|
40
40
|
browser = Browser.new(:log_level => @browser.log_level)
|
41
|
-
browser.update_page(@object.click)
|
41
|
+
rescue_status_code_exception { browser.update_page(@object.click) }
|
42
42
|
|
43
43
|
browser
|
44
44
|
end
|
data/lib/celerity/container.rb
CHANGED
@@ -75,20 +75,6 @@ module Celerity
|
|
75
75
|
@browser.page = page
|
76
76
|
end
|
77
77
|
|
78
|
-
#
|
79
|
-
# Used internally.
|
80
|
-
#
|
81
|
-
# @param [String] string The string to match against.
|
82
|
-
# @param [Regexp, String, #to_s] what The match we're looking for.
|
83
|
-
# @return [Fixnum, true, false, nil]
|
84
|
-
#
|
85
|
-
# @api private
|
86
|
-
#
|
87
|
-
|
88
|
-
def matches?(string, what)
|
89
|
-
Regexp === what ? string =~ what : string == what.to_s
|
90
|
-
end
|
91
|
-
|
92
78
|
#--
|
93
79
|
# below methods sorted alphabetically
|
94
80
|
#++
|
@@ -761,6 +747,33 @@ module Celerity
|
|
761
747
|
def uls
|
762
748
|
Uls.new(self)
|
763
749
|
end
|
750
|
+
|
751
|
+
private
|
752
|
+
|
753
|
+
#
|
754
|
+
# Used internally.
|
755
|
+
#
|
756
|
+
# @param [String] string The string to match against.
|
757
|
+
# @param [Regexp, String, #to_s] what The match we're looking for.
|
758
|
+
# @return [Fixnum, true, false, nil]
|
759
|
+
#
|
760
|
+
# @api private
|
761
|
+
#
|
762
|
+
|
763
|
+
def matches?(string, what)
|
764
|
+
Regexp === what ? string =~ what : string == what.to_s
|
765
|
+
end
|
766
|
+
|
767
|
+
#
|
768
|
+
# Rescues HtmlUnit::FailingHttpStatusCodeException and re-raises as
|
769
|
+
# Celerity::NavigationException to avoid the huge JRuby backtrace
|
770
|
+
#
|
771
|
+
|
772
|
+
def rescue_status_code_exception(&blk)
|
773
|
+
yield
|
774
|
+
rescue HtmlUnit::FailingHttpStatusCodeException => e
|
775
|
+
raise NavigationException, e.message, caller
|
776
|
+
end
|
764
777
|
|
765
778
|
end # Container
|
766
779
|
end # Celerity
|
Binary file
|
data/lib/celerity/listener.rb
CHANGED
data/lib/celerity/version.rb
CHANGED
data/lib/celerity.rb
CHANGED
@@ -2,13 +2,13 @@ $:.unshift(File.dirname(__FILE__)) unless $:.include?(File.dirname(__FILE__)) ||
|
|
2
2
|
|
3
3
|
raise "Celerity only works on JRuby at the moment." unless RUBY_PLATFORM =~ /java/
|
4
4
|
|
5
|
-
require
|
5
|
+
require "java"
|
6
6
|
require "logger"
|
7
7
|
require "uri"
|
8
8
|
require "pp"
|
9
9
|
require "timeout"
|
10
10
|
require "time"
|
11
|
-
require
|
11
|
+
require "drb"
|
12
12
|
require "fileutils"
|
13
13
|
require "thread"
|
14
14
|
|
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.1
|
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-
|
14
|
+
date: 2009-03-28 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: 1.
|
25
|
+
version: 1.11.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
|