Module: Watir::Container
- Includes:
- Exception
- Included in:
- Element, ElementMapper, IE, ModalDialog, Table, TableCell
- Defined in:
- lib/watir/container.rb,
lib/watir/camel_case.rb
Overview
This module contains the factory methods that are used to access most html objects
For example, to access a button on a web page that has the following html
<input type=button name='b1' value='Click Me' onClick='javascript:doSomething()'>
the following watir code could be used to click the button
browser.(:name, 'b1').click
or to find the name attribute
browser.(:value, 'Click Me').name
there are many methods available to the Button object – Is includable for classes that have @container, document and __ole_inner_elements
Instance Attribute Summary collapse
-
#activeObjectHighLightColor ⇒ Object
The color we want to use for the active object.
-
#page_container ⇒ Object
The PageContainer object containing this element.
-
#type_keys ⇒ Object
Returns the value of attribute type_keys.
-
#typingspeed ⇒ Object
This is used to change the typing speed when entering text on a page.
Instance Method Summary collapse
-
#__ole_inner_elements ⇒ Object
Searching for Page Elements Not for external consumption.
-
#input_element_locator(how, what, types, klass = nil) ⇒ Object
Locator Methods.
- #locator_for(locator_class, how, what) ⇒ Object
-
#log(what) ⇒ Object
Write the specified string to the log.
-
#set_container(container) ⇒ Object
:nodoc:.
-
#show_all_objects ⇒ Object
This method shows the available objects on the current page.
- #tagged_element_locator(tag, how, what, klass = nil) ⇒ Object
-
#wait(no_sleep = false) ⇒ Object
(also: #waitForIE)
Wait until Browser has finished loading the page.
Instance Attribute Details
#activeObjectHighLightColor ⇒ Object
The color we want to use for the active object. This can be any valid web-friendly color.
30 31 32 |
# File 'lib/watir/container.rb', line 30 def activeObjectHighLightColor @activeObjectHighLightColor end |
#page_container ⇒ Object
The PageContainer object containing this element
32 33 34 |
# File 'lib/watir/container.rb', line 32 def page_container @page_container end |
#type_keys ⇒ Object
Returns the value of attribute type_keys.
28 29 30 |
# File 'lib/watir/container.rb', line 28 def type_keys @type_keys end |
#typingspeed ⇒ Object
This is used to change the typing speed when entering text on a page.
27 28 29 |
# File 'lib/watir/container.rb', line 27 def typingspeed @typingspeed end |
Instance Method Details
#__ole_inner_elements ⇒ Object
Searching for Page Elements Not for external consumption
++
64 65 66 |
# File 'lib/watir/container.rb', line 64 def __ole_inner_elements return document.body.all end |
#input_element_locator(how, what, types, klass = nil) ⇒ Object
Locator Methods
Not for external use, but cannot set to private due to usages in Element classes.
101 102 103 104 105 |
# File 'lib/watir/container.rb', line 101 def input_element_locator(how, what, types, klass=nil) locator = InputElementLocator.new self, types, klass locator.set_specifier how, what locator end |
#locator_for(locator_class, how, what) ⇒ Object
113 114 115 116 117 |
# File 'lib/watir/container.rb', line 113 def locator_for(locator_class, how, what) locator = locator_class.new self locator.set_specifier how, what locator end |
#log(what) ⇒ Object
Write the specified string to the log.
42 43 44 |
# File 'lib/watir/container.rb', line 42 def log(what) @container.logger.debug(what) if @logger end |
#set_container(container) ⇒ Object
:nodoc:
53 54 55 56 |
# File 'lib/watir/container.rb', line 53 def set_container container #:nodoc: @container = container @page_container = container.page_container end |
#show_all_objects ⇒ Object
This method shows the available objects on the current page. This is usually only used for debugging or writing new test scripts. This is a nice feature to help find out what HTML objects are on a page when developing a test case using Watir.
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 |
# File 'lib/watir/container.rb', line 72 def show_all_objects puts "-----------Objects in page -------------" doc = document s = "" props = ["name", "id", "value", "alt", "src"] doc.all.each do |n| begin s += n.invoke("type").to_s.ljust(16) rescue next end props.each do |prop| begin p = n.invoke(prop) s += " " + "#{prop}=#{p}".to_s.ljust(18) rescue # this object probably doesnt have this property end end s += "\n" end puts s end |
#tagged_element_locator(tag, how, what, klass = nil) ⇒ Object
107 108 109 110 111 |
# File 'lib/watir/container.rb', line 107 def tagged_element_locator(tag, how, what, klass=nil) locator = TaggedElementLocator.new self, tag, klass locator.set_specifier how, what locator end |
#wait(no_sleep = false) ⇒ Object Also known as: waitForIE
Wait until Browser has finished loading the page. – called explicitly by most click and set methods
49 50 51 |
# File 'lib/watir/container.rb', line 49 def wait(no_sleep=false) @container.wait(no_sleep) end |