Module: Insite

Included in:
MaterialAngularIO
Defined in:
lib/insite/insite.rb,
lib/insite/errors.rb,
lib/insite/version.rb,
lib/insite/constants.rb,
lib/insite/element/element.rb,
lib/insite/page/defined_page.rb,
lib/insite/component/component.rb,
lib/insite/methods/dom_methods.rb,
lib/insite/page/undefined_page.rb,
lib/insite/methods/common_methods.rb,
lib/insite/element/element_collection.rb,
lib/insite/component/component_methods.rb,
lib/insite/element/generated/class_map.rb,
lib/insite/component/component_collection.rb,
lib/insite/element/generated/element_classes.rb,
lib/insite/component/component_instance_methods.rb,
lib/insite/element/generated/element_instance_methods.rb

Overview

TODO: A lot of this should be handled via delegation.

Defined Under Namespace

Modules: CommonMethods, ComponentInstanceMethods, ComponentMethods, DOMMethods, ElementInstanceMethods, Errors Classes: Anchor, AnchorCollection, Applet, AppletCollection, Area, AreaCollection, Audio, AudioCollection, BR, BRCollection, Base, BaseCollection, Body, BodyCollection, Button, ButtonCollection, Canvas, CanvasCollection, Cell, CellCollection, CheckBox, CheckBoxCollection, Circle, CircleCollection, Component, ComponentCollection, Cursor, CursorCollection, DList, DListCollection, Data, DataCollection, DataList, DataListCollection, DateField, DateFieldCollection, DateTimeField, DateTimeFieldCollection, DefinedPage, Defs, DefsCollection, Desc, DescCollection, Details, DetailsCollection, Directory, DirectoryCollection, Div, DivCollection, Element, ElementCollection, Ellipse, EllipseCollection, Embed, EmbedCollection, FieldSet, FieldSetCollection, FileField, FileFieldCollection, Font, FontCollection, ForeignObject, ForeignObjectCollection, Form, FormCollection, Frame, FrameCollection, FrameSet, FrameSetCollection, G, GCollection, Geometry, GeometryCollection, Gradient, GradientCollection, Graphics, GraphicsCollection, HR, HRCollection, HTMLElement, HTMLElementCollection, Hatch, HatchCollection, Hatchpath, HatchpathCollection, Head, HeadCollection, Heading, HeadingCollection, Hidden, HiddenCollection, Html, HtmlCollection, IFrame, IFrameCollection, Image, ImageCollection, Input, InputCollection, Keygen, KeygenCollection, LI, LICollection, Label, LabelCollection, Legend, LegendCollection, Line, LineCollection, LinearGradient, LinearGradientCollection, Map, MapCollection, Marker, MarkerCollection, Marquee, MarqueeCollection, Media, MediaCollection, Menu, MenuCollection, MenuItem, MenuItemCollection, Mesh, MeshCollection, MeshGradient, MeshGradientCollection, Meshpatch, MeshpatchCollection, Meshrow, MeshrowCollection, Meta, MetaCollection, Metadata, MetadataCollection, Meter, MeterCollection, Mod, ModCollection, OList, OListCollection, Object, ObjectCollection, OptGroup, OptGroupCollection, Option, OptionCollection, Output, OutputCollection, Paragraph, ParagraphCollection, Param, ParamCollection, Path, PathCollection, Pattern, PatternCollection, Picture, PictureCollection, Polygon, PolygonCollection, Polyline, PolylineCollection, Pre, PreCollection, Progress, ProgressCollection, Quote, QuoteCollection, RadialGradient, RadialGradientCollection, Radio, RadioCollection, Rect, RectCollection, Row, RowCollection, SVG, SVGCollection, SVGElement, SVGElementCollection, Script, ScriptCollection, Select, SelectCollection, Solidcolor, SolidcolorCollection, Source, SourceCollection, Span, SpanCollection, Stop, StopCollection, Style, StyleCollection, Switch, SwitchCollection, Symbol, SymbolCollection, TSpan, TSpanCollection, Table, TableCaption, TableCaptionCollection, TableCell, TableCellCollection, TableCol, TableColCollection, TableCollection, TableDataCell, TableDataCellCollection, TableHeaderCell, TableHeaderCellCollection, TableRow, TableRowCollection, TableSection, TableSectionCollection, Template, TemplateCollection, TextArea, TextAreaCollection, TextContent, TextContentCollection, TextField, TextFieldCollection, TextPath, TextPathCollection, TextPositioning, TextPositioningCollection, Time, TimeCollection, Title, TitleCollection, Track, TrackCollection, UList, UListCollection, UndefinedPage, Unknown, UnknownCollection, Use, UseCollection, Video, VideoCollection, View, ViewCollection

Constant Summary collapse

