Module: WatirNg

Defined in:
lib/watir-ng.rb,
lib/watir-ng/version.rb

Overview

Adds AngularJS ‘ng` directives as identifiers for `Watir::Webdriver` elements.

Constant Summary collapse

VERSION =

:nodoc:

'2.1.1'

Class Method Summary collapse

Class Method Details

.custom_directivesArray

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Return array of custom directives.

Returns:

  • (Array)


62
63
64
# File 'lib/watir-ng.rb', line 62

def custom_directives
  @custom_directives ||= []
end

.directivesArray<Symbol>

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Return array of ng directives.

Returns:

  • (Array<Symbol>)


45
46
47
48
49
50
51
52
53
54
# File 'lib/watir-ng.rb', line 45

def directives
  %w(ng_jq ng_app ng_href ng_src ng_srcset ng_disabled ng_checked ng_readonly 
     ng_selected ng_open ng_form ng_value ng_bind ng_bind_template ng_bind_html 
     ng_change ng_class ng_class_odd ng_class_even ng_cloak ng_controller ng_csp 
     ng_click ng_dblclick ng_mousedown ng_mouseup ng_mouseover ng_mouseenter 
     ng_mouseleave ng_mousemove ng_keydown ng_keyup ng_keypress ng_submit ng_focus
     ng_blur ng_copy ng_cut ng_paste ng_if ng_include ng_init ng_list ng_model 
     ng_model_options ng_non_bindable ng_options ng_pluralize ng_repeat ng_show 
     ng_hide ng_style ng_switch ng_transclude).map(&:to_sym)
end

.patch!Array

Patch Watir::HTMLElements with ng and custom directives.

Examples:

require 'watir-webdriver'
require 'watir-ng'
WatirNg.patch!
browser = Watir::Browser.start

Returns:

  • (Array)


34
35
36
37
# File 'lib/watir-ng.rb', line 34

def patch!
  attributes = directives.push *custom_directives.map(&:to_sym)
  Watir::HTMLElement.attributes.push *attributes
end

.register(*args) ⇒ WatirNg

Register custom directives as element identifiers.

Examples:

WatirNg.register "ng_foo", :ng_bar

Parameters:

  • custom_directives (Symbol, String)

Returns:



19
20
21
# File 'lib/watir-ng.rb', line 19

def register *args
  tap { |ng| ng.custom_directives.push *args }
end