locatine 0.02058 → 0.02539
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +159 -4
- data/bin/locatine-daemon.rb +8 -0
- data/lib/locatine.rb +1 -0
- data/lib/locatine/app/manifest.json +1 -1
- data/lib/locatine/daemon.rb +93 -0
- data/lib/locatine/daemon_helpers.rb +52 -0
- data/lib/locatine/for_search/data_generate.rb +12 -45
- data/lib/locatine/for_search/data_logic.rb +32 -10
- data/lib/locatine/for_search/defaults.rb +40 -0
- data/lib/locatine/for_search/dialog_logic.rb +1 -44
- data/lib/locatine/for_search/element_selection.rb +80 -0
- data/lib/locatine/for_search/file_work.rb +11 -10
- data/lib/locatine/for_search/find_by_guess.rb +41 -38
- data/lib/locatine/for_search/find_by_locator.rb +0 -30
- data/lib/locatine/for_search/find_by_magic.rb +30 -81
- data/lib/locatine/for_search/find_logic.rb +6 -2
- data/lib/locatine/for_search/helpers.rb +20 -10
- data/lib/locatine/for_search/highlight.rb +1 -1
- data/lib/locatine/for_search/merge.rb +4 -2
- data/lib/locatine/for_search/page_work.rb +126 -0
- data/lib/locatine/for_search/public.rb +35 -22
- data/lib/locatine/for_search/saying.rb +28 -3
- data/lib/locatine/for_search/xpath_generator.rb +10 -11
- data/lib/locatine/large_scripts/element.js +31 -0
- data/lib/locatine/large_scripts/page.js +60 -0
- data/lib/locatine/scope.rb +1 -0
- data/lib/locatine/search.rb +11 -4
- data/lib/locatine/version.rb +1 -1
- metadata +26 -12
- data/lib/locatine/for_search/find_by_css.rb +0 -47
@@ -0,0 +1,60 @@
|
|
1
|
+
|
2
|
+
function walk(elm) {
|
3
|
+
let node;
|
4
|
+
|
5
|
+
const tagName = elm.tagName.toLowerCase();
|
6
|
+
const array = Array.prototype.slice.call( document.getElementsByTagName(tagName) );
|
7
|
+
const index = array.indexOf(elm);
|
8
|
+
const relative = elm.getBoundingClientRect();
|
9
|
+
|
10
|
+
// init item
|
11
|
+
const item = {tag: tagName,
|
12
|
+
index: index,
|
13
|
+
style: getComputedStyle(elm).cssText,
|
14
|
+
text: "",
|
15
|
+
attrs: {},
|
16
|
+
coordinates: {top:0, bottom:0, left:0, right:0},
|
17
|
+
children: []};
|
18
|
+
|
19
|
+
// text for item
|
20
|
+
if (elm.childNodes) {
|
21
|
+
for (let z = 0; z < elm.childNodes.length; ++z){
|
22
|
+
if (elm.childNodes[z].nodeType === 3){
|
23
|
+
item.text += elm.childNodes[z].textContent;
|
24
|
+
}
|
25
|
+
}
|
26
|
+
} else {
|
27
|
+
item.text = elm.textContent
|
28
|
+
}
|
29
|
+
|
30
|
+
// attributes for item
|
31
|
+
atts = elm.attributes;
|
32
|
+
if (atts) {
|
33
|
+
for (var att, k = 0, n = atts.length; k < n; k++){
|
34
|
+
att = atts[k];
|
35
|
+
item.attrs[att.nodeName] = att.nodeValue;
|
36
|
+
}
|
37
|
+
}
|
38
|
+
|
39
|
+
item.coordinates.top = relative["top"] + window.scrollY;
|
40
|
+
item.coordinates.bottom = relative["bottom"] + window.scrollY;
|
41
|
+
item.coordinates.left = relative["left"] + window.scrollX;
|
42
|
+
item.coordinates.right = relative["right"] + window.scrollX;
|
43
|
+
|
44
|
+
// Handle child elements (not magic ones)
|
45
|
+
for (node = elm.firstChild; node; node = node.nextSibling) {
|
46
|
+
if (node.nodeType === 1) { // 1 == Element
|
47
|
+
if (node.attributes['id']) {
|
48
|
+
if (node.attributes['id'].value !== 'locatine_magic_div') {
|
49
|
+
item.children.push(walk(node))
|
50
|
+
}
|
51
|
+
} else {
|
52
|
+
item.children.push(walk(node))
|
53
|
+
}
|
54
|
+
}
|
55
|
+
}
|
56
|
+
|
57
|
+
return item;
|
58
|
+
}
|
59
|
+
let result = walk(document.body);
|
60
|
+
return [result];
|
data/lib/locatine/scope.rb
CHANGED
@@ -80,6 +80,7 @@ module Locatine
|
|
80
80
|
item = @search.send(:ask, @scope, '', nil, vars)
|
81
81
|
return find_all(vars) if item[:element].nil?
|
82
82
|
|
83
|
+
@search.send(:set_env_for_search, nil, nil, nil, nil, nil, nil)
|
83
84
|
@search.send(:store, item[:attributes], @scope, item[:name])
|
84
85
|
new_define(vars)
|
85
86
|
end
|
data/lib/locatine/search.rb
CHANGED
@@ -1,19 +1,20 @@
|
|
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'
|
8
8
|
require 'locatine/for_search/public'
|
9
9
|
require 'locatine/for_search/saying'
|
10
10
|
require 'locatine/for_search/helpers'
|
11
|
+
require 'locatine/for_search/defaults'
|
11
12
|
require 'locatine/for_search/file_work'
|
13
|
+
require 'locatine/for_search/page_work'
|
12
14
|
require 'locatine/for_search/listening'
|
13
15
|
require 'locatine/for_search/highlight'
|
14
16
|
require 'locatine/for_search/data_logic'
|
15
17
|
require 'locatine/for_search/find_logic'
|
16
|
-
require 'locatine/for_search/find_by_css'
|
17
18
|
require 'locatine/for_search/name_helper'
|
18
19
|
require 'locatine/for_search/dialog_logic'
|
19
20
|
require 'locatine/for_search/find_by_magic'
|
@@ -21,6 +22,7 @@ require 'locatine/for_search/find_by_guess'
|
|
21
22
|
require 'locatine/for_search/data_generate'
|
22
23
|
require 'locatine/for_search/xpath_generator'
|
23
24
|
require 'locatine/for_search/find_by_locator'
|
25
|
+
require 'locatine/for_search/element_selection'
|
24
26
|
|
25
27
|
module Locatine
|
26
28
|
##
|
@@ -32,12 +34,13 @@ module Locatine
|
|
32
34
|
include Locatine::ForSearch::Public
|
33
35
|
include Locatine::ForSearch::Saying
|
34
36
|
include Locatine::ForSearch::Helpers
|
37
|
+
include Locatine::ForSearch::Defaults
|
35
38
|
include Locatine::ForSearch::FileWork
|
39
|
+
include Locatine::ForSearch::PageWork
|
36
40
|
include Locatine::ForSearch::DataLogic
|
37
41
|
include Locatine::ForSearch::Listening
|
38
42
|
include Locatine::ForSearch::FindLogic
|
39
43
|
include Locatine::ForSearch::Highlight
|
40
|
-
include Locatine::ForSearch::FindByCss
|
41
44
|
include Locatine::ForSearch::NameHelper
|
42
45
|
include Locatine::ForSearch::FindByMagic
|
43
46
|
include Locatine::ForSearch::DialogLogic
|
@@ -45,6 +48,7 @@ module Locatine
|
|
45
48
|
include Locatine::ForSearch::DataGenerate
|
46
49
|
include Locatine::ForSearch::FindByLocator
|
47
50
|
include Locatine::ForSearch::XpathGenerator
|
51
|
+
include Locatine::ForSearch::ElementSelection
|
48
52
|
|
49
53
|
attr_accessor :data,
|
50
54
|
:depth,
|
@@ -53,7 +57,10 @@ module Locatine
|
|
53
57
|
:scope,
|
54
58
|
:tolerance,
|
55
59
|
:visual_search,
|
56
|
-
:no_fail
|
60
|
+
:no_fail,
|
61
|
+
:trusted,
|
62
|
+
:untrusted,
|
63
|
+
:autolearn
|
57
64
|
attr_reader :json,
|
58
65
|
:browser
|
59
66
|
end
|
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.02539'
|
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-09-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -81,40 +81,48 @@ dependencies:
|
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '6.16'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
|
-
name:
|
84
|
+
name: webdrivers
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
87
|
- - "~>"
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version: '
|
89
|
+
version: '4.0'
|
90
|
+
- - ">="
|
91
|
+
- !ruby/object:Gem::Version
|
92
|
+
version: 4.0.1
|
90
93
|
type: :runtime
|
91
94
|
prerelease: false
|
92
95
|
version_requirements: !ruby/object:Gem::Requirement
|
93
96
|
requirements:
|
94
97
|
- - "~>"
|
95
98
|
- !ruby/object:Gem::Version
|
96
|
-
version: '
|
99
|
+
version: '4.0'
|
100
|
+
- - ">="
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: 4.0.1
|
97
103
|
- !ruby/object:Gem::Dependency
|
98
|
-
name:
|
104
|
+
name: sinatra
|
99
105
|
requirement: !ruby/object:Gem::Requirement
|
100
106
|
requirements:
|
101
|
-
- - "
|
107
|
+
- - ">="
|
102
108
|
- !ruby/object:Gem::Version
|
103
|
-
version:
|
109
|
+
version: 2.0.5
|
104
110
|
type: :runtime
|
105
111
|
prerelease: false
|
106
112
|
version_requirements: !ruby/object:Gem::Requirement
|
107
113
|
requirements:
|
108
|
-
- - "
|
114
|
+
- - ">="
|
109
115
|
- !ruby/object:Gem::Version
|
110
|
-
version:
|
116
|
+
version: 2.0.5
|
111
117
|
description: The main goal to write locators never
|
112
118
|
email: s_seleznev_qa@hotmail.com
|
113
|
-
executables:
|
119
|
+
executables:
|
120
|
+
- locatine-daemon.rb
|
114
121
|
extensions: []
|
115
122
|
extra_rdoc_files: []
|
116
123
|
files:
|
117
124
|
- README.md
|
125
|
+
- bin/locatine-daemon.rb
|
118
126
|
- lib/locatine.rb
|
119
127
|
- lib/locatine/app/background.js
|
120
128
|
- lib/locatine/app/content.css
|
@@ -125,12 +133,15 @@ files:
|
|
125
133
|
- lib/locatine/app/popup.css
|
126
134
|
- lib/locatine/app/popup.html
|
127
135
|
- lib/locatine/app/popup.js
|
136
|
+
- lib/locatine/daemon.rb
|
137
|
+
- lib/locatine/daemon_helpers.rb
|
128
138
|
- lib/locatine/for_search.rb
|
129
139
|
- lib/locatine/for_search/data_generate.rb
|
130
140
|
- lib/locatine/for_search/data_logic.rb
|
141
|
+
- lib/locatine/for_search/defaults.rb
|
131
142
|
- lib/locatine/for_search/dialog_logic.rb
|
143
|
+
- lib/locatine/for_search/element_selection.rb
|
132
144
|
- lib/locatine/for_search/file_work.rb
|
133
|
-
- lib/locatine/for_search/find_by_css.rb
|
134
145
|
- lib/locatine/for_search/find_by_guess.rb
|
135
146
|
- lib/locatine/for_search/find_by_locator.rb
|
136
147
|
- lib/locatine/for_search/find_by_magic.rb
|
@@ -140,11 +151,14 @@ files:
|
|
140
151
|
- lib/locatine/for_search/listening.rb
|
141
152
|
- lib/locatine/for_search/merge.rb
|
142
153
|
- lib/locatine/for_search/name_helper.rb
|
154
|
+
- lib/locatine/for_search/page_work.rb
|
143
155
|
- lib/locatine/for_search/public.rb
|
144
156
|
- lib/locatine/for_search/saying.rb
|
145
157
|
- lib/locatine/for_search/xpath_generator.rb
|
146
158
|
- lib/locatine/large_scripts/css.js
|
147
159
|
- lib/locatine/large_scripts/dimensions.js
|
160
|
+
- lib/locatine/large_scripts/element.js
|
161
|
+
- lib/locatine/large_scripts/page.js
|
148
162
|
- lib/locatine/scope.rb
|
149
163
|
- lib/locatine/search.rb
|
150
164
|
- lib/locatine/version.rb
|
@@ -1,47 +0,0 @@
|
|
1
|
-
module Locatine
|
2
|
-
module ForSearch
|
3
|
-
##
|
4
|
-
# Looking for elements by css values
|
5
|
-
module FindByCss
|
6
|
-
private
|
7
|
-
|
8
|
-
def css_array_by_data(data, vars)
|
9
|
-
q_css = []
|
10
|
-
get_trusted(data['0']).each do |hash|
|
11
|
-
if hash['type'] == 'css'
|
12
|
-
value = process_string(hash['value'], vars) if vars[hash['name']]
|
13
|
-
q_css.push("#{hash['name']}: #{value || hash['value']}")
|
14
|
-
end
|
15
|
-
end
|
16
|
-
q_css
|
17
|
-
end
|
18
|
-
|
19
|
-
def return_caught_elements(caught)
|
20
|
-
all = []
|
21
|
-
caught.each do |i|
|
22
|
-
@help_hash[i[0]] ||= engine.elements(tag_name: i[0].downcase).to_a
|
23
|
-
elm = @help_hash[i[0]][i[1].to_i]
|
24
|
-
all.push(elm) if elm
|
25
|
-
end
|
26
|
-
all
|
27
|
-
end
|
28
|
-
|
29
|
-
def select_elements_from_raws_by_css(q_css, raws)
|
30
|
-
all = []
|
31
|
-
@help_hash = {}
|
32
|
-
q_css.each do |item|
|
33
|
-
caught = (raws.select { |i| i[2].include?(item) })
|
34
|
-
all += return_caught_elements(caught)
|
35
|
-
end
|
36
|
-
all
|
37
|
-
end
|
38
|
-
|
39
|
-
def full_find_by_css(data, vars)
|
40
|
-
q_css = css_array_by_data(data, vars)
|
41
|
-
script = File.read("#{HOME}/large_scripts/css.js")
|
42
|
-
raws = engine.execute_script(script)
|
43
|
-
select_elements_from_raws_by_css(q_css, raws)
|
44
|
-
end
|
45
|
-
end
|
46
|
-
end
|
47
|
-
end
|