Module: Vapir

Extended by:
Configurable, Waiter::WaitUntil
Includes:
Waiter::WaitUntil
Defined in:
lib/vapir-common.rb,
lib/vapir-common/config.rb,
lib/vapir-common/waiter.rb,
lib/vapir-common/browser.rb,
lib/vapir-common/element.rb,
lib/vapir-common/options.rb,
lib/vapir-common/version.rb,
lib/vapir-common/browsers.rb,
lib/vapir-common/keycodes.rb,
lib/vapir-common/container.rb,
lib/vapir-common/specifier.rb,
lib/vapir-common/exceptions.rb,
lib/vapir-common/modal_dialog.rb,
lib/vapir-common/page_container.rb,
lib/vapir-common/elements/elements.rb,
lib/vapir-common/element_collection.rb,
lib/vapir-common/element_class_and_module.rb,
lib/vapir-common/external/core_extensions.rb

Defined Under Namespace

Modules: Area, Button, CheckBox, Common, Configurable, Container, Dd, Div, Dl, Dt, Element, ElementClassAndModuleMethods, ElementHelper, ElementObjectCandidates, Em, Exception, FileField, Form, Frame, H1, H2, H3, H4, H5, H6, HasRowsAndColumns, Hidden, Image, InputElement, Label, Li, Link, Map, ModalDialog, Ol, Option, P, PageContainer, Pre, Radio, RadioCheckBoxCommon, SelectList, Span, Strong, TBody, Table, TableCell, TableRow, TextField, Ul, WatirConfigCompatibility Classes: Browser, Configuration, ElementCollection, HashConfigurationWithOtherStuff, Waiter, YamlConfiguration

Constant Summary collapse

SupportedBrowsers =
{
  :ie => {:class_name => 'Vapir::IE', :require => 'vapir-ie', :gem => 'vapir-ie'},
  :firefox => {:class_name => 'Vapir::Firefox', :require => 'vapir-firefox', :gem => 'vapir-firefox'},
}
KeyCodes =

Hash of all known key codes. hash keys are symbols representing the key. hash values are integers.

(('0'..'9').to_a+('a'..'z').to_a).inject({}){|hash, char| hash.merge(char.to_sym => char.vapir_ord) }.merge(
{
  :cancel        => 3,
  :help          => 6,
  :back_space    => 8,
  :tab           => 9,
  :clear         => 12,
  :return        => 13,
  :enter         => 14,
  :shift         => 16,
  :control       => 17,
  :alt           => 18,
  :pause         => 19,
  :caps_lock     => 20,
  :escape        => 27,
  :space         => 32,
  :page_up       => 33,
  :page_down     => 34,
  :end           => 35,
  :home          => 36,
  :left          => 37,
  :up            => 38,
  :right         => 39,
  :down          => 40,
  :printscreen   => 44,
  :insert        => 45,
  :delete        => 46,
  :semicolon     => 59,
  :equals        => 61,
  :context_menu  => 93,
  :numpad0       => 96,
  :numpad1       => 97,
  :numpad2       => 98,
  :numpad3       => 99,
  :numpad4       => 100,
  :numpad5       => 101,
  :numpad6       => 102,
  :numpad7       => 103,
  :numpad8       => 104,
  :numpad9       => 105,
  :multiply      => 106,
  :add           => 107,
  :separator     => 108,
  :subtract      => 109,
  :decimal       => 110,
  :divide        => 111,
  :f1            => 112,
  :f2            => 113,
  :f3            => 114,
  :f4            => 115,
  :f5            => 116,
  :f6            => 117,
  :f7            => 118,
  :f8            => 119,
  :f9            => 120,
  :f10           => 121,
  :f11           => 122,
  :f12           => 123,
  :f13           => 124,
  :f14           => 125,
  :f15           => 126,
  :f16           => 127,
  :f17           => 128,
  :f18           => 129,
  :f19           => 130,
  :f20           => 131,
  :f21           => 132,
  :f22           => 133,
  :f23           => 134,
  :f24           => 135,
  :num_lock      => 144,
  :scroll_lock   => 145,
  :comma         => 188,
  :dash          => 189,
  :period        => 190,
  :slash         => 191,
  :back_quote    => 192,
  :open_bracket  => 219,
  :back_slash    => 220,
  :close_bracket => 221,
  :quote         => 222,
  :meta          => 224,
})
PrintKeyCodes =

Hash of key codes for characters that get printed when you hit the key (in a text field for example). hash keys are single-character strings; values are integers.

(('0'..'9').to_a+('a'..'z').to_a).inject({}){|hash, char| hash.merge(char => char.to_sym) }.merge(
{
  "\t" => :tab,
  #"\n" => :return,
  #"\n" => :enter,
  ' '  => :space,
  ';'  => :semicolon,
  '='  => :equals,
  ','  => :comma,
  '.'  => :period,
  '/'  => :slash,
  "`"  => :back_quote,
  '['  => :open_bracket,
  "\\" => :back_slash,
  ']'  => :close_bracket,
  "'"  => :quote,
}).inject({}){|hash, (key, key_codes_key)| hash.merge(key => KeyCodes[key_codes_key]) }
ShiftPrintKeyCodes =