VERSION =
'0.0.6'
METHOD_MAP =
{Watir::Rect=>[:rect],
 Watir::Menu=>[:menu],
 Watir::HTMLElement=>
  [:var,
   :i,
   :abbr,
   :summary,
   :cite,
   :code,
   :address,
   :article,
   :aside,
   :bdi,
   :bdo,
   :dfn,
   :dt,
   :em,
   :figcaption,
   :figure,
   :footer,
   :kbd,
   :header,
   :mark,
   :noscript,
   :main,
   :nav,
   :dd,
   :rb,
   :rp,
   :rtc,
   :s,
   :rt,
   :small,
   :samp,
   :sub,
   :section,
   :strong,
   :sup,
   :element,
   :u,
   :b,
   :ruby,
   :wbr],
 Watir::Anchor=>[:a, :link],
 Watir::HTMLElementCollection=>
  [:headers,
   :is,
   :vars,
   :elements,
   :abbrs,
   :addresses,
   :articles,
   :asides,
   :bs,
   :bdis,
   :bdos,
   :cites,
   :codes,
   :dds,
   :dfns,
   :dts,
   :ems,
   :figures,
   :figcaptions,
   :footers,
   :mains,
   :marks,
   :kbds,
   :noscripts,
   :navs,
   :rps,
   :rubies,
   :rbs,
   :ss,
   :rtcs,
   :smalls,
   :samps,
   :rts,
   :sections,
   :subs,
   :summaries,
   :sups,
   :strongs,
   :us,
   :wbrs],
Watir::TimeCollection=>[:times],
Watir::Circle=>[:circle],
Watir::CircleCollection=>[:circles],
Watir::Cursor=>[:cursor],
Watir::CursorCollection=>[:cursors],
Watir::Defs=>[:defs],
Watir::DefsCollection=>[:defss],
Watir::Desc=>[:desc],
Watir::DescCollection=>[:descs],
Watir::Ellipse=>[:ellipse],
Watir::EllipseCollection=>[:ellipses],
Watir::ForeignObject=>[:foreign_object],
Watir::ForeignObjectCollection=>[:foreign_objects],
Watir::GCollection=>[:gs],
Watir::Button=>[:button],
Watir::Hatchpath=>[:hatchpath],
Watir::HatchpathCollection=>[:hatchpaths],
Watir::LinearGradient=>[:linear_gradient],
Watir::LinearGradientCollection=>[:linear_gradients],
Watir::Marker=>[:marker],
Watir::MarkerCollection=>[:markers],
Watir::Mesh=>[:mesh],
Watir::MeshCollection=>[:meshes],
Watir::MeshGradient=>[:meshgradient],
Watir::MeshGradientCollection=>[:meshgradients],
Watir::Meshpatch=>[:meshpatch],
Watir::MeshpatchCollection=>[:meshpatches],
Watir::Meshrow=>[:meshrow],
Watir::MeshrowCollection=>[:meshrows],
Watir::MetadataCollection=>[:metadatas],
Watir::PatternCollection=>[:patterns],
Watir::Polygon=>[:polygon],
Watir::Pre=>[:pre],
Watir::PolygonCollection=>[:polygons],
Watir::Polyline=>[:polyline],
Watir::AreaCollection=>[:areas],
Watir::PolylineCollection=>[:polylines],
Watir::Script=>[:script],
Watir::Solidcolor=>[:solidcolor],
Watir::RadialGradient=>[:radial_gradient],
Watir::RadialGradientCollection=>[:radial_gradients],
Watir::SolidcolorCollection=>[:solidcolors],
Watir::RectCollection=>[:rects],
Watir::SVG=>[:svg],
Watir::SVGCollection=>[:svgs],
Watir::StopCollection=>[:stops],
Watir::SwitchCollection=>[:switches],
Watir::Body=>[:body],
Watir::LI=>[:li],
Watir::TextPathCollection=>[:text_paths],
Watir::Metadata=>[:metadata],
Watir::TSpan=>[:tspan],
Watir::TextPath=>[:text_path],
Watir::UseCollection=>[:uses],
Watir::View=>[:view],
Watir::ViewCollection=>[:views],
Watir::TSpanCollection=>[:tspans],
Watir::DateField=>[:date_field],
Watir::CheckBox=>[:checkbox],
Watir::CheckBoxCollection=>[:checkboxes],
Watir::Style=>[:style],
Watir::DateTimeField=>[:date_time_field],
Watir::DateTimeFieldCollection=>[:date_time_fields],
Watir::DateFieldCollection=>[:date_fields],
Watir::FileField=>[:file_field],
Watir::FileFieldCollection=>[:file_fields],
Watir::Font=>[:font],
Watir::FontCollection=>[:fonts],
Watir::ImageCollection=>[:imgs, :images],
Watir::FrameCollection=>[:frames],
Watir::HiddenCollection=>[:hiddens],
Watir::Image=>[:img, :image],
Watir::AnchorCollection=>[:as, :links],
Watir::Radio=>[:radio],
Watir::Track=>[:track],
Watir::RadioCollection=>[:radios],
Watir::Select=>[:select, :select_list],
Watir::SelectCollection=>[:selects, :select_lists],
Watir::Pattern=>[:pattern],
Watir::TextField=>[:text_field],
Watir::TextFieldCollection=>[:text_fields],
Watir::Use=>[:use],
Watir::TableCaption=>[:caption],
Watir::FieldSet=>[:fieldset, :field_set],
Watir::RadioSet=>[:radio_set],
Watir::FieldSetCollection=>[:fieldsets, :field_sets],
Watir::Input=>[:input],
Watir::Output=>[:output],
Watir::Area=>[:area],
Watir::Audio=>[:audio],
Watir::AudioCollection=>[:audios],
Watir::BaseCollection=>[:bases],
Watir::Quote=>[:blockquote, :q],
Watir::QuoteCollection=>[:blockquotes, :qs],
Watir::BodyCollection=>[:bodys],
Watir::BR=>[:br],
Watir::BRCollection=>[:brs],
Watir::ButtonCollection=>[:buttons],
Watir::Canvas=>[:canvas],
Watir::CanvasCollection=>[:canvases],
Watir::TableCaptionCollection=>[:captions],
Watir::TableCol=>[:colgroup, :col],
Watir::TableColCollection=>[:colgroups, :cols],
Watir::DataCollection=>[:datas],
Watir::DataList=>[:datalist],
Watir::DataListCollection=>[:datalists],
Watir::Mod=>[:del, :ins],
Watir::ModCollection=>[:dels, :inses],
Watir::DetailsCollection=>[:detailses],
Watir::DivCollection=>[:divs],
Watir::DList=>[:dl],
Watir::DListCollection=>[:dls],
Watir::Embed=>[:embed],
Watir::EmbedCollection=>[:embeds],
Watir::FormCollection=>[:forms],
Watir::FrameSet=>[:frameset],
Watir::FrameSetCollection=>[:framesets],
Watir::Heading=>[:h1, :h2, :h4, :h5, :h6, :h3],
Watir::HeadingCollection=>[:h1s, :h2s, :h3s, :h4s, :h5s, :h6s],
Watir::Form=>[:form],
Watir::Head=>[:head],
Watir::HeadCollection=>[:heads],
Watir::HRCollection=>[:hrs],
Watir::HtmlCollection=>[:htmls],
Watir::HR=>[:hr],
Watir::IFrame=>[:iframe],
Watir::Keygen=>[:keygen],
Watir::InputCollection=>[:inputs],
Watir::KeygenCollection=>[:keygens],
Watir::LegendCollection=>[:legends],
Watir::LICollection=>[:lis],
Watir::IFrameCollection=>[:iframes],
Watir::MenuItem=>[:menuitem],
Watir::MenuCollection=>[:menus],
Watir::Legend=>[:legend],
Watir::Meter=>[:meter],
Watir::Label=>[:label],
Watir::Div=>[:div],
Watir::MapCollection=>[:maps],
Watir::MeterCollection=>[:meters],
Watir::MetaCollection=>[:metas],
Watir::Param=>[:param],
Watir::MenuItemCollection=>[:menuitems],
Watir::Data=>[:data],
Watir::OptGroupCollection=>[:optgroups],
Watir::OList=>[:ol],
Watir::OptGroup=>[:optgroup],
Watir::ParamCollection=>[:params],
Watir::PreCollection=>[:pres],
Watir::Object=>[:object],
Watir::OListCollection=>[:ols],
Watir::ParagraphCollection=>[:ps],
Watir::ObjectCollection=>[:objects],
Watir::Picture=>[:picture],
Watir::PictureCollection=>[:pictures],
Watir::Progress=>[:progress],
Watir::Map=>[:map],
Watir::OutputCollection=>[:outputs],
Watir::OptionCollection=>[:options],
Watir::ScriptCollection=>[:scripts],
Watir::ProgressCollection=>[:progresses],
Watir::SpanCollection=>[:spans],
Watir::Source=>[:source],
Watir::StyleCollection=>[:styles],
Watir::Paragraph=>[:p],
Watir::TableSectionCollection=>[:tbodys, :tfoots, :theads],
Watir::TableDataCell=>[:td],
Watir::TableDataCellCollection=>[:tds],
Watir::Span=>[:span],
Watir::TableCollection=>[:tables],
Watir::TableSection=>[:tbody, :tfoot, :thead],
Watir::Meta=>[:meta],
Watir::TableHeaderCell=>[:th],
Watir::TableHeaderCellCollection=>[:ths],
Watir::Template=>[:template],
Watir::TextArea=>[:textarea],
Watir::TemplateCollection=>[:templates],
Watir::TitleCollection=>[:titles],
Watir::TextAreaCollection=>[:textareas],
Watir::TrackCollection=>[:tracks],
Watir::UList=>[:ul],
Watir::Table=>[:table],
Watir::Base=>[:base],
Watir::TableRowCollection=>[:trs],
Watir::Line=>[:line],
Watir::Symbol=>[:symbol],
Watir::UListCollection=>[:uls],
Watir::Video=>[:video],
Watir::VideoCollection=>[:videos],
Watir::G=>[:g],
Watir::Frame=>[:frame],
Watir::SourceCollection=>[:sources],
Watir::Option=>[:option],
Watir::PathCollection=>[:paths],
Watir::TableRow=>[:tr],
Watir::Path=>[:path],
Watir::LineCollection=>[:lines],
Watir::LabelCollection=>[:labels],
Watir::Time=>[:time],
Watir::SymbolCollection=>[:symbols],
Watir::Details=>[:details],
Watir::Stop=>[:stop],
Watir::Switch=>[:switch],
Watir::Hidden=>[:hidden]
}.freeze
DOM_METHODS =

