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 (also: #td)
- #cells ⇒ Celerity::TableCells (also: #tds)
-
#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
- #del(*args) ⇒ Celerity::Del
- #dels ⇒ Celerity::Dels
- #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
- #ins(*args) ⇒ Celerity::Ins
- #inses(*args) ⇒ Celerity::Inses
-
#inspect ⇒ Object
Override inspect for readability.
- #label(*args) ⇒ Celerity::Label
- #labels ⇒ Celerity::Labels
- #li(*args) ⇒ Celerity::Li
- #link(*args) ⇒ Celerity::Link (also: #a)
- #links ⇒ Celerity::Links (also: #as)
- #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 Also known as: td
118 119 120 |
# File 'lib/celerity/container.rb', line 118 def cell(*args) TableCell.new(self, *args) end |
#cells ⇒ Celerity::TableCells Also known as: tds
127 128 129 |
# File 'lib/celerity/container.rb', line 127 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
144 145 146 |
# File 'lib/celerity/container.rb', line 144 def check_box(*args) CheckBox.new(self, *args) end |
#checkboxes ⇒ Celerity::CheckBoxes
152 153 154 |
# File 'lib/celerity/container.rb', line 152 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
160 161 162 |
# File 'lib/celerity/container.rb', line 160 def dd(*args) Dd.new(self, *args) end |
#dds ⇒ Celerity::Dds
168 169 170 |
# File 'lib/celerity/container.rb', line 168 def dds Dds.new(self) end |
#del(*args) ⇒ Celerity::Del
176 177 178 |
# File 'lib/celerity/container.rb', line 176 def del(*args) Del.new(self, *args) end |
#dels ⇒ Celerity::Dels
184 185 186 |
# File 'lib/celerity/container.rb', line 184 def dels Dels.new(self) end |
#div(*args) ⇒ Celerity::Div
192 193 194 |
# File 'lib/celerity/container.rb', line 192 def div(*args) Div.new(self, *args) end |
#divs ⇒ Celerity::Divs
200 201 202 |
# File 'lib/celerity/container.rb', line 200 def divs Divs.new(self) end |
#dl(*args) ⇒ Celerity::Dl
208 209 210 |
# File 'lib/celerity/container.rb', line 208 def dl(*args) Dl.new(self, *args) end |
#dls ⇒ Celerity::Dls
216 217 218 |
# File 'lib/celerity/container.rb', line 216 def dls Dls.new(self) end |
#dt(*args) ⇒ Celerity::Dt
224 225 226 |
# File 'lib/celerity/container.rb', line 224 def dt(*args) Dt.new(self, *args) end |
#dts ⇒ Celerity::Dts
232 233 234 |
# File 'lib/celerity/container.rb', line 232 def dts Dts.new(self) end |
#em(*args) ⇒ Celerity::Em
240 241 242 |
# File 'lib/celerity/container.rb', line 240 def em(*args) Em.new(self, *args) end |
#ems ⇒ Celerity::Ems
248 249 250 |
# File 'lib/celerity/container.rb', line 248 def ems Ems.new(self) end |
#file_field(*args) ⇒ Celerity::FileField
256 257 258 |
# File 'lib/celerity/container.rb', line 256 def file_field(*args) FileField.new(self, *args) end |
#file_fields ⇒ Celerity::FileFields
264 265 266 |
# File 'lib/celerity/container.rb', line 264 def file_fields FileFields.new(self) end |
#form(*args) ⇒ Celerity::Form
272 273 274 |
# File 'lib/celerity/container.rb', line 272 def form(*args) Form.new(self, *args) end |
#forms ⇒ Celerity::Forms
280 281 282 |
# File 'lib/celerity/container.rb', line 280 def forms Forms.new(self) end |
#frame(*args) ⇒ Celerity::Frame
288 289 290 |
# File 'lib/celerity/container.rb', line 288 def frame(*args) Frame.new(self, *args) end |
#frames ⇒ Celerity::Frames
296 297 298 |
# File 'lib/celerity/container.rb', line 296 def frames Frames.new(self) end |
#h1(*args) ⇒ Celerity::H1
304 305 306 |
# File 'lib/celerity/container.rb', line 304 def h1(*args) H1.new(self, *args) end |
#h1s ⇒ Celerity::H1s
312 313 314 |
# File 'lib/celerity/container.rb', line 312 def h1s H1s.new(self) end |
#h2(*args) ⇒ Celerity::H2
320 321 322 |
# File 'lib/celerity/container.rb', line 320 def h2(*args) H2.new(self, *args) end |
#h2s ⇒ Celerity::H2s
328 329 330 |
# File 'lib/celerity/container.rb', line 328 def h2s H2s.new(self) end |
#h3(*args) ⇒ Celerity::H3
336 337 338 |
# File 'lib/celerity/container.rb', line 336 def h3(*args) H3.new(self, *args) end |
#h3s ⇒ Celerity::H3s
344 345 346 |
# File 'lib/celerity/container.rb', line 344 def h3s H3s.new(self) end |
#h4(*args) ⇒ Celerity::H4
352 353 354 |
# File 'lib/celerity/container.rb', line 352 def h4(*args) H4.new(self, *args) end |
#h4s ⇒ Celerity::H4s
360 361 362 |
# File 'lib/celerity/container.rb', line 360 def h4s H4s.new(self) end |
#h5(*args) ⇒ Celerity::H5
368 369 370 |
# File 'lib/celerity/container.rb', line 368 def h5(*args) H5.new(self, *args) end |
#h5s ⇒ Celerity::H5s
376 377 378 |
# File 'lib/celerity/container.rb', line 376 def h5s H5s.new(self) end |
#h6(*args) ⇒ Celerity::H6
384 385 386 |
# File 'lib/celerity/container.rb', line 384 def h6(*args) H6.new(self, *args) end |
#h6s ⇒ Celerity::H6s
392 393 394 |
# File 'lib/celerity/container.rb', line 392 def h6s H6s.new(self) end |
#hidden(*args) ⇒ Celerity::Hidden
400 401 402 |
# File 'lib/celerity/container.rb', line 400 def hidden(*args) Hidden.new(self, *args) end |
#hiddens ⇒ Celerity::Hiddens
408 409 410 |
# File 'lib/celerity/container.rb', line 408 def hiddens Hiddens.new(self) end |
#image(*args) ⇒ Celerity::Image
433 434 435 |
# File 'lib/celerity/container.rb', line 433 def image(*args) Image.new(self, *args) end |
#images ⇒ Celerity::Images
441 442 443 |
# File 'lib/celerity/container.rb', line 441 def images Images.new(self) end |
#ins(*args) ⇒ Celerity::Ins
416 417 418 |
# File 'lib/celerity/container.rb', line 416 def ins(*args) Ins.new(self, *args) end |
#inses(*args) ⇒ Celerity::Inses
424 425 426 |
# File 'lib/celerity/container.rb', line 424 def inses(*args) Inses.new(self, *args) 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
449 450 451 |
# File 'lib/celerity/container.rb', line 449 def label(*args) Label.new(self, *args) end |
#labels ⇒ Celerity::Labels
457 458 459 |
# File 'lib/celerity/container.rb', line 457 def labels Labels.new(self) end |
#li(*args) ⇒ Celerity::Li
465 466 467 |
# File 'lib/celerity/container.rb', line 465 def li(*args) Li.new(self, *args) end |
#link(*args) ⇒ Celerity::Link Also known as: a
481 482 483 |
# File 'lib/celerity/container.rb', line 481 def link(*args) Link.new(self, *args) end |
#links ⇒ Celerity::Links Also known as: as
490 491 492 |
# File 'lib/celerity/container.rb', line 490 def links Links.new(self) end |
#lis ⇒ Celerity::Lis
473 474 475 |
# File 'lib/celerity/container.rb', line 473 def lis Lis.new(self) end |
#map(*args) ⇒ Celerity::Map
499 500 501 |
# File 'lib/celerity/container.rb', line 499 def map(*args) Map.new(self, *args) end |
#maps ⇒ Celerity::Maps
507 508 509 |
# File 'lib/celerity/container.rb', line 507 def maps Maps.new(self) end |
#meta(*args) ⇒ Celerity::Meta
515 516 517 |
# File 'lib/celerity/container.rb', line 515 def (*args) Meta.new(self, *args) end |
#metas(*args) ⇒ Celerity::Metas
523 524 525 |
# File 'lib/celerity/container.rb', line 523 def (*args) Metas.new(self, *args) end |
#ol(*args) ⇒ Celerity::Ol
531 532 533 |
# File 'lib/celerity/container.rb', line 531 def ol(*args) Ol.new(self, *args) end |
#ols ⇒ Celerity::Ols
539 540 541 |
# File 'lib/celerity/container.rb', line 539 def ols Ols.new(self) end |
#option(*args) ⇒ Celerity::Option
547 548 549 |
# File 'lib/celerity/container.rb', line 547 def option(*args) Option.new(self, *args) end |
#p(*args) ⇒ Celerity::P
555 556 557 |
# File 'lib/celerity/container.rb', line 555 def p(*args) P.new(self, *args) end |
#pre(*args) ⇒ Celerity::Pre
571 572 573 |
# File 'lib/celerity/container.rb', line 571 def pre(*args) Pre.new(self, *args) end |
#pres ⇒ Celerity::Pres
579 580 581 |
# File 'lib/celerity/container.rb', line 579 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
595 596 597 |
# File 'lib/celerity/container.rb', line 595 def radio(*args) Radio.new(self, *args) end |
#radios ⇒ Celerity::Radios
603 604 605 |
# File 'lib/celerity/container.rb', line 603 def radios Radios.new(self) end |
#row(*args) ⇒ Celerity::TableRow
611 612 613 |
# File 'lib/celerity/container.rb', line 611 def row(*args) TableRow.new(self, *args) end |
#rows ⇒ Celerity::TableRows
619 620 621 |
# File 'lib/celerity/container.rb', line 619 def rows TableRows.new(self) end |
#select_list(*args) ⇒ Celerity::SelectList
627 628 629 |
# File 'lib/celerity/container.rb', line 627 def select_list(*args) SelectList.new(self, *args) end |
#select_lists ⇒ Celerity::SelectLists
635 636 637 |
# File 'lib/celerity/container.rb', line 635 def select_lists SelectLists.new(self) end |
#span(*args) ⇒ Celerity::Span
643 644 645 |
# File 'lib/celerity/container.rb', line 643 def span(*args) Span.new(self, *args) end |
#spans ⇒ Celerity::Spans
651 652 653 |
# File 'lib/celerity/container.rb', line 651 def spans Spans.new(self) end |
#strong(*args) ⇒ Celerity::Spans
659 660 661 |
# File 'lib/celerity/container.rb', line 659 def strong(*args) Strong.new(self, *args) end |
#strongs ⇒ Celerity::Strongs
667 668 669 |
# File 'lib/celerity/container.rb', line 667 def strongs Strongs.new(self) end |
#table(*args) ⇒ Celerity::Table
675 676 677 |
# File 'lib/celerity/container.rb', line 675 def table(*args) Table.new(self, *args) end |
#tables ⇒ Celerity::Tables
683 684 685 |
# File 'lib/celerity/container.rb', line 683 def tables Tables.new(self) end |
#tbodies ⇒ Celerity::TableBodies Also known as: bodies
699 700 701 |
# File 'lib/celerity/container.rb', line 699 def tbodies TableBodies.new(self) end |
#tbody(*args) ⇒ Celerity::TableBody Also known as: body
691 692 693 |
# File 'lib/celerity/container.rb', line 691 def tbody(*args) TableBody.new(self, *args) end |
#text_field(*args) ⇒ Celerity::TextField
707 708 709 |
# File 'lib/celerity/container.rb', line 707 def text_field(*args) TextField.new(self, *args) end |
#text_fields ⇒ Celerity::TextFields
715 716 717 |
# File 'lib/celerity/container.rb', line 715 def text_fields TextFields.new(self) end |
#tfoot(*args) ⇒ Celerity::TableFooter
723 724 725 |
# File 'lib/celerity/container.rb', line 723 def tfoot(*args) TableFooter.new(self, *args) end |
#tfoots ⇒ Celerity::TableFooters Also known as: tfeet
731 732 733 |
# File 'lib/celerity/container.rb', line 731 def tfoots TableFooters.new(self) end |
#th(*args) ⇒ Celerity::Th
Watir’s cells() won’t find <th> elements. This is a workaround.
743 744 745 |
# File 'lib/celerity/container.rb', line 743 def th(*args) Th.new(self, *args) end |
#thead(*args) ⇒ Celerity::TableHeader
760 761 762 |
# File 'lib/celerity/container.rb', line 760 def thead(*args) TableHeader.new(self, *args) end |
#theads ⇒ Celerity::TableHeaders
768 769 770 |
# File 'lib/celerity/container.rb', line 768 def theads TableHeaders.new(self) end |
#ths ⇒ Object
FIXME: implement or change api,
752 753 754 |
# File 'lib/celerity/container.rb', line 752 def ths raise NotImplementedError end |
#ul(*args) ⇒ Celerity::Ul
776 777 778 |
# File 'lib/celerity/container.rb', line 776 def ul(*args) Ul.new(self, *args) end |
#uls ⇒ Celerity::Uls
784 785 786 |
# File 'lib/celerity/container.rb', line 784 def uls Uls.new(self) end |