watigiri 0.2.1 → 0.2.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4b36e470816ed59fba3a8f7cd7357b9e75c8aeba
4
- data.tar.gz: a28a573735e93769350e3334a765a9517bc9740e
3
+ metadata.gz: b54f1a44d2ce370b82465ea35623426beb9cc700
4
+ data.tar.gz: 16c9d06260d4a01271bc7f789a816e9d20cbdee3
5
5
  SHA512:
6
- metadata.gz: f683a88e709c46de0d7d8cbc91adaba4c4e6641c8e450b630768ccc8f43b0dc454b272b0e833ca27a770904c9d4ff867bda4faae1f8f969411112b850de6e445
7
- data.tar.gz: e46b1b71bb6d266d6b24492ab6ba989c3cbd8da455f5183d28d21694f60c65ba87ecece979204d6be072784a8b7a6c813d41913f3296c7ec4dd35bcdc4956da7
6
+ metadata.gz: 68cad5b608ac6b3eebc53f1c36b62371c968db2af9035cfa352a5f96c915a5ca0cb9eb3651f275d3b634fabf44f68fd360905298d7db485a0ce9d9c75ff3a10c
7
+ data.tar.gz: be6cb2c9ff17d61c292c4b26a86ed4ddc9da9eabc95a8ec777cafa0cecaad50ad8f9bae0143b7b6513a6fcf553f95d0e5c5b06e18124c78151c738d8cbb0032b
data/README.md CHANGED
@@ -1,8 +1,20 @@
1
1
  # Watigiri
2
2
 
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/watigiri`. To experiment with that code, run `bin/console` for an interactive prompt.
4
-
5
- TODO: Delete this and the text above, and describe your gem
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
- TODO: Write usage instructions here
26
-
27
- ## Development
37
+ First require it in your code:
38
+ ```ruby
39
+ require 'watigiri'
40
+ ```
28
41
 
29
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
42
+ Once required, Watigiri will automatically speed up the location of elements using regular expression values.
30
43
 
31
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
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/[USERNAME]/watigiri.
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 = find_first_by_multiple
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 = find_all_by_multiple
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 filter_elements noko_elements, visible, idx, number
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
- number == :single ? noko_elements[idx || 0] : noko_elements
60
+ filter == :first ? noko_elements[idx || 0] : noko_elements
61
61
  end
62
62
 
63
- def filter_elements_by_regex(noko_elements, rx_selector, method)
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.1"
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.8", ">= 6.8.2"
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.1
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-09-06 00:00:00.000000000 Z
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.8'
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.8'
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