Watir DOM methods. This data is used to create class-level element accessors for page objects.

%i(
  a            br          datalists         elements          forms       hidden   li                meshpatches  params            rect          source     tbody        tspan
  abbr         brs         datas             ellipse           frame       hiddens  line              meshrow      path              rects         sources    tbodys       tspans
  abbrs        bs          date_field        ellipses          frames      hr       linear_gradient   meshrows     paths             rp            span       td           u
  address      button      date_fields       em                frameset    hrs      linear_gradients  meta         pattern           rps           spans      tds          ul
  addresses    buttons     date_time_field   embed             framesets   htmls    lines             metadata     patterns          rt            ss         template     uls
  area         canvas      date_time_fields  embeds            g           i        link              metadatas    picture           rtc           stop       templates    us
  areas        canvases    dd                ems               gs          iframe   links             metas        pictures          rtcs          stops      text_field   use
  article      caption     dds               extract_selector  h1          iframes  lis               meter        polygon           rts           strong     text_fields  uses
  articles     captions    defs              field_set         h1s         image    main              meters       polygons          rubies        strongs    text_path    var
  as           checkbox    defss             field_sets        h2          images   mains             nav          polyline          ruby          style      text_paths   vars
  aside        checkboxes  del               fieldset          h2s         img      map               navs         polylines         s             styles     textarea     video
  asides       circle      dels              fieldsets         h3          imgs     maps              noscript     pre               samp          sub        textareas    videos
  audio        circles     desc              figcaption        h3s         input    mark              noscripts    pres              samps         subs       tfoot        view
  audios       cite        descs             figcaptions       h4          inputs   marker            object       progress          script        summaries  tfoots       views
  b            cites       details           figure            h4s         ins      markers           objects      progresses        scripts       summary    th           wbr
  base         code        detailses         figures           h5          inses    marks             ol           ps                section       sup        thead        wbrs
  bases        codes       dfn               file_field        h5s         is       menu              ols          q                 sections      sups       theads
  bdi          col         dfns              file_fields       h6          kbd      menuitem          optgroup     qs                select        svg        ths
  bdis         colgroup    div               font              h6s         kbds     menuitems         optgroups    radial_gradient   select_list   svgs       time
  bdo          colgroups   divs              fonts             hatchpath   keygen   menus             option       radial_gradients  select_lists  switch     times
  bdos         cols        dl                footer            hatchpaths  keygens  mesh              options      radio             selects       switches   titles
  blockquote   cursor      dls               footers           head        label    meshes            output       radio_set         small         symbol     tr
  blockquotes  cursors     dt                foreign_object    header      labels   meshgradient      outputs      radios            smalls        symbols    track
  body         data        dts               foreign_objects   headers     legend   meshgradients     p            rb                solidcolor    table      tracks
  bodys        datalist    element           form              heads       legends  meshpatch         param        rbs               solidcolors   tables     trs
).freeze
CLASS_MAP =
{
  Watir::Anchor => Insite::Anchor,
  Watir::AnchorCollection => Insite::AnchorCollection,
  Watir::Applet => Insite::Applet,
  Watir::AppletCollection => Insite::AppletCollection,
  Watir::Area => Insite::Area,
  Watir::AreaCollection => Insite::AreaCollection,
  Watir::Audio => Insite::Audio,
  Watir::AudioCollection => Insite::AudioCollection,
  Watir::BR => Insite::BR,
  Watir::BRCollection => Insite::BRCollection,
  Watir::Base => Insite::Base,
  Watir::BaseCollection => Insite::BaseCollection,
  Watir::Body => Insite::Body,
  Watir::BodyCollection => Insite::BodyCollection,
  Watir::Button => Insite::Button,
  Watir::ButtonCollection => Insite::ButtonCollection,
  Watir::Canvas => Insite::Canvas,
  Watir::CanvasCollection => Insite::CanvasCollection,
  Watir::Cell => Insite::Cell,
  Watir::CellCollection => Insite::CellCollection,
  Watir::CheckBox => Insite::CheckBox,
  Watir::CheckBoxCollection => Insite::CheckBoxCollection,
  Watir::Circle => Insite::Circle,
  Watir::CircleCollection => Insite::CircleCollection,
  Watir::Cursor => Insite::Cursor,
  Watir::CursorCollection => Insite::CursorCollection,
  Watir::DList => Insite::DList,
  Watir::DListCollection => Insite::DListCollection,
  Watir::Data => Insite::Data,
  Watir::DataCollection => Insite::DataCollection,
  Watir::DataList => Insite::DataList,
  Watir::DataListCollection => Insite::DataListCollection,
  Watir::DateField => Insite::DateField,
  Watir::DateFieldCollection => Insite::DateFieldCollection,
  Watir::DateTimeField => Insite::DateTimeField,
  Watir::DateTimeFieldCollection => Insite::DateTimeFieldCollection,
  Watir::Defs => Insite::Defs,
  Watir::DefsCollection => Insite::DefsCollection,
  Watir::Desc => Insite::Desc,
  Watir::DescCollection => Insite::DescCollection,
  Watir::Details => Insite::Details,
  Watir::DetailsCollection => Insite::DetailsCollection,
  Watir::Directory => Insite::Directory,
  Watir::DirectoryCollection => Insite::DirectoryCollection,
  Watir::Div => Insite::Div,
  Watir::DivCollection => Insite::DivCollection,
  Watir::Ellipse => Insite::Ellipse,
  Watir::EllipseCollection => Insite::EllipseCollection,
  Watir::Embed => Insite::Embed,
  Watir::EmbedCollection => Insite::EmbedCollection,
  Watir::FieldSet => Insite::FieldSet,
  Watir::FieldSetCollection => Insite::FieldSetCollection,
  Watir::FileField => Insite::FileField,
  Watir::FileFieldCollection => Insite::FileFieldCollection,
  Watir::Font => Insite::Font,
  Watir::FontCollection => Insite::FontCollection,
  Watir::ForeignObject => Insite::ForeignObject,
  Watir::ForeignObjectCollection => Insite::ForeignObjectCollection,
  Watir::Form => Insite::Form,
  Watir::FormCollection => Insite::FormCollection,
  Watir::Frame => Insite::Frame,
  Watir::FrameCollection => Insite::FrameCollection,
  Watir::FrameSet => Insite::FrameSet,
  Watir::FrameSetCollection => Insite::FrameSetCollection,
  Watir::G => Insite::G,
  Watir::GCollection => Insite::GCollection,
  Watir::Geometry => Insite::Geometry,
  Watir::GeometryCollection => Insite::GeometryCollection,
  Watir::Gradient => Insite::Gradient,
  Watir::GradientCollection => Insite::GradientCollection,
  Watir::Graphics => Insite::Graphics,
  Watir::GraphicsCollection => Insite::GraphicsCollection,
  Watir::HR => Insite::HR,
  Watir::HRCollection => Insite::HRCollection,
  Watir::HTMLElement => Insite::HTMLElement,
  Watir::HTMLElementCollection => Insite::HTMLElementCollection,
  Watir::Hatch => Insite::Hatch,
  Watir::HatchCollection => Insite::HatchCollection,
  Watir::Hatchpath => Insite::Hatchpath,
  Watir::HatchpathCollection => Insite::HatchpathCollection,
  Watir::Head => Insite::Head,
  Watir::HeadCollection => Insite::HeadCollection,
  Watir::Heading => Insite::Heading,
  Watir::HeadingCollection => Insite::HeadingCollection,
  Watir::Hidden => Insite::Hidden,
  Watir::HiddenCollection => Insite::HiddenCollection,
  Watir::Html => Insite::Html,
  Watir::HtmlCollection => Insite::HtmlCollection,
  Watir::IFrame => Insite::IFrame,
  Watir::IFrameCollection => Insite::IFrameCollection,
  Watir::Image => Insite::Image,
  Watir::ImageCollection => Insite::ImageCollection,
  Watir::Input => Insite::Input,
  Watir::InputCollection => Insite::InputCollection,
  Watir::Keygen => Insite::Keygen,
  Watir::KeygenCollection => Insite::KeygenCollection,
  Watir::LI => Insite::LI,
  Watir::LICollection => Insite::LICollection,
  Watir::Label => Insite::Label,
  Watir::LabelCollection => Insite::LabelCollection,
  Watir::Legend => Insite::Legend,
  Watir::LegendCollection => Insite::LegendCollection,
  Watir::Line => Insite::Line,
  Watir::LineCollection => Insite::LineCollection,
  Watir::LinearGradient => Insite::LinearGradient,
  Watir::LinearGradientCollection => Insite::LinearGradientCollection,
  Watir::Map => Insite::Map,
  Watir::MapCollection => Insite::MapCollection,
  Watir::Marker => Insite::Marker,
  Watir::MarkerCollection => Insite::MarkerCollection,
  Watir::Marquee => Insite::Marquee,
  Watir::MarqueeCollection => Insite::MarqueeCollection,
  Watir::Media => Insite::Media,
  Watir::MediaCollection => Insite::MediaCollection,
  Watir::Menu => Insite::Menu,
  Watir::MenuCollection => Insite::MenuCollection,
  Watir::MenuItem => Insite::MenuItem,
  Watir::MenuItemCollection => Insite::MenuItemCollection,
  Watir::Mesh => Insite::Mesh,
  Watir::MeshCollection => Insite::MeshCollection,
  Watir::MeshGradient => Insite::MeshGradient,
  Watir::MeshGradientCollection => Insite::MeshGradientCollection,
  Watir::Meshpatch => Insite::Meshpatch,
  Watir::MeshpatchCollection => Insite::MeshpatchCollection,
  Watir::Meshrow => Insite::Meshrow,
  Watir::MeshrowCollection => Insite::MeshrowCollection,
  Watir::Meta => Insite::Meta,
  Watir::MetaCollection => Insite::MetaCollection,
  Watir::Metadata => Insite::Metadata,
  Watir::MetadataCollection => Insite::MetadataCollection,
  Watir::Meter => Insite::Meter,
  Watir::MeterCollection => Insite::MeterCollection,
  Watir::Mod => Insite::Mod,
  Watir::ModCollection => Insite::ModCollection,
  Watir::OList => Insite::OList,
  Watir::OListCollection => Insite::OListCollection,
  Watir::Object => Insite::Object,
  Watir::ObjectCollection => Insite::ObjectCollection,
  Watir::OptGroup => Insite::OptGroup,
  Watir::OptGroupCollection => Insite::OptGroupCollection,
  Watir::Option => Insite::Option,
  Watir::OptionCollection => Insite::OptionCollection,
  Watir::Output => Insite::Output,
  Watir::OutputCollection => Insite::OutputCollection,
  Watir::Paragraph => Insite::Paragraph,
  Watir::ParagraphCollection => Insite::ParagraphCollection,
  Watir::Param => Insite::Param,
  Watir::ParamCollection => Insite::ParamCollection,
  Watir::Path => Insite::Path,
  Watir::PathCollection => Insite::PathCollection,
  Watir::Pattern => Insite::Pattern,
  Watir::PatternCollection => Insite::PatternCollection,
  Watir::Picture => Insite::Picture,
  Watir::PictureCollection => Insite::PictureCollection,
  Watir::Polygon => Insite::Polygon,
  Watir::PolygonCollection => Insite::PolygonCollection,
  Watir::Polyline => Insite::Polyline,
  Watir::PolylineCollection => Insite::PolylineCollection,
  Watir::Pre => Insite::Pre,
  Watir::PreCollection => Insite::PreCollection,
  Watir::Progress => Insite::Progress,
  Watir::ProgressCollection => Insite::ProgressCollection,
  Watir::Quote => Insite::Quote,
  Watir::QuoteCollection => Insite::QuoteCollection,
  Watir::RadialGradient => Insite::RadialGradient,
  Watir::RadialGradientCollection => Insite::RadialGradientCollection,
  Watir::Radio => Insite::Radio,
  Watir::RadioCollection => Insite::RadioCollection,
  Watir::Rect => Insite::Rect,
  Watir::RectCollection => Insite::RectCollection,
  Watir::Row => Insite::Row,
  Watir::RowCollection => Insite::RowCollection,
  Watir::SVG => Insite::SVG,
  Watir::SVGCollection => Insite::SVGCollection,
  Watir::SVGElement => Insite::SVGElement,
  Watir::SVGElementCollection => Insite::SVGElementCollection,
  Watir::Script => Insite::Script,
  Watir::ScriptCollection => Insite::ScriptCollection,
  Watir::Select => Insite::Select,
  Watir::SelectCollection => Insite::SelectCollection,
  Watir::Solidcolor => Insite::Solidcolor,
  Watir::SolidcolorCollection => Insite::SolidcolorCollection,
  Watir::Source => Insite::Source,
  Watir::SourceCollection => Insite::SourceCollection,
  Watir::Span => Insite::Span,
  Watir::SpanCollection => Insite::SpanCollection,
  Watir::Stop => Insite::Stop,
  Watir::StopCollection => Insite::StopCollection,
  Watir::Style => Insite::Style,
  Watir::StyleCollection => Insite::StyleCollection,
  Watir::Switch => Insite::Switch,
  Watir::SwitchCollection => Insite::SwitchCollection,
  Watir::Symbol => Insite::Symbol,
  Watir::SymbolCollection => Insite::SymbolCollection,
  Watir::TSpan => Insite::TSpan,
  Watir::TSpanCollection => Insite::TSpanCollection,
  Watir::Table => Insite::Table,
  Watir::TableCaption => Insite::TableCaption,
  Watir::TableCaptionCollection => Insite::TableCaptionCollection,
  Watir::TableCell => Insite::TableCell,
  Watir::TableCellCollection => Insite::TableCellCollection,
  Watir::TableCol => Insite::TableCol,
  Watir::TableColCollection => Insite::TableColCollection,
  Watir::TableCollection => Insite::TableCollection,
  Watir::TableDataCell => Insite::TableDataCell,
  Watir::TableDataCellCollection => Insite::TableDataCellCollection,
  Watir::TableHeaderCell => Insite::TableHeaderCell,
  Watir::TableHeaderCellCollection => Insite::TableHeaderCellCollection,
  Watir::TableRow => Insite::TableRow,
  Watir::TableRowCollection => Insite::TableRowCollection,
  Watir::TableSection => Insite::TableSection,
  Watir::TableSectionCollection => Insite::TableSectionCollection,
  Watir::Template => Insite::Template,
  Watir::TemplateCollection => Insite::TemplateCollection,
  Watir::TextArea => Insite::TextArea,
  Watir::TextAreaCollection => Insite::TextAreaCollection,
  Watir::TextContent => Insite::TextContent,
  Watir::TextContentCollection => Insite::TextContentCollection,
  Watir::TextField => Insite::TextField,
  Watir::TextFieldCollection => Insite::TextFieldCollection,
  Watir::TextPath => Insite::TextPath,
  Watir::TextPathCollection => Insite::TextPathCollection,
  Watir::TextPositioning => Insite::TextPositioning,
  Watir::TextPositioningCollection => Insite::TextPositioningCollection,
  Watir::Time => Insite::Time,
  Watir::TimeCollection => Insite::TimeCollection,
  Watir::Title => Insite::Title,
  Watir::TitleCollection => Insite::TitleCollection,
  Watir::Track => Insite::Track,
  Watir::TrackCollection => Insite::TrackCollection,
  Watir::UList => Insite::UList,
  Watir::UListCollection => Insite::UListCollection,
  Watir::Unknown => Insite::Unknown,
  Watir::UnknownCollection => Insite::UnknownCollection,
  Watir::Use => Insite::Use,
  Watir::UseCollection => Insite::UseCollection,
  Watir::Video => Insite::Video,
  Watir::VideoCollection => Insite::VideoCollection,
  Watir::View => Insite::View,
  Watir::ViewCollection => Insite::ViewCollection,
}.freeze

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(mth, *args, &block) ⇒ Object

