watir_angular 0.2.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +13 -0
- data/lib/watir_angular.rb +11 -20
- data/watir_angular.gemspec +2 -2
- metadata +4 -13
- data/lib/extensions/watir/browser.rb +0 -16
- data/lib/watir_angular/locators/element/selector_builder.rb +0 -61
- data/support/travis.sh +0 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 92861e78110e040eac6d0d6cc163a51a39b246ff
|
4
|
+
data.tar.gz: 42f962e3e5e58a6b399ceaf8b7a5dfcf88a10924
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5b9c5ddf6de13251fcc8a4f8b098e5c161f6fd1e9f428da08f9cf916232d2250d48429f1386380537d72fa55654579e2b2243f32fc5e3eb2c69ad45de08efc7f
|
7
|
+
data.tar.gz: e3fe8f2eb14adf70b99db6eeaeb404a9db47f95d7fa1dbb6f77533344b8ff66885b3e2dbf66f0d4ea94f23c8146b40ab513d93f03eb2960fba858d2fb20886bb
|
data/README.md
CHANGED
@@ -28,10 +28,23 @@ Or install it yourself as:
|
|
28
28
|
|
29
29
|
## Usage
|
30
30
|
|
31
|
+
To have access to all `ng-*` locators and methods, simply require the gem
|
31
32
|
```ruby
|
32
33
|
require "watir_angular"
|
33
34
|
```
|
34
35
|
|
36
|
+
To explicitly specify a wait for angular executions to complete
|
37
|
+
```ruby
|
38
|
+
browser = Watir::Browser.new
|
39
|
+
WatirAngular.wait_for_angular(browser)
|
40
|
+
```
|
41
|
+
|
42
|
+
To automatically wait for angular executions to complete after each method
|
43
|
+
```ruby
|
44
|
+
browser = Watir::Browser.new
|
45
|
+
WatirAngular.inject_angular_wait(browser)
|
46
|
+
```
|
47
|
+
|
35
48
|
## Contributing
|
36
49
|
|
37
50
|
Bug reports and pull requests are welcome on GitHub at https://github.com/titusfortner/watir_angular.
|
data/lib/watir_angular.rb
CHANGED
@@ -1,15 +1,18 @@
|
|
1
|
-
# Code on
|
1
|
+
# Code on this page is based on code by westlm1@NW110283.nwie.net
|
2
2
|
# From https://github.com/watir/watir/pull/387
|
3
3
|
|
4
4
|
require "watir"
|
5
|
-
|
5
|
+
|
6
|
+
Watir::Locators::Element::SelectorBuilder.send(:remove_const, :WILDCARD_ATTRIBUTE)
|
7
|
+
Watir::Locators::Element::SelectorBuilder::WILDCARD_ATTRIBUTE = /^(aria|data|ng)_(.+)$/
|
6
8
|
|
7
9
|
module WatirAngular
|
8
|
-
def wait_for_angular(timeout: Watir.default_timeout)
|
10
|
+
def self.wait_for_angular(browser, timeout: Watir.default_timeout)
|
11
|
+
wd = browser.wd
|
9
12
|
angular_element = "document.querySelectorAll('[ng-app]')[0]"
|
10
13
|
wd.execute_script("angular.element(#{angular_element}).scope().pageFinishedRendering = false")
|
11
14
|
wd.execute_script("angular.getTestability(#{angular_element}).whenStable(function(){angular.element(#{angular_element}).scope().pageFinishedRendering = true})")
|
12
|
-
wait_until(timeout: timeout, message: "waiting for angular to render") do
|
15
|
+
browser.wait_until(timeout: timeout, message: "waiting for angular to render") do
|
13
16
|
wd.execute_script("return angular.element(#{angular_element}).scope().pageFinishedRendering")
|
14
17
|
end
|
15
18
|
rescue Selenium::WebDriver::Error::InvalidElementStateError
|
@@ -21,20 +24,8 @@ module WatirAngular
|
|
21
24
|
raise unless ex.message.include? "angular is not defined"
|
22
25
|
# angular not used in the application, continue as normal
|
23
26
|
end
|
24
|
-
end
|
25
|
-
|
26
|
-
require 'extensions/watir/browser'
|
27
|
-
Watir.locator_namespace = WatirAngular::Locators
|
28
|
-
|
29
|
-
WatirAngular::Locators::Element::Locator = Watir::Locators::Element::Locator
|
30
|
-
WatirAngular::Locators::Element::Validator = Watir::Locators::Element::Validator
|
31
|
-
|
32
|
-
# Behaviors for element subclasses to come from Watir rather than WatirAngular superclass element
|
33
|
-
WatirAngular::Locators::Button::Locator = Watir::Locators::Button::Locator
|
34
|
-
WatirAngular::Locators::Button::Validator = Watir::Locators::Button::Validator
|
35
|
-
WatirAngular::Locators::Cell::Locator = Watir::Locators::Cell::Locator
|
36
|
-
WatirAngular::Locators::Row::Locator = Watir::Locators::Row::Locator
|
37
|
-
WatirAngular::Locators::TextArea::Locator = Watir::Locators::TextArea::Locator
|
38
|
-
WatirAngular::Locators::TextField::Locator = Watir::Locators::TextField::Locator
|
39
|
-
WatirAngular::Locators::TextField::Validator = Watir::Locators::TextField::Validator
|
40
27
|
|
28
|
+
def self.inject_wait(browser)
|
29
|
+
browser.after_hooks.add ->(browser) { wait_for_angular(browser) }
|
30
|
+
end
|
31
|
+
end
|
data/watir_angular.gemspec
CHANGED
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
4
|
|
5
5
|
Gem::Specification.new do |spec|
|
6
6
|
spec.name = "watir_angular"
|
7
|
-
spec.version = "0.
|
7
|
+
spec.version = "0.3.0"
|
8
8
|
spec.authors = ["Titus Fortner"]
|
9
9
|
spec.email = ["titusfortner@gmail.com"]
|
10
10
|
|
@@ -20,7 +20,7 @@ Gem::Specification.new do |spec|
|
|
20
20
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
21
21
|
spec.require_paths = ["lib"]
|
22
22
|
|
23
|
-
spec.add_runtime_dependency "watir", "~> 6.
|
23
|
+
spec.add_runtime_dependency "watir", "~> 6.9"
|
24
24
|
|
25
25
|
spec.add_development_dependency "bundler", "~> 1.15"
|
26
26
|
spec.add_development_dependency "rake", "~> 10.0"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: watir_angular
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Titus Fortner
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-11-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: watir
|
@@ -16,20 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '6.
|
20
|
-
- - ">="
|
21
|
-
- !ruby/object:Gem::Version
|
22
|
-
version: 6.8.2
|
19
|
+
version: '6.9'
|
23
20
|
type: :runtime
|
24
21
|
prerelease: false
|
25
22
|
version_requirements: !ruby/object:Gem::Requirement
|
26
23
|
requirements:
|
27
24
|
- - "~>"
|
28
25
|
- !ruby/object:Gem::Version
|
29
|
-
version: '6.
|
30
|
-
- - ">="
|
31
|
-
- !ruby/object:Gem::Version
|
32
|
-
version: 6.8.2
|
26
|
+
version: '6.9'
|
33
27
|
- !ruby/object:Gem::Dependency
|
34
28
|
name: bundler
|
35
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -101,10 +95,7 @@ files:
|
|
101
95
|
- LICENSE.txt
|
102
96
|
- README.md
|
103
97
|
- Rakefile
|
104
|
-
- lib/extensions/watir/browser.rb
|
105
98
|
- lib/watir_angular.rb
|
106
|
-
- lib/watir_angular/locators/element/selector_builder.rb
|
107
|
-
- support/travis.sh
|
108
99
|
- watir_angular.gemspec
|
109
100
|
homepage: http://github.com/titusfortner/watir_angular
|
110
101
|
licenses:
|
@@ -1,16 +0,0 @@
|
|
1
|
-
module Watir
|
2
|
-
|
3
|
-
class Browser
|
4
|
-
include WatirAngular
|
5
|
-
|
6
|
-
# TODO - reimplement with Watir Executor when available
|
7
|
-
|
8
|
-
alias_method :watir_initialize, :initialize
|
9
|
-
|
10
|
-
def initialize(*args)
|
11
|
-
watir_initialize(*args)
|
12
|
-
proc = ->(browser) { browser.wait_for_angular }
|
13
|
-
@after_hooks.add(proc)
|
14
|
-
end
|
15
|
-
end # Browser
|
16
|
-
end # Watir
|
@@ -1,61 +0,0 @@
|
|
1
|
-
module WatirAngular
|
2
|
-
module Locators
|
3
|
-
|
4
|
-
module SelectorHelpers
|
5
|
-
def assert_valid_as_attribute(attribute)
|
6
|
-
return if ng_attribute?(attribute)
|
7
|
-
super
|
8
|
-
end
|
9
|
-
|
10
|
-
def ng_attribute?(attribute)
|
11
|
-
ng_attributes.include? attribute[/^ng_(.+)$/, 1]
|
12
|
-
end
|
13
|
-
|
14
|
-
def ng_attributes
|
15
|
-
%w[app bind bind_html bind_template blur change checked class
|
16
|
-
class_even class_odd click cloak controller copy csp cut dblclick disabled focus
|
17
|
-
form hide href if include init jq keydown keypress keyup list maxlength
|
18
|
-
minlength model model_options mousedown mouseenter mouseleave mousemove mouseover
|
19
|
-
mouseup non_bindable open options paste pluralize readonly repeat required selected
|
20
|
-
show src srcset style submit switch transclude value]
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
class Element
|
25
|
-
class SelectorBuilder < Watir::Locators::Element::SelectorBuilder
|
26
|
-
include SelectorHelpers
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
class Button
|
31
|
-
class SelectorBuilder < Watir::Locators::Button::SelectorBuilder
|
32
|
-
include SelectorHelpers
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
class Cell
|
37
|
-
class SelectorBuilder < Watir::Locators::Cell::SelectorBuilder
|
38
|
-
include SelectorHelpers
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
class Row
|
43
|
-
class SelectorBuilder < Watir::Locators::Row::SelectorBuilder
|
44
|
-
include SelectorHelpers
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
class TextArea
|
49
|
-
class SelectorBuilder < Watir::Locators::TextArea::SelectorBuilder
|
50
|
-
include SelectorHelpers
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
class TextField
|
55
|
-
class SelectorBuilder < Watir::Locators::TextField::SelectorBuilder
|
56
|
-
include SelectorHelpers
|
57
|
-
end
|
58
|
-
end
|
59
|
-
|
60
|
-
end
|
61
|
-
end
|