Module: Insite

Includes:
CommonMethods
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, 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, Head, HeadCollection, Heading, HeadingCollection, Hidden, HiddenCollection, Html, HtmlCollection, IFrame, IFrameCollection, Image, ImageCollection, Input, InputCollection, LI, LICollection, Label, LabelCollection, Legend, LegendCollection, Line, LineCollection, LinearGradient, LinearGradientCollection, Map, MapCollection, Marker, MarkerCollection, Marquee, MarqueeCollection, Media, MediaCollection, 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, 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.2.6'
METHOD_MAP =
{Watir::Rect=>[:rect],
 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::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::LinearGradient=>[:linear_gradient],
Watir::LinearGradientCollection=>[:linear_gradients],
Watir::Marker=>[:marker],
Watir::MarkerCollection=>[:markers],
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::RadialGradient=>[:radial_gradient],
Watir::RadialGradientCollection=>[:radial_gradients],
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::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::InputCollection=>[:inputs],
Watir::LegendCollection=>[:legends],
Watir::LICollection=>[:lis],
Watir::IFrameCollection=>[:iframes],
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::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                             params            rect          source     tbody        tspan
  abbr         brs         datas             ellipse           frame       hiddens  line                           path              rects         sources    tbodys       tspans
  abbrs        bs          date_field        ellipses          frames      hr       linear_gradient                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                         ols          q                 sections      sups       theads
  bdi          col         dfns              file_fields       h6          kbd                        optgroup     qs                select        svg        ths
  bdis         colgroup    div               font              h6s         kbds                       optgroups    radial_gradient   select_list   svgs       time
  bdo          colgroups   divs              fonts                                                    option       radial_gradients  select_lists  switch     times
  bdos         cols        dl                footer                                                   options      radio             selects       switches   titles
  blockquote               dls               footers           head        label                      output       small             symbol        tr
  blockquotes              dt                foreign_object    header      labels                     outputs      radios            smalls        symbols    track
  body         data        dts               foreign_objects   headers     legend                     p            rb                              table      tracks
  bodys        datalist    element           form              heads       legends                    param        rbs                             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::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::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::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::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::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

Methods included from CommonMethods

#document, #process_browser, #update_object

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.



263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
# File 'lib/insite/insite.rb', line 263

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.



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

def arguments
  @arguments
end

#base_urlObject (readonly)

Returns the value of attribute base_url.



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

def base_url
  @base_url
end

#browserObject

Returns the value of attribute browser.



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

def browser
  @browser
end

#browser_typeObject (readonly)

Returns the value of attribute browser_type.



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

def browser_type
  @browser_type
end

#most_recent_pageObject

Returns the value of attribute most_recent_page.



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

def most_recent_page
  @most_recent_page
end

#pagesObject

Returns the value of attribute pages.



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

def pages
  @pages
end

#siteObject (readonly)

Returns the value of attribute site.



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

def site
  @site
end

#unique_methodsObject (readonly)

Returns the value of attribute unique_methods.



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

def unique_methods
  @unique_methods
end

Class Method Details

.class_to_tag(klass) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
# File 'lib/insite/insite.rb', line 16

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.



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/insite/insite.rb', line 35

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



28
29
30
# File 'lib/insite/insite.rb', line 28

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)


58
59
60
61
62
63
64
# File 'lib/insite/insite.rb', line 58

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

#closeObject

Closes the site object’s browser/driver.



67
68
69
# File 'lib/insite/insite.rb', line 67

def close
  @browser.close if browser?
end

#driverObject

Returns a Selenium driver object.



72
73
74
# File 'lib/insite/insite.rb', line 72

def driver
  @browser.driver
end

#driver?Boolean

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

Returns:

  • (Boolean)


77
78
79
# File 'lib/insite/insite.rb', line 77

def driver?
  browser?
end

#find_non_standard_tagsObject



233
234
235
236
237
# File 'lib/insite/insite.rb', line 233

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

#htmlObject



239
240
241
# File 'lib/insite/insite.rb', line 239

def html
  @browser.html
end

#html_tagsObject



243
244
245
246
247
248
# File 'lib/insite/insite.rb', line 243

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.



119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
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
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
# File 'lib/insite/insite.rb', line 119