In cases where Insite doesn’t recognize a method call it will try to do the following:

  • Delegate the method call to the most recently accessed page, which is stored in Insite#most_recent_page.

  • If the cached page doesn’t respond to the method, Insite will update the cache and then try to delegate the method again.

If delegation doesn’t work then a NoMethodError will be raised with some details about what was attempted.



228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
# File 'lib/insite/insite.rb', line 228

def method_missing(mth, *args, &block)
  original_page = @most_recent_page
  if original_page.respond_to?(mth)
    original_page.public_send(mth, *args, &block)
  else
    new_page = page
    if new_page.respond_to?(mth)
      page.public_send(mth, *args, &block)
    elsif !new_page.defined?
      raise NoMethodError, "Could not apply #{mth}. The current page could not be " \
      "recognized. Current URL #{@browser.url}"
    else
      # TODO: Make it clearer where the method got called.
      raise(
        NoMethodError,
        "Unable to apply method call :#{mth}. The site object doesn't support it. " \
        "The currently displayed page (#{new_page}) doesn't support it either.\n" \
        "Page:\t\t#{new_page.class}\n" \
        "Current URL:\t#{@browser.url}\n\n",
        caller
      )
    end
  end
end

Instance Attribute Details

#argumentsObject

Returns the value of attribute arguments.



