watir_angular 0.1.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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: b88af5a1527779734181b1cdd1e8c5df74c59121
4
+ data.tar.gz: 0a058924f1d6a54ef8a59be0e569f85be65a7b06
5
+ SHA512:
6
+ metadata.gz: c8b3b29efc77708b7d4fc051c652a1b4ffbc1eebc3783e648680158a6bce4876ec22e478d58a7e975490a4d4f1160c4e5ee85900c04ee9d2d07e8de892772d7a
7
+ data.tar.gz: 61c71af4e3a6bcfbe298ccd24e1511c6b2bb8b7d91e06e2dc262ed5a5fbec330f5bab0dd713fcab6c93d9778c9a69b26a7086e1484e6ba886a23b65242c1032b
data/.gitignore ADDED
@@ -0,0 +1,13 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+
11
+ # rspec failure tracking
12
+ .rspec_status
13
+ .idea
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/.travis.yml ADDED
@@ -0,0 +1,8 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.4.1
5
+ before_install:
6
+ - export DISPLAY=:99
7
+ - sh -e /etc/init.d/xvfb start
8
+ - export PATH=~/.webdrivers:$PATH
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source "https://rubygems.org"
2
+
3
+ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ # Specify your gem's dependencies in watir_angular.gemspec
6
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2017 Titus Fortner
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,35 @@
1
+ # WatirAngular
2
+
3
+ This gem will automatically wait for Angular events after each action that is
4
+ likely to change the DOM. (Using `Watir::AfterHook` class)
5
+
6
+ This gem adds direct locator support for all `ng-` specific tags, like:
7
+
8
+ ```ruby
9
+ browser.div(ng_model: 'foo')
10
+ browser.div(ng_class_even: 'bar')
11
+ ```
12
+
13
+ ## Installation
14
+
15
+ Add this line to your application's Gemfile:
16
+
17
+ ```ruby
18
+ gem 'watir_angular'
19
+ ```
20
+
21
+ And then execute:
22
+
23
+ $ bundle
24
+
25
+ Or install it yourself as:
26
+
27
+ $ gem install watir_angular
28
+
29
+ ## Contributing
30
+
31
+ Bug reports and pull requests are welcome on GitHub at https://github.com/titusfortner/watir_angular.
32
+
33
+ ## License
34
+
35
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,9 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ require 'watirspec/rake_tasks'
7
+ WatirSpec::RakeTasks.new
8
+
9
+ task default: %i[spec watirspec:run]
@@ -0,0 +1,16 @@
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
@@ -0,0 +1,30 @@
1
+ # Code on Page is based on code by westlm1@NW110283.nwie.net
2
+ # From https://github.com/watir/watir/pull/387
3
+
4
+ require "watir"
5
+
6
+ require 'watir_angular/locators/element/locator'
7
+ require 'watir_angular/locators/element/selector_builder'
8
+ require 'watir_angular/locators/element/validator'
9
+
10
+ module WatirAngular
11
+ def wait_for_angular(timeout: Watir.default_timeout)
12
+ angular_element = "document.querySelectorAll('[ng-app]')[0]"
13
+ wd.execute_script("angular.element(#{angular_element}).scope().pageFinishedRendering = false")
14
+ wd.execute_script("angular.getTestability(#{angular_element}).whenStable(function(){angular.element(#{angular_element}).scope().pageFinishedRendering = true})")
15
+ wait_until(timeout: timeout, message: "waiting for angular to render") do
16
+ wd.execute_script("return angular.element(#{angular_element}).scope().pageFinishedRendering")
17
+ end
18
+ rescue Selenium::WebDriver::Error::InvalidElementStateError
19
+ # no ng-app found on page, continue as normal
20
+ rescue Selenium::WebDriver::Error::JavascriptError
21
+ # angular not used in the application, continue as normal
22
+ rescue Selenium::WebDriver::Error::UnknownError => ex
23
+ # TODO - this may be a bug in chromedriver that it is not a JavaScriptError
24
+ raise unless ex.message.include? "angular is not defined"
25
+ # angular not used in the application, continue as normal
26
+ end
27
+ end
28
+
29
+ require 'extensions/watir/browser'
30
+ Watir.locator_namespace = WatirAngular::Locators
@@ -0,0 +1,8 @@
1
+ module WatirAngular
2
+ module Locators
3
+ class Element
4
+ class Locator < Watir::Locators::Element::Locator
5
+ end
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,28 @@
1
+ module WatirAngular
2
+ module Locators
3
+ class Element
4
+ class SelectorBuilder < Watir::Locators::Element::SelectorBuilder
5
+
6
+ private
7
+
8
+ def assert_valid_as_attribute(attribute)
9
+ return if ng_attribute?(attribute)
10
+ super
11
+ end
12
+
13
+ def ng_attribute?(attribute)
14
+ ng_attributes.include? attribute[/^ng_(.+)$/, 1]
15
+ end
16
+
17
+ def ng_attributes
18
+ %w[app bind bind_html bind_template blur change checked class
19
+ class_even class_odd click cloak controller copy csp cut dblclick disabled focus
20
+ form hide href if include init jq keydown keypress keyup list maxlength
21
+ minlength model model_options mousedown mouseenter mouseleave mousemove mouseover
22
+ mouseup non_bindable open options paste pluralize readonly repeat required selected
23
+ show src srcset style submit switch transclude value]
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,8 @@
1
+ module WatirAngular
2
+ module Locators
3
+ class Element
4
+ class Validator < Watir::Locators::Element::Validator
5
+ end
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,29 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "watir_angular"
7
+ spec.version = "0.1.0"
8
+ spec.authors = ["Titus Fortner"]
9
+ spec.email = ["titusfortner@gmail.com"]
10
+
11
+ spec.summary = %q{Custom support for using Watir with Angular based websites.}
12
+ spec.description = %q{Adds direct support for Angular specific locators and waiting strategies for use with Watir}
13
+ spec.homepage = 'http://github.com/titusfortner/watir_angular'
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
17
+ f.match(%r{^(test|spec|features)/})
18
+ end
19
+ spec.bindir = "exe"
20
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
21
+ spec.require_paths = ["lib"]
22
+
23
+ spec.add_runtime_dependency "watir", "~> 6.8"
24
+
25
+ spec.add_development_dependency "bundler", "~> 1.15"
26
+ spec.add_development_dependency "rake", "~> 10.0"
27
+ spec.add_development_dependency "rspec", "~> 3.0"
28
+ spec.add_development_dependency "webdrivers", "~> 3.0"
29
+ end
metadata ADDED
@@ -0,0 +1,128 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: watir_angular
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Titus Fortner
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2017-09-05 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: watir
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '6.8'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '6.8'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.15'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.15'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '10.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '10.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '3.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '3.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: webdrivers
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '3.0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '3.0'
83
+ description: Adds direct support for Angular specific locators and waiting strategies
84
+ for use with Watir
85
+ email:
86
+ - titusfortner@gmail.com
87
+ executables: []
88
+ extensions: []
89
+ extra_rdoc_files: []
90
+ files:
91
+ - ".gitignore"
92
+ - ".rspec"
93
+ - ".travis.yml"
94
+ - Gemfile
95
+ - LICENSE.txt
96
+ - README.md
97
+ - Rakefile
98
+ - lib/extensions/watir/browser.rb
99
+ - lib/watir_angular.rb
100
+ - lib/watir_angular/locators/element/locator.rb
101
+ - lib/watir_angular/locators/element/selector_builder.rb
102
+ - lib/watir_angular/locators/element/validator.rb
103
+ - watir_angular.gemspec
104
+ homepage: http://github.com/titusfortner/watir_angular
105
+ licenses:
106
+ - MIT
107
+ metadata: {}
108
+ post_install_message:
109
+ rdoc_options: []
110
+ require_paths:
111
+ - lib
112
+ required_ruby_version: !ruby/object:Gem::Requirement
113
+ requirements:
114
+ - - ">="
115
+ - !ruby/object:Gem::Version
116
+ version: '0'
117
+ required_rubygems_version: !ruby/object:Gem::Requirement
118
+ requirements:
119
+ - - ">="
120
+ - !ruby/object:Gem::Version
121
+ version: '0'
122
+ requirements: []
123
+ rubyforge_project:
124
+ rubygems_version: 2.6.11
125
+ signing_key:
126
+ specification_version: 4
127
+ summary: Custom support for using Watir with Angular based websites.
128
+ test_files: []