def initialize(base_url = nil, hsh={})
  if hsh.include?(:scheme)
    @arguments = hsh.with_indifferent_access
  else
    base_url.match(/(https|http)/i)
    scheme = $1 || 'https'
    @arguments = hsh.merge({scheme: scheme}).with_indifferent_access
  end

  @site = self
  @base_url     = base_url
  @browser_type = (@arguments[:browser] ? @arguments[:browser].to_sym : nil)

  # Don't include the base page class or any page templates in the site's
  # pages. Those should never be used directly.
  @pages = self.class::DefinedPage.descendants.reject do |pg|
    pg.page_template? || pg == self.class::Page
  end

  # Builds generic components for 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

      # Update the site class with methods for each page that is defined.
      self.class.class_eval do

        # Returns a page object for the page.
        define_method(current_page.to_s.underscore) do |args = nil, block = nil|
          current_page.new(self, args)
        end

        # Returns true if the page is being displayed, false if not.
        define_method("#{current_page.to_s.underscore}?") do
          on_page? current_page
        end

        # Similar to the method above but attempts navigation prior to the page
        # check. Returns a boolean rather than a page object: true if the
        # right page was loaded successfully, false if not. A navigation attempt
        # always occurs when this method is called.
        #
        # The main benefit of this method is to make it easier to write test
        # scenarios for situations where you know navigation is going to fail
        # (Examples of this would be session timeouts or role/privilege
        # test scenarios.) Normally an Insite::Errors::WrongPageError is
        # automatically raised when a navigation attempt fails. So in order to
        # test these sorts of scenarios you'd have to do a little more work to
        # handle the exception. Examples in RSpec:
        #
        # The "hard" way:
        # expect {s.login_page }.to raise_error(Insite::Errors::WrongPageError)
        #
        # The same assert using this method:
        # expect(s.try_login_page).to be_truthy
        define_method("try_#{current_page.to_s.underscore}") do |args = nil, block = nil|
          begin
            current_page.new(self, args)
            true
          rescue Insite::Errors::WrongPageError => e
            return false
          end
        end
      end
    end
  end

  # Sort templates by variable count: Templates with more vars will be
  # prioritized. This will partially eliminate the potential for a match on
  # the wrong template when there are two or more templates that match the
  # URL.
  @pages = @pages.sort do |pg1, pg2|
    pg1.url_template.variables.length <=> pg2.url_template.variables.length
  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.



228
229
230
231
# File 'lib/insite/insite.rb', line 228

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

#non_standard_tag_xpathObject



250
251
252
# File 'lib/insite/insite.rb', line 250

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)


307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
# File 'lib/insite/insite.rb', line 307

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


338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
# File 'lib/insite/insite.rb', line 338

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 UndefinedPage class for more details.



363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
# File 'lib/insite/insite.rb', line 363

def page
  # 1.)
  # Before anything else, look to see if it's the most recent page:
  return @most_recent_page if @most_recent_page && @most_recent_page.on_page?
  process_browser
  url = @browser.url

  found_page = nil
  # 2.)
  # Ensure that static templates are always prioritized when attempting to
  # match, which will prevent the wrong template from getting matched in this
  # scenario:
  #  - "/accounts/{account_code}"
  #  - "/accounts/new"
  #
  # Start by working through the array from FRONT to BACK, since any static
  # templates will be at the front of the array. Stop when we start to see
  # templates whth vars (These will get handled in the next statement.)
  @pages.each do |pg|
    break if pg.url_template.variables.length > 0

    if pg.url_matcher && pg.url_matcher =~ url
      found_page = pg
    elsif pg.url_template.match(url)
      found_page = pg
    else
      next
    end

    break if found_page
  end

  # 3.) Now we've reached the templates that include one or more variables.
  # For these, we want to try to match on the templates with more variables.
  # This prevents an invalid match in the following situation and removes the
  # need to provide a URL matcher to override the URL template:
  # - "/accounts/{account_code}/edit"
  # - "/accounts/{account_code}"
  # Now work through all the array from BACK to FRONT, stopping when we reach
  # the point where we see templates without a var (since those were already
  # handled above.)
  @pages.reverse.each do |pg|
    break if pg.url_template.variables.length == 0

    if pg.url_matcher && pg.url_matcher =~ url
      found_page = pg
    elsif 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)


431
432
433
434
# File 'lib/insite/insite.rb', line 431

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

#targetObject



436
437
438
# File 'lib/insite/insite.rb', line 436

def target
  @browser
end

#textObject



440
441
442
# File 'lib/insite/insite.rb', line 440

def text
  @browser.text
end

#uriObject

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



445
446
447
# File 'lib/insite/insite.rb', line 445

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

#urlObject

Returns the current browser URL.



450
451
452
# File 'lib/insite/insite.rb', line 450

def url
  @browser.url
end