11
12
13
# File 'lib/insite/insite.rb', line 11

def arguments
  @arguments
end

#base_urlObject (readonly)

Returns the value of attribute base_url.



10
11
12
# File 'lib/insite/insite.rb', line 10

def base_url
  @base_url
end

#browserObject

Returns the value of attribute browser.



11
12
13
# File 'lib/insite/insite.rb', line 11

def browser
  @browser
end

#browser_typeObject (readonly)

Returns the value of attribute browser_type.



10
11
12
# File 'lib/insite/insite.rb', line 10

def browser_type
  @browser_type
end

#most_recent_pageObject

Returns the value of attribute most_recent_page.



11
12
13
# File 'lib/insite/insite.rb', line 11

def most_recent_page
  @most_recent_page
end

#pagesObject

Returns the value of attribute pages.



11
12
13
# File 'lib/insite/insite.rb', line 11

def pages
  @pages
end

#unique_methodsObject (readonly)

Returns the value of attribute unique_methods.



10
11
12
# File 'lib/insite/insite.rb', line 10

def unique_methods
  @unique_methods
end

Class Method Details

.class_to_tag(klass) ⇒ Object



13
14
15
16
17
18
19
20
21
22
# File 'lib/insite/insite.rb', line 13

def self.class_to_tag(klass)
  if klass.respond_to?(:collection) && klass.collection?
    Watir.tag_to_class.key(klass) ||
    Watir.tag_to_class.key(CLASS_MAP.key(klass)) ||
    Watir.tag_to_class.key(CLASS_MAP.key(klass.collection_member_class))
  else
    Watir.tag_to_class.key(klass) ||
    Watir.tag_to_class.key(CLASS_MAP.key(klass))
  end
