Repository navigation
FAQ
Either instantiate the Browser with
browser = Celerity::Browser.new(:log_level => :off)or set it later
browser.log_level = :offSee also the full list of supported options.
To stay compatible with Watir, locating elements by :index or fetching elements from ElementCollection subclasses is 1-indexed.
To change this to zero-index, versions >= 0.0.6.10 lets you set
Celerity.index_offset = 0Celerity encodes all strings as UTF-8, so if you save your test scripts as UTF-8 everything should work fine.
To make Watir use UTF-8, add this line to your test suite (WTR-219):
WIN32OLE.codepage = WIN32OLE::CP_UTF8 Celerity uses HtmlUnit, a headless Java browser library, to interact with web pages, which makes it a lot faster than driving
a real browser at the cost of not having any visual feedback from your tests. To work around this you can use one of apps from the CelerityViewers repo to simulate driving a browser. Celerity won’t actually drive these, but sends them an HTML string over DRb on every page load.
See Ajax.
Use ClickableElement#click_and_attach. This method returns a new browser instance with the page returned when clicking the element.
Example:
popup_browser = browser.link(:id, 'popup').click_and_attach
# do something with popup_browser
popup_browser.close
# continue working with browser
HtmlUnit provides a listener interface for alert() and confirm() calls.
To access this with Celerity, you can use:
browser.add_listener(:alert) { |page, message| ... }browser.add_listener(:confirm) { |page, message| ... }If the value returned from the :confirm block is false, the "Cancel" button will be clicked.
You can also use Browser#confirm for easier interaction:
browser.confirm(false) do
# trigger confirm() call
endIf you have a link or button that returns a document you normally wouldn’t view in a browser, you can use ClickableElement#download to get an IO object instead.
browser.link(:id, 'pdf').download #=> #<IO:0x11ce78c>
This is caused by a JRuby bug in versions pre-1.2.
Update to JRuby >= 1.2 to get rid of this problem.
This is caused by a JRuby bug, and only appears when running off jruby-complete.jar. Until the bug is fixed, you can solve the problem by doing a proper install of JRuby or adding this:
require "thread.rb"