locatine 0.02058 → 0.02247
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 +1 -1
- data/lib/locatine/app/manifest.json +1 -1
- data/lib/locatine/for_search/dialog_logic.rb +0 -44
- data/lib/locatine/for_search/element_selection.rb +80 -0
- data/lib/locatine/for_search/file_work.rb +1 -0
- data/lib/locatine/for_search/highlight.rb +1 -1
- data/lib/locatine/for_search/merge.rb +2 -1
- data/lib/locatine/for_search/saying.rb +13 -1
- data/lib/locatine/search.rb +3 -1
- data/lib/locatine/version.rb +1 -1
- metadata +12 -5
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 023773fde5af096ee6f8b04948dbeadcee35f3d2
|
|
4
|
+
data.tar.gz: 2071bcae7bf758afc1196a82f04f74690931f9c0
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: c3c8e5959c2fd4b850608ee0d998357c32ce9af253e6726c3077f6eafeeef4625a85fa0e5c70f10564d14c1d46756efe61a9823f4e68f2ac37dd5000d008d1bb
|
|
7
|
+
data.tar.gz: 99f44eb1de8f7158f8b108edc971c2682322fc2fb60db7e2729da318a73729e21f1dece359616bdfd14e9703a8277b6372c968cac73725fd82e930a85d61fa80
|
data/README.md
CHANGED
|
@@ -16,7 +16,7 @@ That's it.
|
|
|
16
16
|
|
|
17
17
|
## Stage of development:
|
|
18
18
|
|
|
19
|
-
Version of Locatine is **0.
|
|
19
|
+
Version of Locatine is **0.02247** only. It means so far this is an alfa. You can use it in a real project if you are a risky person.
|
|
20
20
|
|
|
21
21
|
## Installation
|
|
22
22
|
|
|
@@ -18,50 +18,6 @@ module Locatine
|
|
|
18
18
|
return element, attributes
|
|
19
19
|
end
|
|
20
20
|
|
|
21
|
-
def add_selected_attributes(new_attributes, attributes)
|
|
22
|
-
if get_from_app('locatinecollection') == 'true'
|
|
23
|
-
get_commons(new_attributes, attributes.to_h)
|
|
24
|
-
else
|
|
25
|
-
new_attributes
|
|
26
|
-
end
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
def selected_element_attributes(tag, index, vars)
|
|
30
|
-
generate_data([engine.elements(tag_name: tag)[index]], vars).to_h
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
def selected_element(tag, index, vars, attributes)
|
|
34
|
-
new_attributes = selected_element_attributes(tag, index, vars)
|
|
35
|
-
new_attributes = add_selected_attributes(new_attributes, attributes)
|
|
36
|
-
element = find_by_data(new_attributes, vars)
|
|
37
|
-
return element, new_attributes
|
|
38
|
-
end
|
|
39
|
-
|
|
40
|
-
def working_on_selected(tag, index, vars, attributes)
|
|
41
|
-
send_working(tag, index)
|
|
42
|
-
element, new_attributes = selected_element(tag, index, vars, attributes)
|
|
43
|
-
warn_dropping(tag, index) unless element
|
|
44
|
-
|
|
45
|
-
warn_type(tag) if @type && !element
|
|
46
|
-
|
|
47
|
-
return_selected(element, attributes, new_attributes, vars)
|
|
48
|
-
end
|
|
49
|
-
|
|
50
|
-
def return_old_selection(attrs, vars)
|
|
51
|
-
return find_by_data(attrs, vars).to_a, attrs.to_h if attrs.to_h != {}
|
|
52
|
-
|
|
53
|
-
return nil, {}
|
|
54
|
-
end
|
|
55
|
-
|
|
56
|
-
def return_selected(element, attributes, new_attributes, vars)
|
|
57
|
-
if !element && new_attributes.to_h != {}
|
|
58
|
-
send_lost
|
|
59
|
-
return return_old_selection(attributes, vars)
|
|
60
|
-
|
|
61
|
-
end
|
|
62
|
-
return element, new_attributes
|
|
63
|
-
end
|
|
64
|
-
|
|
65
21
|
def what_was_selected(element, attributes, vars)
|
|
66
22
|
tag, index = tag_index
|
|
67
23
|
send_to_app('locatineconfirmed', 'ok')
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
module Locatine
|
|
2
|
+
module ForSearch
|
|
3
|
+
##
|
|
4
|
+
# Cooking element data for dialog
|
|
5
|
+
module ElementSelection
|
|
6
|
+
private
|
|
7
|
+
|
|
8
|
+
def add_selected_attributes(new_attributes, attributes)
|
|
9
|
+
if get_from_app('locatinecollection') == 'true'
|
|
10
|
+
get_commons(new_attributes, attributes.to_h)
|
|
11
|
+
else
|
|
12
|
+
new_attributes
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def simple_attrs(tag, index, vars)
|
|
17
|
+
element = engine.elements(tag_name: tag)[index]
|
|
18
|
+
attrs = generate_data([element], vars).to_h
|
|
19
|
+
return element, attrs
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def negative_needed(element, vars, old_depth)
|
|
23
|
+
@depth = old_depth
|
|
24
|
+
warn_no_negatives
|
|
25
|
+
generate_data([element], vars).to_h
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def complex_attrs(element, vars, old_depth = @depth)
|
|
29
|
+
attrs = get_family_info(element, vars).to_h
|
|
30
|
+
return negative_needed(element, vars, old_depth) if attrs.length < @depth
|
|
31
|
+
|
|
32
|
+
if find_by_data(attrs, vars).length > 1
|
|
33
|
+
@depth +=1
|
|
34
|
+
return complex_attrs(element, vars, old_depth)
|
|
35
|
+
end
|
|
36
|
+
@depth = old_depth
|
|
37
|
+
attrs
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def selected_element_attributes(tag, index, vars)
|
|
41
|
+
element, attrs = simple_attrs(tag, index, vars)
|
|
42
|
+
length = find_by_data(attrs, vars).to_a.length
|
|
43
|
+
attrs = complex_attrs(element, vars) if length > 1
|
|
44
|
+
attrs
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
def selected_element(tag, index, vars, attributes)
|
|
48
|
+
new_attributes = selected_element_attributes(tag, index, vars)
|
|
49
|
+
new_attributes = add_selected_attributes(new_attributes, attributes)
|
|
50
|
+
element = find_by_data(new_attributes, vars)
|
|
51
|
+
return element, new_attributes
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
def working_on_selected(tag, index, vars, attributes)
|
|
55
|
+
send_working(tag, index)
|
|
56
|
+
element, new_attributes = selected_element(tag, index, vars, attributes)
|
|
57
|
+
warn_dropping(tag, index) unless element
|
|
58
|
+
|
|
59
|
+
warn_type(tag) if @type && !element
|
|
60
|
+
|
|
61
|
+
return_selected(element, attributes, new_attributes, vars)
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
def return_old_selection(attrs, vars)
|
|
65
|
+
return find_by_data(attrs, vars).to_a, attrs.to_h if attrs.to_h != {}
|
|
66
|
+
|
|
67
|
+
return nil, {}
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
def return_selected(element, attributes, new_attributes, vars)
|
|
71
|
+
if !element && new_attributes.to_h != {}
|
|
72
|
+
send_lost
|
|
73
|
+
return return_old_selection(attributes, vars)
|
|
74
|
+
|
|
75
|
+
end
|
|
76
|
+
return element, new_attributes
|
|
77
|
+
end
|
|
78
|
+
end
|
|
79
|
+
end
|
|
80
|
+
end
|
|
@@ -35,6 +35,7 @@ module Locatine
|
|
|
35
35
|
# Setting stability
|
|
36
36
|
def set_stability(first, second)
|
|
37
37
|
second = first if second.to_h == {}
|
|
38
|
+
first = second.merge first
|
|
38
39
|
final = Hash.new { |hash, key| hash[key] = [] }
|
|
39
40
|
first.each_pair do |depth, array|
|
|
40
41
|
final[depth] = same_entries(array, second, depth, true).uniq
|
|
@@ -27,7 +27,7 @@ module Locatine
|
|
|
27
27
|
##
|
|
28
28
|
# We can highlight\unhighlight tons of elements at once
|
|
29
29
|
def mass_highlight_turn(mass, turn_on = true)
|
|
30
|
-
warn_much_highlight if turn_on && mass.length > 50
|
|
30
|
+
warn_much_highlight(mass.length) if turn_on && mass.length > 50
|
|
31
31
|
mass[0..49].each do |element|
|
|
32
32
|
if turn_on
|
|
33
33
|
highlight element
|
|
@@ -16,7 +16,8 @@ module Locatine
|
|
|
16
16
|
def same_entries(array, second, depth, stability_up = false)
|
|
17
17
|
result = []
|
|
18
18
|
array.each do |hash|
|
|
19
|
-
|
|
19
|
+
item = second[depth]
|
|
20
|
+
to_add = item.nil? ? [] : select_same(second[depth], hash)
|
|
20
21
|
to_add = stability_bump(to_add, hash) if stability_up
|
|
21
22
|
result += to_add
|
|
22
23
|
end
|
|
@@ -146,7 +146,19 @@ module Locatine
|
|
|
146
146
|
end
|
|
147
147
|
|
|
148
148
|
def warn_not_found(name, scope)
|
|
149
|
-
"Locatine cannot find element #{name} in #{scope}"
|
|
149
|
+
send_warn "Locatine cannot find element #{name} in #{scope}"
|
|
150
|
+
end
|
|
151
|
+
|
|
152
|
+
def warn_totally_same(how_deep)
|
|
153
|
+
send_warn('There are more than one elements with totally similar'\
|
|
154
|
+
" attributes. Custom depth for element is set to #{how_deep}.")
|
|
155
|
+
end
|
|
156
|
+
|
|
157
|
+
def warn_no_negatives
|
|
158
|
+
send_warn 'The only way to find the selected element is to use'\
|
|
159
|
+
" negative expression like //*[not(@id='something')]. Locatine does"\
|
|
160
|
+
' not support it. So you must to provide for element a custom locator.'\
|
|
161
|
+
' Or find it as a part of collection and than return it by index'
|
|
150
162
|
end
|
|
151
163
|
|
|
152
164
|
def raise_not_found(name, scope)
|
data/lib/locatine/search.rb
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
require 'watir'
|
|
2
2
|
require 'json'
|
|
3
3
|
require 'fileutils'
|
|
4
|
-
require '
|
|
4
|
+
require 'webdrivers'
|
|
5
5
|
|
|
6
6
|
# Internal requires
|
|
7
7
|
require 'locatine/for_search/merge'
|
|
@@ -21,6 +21,7 @@ require 'locatine/for_search/find_by_guess'
|
|
|
21
21
|
require 'locatine/for_search/data_generate'
|
|
22
22
|
require 'locatine/for_search/xpath_generator'
|
|
23
23
|
require 'locatine/for_search/find_by_locator'
|
|
24
|
+
require 'locatine/for_search/element_selection'
|
|
24
25
|
|
|
25
26
|
module Locatine
|
|
26
27
|
##
|
|
@@ -45,6 +46,7 @@ module Locatine
|
|
|
45
46
|
include Locatine::ForSearch::DataGenerate
|
|
46
47
|
include Locatine::ForSearch::FindByLocator
|
|
47
48
|
include Locatine::ForSearch::XpathGenerator
|
|
49
|
+
include Locatine::ForSearch::ElementSelection
|
|
48
50
|
|
|
49
51
|
attr_accessor :data,
|
|
50
52
|
:depth,
|
data/lib/locatine/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: locatine
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: '0.
|
|
4
|
+
version: '0.02247'
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Sergei Seleznev
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2019-
|
|
11
|
+
date: 2019-05-06 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bundler
|
|
@@ -95,19 +95,25 @@ dependencies:
|
|
|
95
95
|
- !ruby/object:Gem::Version
|
|
96
96
|
version: '2.0'
|
|
97
97
|
- !ruby/object:Gem::Dependency
|
|
98
|
-
name:
|
|
98
|
+
name: webdrivers
|
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
|
100
100
|
requirements:
|
|
101
101
|
- - "~>"
|
|
102
102
|
- !ruby/object:Gem::Version
|
|
103
|
-
version: '
|
|
103
|
+
version: '3.8'
|
|
104
|
+
- - ">="
|
|
105
|
+
- !ruby/object:Gem::Version
|
|
106
|
+
version: 3.8.0
|
|
104
107
|
type: :runtime
|
|
105
108
|
prerelease: false
|
|
106
109
|
version_requirements: !ruby/object:Gem::Requirement
|
|
107
110
|
requirements:
|
|
108
111
|
- - "~>"
|
|
109
112
|
- !ruby/object:Gem::Version
|
|
110
|
-
version: '
|
|
113
|
+
version: '3.8'
|
|
114
|
+
- - ">="
|
|
115
|
+
- !ruby/object:Gem::Version
|
|
116
|
+
version: 3.8.0
|
|
111
117
|
description: The main goal to write locators never
|
|
112
118
|
email: s_seleznev_qa@hotmail.com
|
|
113
119
|
executables: []
|
|
@@ -129,6 +135,7 @@ files:
|
|
|
129
135
|
- lib/locatine/for_search/data_generate.rb
|
|
130
136
|
- lib/locatine/for_search/data_logic.rb
|
|
131
137
|
- lib/locatine/for_search/dialog_logic.rb
|
|
138
|
+
- lib/locatine/for_search/element_selection.rb
|
|
132
139
|
- lib/locatine/for_search/file_work.rb
|
|
133
140
|
- lib/locatine/for_search/find_by_css.rb
|
|
134
141
|
- lib/locatine/for_search/find_by_guess.rb
|