marta 0.35324 → 0.36651
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -2
- data/lib/marta/black_magic.rb +31 -12
- data/lib/marta/data/page.js +6 -0
- data/lib/marta/version.rb +1 -1
- data/lib/marta/x_path.rb +30 -8
- 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: 3fff8db3d7bb63b3a765a6245f661c3af8feceb1
|
4
|
+
data.tar.gz: 60b85051a58507f6346f1a2d27aa562552093219
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 768f7c86b374d6aab228142d2048f05f55caad520c8c2940cd29f50eeff968d1d16f11759283c3cebf6b1afaca17f165916ba71077ec66a6925d8fef4f5f485a
|
7
|
+
data.tar.gz: e3f9941f06ab4846963376462cca33ac56a0a57a4ca5c251666b2c506691849fb027ef27e0ed2ec582b2ee0382301f3e793781fdca2875e1b51db2409d1f4faf
|
data/README.md
CHANGED
@@ -184,7 +184,7 @@ engine.element(id: 'will_be_located_without_Marta')
|
|
184
184
|
|
185
185
|
**Q: How can I find a collection of elements?**
|
186
186
|
|
187
|
-
*A: When defining an element you can set a collection checkbox at the top of the dialog. In that case Marta will return Watir::ElementCollection.*
|
187
|
+
*A: When defining an element you can set a collection checkbox at the top of the dialog. In that case Marta will return Watir::ElementCollection. When collection mark is enabled Marta will try to find all the elements of the kind. Click the first and the second element of a kind and Marta will try to find all elements of that kind. If Marta will add to many elements to the collection press shift and click the element that should be excluded. Try it. This is fun.*
|
188
188
|
|
189
189
|
**Q: How can I find an invisible element? Or hardly clickable element with 1px size?**
|
190
190
|
|
@@ -276,7 +276,7 @@ g_page.search "I am in love with selenium."
|
|
276
276
|
|
277
277
|
**Q: What else?**
|
278
278
|
|
279
|
-
*A: Nothing. Marta is under development. Her version is 0.
|
279
|
+
*A: Nothing. Marta is under development. Her version is 0.36651. All the necessary features are working already but there are tons of things that should be done. And I am not a professional developer.*
|
280
280
|
|
281
281
|
## Internal Design
|
282
282
|
|
data/lib/marta/black_magic.rb
CHANGED
@@ -92,10 +92,10 @@ module Marta
|
|
92
92
|
array_of_elements, array_of_els_xpaths = Array.new, Array.new
|
93
93
|
something = nil
|
94
94
|
array_of_xpaths.each do |xpath|
|
95
|
-
something = @engine.
|
96
|
-
if something.
|
97
|
-
array_of_elements
|
98
|
-
array_of_els_xpaths.push xpath
|
95
|
+
something = @engine.elements(xpath: xpath)
|
96
|
+
if something.to_a.length > 0
|
97
|
+
array_of_elements += something.to_a
|
98
|
+
something.to_a.length.times {array_of_els_xpaths.push xpath}
|
99
99
|
end
|
100
100
|
end
|
101
101
|
return array_of_elements, array_of_els_xpaths
|
@@ -105,17 +105,36 @@ module Marta
|
|
105
105
|
def get_search_result(result, array_of_elements, array_of_els_xpaths)
|
106
106
|
something = result
|
107
107
|
if array_of_elements.size > 0
|
108
|
-
|
109
|
-
|
108
|
+
inputs = get_result_inputs(array_of_elements)
|
109
|
+
most_uniq_xpath_by_inputs(array_of_els_xpaths, inputs)
|
110
|
+
array_of_elements[array_of_els_xpaths.index(@xpath)]
|
110
111
|
else
|
111
|
-
|
112
|
+
something
|
112
113
|
end
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
114
|
+
end
|
115
|
+
|
116
|
+
# Getting indexes of the most common element in the array of suggested
|
117
|
+
# elements
|
118
|
+
def get_result_inputs(array_of_elements)
|
119
|
+
result = array_of_elements.group_by(&:itself).
|
120
|
+
values.max_by(&:size).first
|
121
|
+
array_of_elements.each_index.
|
122
|
+
select{|i| array_of_elements[i] == result}
|
123
|
+
end
|
124
|
+
|
125
|
+
# Getting the most specific xpath for the most common element in order
|
126
|
+
# to locate it only
|
127
|
+
def most_uniq_xpath_by_inputs(array_of_els_xpaths, inputs)
|
128
|
+
xpaths = Array.new
|
129
|
+
array_of_els_xpaths.
|
130
|
+
each_with_index{|e, i| xpaths.push e if inputs.include?(i)}
|
131
|
+
@xpath = xpaths[0]
|
132
|
+
xpaths.each do |x|
|
133
|
+
current_count = array_of_els_xpaths.count(x)
|
134
|
+
proposed_count = array_of_els_xpaths.count(@xpath)
|
135
|
+
@xpath = x if current_count < proposed_count
|
117
136
|
end
|
118
|
-
|
137
|
+
@xpath
|
119
138
|
end
|
120
139
|
|
121
140
|
# The core of Black Magic Algorithm
|
data/lib/marta/data/page.js
CHANGED
@@ -46,6 +46,12 @@ document.marta_add_data = function() {
|
|
46
46
|
document.getElementById("marta_name"+document.marta_room ).value = key;
|
47
47
|
document.getElementById("marta_default_value"+document.marta_room ).value = document.old_marta_Data[key];
|
48
48
|
};
|
49
|
+
if (document.marta_room == 0) {
|
50
|
+
document.marta_add_field();
|
51
|
+
document.getElementById("marta_name"+document.marta_room ).value = "url";
|
52
|
+
document.marta_add_field();
|
53
|
+
document.getElementById("marta_name"+document.marta_room ).value = "path";
|
54
|
+
};
|
49
55
|
};
|
50
56
|
|
51
57
|
document.marta_delete_line = function(theEvent) {
|
data/lib/marta/version.rb
CHANGED
data/lib/marta/x_path.rb
CHANGED
@@ -89,15 +89,27 @@ module Marta
|
|
89
89
|
def generate_xpaths(depth)
|
90
90
|
result_array = Array.new
|
91
91
|
form_variants(depth).each do |variant|
|
92
|
-
|
92
|
+
xpaths = [""]
|
93
93
|
variant.each do |part|
|
94
|
-
|
94
|
+
xpaths = tree_push(xpaths, part[:full])
|
95
95
|
end
|
96
|
-
result_array
|
96
|
+
result_array += xpaths
|
97
97
|
end
|
98
98
|
result_array
|
99
99
|
end
|
100
100
|
|
101
|
+
# Sometimes we need to double number of variants since there
|
102
|
+
# are more than one option to try
|
103
|
+
def tree_push(main, what)
|
104
|
+
result = Array.new
|
105
|
+
what.each do |part|
|
106
|
+
main.each do |host_item|
|
107
|
+
result.push(process_string(host_item + part, @requestor))
|
108
|
+
end
|
109
|
+
end
|
110
|
+
result
|
111
|
+
end
|
112
|
+
|
101
113
|
# Special method to get the single xpath only. Without unknowns
|
102
114
|
def generate_xpath
|
103
115
|
generate_xpaths(0).join
|
@@ -158,9 +170,10 @@ module Marta
|
|
158
170
|
def form_hash_for_attribute(attribute, value, negative)
|
159
171
|
not_start, not_end = get_nots_frames(negative)
|
160
172
|
if (attribute == 'retrieved_by_marta_text')
|
161
|
-
make_hash("[#{not_start}contains(text(),'#{value}')#{not_end}]", "")
|
173
|
+
make_hash("[#{not_start}contains(text(),'#{value}')#{not_end}]", [""])
|
162
174
|
else
|
163
|
-
make_hash("[#{not_start}@#{attribute}='#{value}'#{not_end}]", ""
|
175
|
+
make_hash("[#{not_start}@#{attribute}='#{value}'#{not_end}]", ["",
|
176
|
+
"[#{not_start}@*='#{value}'#{not_end}]"])
|
164
177
|
end
|
165
178
|
end
|
166
179
|
|
@@ -174,8 +187,11 @@ module Marta
|
|
174
187
|
not_start, not_end = get_nots_frames(negative)
|
175
188
|
value.each do |value_part|
|
176
189
|
if value_part.gsub(' ','') != ''
|
177
|
-
result_array.
|
178
|
-
|
190
|
+
result_array.
|
191
|
+
push make_hash("[#{not_start}contains(@#{attribute},"\
|
192
|
+
"'#{value_part}')#{not_end}]", ["",
|
193
|
+
"[#{not_start}@*[contains"\
|
194
|
+
"(.,'#{value_part}')]#{not_end}]"])
|
179
195
|
end
|
180
196
|
end
|
181
197
|
result_array
|
@@ -183,7 +199,13 @@ module Marta
|
|
183
199
|
|
184
200
|
# Creating the smallest possible part of array hash
|
185
201
|
def make_hash(full, empty)
|
186
|
-
|
202
|
+
if empty.class != Array
|
203
|
+
empty = [empty]
|
204
|
+
end
|
205
|
+
if full.class != Array
|
206
|
+
full = [full]
|
207
|
+
end
|
208
|
+
{full: full, empty: empty}
|
187
209
|
end
|
188
210
|
end
|
189
211
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: marta
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '0.
|
4
|
+
version: '0.36651'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sergei Seleznev
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-11-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|