end

.included(base) ⇒ Object

Automatically sets up a Page class when Insite is included. Probably overkill but it protects against the case where two different sites are used at the same time: Each site will use its own page objects only.



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/insite/insite.rb', line 31

def self.included(base)
  mod = Module.new
  base.const_set('ComponentMethods', mod)

  klass = Class.new(DefinedPage)
  base.const_set('Page', klass)
  base::send(:extend, ComponentMethods)

  klass = Class.new(UndefinedPage)
  base.const_set('UndefinedPage', klass)

  class << base
    attr_reader :custom_tags
    @custom_tags = []
  end

  base.define_singleton_method(:set_custom_tags) do |*tags|
    @custom_tags ||= []
    tags.sort.each { |t| @custom_tags << t.to_s.downcase.dasherize }
  end
end

.tag_to_class(tag) ⇒ Object



24
25
26
# File 'lib/insite/insite.rb', line 24

def self.tag_to_class(tag)
  CLASS_MAP[Watir.tag_to_class[tag.to_sym]] || Insite::HTMLElement
end

Instance Method Details

#browser?Boolean

Returns true if there’s an open browser (that’s also responding.) False if not.

Returns:

  • (Boolean)


54
55
56
57
58
59
60
# File 'lib/insite/insite.rb', line 54

