locatine 0.01454 → 0.01546
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/locatine/app/manifest.json +1 -1
- data/lib/locatine/data_generate.rb +2 -2
- data/lib/locatine/find_by_locator.rb +1 -1
- data/lib/locatine/find_by_magic.rb +23 -13
- data/lib/locatine/find_logic.rb +11 -5
- data/lib/locatine/helpers.rb +6 -0
- data/lib/locatine/public.rb +3 -5
- data/lib/locatine/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8a4b678e1915017d1898771afe9cd2b737051b62
|
4
|
+
data.tar.gz: 8adbe3846eecb369e49483a1aa2e08b291dddf6c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f79005a1036bbe968439219a2b3c90ec183b95d4ae7990cebdee2aa9065186a93dcb96c592dd5dd894a1b1f633eb20d9e5ee604206c8c6ef88296eb2a936a531
|
7
|
+
data.tar.gz: 53b87536a961b56ec9b82a2762812dfd151b7454b716eb108137f97fa8d71e751fca8c564c6da414c0f8d68c5784a69d0c2d4853e9a477d2b248a7b9f5497560
|
@@ -87,9 +87,9 @@ module Locatine
|
|
87
87
|
attributes.each_pair do |name, value|
|
88
88
|
next if name.to_s == 'locatineclass'
|
89
89
|
|
90
|
-
value.split(/['" ]/).uniq.each do |part|
|
90
|
+
value.split(/['" ]/).reject(&:empty?).uniq.each do |part|
|
91
91
|
array.push('name' => name.to_s, 'type' => 'attribute',
|
92
|
-
'value' => part)
|
92
|
+
'value' => part)
|
93
93
|
end
|
94
94
|
end
|
95
95
|
array
|
@@ -22,7 +22,7 @@ module Locatine
|
|
22
22
|
results = engine.send(method, locator)
|
23
23
|
return correct_method_detected(results) if collection?(results.class)
|
24
24
|
|
25
|
-
|
25
|
+
acceptable_method_detected(results, method, locator)
|
26
26
|
end
|
27
27
|
|
28
28
|
def correct_method_detected(results)
|
@@ -6,29 +6,39 @@ module Locatine
|
|
6
6
|
|
7
7
|
##
|
8
8
|
# Getting all the elements via black magic
|
9
|
-
def find_by_magic(name, scope, data, vars)
|
9
|
+
def find_by_magic(name, scope, data, vars, exact)
|
10
10
|
warn "#{name} in #{scope} is lost. Looking for it."
|
11
11
|
@cold_time = 0
|
12
12
|
all = all_options(data, vars)
|
13
13
|
@cold_time = nil
|
14
|
-
raise "Unable to find element #{name} in #{scope}" if all.empty?
|
14
|
+
raise "Unable to find element #{name} in #{scope}" if all.empty? && !exact
|
15
15
|
|
16
|
-
suggest_by_all(all, data, vars, name, scope)
|
16
|
+
suggest_by_all(all, data, vars, name, scope, exact)
|
17
17
|
end
|
18
18
|
|
19
19
|
def similar_enough(data, attributes)
|
20
|
-
|
21
|
-
data['0'].length
|
20
|
+
same = same_entries(data['0'], attributes, '0').length
|
21
|
+
all = data['0'].length
|
22
|
+
sameness = (same * 100) / all
|
23
|
+
sameness >= 100 - @current_t
|
22
24
|
end
|
23
25
|
|
24
|
-
def
|
26
|
+
def best_of_all(all, vars)
|
25
27
|
max = all.count(all.max_by { |i| all.count(i) })
|
26
|
-
|
27
|
-
attributes = generate_data(
|
28
|
-
|
29
|
-
|
28
|
+
suggest = (all.select { |i| all.count(i) == max }).uniq unless max.zero?
|
29
|
+
attributes = generate_data(suggest, vars) unless suggest.nil?
|
30
|
+
return suggest, attributes
|
31
|
+
end
|
32
|
+
|
33
|
+
def suggest_by_all(all, data, vars, name, scope, exact)
|
34
|
+
suggest, attributes = best_of_all(all, vars)
|
35
|
+
ok = similar_enough(data, attributes) unless suggest.nil?
|
36
|
+
spawn = !ok && !exact
|
37
|
+
raise "Unable to find element similar to #{name} in #{scope}" if spawn
|
38
|
+
|
39
|
+
return suggest, attributes if ok
|
30
40
|
|
31
|
-
return
|
41
|
+
return nil, nil
|
32
42
|
end
|
33
43
|
|
34
44
|
def all_options(data, vars)
|
@@ -44,8 +54,8 @@ module Locatine
|
|
44
54
|
end
|
45
55
|
|
46
56
|
def min_max_by_size(middle, size)
|
47
|
-
min = middle - (size.to_i * (
|
48
|
-
max = middle + (size.to_i * (
|
57
|
+
min = middle - (size.to_i * (200 - @current_t)) / 200
|
58
|
+
max = middle + (size.to_i * (200 - @current_t)) / 200
|
49
59
|
return min, max
|
50
60
|
end
|
51
61
|
|
data/lib/locatine/find_logic.rb
CHANGED
@@ -16,7 +16,7 @@ module Locatine
|
|
16
16
|
attributes.each_pair do |_depth, array|
|
17
17
|
s.push array.max_by { |item| item['stability'].to_i }['stability'].to_i
|
18
18
|
end
|
19
|
-
s.max
|
19
|
+
s.max >= @stability_limit
|
20
20
|
end
|
21
21
|
|
22
22
|
def data_search(name, scope, vars, exact)
|
@@ -24,7 +24,7 @@ module Locatine
|
|
24
24
|
attributes = generate_data(result, vars) if result
|
25
25
|
if !result && (!exact || !stable?(@data[scope][name]))
|
26
26
|
result, attributes = find_by_magic(name, scope,
|
27
|
-
@data[scope][name], vars)
|
27
|
+
@data[scope][name], vars, exact)
|
28
28
|
end
|
29
29
|
return result, attributes
|
30
30
|
end
|
@@ -37,15 +37,21 @@ module Locatine
|
|
37
37
|
end
|
38
38
|
|
39
39
|
def full_search(name, scope, vars, locator, exact)
|
40
|
-
result, attributes =
|
41
|
-
result, attributes = core_search(name, scope, vars, exact) unless result
|
42
|
-
result, attributes = ask(scope, name, result, vars) if @learn
|
40
|
+
result, attributes = search_steps(name, scope, vars, locator, exact)
|
43
41
|
raise "Nothing was found for #{scope} #{name}" if !result && !exact
|
44
42
|
|
45
43
|
store(attributes, scope, name) if result
|
46
44
|
return result, attributes
|
47
45
|
end
|
48
46
|
|
47
|
+
def search_steps(name, scope, vars, locator, exact)
|
48
|
+
result, attributes = locator_search(locator, vars)
|
49
|
+
ok = result || ((locator != {}) && exact)
|
50
|
+
result, attributes = core_search(name, scope, vars, exact) unless ok
|
51
|
+
result, attributes = ask(scope, name, result, vars) if @learn
|
52
|
+
return result, attributes
|
53
|
+
end
|
54
|
+
|
49
55
|
def locator_search(locator, vars)
|
50
56
|
result = find_by_locator(locator) if locator != {}
|
51
57
|
attributes = generate_data(result, vars) if result
|
data/lib/locatine/helpers.rb
CHANGED
@@ -19,6 +19,12 @@ module Locatine
|
|
19
19
|
(@iframe || @browser)
|
20
20
|
end
|
21
21
|
|
22
|
+
def set_env_for_search(look_in, iframe, tolerance)
|
23
|
+
@type = look_in
|
24
|
+
@iframe = iframe
|
25
|
+
@current_t = tolerance || @tolerance
|
26
|
+
end
|
27
|
+
|
22
28
|
def not_magic_div
|
23
29
|
"[not(@id = 'locatine_magic_div')]"
|
24
30
|
end
|
data/lib/locatine/public.rb
CHANGED
@@ -30,9 +30,9 @@ module Locatine
|
|
30
30
|
depth: 3,
|
31
31
|
browser: nil,
|
32
32
|
learn: ENV['LEARN'].nil? ? false : true,
|
33
|
-
stability_limit:
|
33
|
+
stability_limit: 1000,
|
34
34
|
scope: 'Default',
|
35
|
-
tolerance:
|
35
|
+
tolerance: 67,
|
36
36
|
visual_search: false)
|
37
37
|
import_browser browser
|
38
38
|
import_file(json)
|
@@ -85,9 +85,7 @@ module Locatine
|
|
85
85
|
collection: false,
|
86
86
|
tolerance: nil)
|
87
87
|
name = set_name(simple_name, name)
|
88
|
-
|
89
|
-
@iframe = iframe
|
90
|
-
@tolerance ||= tolerance
|
88
|
+
set_env_for_search(look_in, iframe, tolerance)
|
91
89
|
scope ||= @scope.nil? ? 'Default' : @scope
|
92
90
|
result, attributes = full_search(name, scope, vars, locator, exact)
|
93
91
|
return { xpath: generate_xpath(attributes, vars) } if result &&
|
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.01546'
|
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-03-
|
11
|
+
date: 2019-03-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|