Friday, January 21, 2011

Frames in WATIR: watir Frames

we can find out, if our page have frmes by following techniques..

ie.show_frames
This is a good method to use with IRB. It prints out the index and the name of the frames in the current page. Like this:
irb(main):009:0> ie.show_frames
there are 2 frames
frame index: 1 name: menu
frame index: 2 name: main
=> 0..1


If you want to ask Watir directly which HTML elements it knows about, execute this code (contributed by Bret Pettichord at watir-general, works only on Windows):

require 'watir/ie'

def is_element_subclass? klass
while klass = klass.superclass
return true if klass == Watir::Element
end
end

ObjectSpace.each_object(Class){|c| puts c if is_element_subclass?(c)}
You should get this (for Watir 1.6.5):

Watir::Link
Watir::Image
Watir::TableCell
Watir::TableRow
Watir::TableBody
Watir::TableBodies
Watir::Table
Watir::CheckBox
Watir::Radio
Watir::RadioCheckCommon
Watir::FileField
Watir::Hidden
Watir::TextField
Watir::Button
Watir::SelectList
Watir::InputElement
Watir::Em
Watir::Strong
Watir::Dd
Watir::Dt
Watir::Dl
Watir::H6
Watir::H5
Watir::H4
Watir::H3
Watir::H2
Watir::H1
Watir::Ul
Watir::Li
Watir::Label
Watir::Area
Watir::Map
Watir::Span
Watir::Div
Watir::P
Watir::Pre
Watir::NonControlElement
Watir::Form

No comments:

Post a Comment