def browser?
  begin
    @browser.exists?
  rescue => e
    false
  end
end

#closeObject

Closes the site object’s browser/driver.



63
64
65
# File 'lib/insite/insite.rb', line 63

def close
  @browser.close if browser?
end

#describeObject



67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
# File 'lib/insite/insite.rb', line 67

def describe
puts <<-EOF
Wrapper class for all pages defined for the site.
Site:\t#{self.class} (#{__FILE__})
Base URL:\t#{@base_url}
Browser:\t#{@browser}
Current Page:\t#{page.class}

Page Accessor Methods (Use '?' with name to check for presence.)
-----------------------------------------------------------------
#{
tmp = []
max = pages.map(&:to_s).max { |x| x.length }
if max.length > 40
  pages.map(&:to_s).sort.map(&:underscore).join("\n")
else
  pages.map(&:to_s).sort.map(&:underscore).each_slice(2) do |arr|
    tmp << arr[0].to_s.ljust(40) + arr[1].to_s.ljust(40)
  end
  tmp.join("\n")
end
}
EOF
end

#driverObject

Returns a Selenium driver object.



93
94
95
# File 'lib/insite/insite.rb', line 93

def driver
  @browser.driver
end

#driver?Boolean

Returns true if there’s an open driver (that’s also responding.) False if not.

Returns:

  • (Boolean)


98
99
100
# File 'lib/insite/insite.rb', line 98

def driver?
  browser?
end

#find_non_standard_tagsObject



202
203
204
205
206
# File 'lib/insite/insite.rb', line 202

def find_non_standard_tags
  @browser.elements(xpath: non_standard_tag_xpath).map do |e|
    e.html.match(/<(\S+?(?=[\s,>]))/)[1]
  end.uniq.sort
end

#generate_tag_classesObject



102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
# File 'lib/insite/insite.rb', line 102

def generate_tag_classes
  tags = []
  cli = Highline.new

  loop do
    tags = (tags + find_non_standard_tags).uniq.sort
    cli.choose do |menu|
      menu.prompt "Found #{tags.length} non-standard tags. Choose one of the following options:"
      menu.choice(:list_tags) { puts tags.join(",\n") + "\n" }
      menu.choice(:continue)  {}
      menu.choice(:write_to_console) do
      end
      menu.choice(:exist_without_writing) { break }

    end
  end
end

#html_tagsObject



208
209
210
211
212
213
# File 'lib/insite/insite.rb', line 208

def html_tags
  %i(html title head body) + Insite::METHOD_MAP.values.flatten.each do |mth|
    elem = @browser.send(mth)
    elem.respond_to?(:selector) ? elem.selector.values.first.to_s : nil
  end.sort
end

#initialize(base_url = nil, hsh = {}) ⇒ Object

Creates a site object, which will have accessor methods for all pages that you have defined for the site. This object takes a hash argument. There is only one required value (the base_url for the site.) Example:

class MySite
  include Insite
end

# Note: This base URL can be overridden when defining a page.
site = MySite.new("https://foo.com")

You can also specify any other arguments that you want for later use:

site = MySite.new("http://foo.com", arg1, arg2, key1: val1, key2: val2)

site.foo
=> true
site.bar
=> 1

TODO: Sort args.



139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
# File 'lib/insite/insite.rb', line 139

