Class | Celerity::Browser |
In: |
lib/celerity/watir_compatibility.rb
lib/celerity/browser.rb |
Parent: | Object |
start | -> | start_window |
Added for Watir compatibility - not in use by Celerity |
attach_timeout | [RW] | Added for Watir compatibility - not in use by Celerity |
charset | [RW] | |
object | [RW] | |
options | [R] | |
page | [RW] | |
speed | [RW] | Added for Watir compatibility - not in use by Celerity |
viewer | [R] | |
visible | [RW] | Added for Watir compatibility - not in use by Celerity |
visible | [RW] | Added for Watir compatibility - not in use by Celerity |
webclient | [R] |
Creates a browser object.
@see Celerity::Container for an introduction to the main API.
@option opts :browser [:internet_explorer, :firefox, :firefox3] (:firefox3) Set the BrowserVersion used by HtmlUnit. Defaults to Firefox 3. @option opts :charset [String] ("UTF-8") Specify the charset that webclient will use for requests. @option opts :css [Boolean] (true) Enable/disable CSS. Enabled by default. @option opts :ignore_pattern [Regexp] See Browser#ignore_pattern= @option opts :javascript_enabled [Boolean] (true) Enable/disable JavaScript evaluation. Enabled by default. @option opts :javascript_exceptions [Boolean] (false) Raise exceptions on script errors. Disabled by default. @option opts :log_level [Symbol] (:warning) @see log_level= @option opts :proxy [String] (nil) Proxy server to use, in address:port format. @option opts :refresh_handler [:immediate, :waiting, :threaded] (:immediate) Set HtmlUnit‘s refresh handler. @option opts :render [:html, :xml] (:html) What DOM representation to send to connected viewers. @option opts :resynchronize [Boolean] (false) Use HtmlUnit::NicelyResynchronizingAjaxController to resynchronize Ajax calls. @option opts :secure_ssl [Boolean] (true) Enable/disable secure SSL. Enabled by default. @option opts :status_code_exceptions [Boolean] (false) Raise exceptions on failing status codes (404 etc.). Disabled by default. @option opts :user_agent [String] Override the User-Agent set by the :browser option @option opts :default_wait [Integer] The default number of seconds to wait when Browser#wait is called. @option opts :viewer [String, false] ("127.0.0.1:6429") Connect to a CelerityViewer if available.
@return [Celerity::Browser] An instance of the browser.
@api public
Initialize a browser and go to the given URL
@param [String] uri The URL to go to. @return [Celerity::Browser] instance.
Add a ‘checker’ proc that will be run on every page load
@param [Proc] checker The proc to be run (can also be given as a block) @yieldparam [Celerity::Browser] browser The current browser object. @raise [ArgumentError] if no Proc or block was given.
Add a cookie with the given parameters (Celerity only)
@param [String] domain @param [String] name @param [String] value
@option opts :path [String] ("/") A path @option opts :expires [Time] (1 day from now) An expiration date @option opts :secure [Boolean] (false)
Add a listener block for one of the available types. (Celerity only) Types map to HtmlUnit interfaces like this:
:status => StatusHandler :alert => AlertHandler ( window.alert() ) :web_window_event => WebWindowListener :html_parser => HTMLParserListener :incorrectness => IncorrectnessListener :confirm => ConfirmHandler ( window.confirm() ) :prompt => PromptHandler ( window.prompt() )
Examples:
browser.add_listener(:status) { |page, message| ... } browser.add_listener(:alert) { |page, message| ... } browser.add_listener(:web_window_event) { |web_window_event| ... } browser.add_listener(:html_parser) { |message, url, line, column, key| ... } browser.add_listener(:incorrectness) { |message, origin| ... } browser.add_listener(:confirm) { |page, message| ...; true } browser.add_listener(:prompt) { |page, message| ... }
@param [Symbol] type One of the above symbols. @param [Proc] block A block to be executed for events of this type.
Check that we have a @page object.
@raise [UnknownObjectException] if no page is loaded. @api private
Allows you to temporarliy switch to HtmlUnit‘s default AjaxController, so ajax calls are performed asynchronously. This is useful if you have created the Browser with :resynchronize => true, but want to switch it off temporarily.
@yieldparam [Celerity::Browser] browser The current browser object. @see Celerity::Browser#new
Set the credentials used for basic HTTP authentication. (Celerity only)
Example:
browser.credentials = "username:password"
@param [String] A string with username / password, separated by a colon
If a request is made to an URL that matches the pattern set here, Celerity will ignore the request and return an empty page with content type "text/html" instead.
This is useful to block unwanted requests (like ads/banners).
:finest, :finer, :fine, :config, :info, :warning, :severe, or :off, :all
@return [Symbol] the current log level
Sets the current page object for the browser
@param [HtmlUnit::HtmlPage] value The page to set. @api private
Remove the cookie with the given domain and name (Celerity only)
@param [String] domain @param [String] name
@raise [CookieNotFoundError] if the cookie doesn‘t exist
Allows you to temporarily switch to HtmlUnit‘s NicelyResynchronizingAjaxController to resynchronize ajax calls.
@browser.resynchronized do |b| b.link(:id, 'trigger_ajax_call').click end
@yieldparam [Celerity::Browser] browser The current browser object. @see Celerity::Browser#new for how to configure the browser to always use this.
Wait until the given block evaluates to true (Celerity only)
@param [Fixnum] timeout Number of seconds to wait before timing out (default: 30). @yieldparam [Celerity::Browser] browser The browser instance. @see Celerity::Browser#resynchronized
Wait while the given block evaluates to true (Celerity only)
@param [Fixnum] timeout Number of seconds to wait before timing out (default: 30). @yieldparam [Celerity::Browser] browser The browser instance. @see Celerity::Browser#resynchronized