Module: Celerity::Container
- Includes:
- Exception, ShortInspect
- Defined in:
- lib/celerity/container.rb,
lib/celerity/watir_compatibility.rb
Overview
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 ...>
Instance Attribute Summary collapse
-
#browser ⇒ Object
readonly
Points back to the Browser instance that contains this element.
Instance Method Summary collapse
- #area(*args) ⇒ Celerity::Area
- #areas ⇒ Celerity::Areas
- #button(*args) ⇒ Celerity::Button
- #buttons ⇒ Celerity::Buttons
- #cell(*args) ⇒ Celerity::TableCell
- #cells ⇒ Celerity::TableCells
-
#check_box(*args) ⇒ Celerity::CheckBox
(also: #checkbox, #checkBox)
Since finding checkboxes by value is very common, you can use this shorthand:.
- #checkboxes ⇒ Celerity::CheckBoxes
-
#container=(container) ⇒ Object
private
Used internally to update the container object.
-
#contains_text(expected_text) ⇒ Fixnum?
Check if the element contains the given text.
- #dd(*args) ⇒ Celerity::Dd
- #dds ⇒ Celerity::Dds
- #div(*args) ⇒ Celerity::Div
- #divs ⇒ Celerity::Divs
- #dl(*args) ⇒ Celerity::Dl
- #dls ⇒ Celerity::Dls
- #dt(*args) ⇒ Celerity::Dt
- #dts ⇒ Celerity::Dts
- #em(*args) ⇒ Celerity::Em
- #ems ⇒ Celerity::Ems
- #file_field(*args) ⇒ Celerity::FileField
- #file_fields ⇒ Celerity::FileFields
- #form(*args) ⇒ Celerity::Form
- #forms ⇒ Celerity::Forms
- #frame(*args) ⇒ Celerity::Frame
- #frames ⇒ Celerity::Frames
- #h1(*args) ⇒ Celerity::H1
- #h1s ⇒ Celerity::H1s
- #h2(*args) ⇒ Celerity::H2
- #h2s ⇒ Celerity::H2s
- #h3(*args) ⇒ Celerity::H3
- #h3s ⇒ Celerity::H3s
- #h4(*args) ⇒ Celerity::H4
- #h4s ⇒ Celerity::H4s
- #h5(*args) ⇒ Celerity::H5
- #h5s ⇒ Celerity::H5s
- #h6(*args) ⇒ Celerity::H6
- #h6s ⇒ Celerity::H6s
- #hidden(*args) ⇒ Celerity::Hidden
- #hiddens ⇒ Celerity::Hiddens
- #image(*args) ⇒ Celerity::Image
- #images ⇒ Celerity::Images
-
#inspect ⇒ Object
Override inspect for readability.
- #label(*args) ⇒ Celerity::Label
- #labels ⇒ Celerity::Labels
- #li(*args) ⇒ Celerity::Li
- #link(*args) ⇒ Celerity::Link
- #links ⇒ Celerity::Links
- #lis ⇒ Celerity::Lis
- #map(*args) ⇒ Celerity::Map
- #maps ⇒ Celerity::Maps
- #meta(*args) ⇒ Celerity::Meta
- #metas(*args) ⇒ Celerity::Metas
- #ol(*args) ⇒ Celerity::Ol
- #ols ⇒ Celerity::Ols
- #option(*args) ⇒ Celerity::Option
- #p(*args) ⇒ Celerity::P
- #pre(*args) ⇒ Celerity::Pre
- #pres ⇒ Celerity::Pres
- #ps ⇒ Celerity::Ps
-
#radio(*args) ⇒ Celerity::Radio
Since finding radios by value is very common, you can use this shorthand:.
- #radios ⇒ Celerity::Radios
- #row(*args) ⇒ Celerity::TableRow
- #rows ⇒ Celerity::TableRows
- #select_list(*args) ⇒ Celerity::SelectList
- #select_lists ⇒ Celerity::SelectLists
- #span(*args) ⇒ Celerity::Span
- #spans ⇒ Celerity::Spans
- #strong(*args) ⇒ Celerity::Spans
- #strongs ⇒ Celerity::Strongs
- #table(*args) ⇒ Celerity::Table
- #tables ⇒ Celerity::Tables
- #tbodies ⇒ Celerity::TableBodies (also: #bodies)
- #tbody(*args) ⇒ Celerity::TableBody (also: #body)
- #text_field(*args) ⇒ Celerity::TextField
- #text_fields ⇒ Celerity::TextFields
- #tfoot(*args) ⇒ Celerity::TableFooter
- #tfoots ⇒ Celerity::TableFooters (also: #tfeet)
-
#th(*args) ⇒ Celerity::Th
Watir’s cells() won’t find <th> elements.
- #thead(*args) ⇒ Celerity::TableHeader
- #theads ⇒ Celerity::TableHeaders
-
#ths ⇒ Object
FIXME: implement or change api,.
- #ul(*args) ⇒ Celerity::Ul
- #uls ⇒ Celerity::Uls
Methods included from ShortInspect
Instance Attribute Details
#browser ⇒ Object (readonly)
Points back to the Browser instance that contains this element
36 37 38 |
# File 'lib/celerity/container.rb', line 36 def browser @browser end |
Instance Method Details
#area(*args) ⇒ Celerity::Area
86 87 88 |
# File 'lib/celerity/container.rb', line 86 def area(*args) Area.new(self, *args) end |
#areas ⇒ Celerity::Areas
94 95 96 |
# File 'lib/celerity/container.rb', line 94 def areas Areas.new(self) end |
#button(*args) ⇒ Celerity::Button
102 103 104 |
# File 'lib/celerity/container.rb', line 102 def (*args) Button.new(self, *args) end |
#buttons ⇒ Celerity::Buttons
110 111 112 |
# File 'lib/celerity/container.rb', line 110 def Buttons.new(self) end |
#cell(*args) ⇒ Celerity::TableCell
118 119 120 |
# File 'lib/celerity/container.rb', line 118 def cell(*args) TableCell.new(self, *args) end |
#cells ⇒ Celerity::TableCells
126 127 128 |
# File 'lib/celerity/container.rb', line 126 def cells TableCells.new(self) end |
#check_box(*args) ⇒ Celerity::CheckBox Also known as: checkbox, checkBox
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
142 143 144 |
# File 'lib/celerity/container.rb', line 142 def check_box(*args) CheckBox.new(self, *args) end |
#checkboxes ⇒ Celerity::CheckBoxes
150 151 152 |
# File 'lib/celerity/container.rb', line 150 def checkboxes CheckBoxes.new(self) end |
#container=(container) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Used internally to update the container object.
72 73 74 75 76 |
# File 'lib/celerity/container.rb', line 72 def container=(container) @container = container @browser = container.browser container end |
#contains_text(expected_text) ⇒ Fixnum?
Check if the element contains the given text.
45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/celerity/container.rb', line 45 def contains_text(expected_text) assert_exists return nil unless respond_to? :text case expected_text when Regexp text() =~ expected_text when String text().index(expected_text) else raise TypeError, "expected String or Regexp, got #{expected_text.inspect}:#{expected_text.class}" end end |
#dd(*args) ⇒ Celerity::Dd
158 159 160 |
# File 'lib/celerity/container.rb', line 158 def dd(*args) Dd.new(self, *args) end |
#dds ⇒ Celerity::Dds
166 167 168 |
# File 'lib/celerity/container.rb', line 166 def dds Dds.new(self) end |
#div(*args) ⇒ Celerity::Div
174 175 176 |
# File 'lib/celerity/container.rb', line 174 def div(*args) Div.new(self, *args) end |
#divs ⇒ Celerity::Divs
182 183 184 |
# File 'lib/celerity/container.rb', line 182 def divs Divs.new(self) end |
#dl(*args) ⇒ Celerity::Dl
190 191 192 |
# File 'lib/celerity/container.rb', line 190 def dl(*args) Dl.new(self, *args) end |
#dls ⇒ Celerity::Dls
198 199 200 |
# File 'lib/celerity/container.rb', line 198 def dls Dls.new(self) end |
#dt(*args) ⇒ Celerity::Dt
206 207 208 |
# File 'lib/celerity/container.rb', line 206 def dt(*args) Dt.new(self, *args) end |
#dts ⇒ Celerity::Dts
214 215 216 |
# File 'lib/celerity/container.rb', line 214 def dts Dts.new(self) end |
#em(*args) ⇒ Celerity::Em
222 223 224 |
# File 'lib/celerity/container.rb', line 222 def em(*args) Em.new(self, *args) end |
#ems ⇒ Celerity::Ems
230 231 232 |
# File 'lib/celerity/container.rb', line 230 def ems Ems.new(self) end |
#file_field(*args) ⇒ Celerity::FileField
238 239 240 |
# File 'lib/celerity/container.rb', line 238 def file_field(*args) FileField.new(self, *args) end |
#file_fields ⇒ Celerity::FileFields
246 247 248 |
# File 'lib/celerity/container.rb', line 246 def file_fields FileFields.new(self) end |
#form(*args) ⇒ Celerity::Form
254 255 256 |
# File 'lib/celerity/container.rb', line 254 def form(*args) Form.new(self, *args) end |
#forms ⇒ Celerity::Forms
262 263 264 |
# File 'lib/celerity/container.rb', line 262 def forms Forms.new(self) end |
#frame(*args) ⇒ Celerity::Frame
270 271 272 |
# File 'lib/celerity/container.rb', line 270 def frame(*args) Frame.new(self, *args) end |
#frames ⇒ Celerity::Frames
278 279 280 |
# File 'lib/celerity/container.rb', line 278 def frames Frames.new(self) end |
#h1(*args) ⇒ Celerity::H1
286 287 288 |
# File 'lib/celerity/container.rb', line 286 def h1(*args) H1.new(self, *args) end |
#h1s ⇒ Celerity::H1s
294 295 296 |
# File 'lib/celerity/container.rb', line 294 def h1s H1s.new(self) end |
#h2(*args) ⇒ Celerity::H2
302 303 304 |
# File 'lib/celerity/container.rb', line 302 def h2(*args) H2.new(self, *args) end |
#h2s ⇒ Celerity::H2s
310 311 312 |
# File 'lib/celerity/container.rb', line 310 def h2s H2s.new(self) end |
#h3(*args) ⇒ Celerity::H3
318 319 320 |
# File 'lib/celerity/container.rb', line 318 def h3(*args) H3.new(self, *args) end |
#h3s ⇒ Celerity::H3s
326 327 328 |
# File 'lib/celerity/container.rb', line 326 def h3s H3s.new(self) end |
#h4(*args) ⇒ Celerity::H4
334 335 336 |
# File 'lib/celerity/container.rb', line 334 def h4(*args) H4.new(self, *args) end |
#h4s ⇒ Celerity::H4s
342 343 344 |
# File 'lib/celerity/container.rb', line 342 def h4s H4s.new(self) end |
#h5(*args) ⇒ Celerity::H5
350 351 352 |
# File 'lib/celerity/container.rb', line 350 def h5(*args) H5.new(self, *args) end |
#h5s ⇒ Celerity::H5s
358 359 360 |
# File 'lib/celerity/container.rb', line 358 def h5s H5s.new(self) end |
#h6(*args) ⇒ Celerity::H6
366 367 368 |
# File 'lib/celerity/container.rb', line 366 def h6(*args) H6.new(self, *args) end |
#h6s ⇒ Celerity::H6s
374 375 376 |
# File 'lib/celerity/container.rb', line 374 def h6s H6s.new(self) end |
#hidden(*args) ⇒ Celerity::Hidden
382 383 384 |
# File 'lib/celerity/container.rb', line 382 def hidden(*args) Hidden.new(self, *args) end |
#hiddens ⇒ Celerity::Hiddens
390 391 392 |
# File 'lib/celerity/container.rb', line 390 def hiddens Hiddens.new(self) end |
#image(*args) ⇒ Celerity::Image
398 399 400 |
# File 'lib/celerity/container.rb', line 398 def image(*args) Image.new(self, *args) end |
#images ⇒ Celerity::Images
406 407 408 |
# File 'lib/celerity/container.rb', line 406 def images Images.new(self) end |
#inspect ⇒ Object
Override inspect for readability
63 64 65 |
# File 'lib/celerity/container.rb', line 63 def inspect short_inspect :include => %w[@conditions @object] end |
#label(*args) ⇒ Celerity::Label
414 415 416 |
# File 'lib/celerity/container.rb', line 414 def label(*args) Label.new(self, *args) end |
#labels ⇒ Celerity::Labels
422 423 424 |
# File 'lib/celerity/container.rb', line 422 def labels Labels.new(self) end |
#li(*args) ⇒ Celerity::Li
430 431 432 |
# File 'lib/celerity/container.rb', line 430 def li(*args) Li.new(self, *args) end |
#link(*args) ⇒ Celerity::Link
446 447 448 |
# File 'lib/celerity/container.rb', line 446 def link(*args) Link.new(self, *args) end |
#links ⇒ Celerity::Links
454 455 456 |
# File 'lib/celerity/container.rb', line 454 def links Links.new(self) end |
#lis ⇒ Celerity::Lis
438 439 440 |
# File 'lib/celerity/container.rb', line 438 def lis Lis.new(self) end |
#map(*args) ⇒ Celerity::Map
462 463 464 |
# File 'lib/celerity/container.rb', line 462 def map(*args) Map.new(self, *args) end |
#maps ⇒ Celerity::Maps
470 471 472 |
# File 'lib/celerity/container.rb', line 470 def maps Maps.new(self) end |
#meta(*args) ⇒ Celerity::Meta
478 479 480 |
# File 'lib/celerity/container.rb', line 478 def (*args) Meta.new(self, *args) end |
#metas(*args) ⇒ Celerity::Metas
486 487 488 |
# File 'lib/celerity/container.rb', line 486 def (*args) Metas.new(self, *args) end |
#ol(*args) ⇒ Celerity::Ol
494 495 496 |
# File 'lib/celerity/container.rb', line 494 def ol(*args) Ol.new(self, *args) end |
#ols ⇒ Celerity::Ols
502 503 504 |
# File 'lib/celerity/container.rb', line 502 def ols Ols.new(self) end |
#option(*args) ⇒ Celerity::Option
510 511 512 |
# File 'lib/celerity/container.rb', line 510 def option(*args) Option.new(self, *args) end |
#p(*args) ⇒ Celerity::P
518 519 520 |
# File 'lib/celerity/container.rb', line 518 def p(*args) P.new(self, *args) end |
#pre(*args) ⇒ Celerity::Pre
534 535 536 |
# File 'lib/celerity/container.rb', line 534 def pre(*args) Pre.new(self, *args) end |
#pres ⇒ Celerity::Pres
542 543 544 |
# File 'lib/celerity/container.rb', line 542 def pres Pres.new(self) end |
#radio(*args) ⇒ Celerity::Radio
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
558 559 560 |
# File 'lib/celerity/container.rb', line 558 def radio(*args) Radio.new(self, *args) end |
#radios ⇒ Celerity::Radios
566 567 568 |
# File 'lib/celerity/container.rb', line 566 def radios Radios.new(self) end |
#row(*args) ⇒ Celerity::TableRow
574 575 576 |
# File 'lib/celerity/container.rb', line 574 def row(*args) TableRow.new(self, *args) end |
#rows ⇒ Celerity::TableRows
582 583 584 |
# File 'lib/celerity/container.rb', line 582 def rows TableRows.new(self) end |
#select_list(*args) ⇒ Celerity::SelectList
590 591 592 |
# File 'lib/celerity/container.rb', line 590 def select_list(*args) SelectList.new(self, *args) end |
#select_lists ⇒ Celerity::SelectLists
598 599 600 |
# File 'lib/celerity/container.rb', line 598 def select_lists SelectLists.new(self) end |
#span(*args) ⇒ Celerity::Span
606 607 608 |
# File 'lib/celerity/container.rb', line 606 def span(*args) Span.new(self, *args) end |
#spans ⇒ Celerity::Spans
614 615 616 |
# File 'lib/celerity/container.rb', line 614 def spans Spans.new(self) end |
#strong(*args) ⇒ Celerity::Spans
622 623 624 |
# File 'lib/celerity/container.rb', line 622 def strong(*args) Strong.new(self, *args) end |
#strongs ⇒ Celerity::Strongs
630 631 632 |
# File 'lib/celerity/container.rb', line 630 def strongs Strongs.new(self) end |
#table(*args) ⇒ Celerity::Table
638 639 640 |
# File 'lib/celerity/container.rb', line 638 def table(*args) Table.new(self, *args) end |
#tables ⇒ Celerity::Tables
646 647 648 |
# File 'lib/celerity/container.rb', line 646 def tables Tables.new(self) end |
#tbodies ⇒ Celerity::TableBodies Also known as: bodies
662 663 664 |
# File 'lib/celerity/container.rb', line 662 def tbodies TableBodies.new(self) end |
#tbody(*args) ⇒ Celerity::TableBody Also known as: body
654 655 656 |
# File 'lib/celerity/container.rb', line 654 def tbody(*args) TableBody.new(self, *args) end |
#text_field(*args) ⇒ Celerity::TextField
670 671 672 |
# File 'lib/celerity/container.rb', line 670 def text_field(*args) TextField.new(self, *args) end |
#text_fields ⇒ Celerity::TextFields
678 679 680 |
# File 'lib/celerity/container.rb', line 678 def text_fields TextFields.new(self) end |
#tfoot(*args) ⇒ Celerity::TableFooter
686 687 688 |
# File 'lib/celerity/container.rb', line 686 def tfoot(*args) .new(self, *args) end |
#tfoots ⇒ Celerity::TableFooters Also known as: tfeet
694 695 696 |
# File 'lib/celerity/container.rb', line 694 def tfoots .new(self) end |
#th(*args) ⇒ Celerity::Th
Watir’s cells() won’t find <th> elements. This is a workaround.
706 707 708 |
# File 'lib/celerity/container.rb', line 706 def th(*args) Th.new(self, *args) end |
#thead(*args) ⇒ Celerity::TableHeader
723 724 725 |
# File 'lib/celerity/container.rb', line 723 def thead(*args) TableHeader.new(self, *args) end |
#theads ⇒ Celerity::TableHeaders
731 732 733 |
# File 'lib/celerity/container.rb', line 731 def theads TableHeaders.new(self) end |
#ths ⇒ Object
FIXME: implement or change api,
715 716 717 |
# File 'lib/celerity/container.rb', line 715 def ths raise NotImplementedError end |
#ul(*args) ⇒ Celerity::Ul
739 740 741 |
# File 'lib/celerity/container.rb', line 739 def ul(*args) Ul.new(self, *args) end |
#uls ⇒ Celerity::Uls
747 748 749 |
# File 'lib/celerity/container.rb', line 747 def uls Uls.new(self) end |