pincers 0.4.3 → 0.4.4
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/lib/pincers/core/search_context.rb +1 -10
- data/lib/pincers/extension/queries.rb +13 -0
- data/lib/pincers/support/xpath_builder.rb +13 -3
- data/lib/pincers/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: e16b32dabf298054ed5e1d29154cba02910c1820
|
|
4
|
+
data.tar.gz: 2b4a3b62cdaeca0b9339abc309eefff40a6d7aaa
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: d13a6b8b6c4cfadc7a995654c2a0f745861c4aadbee9e725d452cb895d2d43ec0141027245a3d39bb0e5d8ad3ba423d7e53c42846e97f52836e43949e18aa77d
|
|
7
|
+
data.tar.gz: a7adb7894c79e32000cb61d8d54d20c803886d4aa3be30b226e3d526525483e529ea22442250fe4cefca2ed5d90489a1d60fffcfb5486e78fee658d407f3f3ed
|
|
@@ -2,7 +2,6 @@ require 'pincers/extension/queries'
|
|
|
2
2
|
require 'pincers/extension/actions'
|
|
3
3
|
require 'pincers/extension/labs'
|
|
4
4
|
require 'pincers/support/query'
|
|
5
|
-
require 'pincers/support/xpath_builder'
|
|
6
5
|
|
|
7
6
|
module Pincers::Core
|
|
8
7
|
class SearchContext
|
|
@@ -94,15 +93,7 @@ module Pincers::Core
|
|
|
94
93
|
end
|
|
95
94
|
end
|
|
96
95
|
|
|
97
|
-
def xpath(_selector
|
|
98
|
-
_options = _selector if _selector.is_a? Hash
|
|
99
|
-
|
|
100
|
-
unless _block.nil?
|
|
101
|
-
builder = Pincers::Support::XPathBuilder.new
|
|
102
|
-
_block.call builder
|
|
103
|
-
_selector = builder.expression
|
|
104
|
-
end
|
|
105
|
-
|
|
96
|
+
def xpath(_selector, _options={})
|
|
106
97
|
wrap_errors do
|
|
107
98
|
query = Pincers::Support::Query.new backend, :xpath, _selector, _options[:limit]
|
|
108
99
|
wrap_childs query
|
|
@@ -1,8 +1,21 @@
|
|
|
1
|
+
require 'pincers/support/xpath_builder'
|
|
2
|
+
|
|
1
3
|
module Pincers::Extension
|
|
2
4
|
module Queries
|
|
3
5
|
|
|
4
6
|
TEXT_INPUTS = ['text', 'email', 'number', 'email', 'color', 'password', 'search', 'tel', 'url']
|
|
5
7
|
|
|
8
|
+
def search(_options={}, &_block)
|
|
9
|
+
query_options = {
|
|
10
|
+
limit: _options.delete(:limit)
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
builder = Pincers::Support::XPathBuilder.new _options
|
|
14
|
+
_block.call builder unless _block.nil?
|
|
15
|
+
|
|
16
|
+
xpath builder.expression, query_options
|
|
17
|
+
end
|
|
18
|
+
|
|
6
19
|
def value
|
|
7
20
|
case input_mode
|
|
8
21
|
when :checkbox, :radio
|
|
@@ -1,12 +1,22 @@
|
|
|
1
1
|
module Pincers::Support
|
|
2
2
|
class XPathBuilder
|
|
3
3
|
|
|
4
|
-
def initialize
|
|
4
|
+
def initialize(_options={})
|
|
5
5
|
@parts = []
|
|
6
|
+
by_tag _options.delete(:tag) if _options.key? :tag
|
|
7
|
+
by_content _options.delete(:content) if _options.key? :content
|
|
8
|
+
|
|
9
|
+
if _options.key? :class
|
|
10
|
+
_options.delete(:class).split(' ').each { |c| by_class c }
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
_options.each do |key, value|
|
|
14
|
+
by_attribute key, contains: value
|
|
15
|
+
end
|
|
6
16
|
end
|
|
7
17
|
|
|
8
18
|
def expression
|
|
9
|
-
"
|
|
19
|
+
".//*[#{@parts.join(' and ')}]"
|
|
10
20
|
end
|
|
11
21
|
|
|
12
22
|
def by_tag(_name)
|
|
@@ -14,7 +24,7 @@ module Pincers::Support
|
|
|
14
24
|
self
|
|
15
25
|
end
|
|
16
26
|
|
|
17
|
-
def
|
|
27
|
+
def by_content(_contents, _options={})
|
|
18
28
|
# TODO: more options, lowercase support?
|
|
19
29
|
# xpath("//*[text()='#{_contents}'] | //*[@value='#{_contents}']", _options)
|
|
20
30
|
add "(contains(text(), '#{_contents}') or contains(@value, '#{_contents}'))"
|
data/lib/pincers/version.rb
CHANGED