def initialize(base_url = nil, hsh={})
  @arguments       = hsh.with_indifferent_access
  @base_url        = base_url
  @browser_type    = (@arguments[:browser] ? @arguments[:browser].to_sym : nil)
  @pages           = self.class::DefinedPage.descendants.reject { |p| p.page_template? }

  # Build generic components for custom tags, which are defined
  # using Site.custom_tags.
  if self.class.custom_tags
    self.class.custom_tags.each do |tag|
      # TODO: Ditch string interpolation.
      self.class.class_eval %Q{
        class #{tag.underscore.camelize} < Component
          select_by tag_name: "#{tag}"
        end
      }
    end
  end

  # Set up accessor methods for each page and page checking methods..
  @pages.each do |current_page|
    unless current_page.page_template?
      current_page.set_url_template(@base_url)

      if current_page.url_matcher
        unless current_page.url_matcher.is_a? Regexp
          raise Insite::Errors::PageConfigError,
          "A url_matcher was defined for the #{current_page} page but it was not a " \
          "regular expression. Check the value provided to the set_url_matcher method " \
          "in the class definition for this page. Object provided was a " \
          "#{current_page.url_matcher.class.name}"
        end
      end

      self.class.class_eval do
        define_method(current_page.to_s.underscore) do |args = nil, block = nil|
          current_page.new(self, args)
        end

        define_method("#{current_page.to_s.underscore}?") do
          on_page? current_page
        end
      end
    end
  end

  visited = Set.new
  tmp = @pages.map {|p| p.instance_methods }.flatten
  tmp.each do |element|
    if visited.include?(element)
     else
      visited << element
    end
  end
  @unique_methods = visited
end

#inspectObject

Custom inspect method so that console output doesn’t get in the way when debugging.



197
198
199
200
# File 'lib/insite/insite.rb', line 197

def inspect
  "#<#{self.class.name}:0x#{object_id}\n @base_url=\"#{@base_url}\" " \
  "@most_recent_page=#{@most_recent_page}>"
end

#non_standard_tag_xpathObject



215
216
217
# File 'lib/insite/insite.rb', line 215

def non_standard_tag_xpath
  "//*[#{html_tags.map { |sym| "not(local-name(.) = '#{sym}')" }.join(" and ") }]"
end

#on_page?(page_arg = nil) ⇒ Boolean

Returns true or false depending on whether the specified page is displayed. You can use a page object or a PageObject class name to identify the page you are looking for. Examples:

page = site.account_summary_page
=>#<AccountSummaryPage:70341126478080 ...>
site.on_page? page
=>true

site.on_page? AccountSummaryPage
=>true

If no arguments are provided, the currently displayed page will be checked. If a matching page object can be found then true will be returned. if there’s no matching page object, false will be returned.

Insite caches the most recently accessed page. This method updates that cached value, which can be accessed by calling Insite#most_recent_page.

Returns:

  • (Boolean)


270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
# File 'lib/insite/insite.rb', line 270

def on_page?(page_arg = nil)
  if page_arg
    if pages.include?(page_arg) # See if the currently displayed page has the same class.
      if @most_recent_page == page_arg && @most_recent_page.on_page?
        true
      else
        @most_recent_page = page
        @most_recent_page.class == page_arg
      end
    else # See if the currently displayed page is the same type of object.
      if @most_recent_page == page_arg
        @most_recent_page.on_page?
      else
        @most_recent_page = page
        @most_recent_page == page_arg
      end
    end
  else # Just see if the currently displayed page has been defined.
    if @most_recent_page.defined? && @most_recent_page.on_page?
      true
    else
      @most_recent_page = page
      @most_recent_page.on_page?
    end
  end
end

#open(btype = nil, *args) ⇒ Object

Opens a browser. The arguments used here get passed down to the browser constructor. Example:

s = SomeSite.new("http://foo.com")
s.open :firefox


301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
# File 'lib/insite/insite.rb', line 301

def open(btype = nil, *args)
  browser_platform = btype ||= @browser_type

  if browser_platform
    self.instance_variable_set(
      :@browser,
      Watir::Browser.new(browser_platform, *args)
    )
  else
    self.instance_variable_set(
      :@browser,
      Watir::Browser.new(*args)
    )
  end

  Watir.logger.level = :error
  self
end

#pageObject

Looks at the page currently being displayed in the browser and tries to return a page object for it. Does this by looking at the currently displayed URL in the browser.

If a matching page can’t be found then Insite will return an “undefined page” object. See the Un class for more details.



326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
# File 'lib/insite/insite.rb', line 326

def page
  return @most_recent_page if @most_recent_page && @most_recent_page.on_page?
  url = @browser.url
  found_page = nil
  @pages.each do |pg|
    if pg.url_matcher && pg.url_matcher =~ url
      found_page = pg
    elsif !pg.url_matcher && pg.url_template.match(url)
      found_page = pg
    else
      next
    end

    break if found_page
  end

  if found_page && found_page.required_arguments.present?
    if hsh = found_page.url_template.extract(url)
      return found_page.new(self, found_page.url_template.extract(url))
    else
      return found_page.new(self, found_page.url_template.extract(url.split(/(\?|#)/)[0]))
    end
  elsif found_page
    return found_page.new(self)
  else
    return UndefinedPage.new(self)
  end
end

#respond_to_missing?(mth, include_priv = false) ⇒ Boolean

Returns:

  • (Boolean)


355
356
357
358
# File 'lib/insite/insite.rb', line 355

def respond_to_missing?(mth, include_priv = false)
  # TODO: Page context changes.
  @most_recent_page.respond_to?(mth, include_priv) || super
end

#targetObject



360
361
362
# File 'lib/insite/insite.rb', line 360

def target
  @browser
end

#textObject



364
365
366
# File 'lib/insite/insite.rb', line 364

def text
  @browser.text
end

#uriObject

Returns an Addressable::URI object for the current browser URL.



369
370
371
# File 'lib/insite/insite.rb', line 369

def uri
  Addressable::URI.parse(@browser.url)
end

#urlObject

Returns the current browser URL.



374
375
376
# File 'lib/insite/insite.rb', line 374

def url
  @browser.url
end