marta 0.34054 → 0.35324
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/lib/marta.rb +2 -1
- data/lib/marta/data/element.js +41 -12
- data/lib/marta/data/style.css +10 -0
- data/lib/marta/dialogs.rb +23 -2
- data/lib/marta/lightning.rb +13 -3
- data/lib/marta/page_arithmetic.rb +147 -0
- data/lib/marta/read_write.rb +1 -1
- data/lib/marta/simple_element_finder.rb +5 -1
- data/lib/marta/version.rb +1 -1
- data/lib/marta/x_path.rb +41 -21
- data/marta.gemspec +1 -1
- metadata +3 -10
- data/readme_files/456steps.png +0 -0
- data/readme_files/8step.png +0 -0
- data/readme_files/hide.png +0 -0
- data/readme_files/html.png +0 -0
- data/readme_files/itemprop.png +0 -0
- data/readme_files/itemprop2.png +0 -0
- data/readme_files/stop.png +0 -0
- data/readme_files/xpath.png +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 61bcb2398f0d8990eae955226b5b40f1eb9e41d9
|
4
|
+
data.tar.gz: ee3b776091c0e869eb46a1df7b4d4031c5006674
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7b97670a0d556afe54da7c2b4ce0510ab405ba555e9e91200edc6f28de0e32249c2a0dea3bbca80ce29e1a40d9d504ddfc8a5fd677ac84fa2796f2a2cad720cd
|
7
|
+
data.tar.gz: 40bb826d1758ec5ccdea71c801fe68e798a61c46e60fd538dcd87ba4b27f8f687c8015ebb26afad395e68f35e79568e3d0d527163ac20e5919a2e8f62c89fd98
|
data/README.md
CHANGED
@@ -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.35324. 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.rb
CHANGED
@@ -11,6 +11,7 @@ require 'marta/json_2_class'
|
|
11
11
|
require 'marta/black_magic'
|
12
12
|
require 'marta/simple_element_finder'
|
13
13
|
require 'marta/x_path'
|
14
|
+
require 'marta/page_arithmetic'
|
14
15
|
require "watir"
|
15
16
|
require 'fileutils'
|
16
17
|
require 'json'
|
@@ -30,7 +31,7 @@ module Marta
|
|
30
31
|
|
31
32
|
include BlackMagic, XPath, SimpleElementFinder, ClassesCreation,
|
32
33
|
PublicMethods, Dialogs, Injector, Lightning, OptionsAndPaths,
|
33
|
-
Json2Class, ReadWrite, UserValuePrework
|
34
|
+
Json2Class, ReadWrite, UserValuePrework, PageArithmetic
|
34
35
|
|
35
36
|
# open_page can create new instance
|
36
37
|
def self.open_page(*args)
|
data/lib/marta/data/element.js
CHANGED
@@ -3,12 +3,22 @@ document.marta_result = {};
|
|
3
3
|
document.marta_confirm_mark = false;
|
4
4
|
document.marta_test_xx = 0;
|
5
5
|
document.marta_test_yy = 0;
|
6
|
+
document.marta_shift = false;
|
6
7
|
|
7
8
|
document.getElementById("marta_confirm").onclick = function() {document.marta_end_loop()};
|
8
9
|
document.getElementById("marta_set_by_hand").onclick = function() {document.marta_set_by_hand()};
|
9
10
|
document.getElementById("marta_show_html").onclick = function() {document.marta_show_html()};
|
10
11
|
document.getElementById("marta_hide").onclick = function() {document.marta_hide()};
|
11
12
|
document.getElementById("marta_stop").onclick = function() {document.marta_stop()};
|
13
|
+
document.getElementById("marta_array").onclick = function() {document.marta_array_switch()};
|
14
|
+
|
15
|
+
document.marta_array_switch = function(){
|
16
|
+
if (document.getElementById("marta_array").checked) {
|
17
|
+
document.getElementById("marta_hint").innerHTML = "<p>You are selecting a collection. Select two elements of a kind</p><p>And marta will automatically find all the similar elements</p><p>If Marta found too many elements exclude the wrong element by click on it with Shift</p><p>Note: Marta will return Watir::HTMLElementCollection</p>";
|
18
|
+
} else {
|
19
|
+
document.getElementById("marta_hint").innerHTML = "<p>You are selecting a single element.</p><p>Remember Marta will perform .to_subtype for it automatically</p>";
|
20
|
+
};
|
21
|
+
};
|
12
22
|
|
13
23
|
document.marta_stop = function() {
|
14
24
|
if (document.getElementById("marta_magic_div").getAttribute("martastyle") == "off"){
|
@@ -26,7 +36,8 @@ document.marta_magic_click = function(e) {
|
|
26
36
|
if (document.marta_test_xx == 0) {var xx = e.clientX} else {var xx = document.marta_test_xx};
|
27
37
|
if (document.marta_test_yy == 0) {var yy = e.clientY} else {var yy = document.marta_test_yy};
|
28
38
|
document.getElementById("marta_magic_div").setAttribute("martastyle", "off");
|
29
|
-
|
39
|
+
var is_shift = e.shiftKey||document.marta_shift;
|
40
|
+
document.marta_click_work(document.elementFromPoint(xx, yy), is_shift);
|
30
41
|
document.getElementById("marta_magic_div").setAttribute("martastyle", "at_large");
|
31
42
|
};
|
32
43
|
|
@@ -56,7 +67,12 @@ document.marta_add_field = function(title, what, key, marker) {
|
|
56
67
|
var headerDiv = document.marta_create_element(divtest, "div", {"martaclass": "marta_smthing", "class": "label", "id": "marta_title"+document.marta_room}, "ATTR");
|
57
68
|
var contentDiv = document.marta_create_element(divtest, "div", {"martaclass": "marta_smthing", "martastyle": "field_line", "class": "content", "id": "marta_staff"+document.marta_room}, "");
|
58
69
|
var nameField = document.marta_create_element(contentDiv, "input", {"martaclass": "marta_smthing", "martastyle": "name_field", "class": "marta_s_name_field", "type": "text", "disabled": "disabled;", "id": "marta_name"+document.marta_room, "value": ""}, "");
|
59
|
-
var
|
70
|
+
var valueStyle = "value_field";
|
71
|
+
if (title.indexOf("not_") == 0) {
|
72
|
+
var isNot = document.marta_create_element(contentDiv, "input", {"martaclass": "marta_smthing", "martastyle": "not_field", "class": "marta_s_not_field", "type": "text", "disabled": "disabled;", "value": " IS NOT "}, "");
|
73
|
+
valueStyle = "not_value_field";
|
74
|
+
};
|
75
|
+
var valueField = document.marta_create_element(contentDiv, "input", {"martaclass": "marta_smthing", "martastyle": valueStyle, "type": "text", "id": "marta_default_value"+document.marta_room, "value": ""}, "");
|
60
76
|
var cancelButton = document.marta_create_element(contentDiv, "input", {"martaclass": "marta_smthing", "martaroom": document.marta_room, "martastyle": "cancel_button", "type": "button", "id": "delete_marta_value"+document.marta_room, "value": "Delete"}, "");
|
61
77
|
document.getElementById("marta_title"+document.marta_room ).innerHTML = title;
|
62
78
|
document.getElementById("marta_name"+document.marta_room ).value = what;
|
@@ -136,11 +152,15 @@ document.marta_add_data = function() {
|
|
136
152
|
for (var key in document.old_marta_Data[what]){
|
137
153
|
if (/class/.test(key) == true){
|
138
154
|
for (var k = 0, length = document.old_marta_Data[what][key].length; k < length; k++){
|
139
|
-
document.
|
155
|
+
if ((document.old_marta_Data[what][key][k] != "") && (document.old_marta_Data[what][key][k] != null)){
|
156
|
+
document.marta_add_field(what, key, document.old_marta_Data[what][key][k], k);
|
157
|
+
};
|
140
158
|
};
|
141
159
|
}else
|
142
160
|
{
|
143
|
-
document.
|
161
|
+
if ((document.old_marta_Data[what][key] != "") && (document.old_marta_Data[what][key] != null)){
|
162
|
+
document.marta_add_field(what, key, document.old_marta_Data[what][key], "-1");
|
163
|
+
};
|
144
164
|
};
|
145
165
|
};
|
146
166
|
};
|
@@ -153,13 +173,13 @@ document.marta_show_html = function() {
|
|
153
173
|
area.innerHTML = document.spaninize(document.documentElement.innerHTML);
|
154
174
|
};
|
155
175
|
|
156
|
-
document.marta_touch = function(element) {
|
176
|
+
document.marta_touch = function(element, shift) {
|
157
177
|
var control = element.textContent.replace(/</g,"<").replace(/>/g,">");
|
158
178
|
var everything = document.getElementsByTagName("*");
|
159
179
|
for (var i=0, max=everything.length; i < max; i++) {
|
160
180
|
var check = everything[i].outerHTML.replace(/</g,"<").replace(/>/g,">");
|
161
181
|
if (check == control) {
|
162
|
-
document.marta_click_work(everything[i]);
|
182
|
+
document.marta_click_work(everything[i], shift);
|
163
183
|
};
|
164
184
|
};
|
165
185
|
};
|
@@ -197,23 +217,32 @@ document.spaninize = function(string) {
|
|
197
217
|
document.pretouch = function(e) {
|
198
218
|
if (e.target !== e.currentTarget) {
|
199
219
|
var clickedItem = e.target;
|
200
|
-
document.marta_touch(clickedItem);
|
220
|
+
document.marta_touch(clickedItem, e.shiftKey);
|
201
221
|
};
|
202
222
|
};
|
203
223
|
|
204
|
-
document.marta_click_work = function(target) {
|
224
|
+
document.marta_click_work = function(target, shift) {
|
205
225
|
var marta_smthing = target.getAttribute("martaclass")=="marta_smthing";
|
206
226
|
if(!marta_smthing){
|
227
|
+
if (shift) {
|
228
|
+
var self = "not_self";
|
229
|
+
var pappy = "not_pappy";
|
230
|
+
var granny = "not_granny";
|
231
|
+
} else {
|
232
|
+
var self = "self";
|
233
|
+
var pappy = "pappy";
|
234
|
+
var granny = "granny";
|
235
|
+
};
|
207
236
|
document.getElementById("attr_fields").innerHTML="";
|
208
237
|
document.marta_room = 0;
|
209
238
|
document.marta_result = {};
|
210
239
|
document.marta_result["options"] = {};
|
211
|
-
document.marta_after_click(target,
|
240
|
+
document.marta_after_click(target, self);
|
212
241
|
if (!!target.parentElement){
|
213
|
-
document.marta_after_click(target.parentElement,
|
242
|
+
document.marta_after_click(target.parentElement, pappy);
|
214
243
|
};
|
215
244
|
if (!!target.parentElement.parentElement){
|
216
|
-
document.marta_after_click(target.parentElement.parentElement,
|
245
|
+
document.marta_after_click(target.parentElement.parentElement, granny);
|
217
246
|
};
|
218
247
|
document.marta_confirm();
|
219
248
|
};
|
@@ -238,7 +267,7 @@ document.marta_after_click = function(el, what) {
|
|
238
267
|
};
|
239
268
|
};
|
240
269
|
};
|
241
|
-
if (what == "self"){
|
270
|
+
if ((what == "self")||(what == "not_self")){
|
242
271
|
try{
|
243
272
|
document.marta_result[what]["retrieved_by_marta_text"]=el.firstChild.nodeValue;
|
244
273
|
}catch(e){};
|
data/lib/marta/data/style.css
CHANGED
@@ -330,6 +330,16 @@ input[martastyle=name_field]:disabled, input[martastyle=value_field]:disabled{
|
|
330
330
|
background: linear-gradient(to right, lightgrey , white);
|
331
331
|
}
|
332
332
|
|
333
|
+
input[type=text][martastyle=not_value_field] {
|
334
|
+
width: 40%;
|
335
|
+
}
|
336
|
+
|
337
|
+
input[type=text][martastyle=not_field] {
|
338
|
+
width: 10%;
|
339
|
+
color:red;
|
340
|
+
background-color: darkblue;
|
341
|
+
}
|
342
|
+
|
333
343
|
input[martaclass=marta_smthing][type=checkbox] {
|
334
344
|
-webkit-appearance: none;
|
335
345
|
background-color: white;
|
data/lib/marta/dialogs.rb
CHANGED
@@ -3,6 +3,7 @@ require 'marta/x_path'
|
|
3
3
|
require 'marta/lightning'
|
4
4
|
require 'marta/injector'
|
5
5
|
require 'marta/public_methods'
|
6
|
+
require 'marta/page_arithmetic'
|
6
7
|
|
7
8
|
module Marta
|
8
9
|
|
@@ -21,7 +22,8 @@ module Marta
|
|
21
22
|
# @note It is believed that no user will use it
|
22
23
|
class MethodSpeaker
|
23
24
|
|
24
|
-
include XPath, Lightning, Injector, PublicMethods, SimpleElementFinder
|
25
|
+
include XPath, Lightning, Injector, PublicMethods, SimpleElementFinder,
|
26
|
+
PageArithmetic
|
25
27
|
|
26
28
|
def initialize(method_name, requestor)
|
27
29
|
@class_name = requestor.class_name
|
@@ -58,7 +60,7 @@ module Marta
|
|
58
60
|
@result = ask_for_elements
|
59
61
|
mass_highlight_turn(@mass, false)
|
60
62
|
if @result.class == Hash
|
61
|
-
|
63
|
+
attrs_plus_result
|
62
64
|
elsif @result != '1'
|
63
65
|
xpath_way
|
64
66
|
end
|
@@ -70,6 +72,25 @@ module Marta
|
|
70
72
|
end
|
71
73
|
end
|
72
74
|
|
75
|
+
#
|
76
|
+
# This method is responsible for collection in two clicks feature
|
77
|
+
#
|
78
|
+
# If we have two elements of collection this methods returns hash of
|
79
|
+
# element without diffs (only the same attributes). As well this method
|
80
|
+
# is responsible for adding excluding attributes to collection.
|
81
|
+
# Rare case with single element that not has some attribute is not
|
82
|
+
# implemented so far. All that party is for collections now.
|
83
|
+
def attrs_plus_result
|
84
|
+
if !attrs_exists?
|
85
|
+
@attrs = @result
|
86
|
+
elsif !@attrs['options']['collection'] or
|
87
|
+
!@result['options']['collection']
|
88
|
+
@attrs = @result
|
89
|
+
else
|
90
|
+
@attrs = make_collection(@attrs, @result)
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
73
94
|
# Asking: "What are you looking for?"
|
74
95
|
def ask_for_elements
|
75
96
|
ask 'element', "Found #{@found} elements for #{@title}", @attrs
|
data/lib/marta/lightning.rb
CHANGED
@@ -7,14 +7,24 @@ module Marta
|
|
7
7
|
|
8
8
|
# We can highlight an element
|
9
9
|
def highlight(element)
|
10
|
-
|
10
|
+
if is_here?(element)
|
11
|
+
engine.execute_script("arguments[0].setAttribute"\
|
11
12
|
"('martaclass','foundbymarta')", element)
|
13
|
+
end
|
12
14
|
end
|
13
15
|
|
14
16
|
# We can unhighlight an element
|
15
17
|
def unhighlight(element)
|
16
|
-
|
17
|
-
|
18
|
+
if is_here?(element)
|
19
|
+
engine.execute_script("arguments[0].removeAttribute('martaclass')",
|
20
|
+
element)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def is_here?(element)
|
25
|
+
element.exists?
|
26
|
+
rescue
|
27
|
+
false
|
18
28
|
end
|
19
29
|
|
20
30
|
# We can highlight\unhighlight tons of elements at once
|
@@ -0,0 +1,147 @@
|
|
1
|
+
module Marta
|
2
|
+
|
3
|
+
#
|
4
|
+
# This is for merging of Smartpages and elements.
|
5
|
+
#
|
6
|
+
# There is a need too form a right collection out of two elements
|
7
|
+
# Page merging will live here as well.
|
8
|
+
module PageArithmetic
|
9
|
+
|
10
|
+
private
|
11
|
+
|
12
|
+
#
|
13
|
+
# This class is used to merge hashes of elements\methods
|
14
|
+
#
|
15
|
+
# @note It is believed that no user will use it
|
16
|
+
# Now it has only one way to merge hashes
|
17
|
+
# This method is getting common only of two methods in order to generate a
|
18
|
+
# correct hash for collection element. Methods of the class are pretty
|
19
|
+
# esoteric. Refactoring is a must here.
|
20
|
+
class MethodMerger
|
21
|
+
|
22
|
+
# Class is taking two hashes. Sometimes order is valuable
|
23
|
+
def initialize(main_hash, second_hash)
|
24
|
+
@main_hash = main_hash
|
25
|
+
@second_hash = second_hash
|
26
|
+
end
|
27
|
+
|
28
|
+
POSITIVE = ['self', 'pappy', 'granny']
|
29
|
+
NEGATIVE = ['not_self', 'not_pappy', 'not_granny']
|
30
|
+
|
31
|
+
# Main method for adding two elements into a large-wide collection
|
32
|
+
def do_collection
|
33
|
+
result = Hash.new
|
34
|
+
result['options'] = options_merge
|
35
|
+
NEGATIVE.each do |key|
|
36
|
+
result[key] = all_of key
|
37
|
+
end
|
38
|
+
POSITIVE.each do |key|
|
39
|
+
result[key], result["not_#{key}"] =
|
40
|
+
passive_exclude(common_of(key), result["not_#{key}"])
|
41
|
+
end
|
42
|
+
result
|
43
|
+
end
|
44
|
+
|
45
|
+
# The most esoteric part of merging elements into collection
|
46
|
+
# Now we are loosing nots tags if they are not good for us
|
47
|
+
# As well we are loosing positive tags by merging them into alltags
|
48
|
+
# symbol == *. The way out is to use arrays for tags.
|
49
|
+
def options_merge
|
50
|
+
temp = Hash.new
|
51
|
+
temp['collection'] = @main_hash['options']['collection']
|
52
|
+
POSITIVE.each do |key|
|
53
|
+
value = @main_hash['options'][key]
|
54
|
+
main_negative = @main_hash['options']["not_#{key}"]
|
55
|
+
second_negative = @second_hash['options']["not_#{key}"]
|
56
|
+
if (@second_hash['options'][key] == value) or
|
57
|
+
((@second_hash['options'][key].nil?) and (!value.nil?))
|
58
|
+
temp[key] = value
|
59
|
+
else
|
60
|
+
temp[key] = "*"
|
61
|
+
end
|
62
|
+
if (second_negative != temp[key]) and
|
63
|
+
((second_negative == main_negative) or
|
64
|
+
(main_negative.nil?))
|
65
|
+
temp["not_#{key}"] = second_negative
|
66
|
+
end
|
67
|
+
end
|
68
|
+
temp
|
69
|
+
end
|
70
|
+
|
71
|
+
# This method will leave only common elements of both hashes
|
72
|
+
def common_of(what)
|
73
|
+
temp = Hash.new
|
74
|
+
first, second = @main_hash[what], @second_hash[what]
|
75
|
+
if !first.nil? and !second.nil?
|
76
|
+
first.each_pair do |key, value|
|
77
|
+
if second[key] == value
|
78
|
+
temp[key] = value
|
79
|
+
elsif second[key].class == Array and value.class == Array
|
80
|
+
temp[key] = value & second[key]
|
81
|
+
end
|
82
|
+
end
|
83
|
+
else
|
84
|
+
temp = first
|
85
|
+
end
|
86
|
+
temp
|
87
|
+
end
|
88
|
+
|
89
|
+
# This method will leave all the elements of hashes. But if one attribute
|
90
|
+
# is presented in both. Method will use the one from the main.
|
91
|
+
# When it will be possible to use arrays for tags and attributes this
|
92
|
+
# logic will be changed
|
93
|
+
def all_of(what)
|
94
|
+
temp = Hash.new
|
95
|
+
first, second = @main_hash[what], @second_hash[what]
|
96
|
+
if !first.nil?
|
97
|
+
temp = first
|
98
|
+
end
|
99
|
+
if !second.nil? and !temp.nil?
|
100
|
+
second.each_pair do |key, value|
|
101
|
+
if (temp[key].nil?) or ((temp[key] != value) and
|
102
|
+
(temp[key].class != Array) and (value.class != Array))
|
103
|
+
temp[key] = value
|
104
|
+
elsif (temp[key].class == Array) and (value.class == Array)
|
105
|
+
temp[key] = (value + temp[key]).uniq
|
106
|
+
end
|
107
|
+
end
|
108
|
+
if !first.nil?
|
109
|
+
first.each_pair do |key, value|
|
110
|
+
if second[key].nil? and !value.nil?
|
111
|
+
temp[key] = nil
|
112
|
+
end
|
113
|
+
end
|
114
|
+
end
|
115
|
+
else
|
116
|
+
temp = second
|
117
|
+
end
|
118
|
+
temp
|
119
|
+
end
|
120
|
+
|
121
|
+
# That is about excluding only attributes that are not presented as
|
122
|
+
# positives.
|
123
|
+
def passive_exclude(main, passive)
|
124
|
+
temp = main
|
125
|
+
not_temp = passive
|
126
|
+
if !passive.nil?
|
127
|
+
passive.each_pair do |key, value|
|
128
|
+
if !main[key].nil?
|
129
|
+
if main[key] == value
|
130
|
+
not_temp[key] = value.class == Array ? []:nil
|
131
|
+
elsif (value.class == Array) and (main[key].class == Array)
|
132
|
+
not_temp[key] = value - main[key]
|
133
|
+
end
|
134
|
+
end
|
135
|
+
end
|
136
|
+
end
|
137
|
+
return temp, not_temp
|
138
|
+
end
|
139
|
+
end
|
140
|
+
|
141
|
+
# Form collection out of two element hashes
|
142
|
+
def make_collection(one, two)
|
143
|
+
merger = MethodMerger.new(one, two)
|
144
|
+
merger.do_collection
|
145
|
+
end
|
146
|
+
end
|
147
|
+
end
|
data/lib/marta/read_write.rb
CHANGED
@@ -56,7 +56,11 @@ module Marta
|
|
56
56
|
|
57
57
|
# Transforming an element to a subtype
|
58
58
|
def subtype_of(element)
|
59
|
-
@engine.element(xpath: @xpath).
|
59
|
+
if @engine.element(xpath: @xpath).exists?
|
60
|
+
@engine.element(xpath: @xpath).to_subtype
|
61
|
+
else
|
62
|
+
@engine.element(xpath: @xpath)
|
63
|
+
end
|
60
64
|
end
|
61
65
|
|
62
66
|
# Main logic. We are returning a prefinded collection
|
data/lib/marta/version.rb
CHANGED
data/lib/marta/x_path.rb
CHANGED
@@ -8,7 +8,7 @@ module Marta
|
|
8
8
|
private
|
9
9
|
|
10
10
|
#
|
11
|
-
# Here we are
|
11
|
+
# Here we are creating xpath including arrays of xpaths with one-two-...-x
|
12
12
|
# parts that are not known
|
13
13
|
#
|
14
14
|
# @note It is believed that no user will use it
|
@@ -34,7 +34,10 @@ module Marta
|
|
34
34
|
# Getting a part (by data or empty=any)
|
35
35
|
def get_xpaths(todo, what)
|
36
36
|
if todo
|
37
|
-
form_array_hash(@meth['options'][what], @meth[what])
|
37
|
+
result = form_array_hash(@meth['options'][what], @meth[what])
|
38
|
+
result = result + form_array_hash(@meth['options']['not_' + what],
|
39
|
+
@meth['not_' + what], true)
|
40
|
+
result
|
38
41
|
else
|
39
42
|
[make_hash("//", "//"), make_hash("*", "*")]
|
40
43
|
end
|
@@ -118,44 +121,61 @@ module Marta
|
|
118
121
|
end
|
119
122
|
|
120
123
|
# Creating a small part of array hash for tag
|
121
|
-
def form_array_hash_for_tag(tag)
|
124
|
+
def form_array_hash_for_tag(tag, negative)
|
122
125
|
result_array = Array.new
|
123
|
-
|
124
|
-
|
126
|
+
if negative
|
127
|
+
if !tag.nil? and tag != ""
|
128
|
+
result_array.push make_hash("[not(self::#{tag})]", "")
|
129
|
+
end
|
130
|
+
else
|
131
|
+
result_array.push make_hash("/", "//")
|
132
|
+
result_array.push make_hash(tag, "*")
|
133
|
+
end
|
125
134
|
result_array
|
126
135
|
end
|
127
136
|
|
128
137
|
# Creating an array hash
|
129
|
-
def form_array_hash(tag, attrs)
|
130
|
-
result_array = form_array_hash_for_tag(tag)
|
131
|
-
attrs.
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
138
|
+
def form_array_hash(tag, attrs, negative = false)
|
139
|
+
result_array = form_array_hash_for_tag(tag, negative)
|
140
|
+
if !attrs.nil?
|
141
|
+
attrs.each_pair do |attribute, value|
|
142
|
+
if attribute.include?('class')
|
143
|
+
result_array = result_array +
|
144
|
+
form_array_hash_for_class(attribute, value, negative)
|
145
|
+
else
|
146
|
+
if !value.nil? and value != ""
|
147
|
+
result_array.push form_hash_for_attribute(attribute,
|
148
|
+
value,
|
149
|
+
negative)
|
150
|
+
end
|
151
|
+
end
|
137
152
|
end
|
138
153
|
end
|
139
154
|
result_array
|
140
155
|
end
|
141
156
|
|
142
157
|
# Creating a small part of array hash for attribute
|
143
|
-
def form_hash_for_attribute(attribute, value)
|
144
|
-
|
145
|
-
if attribute == 'retrieved_by_marta_text'
|
146
|
-
make_hash("[contains(text(),'#{value}')]", "")
|
158
|
+
def form_hash_for_attribute(attribute, value, negative)
|
159
|
+
not_start, not_end = get_nots_frames(negative)
|
160
|
+
if (attribute == 'retrieved_by_marta_text')
|
161
|
+
make_hash("[#{not_start}contains(text(),'#{value}')#{not_end}]", "")
|
147
162
|
else
|
148
|
-
make_hash("[@#{attribute}='#{value}']", "")
|
163
|
+
make_hash("[#{not_start}@#{attribute}='#{value}'#{not_end}]", "")
|
149
164
|
end
|
150
165
|
end
|
151
166
|
|
167
|
+
def get_nots_frames (negative)
|
168
|
+
return negative ? ["not(", ")"] : ["", ""]
|
169
|
+
end
|
170
|
+
|
152
171
|
# Creating a small part of array hash for attribute contains 'class'
|
153
|
-
def form_array_hash_for_class(attribute, value)
|
172
|
+
def form_array_hash_for_class(attribute, value, negative)
|
154
173
|
result_array = Array.new
|
174
|
+
not_start, not_end = get_nots_frames(negative)
|
155
175
|
value.each do |value_part|
|
156
176
|
if value_part.gsub(' ','') != ''
|
157
|
-
result_array.push make_hash("[contains(@#{attribute},"\
|
158
|
-
"'#{value_part}')]", "")
|
177
|
+
result_array.push make_hash("[#{not_start}contains(@#{attribute},"\
|
178
|
+
"'#{value_part}')#{not_end}]", "")
|
159
179
|
end
|
160
180
|
end
|
161
181
|
result_array
|
data/marta.gemspec
CHANGED
@@ -14,7 +14,7 @@ Gem::Specification.new do |spec|
|
|
14
14
|
spec.homepage = "https://github.com/sseleznevqa/marta"
|
15
15
|
spec.license = "MIT"
|
16
16
|
|
17
|
-
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) } + Dir.glob("lib/marta/data/*")
|
17
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features|readme_files)/}) } + Dir.glob("lib/marta/data/*")
|
18
18
|
spec.bindir = "exe"
|
19
19
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
20
20
|
spec.require_paths = ["lib"]
|
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.35324'
|
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-10-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -136,6 +136,7 @@ files:
|
|
136
136
|
- lib/marta/json_2_class.rb
|
137
137
|
- lib/marta/lightning.rb
|
138
138
|
- lib/marta/options_and_paths.rb
|
139
|
+
- lib/marta/page_arithmetic.rb
|
139
140
|
- lib/marta/public_methods.rb
|
140
141
|
- lib/marta/read_write.rb
|
141
142
|
- lib/marta/simple_element_finder.rb
|
@@ -143,14 +144,6 @@ files:
|
|
143
144
|
- lib/marta/version.rb
|
144
145
|
- lib/marta/x_path.rb
|
145
146
|
- marta.gemspec
|
146
|
-
- readme_files/456steps.png
|
147
|
-
- readme_files/8step.png
|
148
|
-
- readme_files/hide.png
|
149
|
-
- readme_files/html.png
|
150
|
-
- readme_files/itemprop.png
|
151
|
-
- readme_files/itemprop2.png
|
152
|
-
- readme_files/stop.png
|
153
|
-
- readme_files/xpath.png
|
154
147
|
homepage: https://github.com/sseleznevqa/marta
|
155
148
|
licenses:
|
156
149
|
- MIT
|
data/readme_files/456steps.png
DELETED
Binary file
|
data/readme_files/8step.png
DELETED
Binary file
|
data/readme_files/hide.png
DELETED
Binary file
|
data/readme_files/html.png
DELETED
Binary file
|
data/readme_files/itemprop.png
DELETED
Binary file
|
data/readme_files/itemprop2.png
DELETED
Binary file
|
data/readme_files/stop.png
DELETED
Binary file
|
data/readme_files/xpath.png
DELETED
Binary file
|