watigiri 0.2.1 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +24 -9
- data/lib/watigiri/locators/element/locator.rb +6 -5
- data/watigiri.gemspec +2 -2
- metadata +4 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b54f1a44d2ce370b82465ea35623426beb9cc700
|
4
|
+
data.tar.gz: 16c9d06260d4a01271bc7f789a816e9d20cbdee3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 68cad5b608ac6b3eebc53f1c36b62371c968db2af9035cfa352a5f96c915a5ca0cb9eb3651f275d3b634fabf44f68fd360905298d7db485a0ce9d9c75ff3a10c
|
7
|
+
data.tar.gz: be6cb2c9ff17d61c292c4b26a86ed4ddc9da9eabc95a8ec777cafa0cecaad50ad8f9bae0143b7b6513a6fcf553f95d0e5c5b06e18124c78151c738d8cbb0032b
|
data/README.md
CHANGED
@@ -1,8 +1,20 @@
|
|
1
1
|
# Watigiri
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
3
|
+
Watigiri is an add-on to Watir that attempts to make it seamless for actions to be taken using Nokogiri
|
4
|
+
instead of Selenium in the places it makes sense to do so.
|
5
|
+
|
6
|
+
The advantage of Nokogiri is that it parses the DOM very quickly. This provides two primary opportunities for speeding
|
7
|
+
up Watir usage.
|
8
|
+
|
9
|
+
1. Obtaining multiple successive pieces of information about elements from a static DOM. For instance, to verify
|
10
|
+
that the text displayed on a page is the data that was previously entered into a form. Rather than making several
|
11
|
+
dozen wire calls to locate and obtain text information from each, you can make one wire call to obtain the DOM and then
|
12
|
+
quickly locate and obtain all of the information necessary at each element location.
|
13
|
+
|
14
|
+
2. Iterating over a collection of elements. One of the times this happens is when locating elements using Regular
|
15
|
+
Expressions. Watir implements this by locating a subset of elements that might match and then making wire calls
|
16
|
+
on each to check if they actually match the provided regular expression.
|
17
|
+
If the number of elements to be checked is large, using Nokogiri can show a significant performance improvement.
|
6
18
|
|
7
19
|
## Installation
|
8
20
|
|
@@ -22,17 +34,20 @@ Or install it yourself as:
|
|
22
34
|
|
23
35
|
## Usage
|
24
36
|
|
25
|
-
|
26
|
-
|
27
|
-
|
37
|
+
First require it in your code:
|
38
|
+
```ruby
|
39
|
+
require 'watigiri'
|
40
|
+
```
|
28
41
|
|
29
|
-
|
42
|
+
Once required, Watigiri will automatically speed up the location of elements using regular expression values.
|
30
43
|
|
31
|
-
To
|
44
|
+
To speed up the gathering of text values, use the text-bang method (`Element#text!` instead of `Element#text`).
|
45
|
+
Watigiri flushes the cached DOM whenever a user takes an action that might have changed the DOM (clicks, navigations, etc).
|
46
|
+
So the performance improvement will come with the number of successive calls of `#text!` before taking other actions.
|
32
47
|
|
33
48
|
## Contributing
|
34
49
|
|
35
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
50
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/titusfortner/watigiri.
|
36
51
|
|
37
52
|
## License
|
38
53
|
|
@@ -17,7 +17,7 @@ module Watigiri
|
|
17
17
|
return super unless @nokogiri || @regex
|
18
18
|
@query_scope.browser.doc ||= Nokogiri::HTML(@query_scope.html).tap { |d| d.css('script').remove }
|
19
19
|
|
20
|
-
element =
|
20
|
+
element = using_watir(:first)
|
21
21
|
return if element.nil?
|
22
22
|
@nokogiri ? element.element : nokogiri_to_selenium(element)
|
23
23
|
end
|
@@ -29,7 +29,7 @@ module Watigiri
|
|
29
29
|
return super unless @nokogiri || @regex
|
30
30
|
@query_scope.browser.doc ||= Nokogiri::HTML(@query_scope.html).tap { |d| d.css('script').remove }
|
31
31
|
|
32
|
-
elements =
|
32
|
+
elements = using_watir(:all)
|
33
33
|
@nokogiri ? elements : elements.map { |element| nokogiri_to_watir element }
|
34
34
|
end
|
35
35
|
|
@@ -50,19 +50,20 @@ module Watigiri
|
|
50
50
|
end
|
51
51
|
end
|
52
52
|
|
53
|
-
def
|
53
|
+
def filter_elements_by_locator noko_elements, visible = nil, visible_text = nil, idx = nil, tag_name: nil, filter: :first
|
54
54
|
return super unless @nokogiri || @regex
|
55
55
|
return super if noko_elements.first.is_a?(Selenium::WebDriver::Element)
|
56
56
|
|
57
57
|
unless visible.nil?
|
58
58
|
noko_elements.select! { |el| visible == nokogiri_to_watir(el.element).visible? }
|
59
59
|
end
|
60
|
-
|
60
|
+
filter == :first ? noko_elements[idx || 0] : noko_elements
|
61
61
|
end
|
62
62
|
|
63
|
-
def filter_elements_by_regex(noko_elements, rx_selector,
|
63
|
+
def filter_elements_by_regex(noko_elements, rx_selector, filter)
|
64
64
|
return if noko_elements.empty?
|
65
65
|
return super if noko_elements.first.is_a?(Selenium::WebDriver::Element)
|
66
|
+
method = filter == :first ? :find : :select
|
66
67
|
|
67
68
|
if @nokogiri || !@regex
|
68
69
|
return noko_elements.__send__(method) { |el| matches_selector?(el.element, rx_selector) }
|
data/watigiri.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 = "watigiri"
|
7
|
-
spec.version = "0.2.
|
7
|
+
spec.version = "0.2.2"
|
8
8
|
spec.authors = ["Titus Fortner"]
|
9
9
|
spec.email = ["titusfortner@gmail.com"]
|
10
10
|
|
@@ -28,6 +28,6 @@ with Nokogiri calls where designated.
|
|
28
28
|
spec.add_development_dependency "rspec", "~> 3.0"
|
29
29
|
spec.add_development_dependency "webdrivers", "~> 3.0"
|
30
30
|
|
31
|
-
spec.add_runtime_dependency "watir", "~> 6.
|
31
|
+
spec.add_runtime_dependency "watir", "~> 6.10"
|
32
32
|
spec.add_runtime_dependency "nokogiri"
|
33
33
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: watigiri
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2
|
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-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -72,20 +72,14 @@ dependencies:
|
|
72
72
|
requirements:
|
73
73
|
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: '6.
|
76
|
-
- - ">="
|
77
|
-
- !ruby/object:Gem::Version
|
78
|
-
version: 6.8.2
|
75
|
+
version: '6.10'
|
79
76
|
type: :runtime
|
80
77
|
prerelease: false
|
81
78
|
version_requirements: !ruby/object:Gem::Requirement
|
82
79
|
requirements:
|
83
80
|
- - "~>"
|
84
81
|
- !ruby/object:Gem::Version
|
85
|
-
version: '6.
|
86
|
-
- - ">="
|
87
|
-
- !ruby/object:Gem::Version
|
88
|
-
version: 6.8.2
|
82
|
+
version: '6.10'
|
89
83
|
- !ruby/object:Gem::Dependency
|
90
84
|
name: nokogiri
|
91
85
|
requirement: !ruby/object:Gem::Requirement
|