Hash of key codes for characters that get printed when you hit the key combined with the shift key (in a text field for example). hash keys are single-character strings; values are integers.

('A'..'Z').to_a.inject({}){|hash, char| hash.merge(char => char.downcase.to_sym) }.merge(
{
  ')' => :'0',
  '!' => :'1',
  '@' => :'2',
  '#' => :'3',
  '$' => :'4',
  '%' => :'5',
  '^' => :'6',
  '&' => :'7',
  '*' => :'8',
  '(' => :'9',
  ':' => :semicolon,
  '+' => :equals,
  '<' => :comma,
  '>' => :period,
  '?' => :slash,
  '~' => :back_quote,
  '{' => :open_bracket,
  '|' => :back_slash,
  '}' => :close_bracket,
  '"' => :quote,
}).inject({}){|hash, (key, key_codes_key)| hash.merge(key => KeyCodes[key_codes_key]) }
NumpadKeyCodes =

Hash of key codes for characters on the number pad. hash keys are single-character strings; values are integers.

('0'..'9').inject({}){|hash, char| hash.merge(char => "numpad#{char}".to_sym) }.merge(
{
  '*' => :multiply,
  '+' => :add,
  #? => :separator,
  '-' => :subtract,
  '.' => :decimal,
  '/' => :divide,
}).inject({}){|hash, (key, key_codes_key)| hash.merge(key => KeyCodes[key_codes_key]) }
Enumerator =
Object.const_defined?('Enumerator') ? ::Enumerator : Enumerable::Enumerator

Instance Attribute Summary

Attributes included from Configurable

#configuration_parent

Class Method Summary collapse

Methods included from Configurable

config, with_config, without_waiting

Methods included from Waiter::WaitUntil

wait_until

Class Method Details

.config_hashObject



376
377
378
# File 'lib/vapir-common/config.rb', line 376

def (@env_configuration).config_hash
  ENV
end

.fuzzy_match(attr, what) ⇒ Object

fuzzily matches the given attribute with the given ‘what’. if ‘what’ is a regexp, matches it against attr; if it’s a string, downcases and strips before comparing; tries a couple other things; falls back to normal equality-checking. read the source for more information.



317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
# File 'lib/vapir-common/specifier.rb', line 317

def fuzzy_match(attr, what)
  # IF YOU CHANGE THIS, CHANGE THE JAVASCRIPT REIMPLEMENTATION IN match_candidates
  case what
  when String, Symbol
    case attr
    when String, Symbol
      attr.to_s.downcase.strip==what.to_s.downcase.strip
    else
      attr==what
    end
  when Regexp
    case attr
    when Regexp
      attr==what
    else
     attr =~ what
    end
  when Numeric
    attr==what || attr==what.to_s
  else
    attr==what
  end
end

.optionsObject

Raises:

  • (NotImplementedError)


12
13
14
# File 'lib/vapir-common/options.rb', line 12

def options
  raise NotImplementedError, "this method of specifying options is deprecated and gone. see documentation for Vapir.config"
end

.options=(x) ⇒ Object

Raises:

  • (NotImplementedError)


9
10
11
# File 'lib/vapir-common/options.rb', line 9

def options= x
  raise NotImplementedError, "this method of specifying options is deprecated and gone. see documentation for Vapir.config"
end

.options_fileObject

Raises:

  • (NotImplementedError)


6
7
8
# File 'lib/vapir-common/options.rb', line 6

def options_file
  raise NotImplementedError, "this method of specifying options is deprecated and gone. see documentation for Vapir.config"
end

.options_file=(file) ⇒ Object

:nodoc:

Raises:

  • (NotImplementedError)


3
4
5
# File 'lib/vapir-common/options.rb', line 3

def options_file=(file) # :nodoc:
  raise NotImplementedError, "this method of specifying options is deprecated and gone. see documentation for Vapir.config"
end

.require_winwindowObject

requires the winwindow library, raising a more informative error message than the default on failure.



9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/vapir-common.rb', line 9

def self.require_winwindow
  begin
    require 'winwindow'
  rescue LoadError
    message = if RUBY_PLATFORM =~ /mswin|windows|mingw32|cygwin/i
      "This may be resolved by installing the winwindow gem."
    else
      "You do not appear to be on Windows - this method is not likely to work."
    end
    raise LoadError, $!.message + "\n\n#{message}", $!.backtrace
  end
end

.update_from_sourceObject

:nodoc:



330
331
332
333
334
335
336
# File 'lib/vapir-common/config.rb', line 330

def (@configurations).update_from_source # :nodoc:
  self.each do |c|
    if c.respond_to?(:update_from_source)
      c.update_from_source 
    end
  end
end