Module | Celerity::Container |
In: |
lib/celerity/container.rb
lib/celerity/watir_compatibility.rb |
This class contains methods for accessing elements inside a container, usually the Browser object, meaning the current page. The most common syntax is
browser.elem(:attribute, 'value')
Note that the element is located lazily, so no exceptions will be raised if the element doesn‘t exist until you call a method on the resulting object. To do this you would normally use Element#exists? or an action method, like ClickableElement#click. You can also pass in a hash:
browser.link(:index => 1).click
All elements support multiple attributes identification using the hash syntax (though this might not always be compatible with Watir):
browser.span(:class_name => 'product', :index => 5).text
Checkboxes and radio buttons support a special three-argument syntax:
browser.check_box(:name, 'a_name', '1234').set
You can also get all the elements of a certain type by using the plural form (@see Celerity::ElementCollection):
browser.links # => #<Celerity::Links:0x7a1c2da2 ...>
browser | [R] | Points back to the Browser instance that contains this element |
Since finding checkboxes by value is very common, you can use this shorthand:
browser.check_box(:name, 'a_name', '1234').set
or
browser.check_box(:name => 'a_name', :value => '1234').set
@return [Celerity::CheckBox]
Check if the element contains the given text.
@param [String, Regexp] expected_text The text to look for. @return [Fixnum, nil] The index of the matched text, or nil if it doesn‘t match.
Since finding radios by value is very common, you can use this shorthand:
browser.radio(:name, 'a_name', '1234').set
or
browser.radio(:name => 'a_name', :value => '1234').set
@return [Celerity::Radio]