watir-ng 1.1.0 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/README.md +20 -9
- data/lib/watir-ng.rb +54 -48
- data/lib/watir-ng/version.rb +2 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e244c588c9457a7795771827961a9e0b4bd373a3
|
4
|
+
data.tar.gz: 15cd2d67ff0705e6f84fcd6a17a760c80109237a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 932b756b7e15874008d5180fbb27aa81040f32b0af650d4ff0c3a49a7416e1bbe9e5e1972a127d25a9dfc0c0aeb03056fadeab934ba8e7b93dd9368d89803388
|
7
|
+
data.tar.gz: 4edd75c60cc563aab5e9a89276fe14767e19d5d25a4fe3fd26be08af32be0c7d0277534654c3b23a812e23d31646cf56e445dde2c7b9505922257ca63cbe78ae
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,9 @@
|
|
1
1
|
# CHANGELOG
|
2
2
|
|
3
|
+
## v2.0.0 (Feb 24 2016)
|
4
|
+
- Patch browser objects with `WatirNg.patch!`
|
5
|
+
- Add custom directive identifiers with `WatirNg.register`
|
6
|
+
|
3
7
|
## v1.1.0 (Sep 18 2015)
|
4
8
|
- Register custom attributes for identifying elements
|
5
9
|
- Thanks Yehuda Miller (@pittgoose) for the idea
|
data/README.md
CHANGED
@@ -6,23 +6,34 @@ Identify [watir-webdriver](http://github.com/watir/watir-webdriver) elements wit
|
|
6
6
|
|
7
7
|
## Usage
|
8
8
|
|
9
|
-
|
9
|
+
When identifying elements, use the `ng` directives like you would `id`, `class`, etc. Be sure to use underscores instead of dashes though!
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
# To find and click this HTML element:
|
13
|
+
# <button ng-click="foo">Submit</button>
|
14
|
+
|
15
|
+
submit_button = @browser.button(ng_click: "foo")
|
16
|
+
submit_button.click
|
17
|
+
```
|
18
|
+
|
19
|
+
To ensure your browser objects have access to the ng identifiers, run `patch!` before instantiating.
|
10
20
|
|
11
21
|
```ruby
|
12
|
-
require 'watir-webdriver'
|
13
22
|
require 'watir-ng'
|
14
23
|
|
15
|
-
|
24
|
+
WatirNg.patch!
|
25
|
+
|
26
|
+
@browser = Watir::Browser.new
|
16
27
|
```
|
17
28
|
|
18
|
-
|
29
|
+
You can identify elements with custom directives by registering them before patching the browser.
|
19
30
|
|
20
31
|
```ruby
|
21
|
-
|
22
|
-
# <button ng-click="foo">Submit</button>
|
32
|
+
require 'watir-ng'
|
23
33
|
|
24
|
-
|
25
|
-
|
34
|
+
WatirNg.register(:ng_foo, :ng_bar).patch!
|
35
|
+
|
36
|
+
@browser = Watir::Browser.new
|
26
37
|
```
|
27
38
|
|
28
39
|
## Installation
|
@@ -49,5 +60,5 @@ Or install it yourself with:
|
|
49
60
|
|
50
61
|
## Questions, Comments, Concerns
|
51
62
|
|
52
|
-
Find me on Twitter ([@jpdenen](http://twitter.com/jpdenen)) or write up an issue.
|
63
|
+
Find me on Twitter ([@jpdenen](http://twitter.com/jpdenen)), gitter ([@jdenen](http://gitter.im/jdenen)) or write up an [issue](https://github.com/jdenen/watir-ng/issues/new).
|
53
64
|
|
data/lib/watir-ng.rb
CHANGED
@@ -5,57 +5,63 @@ require "watir-ng/version"
|
|
5
5
|
# Adds AngularJS `ng` directives as identifiers for `Watir::Webdriver` elements.
|
6
6
|
#
|
7
7
|
module WatirNg
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
ng_hide ng_style ng_switch ng_transclude
|
22
|
-
)
|
23
|
-
|
24
|
-
#
|
25
|
-
# Inserts `NG_STRINGS` and `custom_directives` into `cls.attributes` as symbols when
|
26
|
-
# included in the class.
|
27
|
-
#
|
28
|
-
# @param cls [Class]
|
29
|
-
# @return [nil]
|
30
|
-
#
|
31
|
-
def self.included cls
|
32
|
-
if cls.respond_to? :attributes
|
33
|
-
ng_directives.push(*custom_directives).each { |ng| cls.attributes << ng }
|
8
|
+
class << self
|
9
|
+
|
10
|
+
#
|
11
|
+
# Register custom directives as element identifiers.
|
12
|
+
#
|
13
|
+
# @example
|
14
|
+
# WatirNg.register "ng_foo", :ng_bar
|
15
|
+
#
|
16
|
+
# @param custom_directives [Symbol, String]
|
17
|
+
# @return [WatirNg]
|
18
|
+
#
|
19
|
+
def register *args
|
20
|
+
tap { |ng| ng.custom_directives.push *args }
|
34
21
|
end
|
35
|
-
end
|
36
22
|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
23
|
+
#
|
24
|
+
# Patch Watir::HTMLElements with ng and custom directives.
|
25
|
+
#
|
26
|
+
# @example
|
27
|
+
# require 'watir-webdriver'
|
28
|
+
# require 'watir-ng'
|
29
|
+
# WatirNg.patch!
|
30
|
+
# browser = Watir::Browser.start
|
31
|
+
#
|
32
|
+
# @return [Array]
|
33
|
+
#
|
34
|
+
def patch!
|
35
|
+
attributes = directives.push *custom_directives.map(&:to_sym)
|
36
|
+
Watir::HTMLElement.attributes.push *attributes
|
37
|
+
end
|
46
38
|
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
39
|
+
# @api private
|
40
|
+
#
|
41
|
+
# Return array of ng directives.
|
42
|
+
#
|
43
|
+
# @return [Array<Symbol>]
|
44
|
+
#
|
45
|
+
def directives
|
46
|
+
%w(ng_jq ng_app ng_href ng_src ng_srcset ng_disabled ng_checked ng_readonly
|
47
|
+
ng_selected ng_open ng_form ng_value ng_bind ng_bind_template ng_bind_html
|
48
|
+
ng_change ng_class ng_class_odd ng_class_even ng_cloak ng_controller ng_csp
|
49
|
+
ng_click ng_dblclick ng_mousedown ng_mouseup ng_mouseover ng_mouseenter
|
50
|
+
ng_mouseleave ng_mousemove ng_keydown ng_keyup ng_keypress ng_submit ng_focus
|
51
|
+
ng_blur ng_copy ng_cut ng_paste ng_if ng_include ng_init ng_list ng_model
|
52
|
+
ng_model_options ng_non_bindable ng_options ng_pluralize ng_repeat ng_show
|
53
|
+
ng_hide ng_style ng_switch ng_transclude).map(&:to_sym)
|
54
|
+
end
|
56
55
|
|
57
|
-
|
58
|
-
|
59
|
-
|
56
|
+
# @api private
|
57
|
+
#
|
58
|
+
# Return array of custom directives.
|
59
|
+
#
|
60
|
+
# @return [Array]
|
61
|
+
#
|
62
|
+
def custom_directives
|
63
|
+
@custom_directives ||= []
|
64
|
+
end
|
65
|
+
|
60
66
|
end
|
61
67
|
end
|
data/lib/watir-ng/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: watir-ng
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Johnson Denen
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-02-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: watir-webdriver
|