cucu 1.3.9__py3-none-any.whl → 1.3.10__py3-none-any.whl
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.
Potentially problematic release.
This version of cucu might be problematic. Click here for more details.
- cucu/fuzzy/core.py +7 -1
- cucu/fuzzy/fuzzy.js +78 -53
- {cucu-1.3.9.dist-info → cucu-1.3.10.dist-info}/METADATA +1 -1
- {cucu-1.3.9.dist-info → cucu-1.3.10.dist-info}/RECORD +6 -6
- {cucu-1.3.9.dist-info → cucu-1.3.10.dist-info}/WHEEL +0 -0
- {cucu-1.3.9.dist-info → cucu-1.3.10.dist-info}/entry_points.txt +0 -0
cucu/fuzzy/core.py
CHANGED
|
@@ -97,6 +97,7 @@ def find(
|
|
|
97
97
|
str(index),
|
|
98
98
|
str(direction.value),
|
|
99
99
|
name_within_thing,
|
|
100
|
+
"true"
|
|
100
101
|
]
|
|
101
102
|
|
|
102
103
|
def execute_fuzzy_find():
|
|
@@ -104,4 +105,9 @@ def find(
|
|
|
104
105
|
script = f"return cucu.fuzzy_find({','.join(args)});"
|
|
105
106
|
return browser.execute(script)
|
|
106
107
|
|
|
107
|
-
|
|
108
|
+
fuzzy_return = search_in_all_frames(browser, execute_fuzzy_find)
|
|
109
|
+
if fuzzy_return is None:
|
|
110
|
+
logger.info("Fuzzy found no element.")
|
|
111
|
+
return None
|
|
112
|
+
logger.info("Fuzzy found element by search term {}".format(fuzzy_return[1]))
|
|
113
|
+
return fuzzy_return[0]
|
cucu/fuzzy/fuzzy.js
CHANGED
|
@@ -54,13 +54,15 @@
|
|
|
54
54
|
things,
|
|
55
55
|
index=0,
|
|
56
56
|
direction=LEFT_TO_RIGHT,
|
|
57
|
-
name_within_thing=false
|
|
57
|
+
name_within_thing=false,
|
|
58
|
+
insert_label=false) {
|
|
58
59
|
var elements = [];
|
|
60
|
+
var element_labels = [];
|
|
59
61
|
var results = null;
|
|
60
62
|
var attributes = ['aria-label', 'title', 'placeholder', 'value'];
|
|
61
63
|
var matchers = ['has_text', 'contains'];
|
|
62
64
|
|
|
63
|
-
name = name.replaceAll('"', '\\"')
|
|
65
|
+
name = name.replaceAll('"', '\\"');
|
|
64
66
|
|
|
65
67
|
/*
|
|
66
68
|
* try to match on exact text but ultimately fall back to matching on
|
|
@@ -75,24 +77,27 @@
|
|
|
75
77
|
for(var tIndex = 0; tIndex < things.length; tIndex++) {
|
|
76
78
|
var thing = things[tIndex];
|
|
77
79
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
if (cucu.debug) { console.log('<thing>name</thing>', results); }
|
|
80
|
+
var nameInTagContentLabel = `<${thing}>${name}</${thing}>`;
|
|
81
|
+
var nameInTagContentJq = `${thing}:vis:${matcher}("${name}")`;
|
|
82
|
+
results = jqCucu(nameInTagContentJq, document.body).toArray();
|
|
83
|
+
if (cucu.debug) { console.log(nameInTagContentLabel, results); }
|
|
83
84
|
elements = elements.concat(results);
|
|
85
|
+
element_labels = element_labels.concat(results.map(x => nameInTagContentLabel));
|
|
84
86
|
|
|
85
|
-
// <thing attribute="name"></thing>
|
|
86
87
|
for(var aIndex=0; aIndex < attributes.length; aIndex++) {
|
|
87
88
|
var attribute_name = attributes[aIndex];
|
|
89
|
+
var nameIsAttributeLabel = `<${thing} attribute="${attribute_name}"></${thing}>`;
|
|
88
90
|
if (matcher == 'has_text') {
|
|
89
|
-
|
|
90
|
-
|
|
91
|
+
var nameIsAttributeJq = `${thing}[${attribute_name}="${name}"]:vis`;
|
|
92
|
+
results = jqCucu(nameIsAttributeJq, document.body).toArray();
|
|
93
|
+
if (cucu.debug) { console.log(nameIsAttributeLabel, results); }
|
|
91
94
|
} else if (matcher == 'contains') {
|
|
92
|
-
|
|
93
|
-
|
|
95
|
+
var nameInAttributeJq = `${thing}[${attribute_name}*="${name}"]:vis`;
|
|
96
|
+
results = jqCucu(nameInAttributeJq, document.body).toArray();
|
|
97
|
+
if (cucu.debug) { console.log(nameIsAttributeLabel, results); }
|
|
94
98
|
}
|
|
95
99
|
elements = elements.concat(results);
|
|
100
|
+
element_labels = element_labels.concat(results.map(x => nameIsAttributeLabel));
|
|
96
101
|
}
|
|
97
102
|
}
|
|
98
103
|
|
|
@@ -107,38 +112,44 @@
|
|
|
107
112
|
for(var tIndex = 0; tIndex < things.length; tIndex++) {
|
|
108
113
|
var thing = things[tIndex];
|
|
109
114
|
|
|
110
|
-
// <thing value="name"></thing>
|
|
111
115
|
if (matcher == 'has_text') {
|
|
112
|
-
|
|
116
|
+
var nameIsValueLabel = `${thing} value="${name}"></${thing}>`;
|
|
117
|
+
var nameIsValueJq = `${thing}:vis`;
|
|
118
|
+
results = jqCucu(nameInValueJq, document.body).filter(function(){
|
|
113
119
|
return this.value == name;
|
|
114
120
|
}).toArray();
|
|
115
|
-
if (cucu.debug) { console.log(
|
|
121
|
+
if (cucu.debug) { console.log(nameIsValueLabel, results); }
|
|
116
122
|
} else if (matcher == 'contains') {
|
|
117
|
-
|
|
123
|
+
var nameInValueLabel = `${thing} value*="${name}"></${thing}>`;
|
|
124
|
+
var nameInValueJq = `${thing}:vis`;
|
|
125
|
+
results = jqCucu(nameInValueJq, document.body).filter(function(){
|
|
118
126
|
return this.value !== undefined && String(this.value).indexOf(name) != -1;
|
|
119
127
|
}).toArray();
|
|
120
|
-
if (cucu.debug) { console.log(
|
|
128
|
+
if (cucu.debug) { console.log(nameInValueLabel, results); }
|
|
121
129
|
}
|
|
122
130
|
elements = elements.concat(results);
|
|
131
|
+
element_labels = element_labels.concat(results.map(x => nameInValueLabel));
|
|
123
132
|
}
|
|
124
133
|
|
|
125
134
|
/*
|
|
126
135
|
* element labeled by another using the for/id attributes
|
|
127
136
|
*/
|
|
128
|
-
var
|
|
137
|
+
var labelForNameJq = `*[for]:vis:${matcher}("${name}")`
|
|
138
|
+
var labels = jqCucu(labelForNameJq, document.body).toArray();
|
|
129
139
|
for(var tIndex = 0; tIndex < things.length; tIndex++) {
|
|
130
140
|
var thing = things[tIndex];
|
|
131
141
|
results = [];
|
|
132
142
|
|
|
133
|
-
|
|
134
|
-
* <* for=...>name</*>...<thing id=...></thing>
|
|
135
|
-
*/
|
|
143
|
+
var labelForNameLabel = `<* for=...>${name}</*>...<${thing} id=...></${thing}>`;
|
|
136
144
|
for(var lIndex=0; lIndex < labels.length; lIndex++) {
|
|
137
145
|
var label = labels[lIndex];
|
|
138
146
|
var id = label.getAttribute('for');
|
|
139
|
-
|
|
140
|
-
|
|
147
|
+
var idMatchesForLabelJq = `${thing}[id="${id}"]:vis`;
|
|
148
|
+
results = jqCucu(idMatchesForLabelJq, document.body).toArray();
|
|
149
|
+
|
|
150
|
+
if (cucu.debug) { console.log(labelForNameLabel, results); }
|
|
141
151
|
elements = elements.concat(results);
|
|
152
|
+
element_labels = element_labels.concat(results.map(x => labelForNameLabel));
|
|
142
153
|
}
|
|
143
154
|
}
|
|
144
155
|
|
|
@@ -148,19 +159,23 @@
|
|
|
148
159
|
for(var tIndex = 0; tIndex < things.length; tIndex++) {
|
|
149
160
|
var thing = things[tIndex];
|
|
150
161
|
|
|
151
|
-
|
|
152
|
-
* <thing><*>...name...</*></thing>
|
|
153
|
-
*/
|
|
162
|
+
var nameInNestedChildLabel = `<${thing}><*>...${name}...</*></${thing}>`;
|
|
154
163
|
results = jqCucu('*:vis:' + matcher + '("' + name + '")', document.body).parents(thing).toArray();
|
|
155
|
-
if (cucu.debug) { console.log(
|
|
164
|
+
if (cucu.debug) { console.log(nameInNestedChildLabel, results); }
|
|
156
165
|
elements = elements.concat(results);
|
|
166
|
+
if (results.length > 0) {
|
|
167
|
+
console.log('!*!*!* Found element labeled by nested child!');
|
|
168
|
+
console.log(`!*!*!* elements: ${elements}`);
|
|
169
|
+
}
|
|
170
|
+
element_labels = element_labels.concat(results.map(x => nameInNestedChildLabel));
|
|
157
171
|
|
|
158
|
-
// <thing><* attribute="name"></*></thing>
|
|
159
172
|
for(var aIndex=0; aIndex < attributes.length; aIndex++) {
|
|
160
173
|
var attribute_name = attributes[aIndex];
|
|
161
|
-
|
|
162
|
-
|
|
174
|
+
var innerNestedElementsLabel = `<${thing}><* ${attribute_name}="${name}"></*></${thing}>`;
|
|
175
|
+
results = jqCucu(`*:vis[${attribute_name}="${name}"]`, document.body).parents(thing).toArray();
|
|
176
|
+
if (cucu.debug) { console.log(innerNestedElementsLabel, results); }
|
|
163
177
|
elements = elements.concat(results);
|
|
178
|
+
element_labels = element_labels.concat(results.map(x => innerNestedElementsLabel));
|
|
164
179
|
}
|
|
165
180
|
}
|
|
166
181
|
|
|
@@ -174,10 +189,11 @@
|
|
|
174
189
|
for(var tIndex = 0; tIndex < things.length; tIndex++) {
|
|
175
190
|
var thing = things[tIndex];
|
|
176
191
|
|
|
177
|
-
|
|
178
|
-
results = jqCucu(
|
|
179
|
-
if (cucu.debug) { console.log(
|
|
192
|
+
var nameIsPreviousSiblingLabel = `<*>${name}</*><${thing}/>`;
|
|
193
|
+
results = jqCucu(`*:vis:${matcher}("${name}")`, document.body).next(thing + ':vis').toArray();
|
|
194
|
+
if (cucu.debug) { console.log(nameIsPreviousSiblingLabel, results); }
|
|
180
195
|
elements = elements.concat(results);
|
|
196
|
+
element_labels = element_labels.concat(results.map(x => nameIsPreviousSiblingLabel));
|
|
181
197
|
}
|
|
182
198
|
}
|
|
183
199
|
|
|
@@ -186,10 +202,11 @@
|
|
|
186
202
|
for(var tIndex = 0; tIndex < things.length; tIndex++) {
|
|
187
203
|
var thing = things[tIndex];
|
|
188
204
|
|
|
189
|
-
|
|
190
|
-
results = jqCucu(
|
|
191
|
-
if (cucu.debug) { console.log(
|
|
205
|
+
var nameIsNextSiblingLabel = `<${thing}/><*>${name}</*>`;
|
|
206
|
+
results = jqCucu(`*:vis:${matcher}("${name}")`, document.body).prev(thing).toArray();
|
|
207
|
+
if (cucu.debug) { console.log(nameIsNextSiblingLabel, results); }
|
|
192
208
|
elements = elements.concat(results);
|
|
209
|
+
element_labels = element_labels.concat(results.map(x => nameIsNextSiblingLabel));
|
|
193
210
|
}
|
|
194
211
|
}
|
|
195
212
|
|
|
@@ -199,12 +216,11 @@
|
|
|
199
216
|
for(var tIndex = 0; tIndex < things.length; tIndex++) {
|
|
200
217
|
var thing = things[tIndex];
|
|
201
218
|
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
results = jqCucu('*:vis:' + matcher + '("' + name + '")', document.body).children(thing + ':vis').toArray();
|
|
206
|
-
if (cucu.debug) { console.log('<*><thing></thing>name</*>', results); }
|
|
219
|
+
var nameIsTextSiblingLabel = `<*><${thing}></${thing}>${name}</*>`;
|
|
220
|
+
results = jqCucu(`*:vis:${matcher}("${name}")`, document.body).children(thing + ':vis').toArray();
|
|
221
|
+
if (cucu.debug) { console.log(nameIsTextSiblingLabel, results); }
|
|
207
222
|
elements = elements.concat(results);
|
|
223
|
+
element_labels = element_labels.concat(results.map(x => nameIsTextSiblingLabel));
|
|
208
224
|
}
|
|
209
225
|
|
|
210
226
|
// element labeled with any previous sibling
|
|
@@ -212,17 +228,19 @@
|
|
|
212
228
|
for(var tIndex = 0; tIndex < things.length; tIndex++) {
|
|
213
229
|
var thing = things[tIndex];
|
|
214
230
|
|
|
215
|
-
|
|
216
|
-
results = jqCucu(
|
|
217
|
-
if (cucu.debug) { console.log(
|
|
231
|
+
var leftToRightLabel = `<*>${name}</*>...<${thing}>...`;
|
|
232
|
+
results = jqCucu(`*:vis:${matcher}("${name}")`, document.body).nextAll(thing + ':vis').toArray();
|
|
233
|
+
if (cucu.debug) { console.log(leftToRightLabel, results); }
|
|
218
234
|
elements = elements.concat(results);
|
|
235
|
+
element_labels = element_labels.concat(results.map(x => leftToRightLabel));
|
|
219
236
|
|
|
220
|
-
|
|
237
|
+
var leftToRightGrandpaLabel = `<...><*>${name}</*></...>...<...><${thing}></...>`;
|
|
221
238
|
// XXX: this rule is horribly complicated and I'd rather see it gone
|
|
222
239
|
// basically: common great grandpranet
|
|
223
|
-
results = jqCucu(
|
|
224
|
-
if (cucu.debug) { console.log(
|
|
240
|
+
results = jqCucu(`*:vis:${matcher}("${name}")`, document.body).nextAll().find(thing + ':vis').toArray();
|
|
241
|
+
if (cucu.debug) { console.log(leftToRightGrandpaLabel, results); }
|
|
225
242
|
elements = elements.concat(results);
|
|
243
|
+
element_labels = element_labels.concat(results.map(x => leftToRightGrandpaLabel));
|
|
226
244
|
}
|
|
227
245
|
}
|
|
228
246
|
|
|
@@ -231,22 +249,29 @@
|
|
|
231
249
|
for(var tIndex = 0; tIndex < things.length; tIndex++) {
|
|
232
250
|
var thing = things[tIndex];
|
|
233
251
|
|
|
234
|
-
|
|
235
|
-
results = jqCucu(
|
|
236
|
-
if (cucu.debug) { console.log(
|
|
252
|
+
var rightToLeftLabel = `<${thing}>...<*>${name}</*>...`;
|
|
253
|
+
results = jqCucu(`*:vis:${matcher}("${name}")`, document.body).prevAll(thing).toArray();
|
|
254
|
+
if (cucu.debug) { console.log(rightToLeftLabel, results); }
|
|
237
255
|
elements = elements.concat(results);
|
|
256
|
+
element_labels = element_labels.concat(results.map(x => rightToLeftLabel));
|
|
238
257
|
|
|
239
|
-
|
|
258
|
+
var rightToLeftGrandpaLabel = `<...><${thing}></...>...<...><*>${name}</*></...>`;
|
|
240
259
|
// XXX: this rule is horribly complicated and I'd rather see it gone
|
|
241
|
-
results = jqCucu(
|
|
242
|
-
if (cucu.debug) { console.log(
|
|
260
|
+
results = jqCucu(`*:vis:${matcher}("${name}")`, document.body).prevAll().find(thing + ':vis').toArray();
|
|
261
|
+
if (cucu.debug) { console.log(rightToLeftGrandpaLabel, results); }
|
|
243
262
|
elements = elements.concat(results);
|
|
263
|
+
element_labels = element_labels.concat(results.map(x => rightToLeftGrandpaLabel));
|
|
244
264
|
}
|
|
245
265
|
}
|
|
246
266
|
}
|
|
247
267
|
|
|
248
268
|
if (cucu.debug) {
|
|
249
269
|
console.log(elements);
|
|
270
|
+
console.log(element_labels);
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
if (elements.length > 0 && insert_label) {
|
|
274
|
+
return [elements[index], element_labels[index]];
|
|
250
275
|
}
|
|
251
276
|
return elements[index];
|
|
252
277
|
};
|
|
@@ -24,8 +24,8 @@ cucu/formatter/json.py,sha256=fJ1dZBGwYD4OkhQFDE49MRKGNzsrhDzQYq-dUfsYh94,10589
|
|
|
24
24
|
cucu/formatter/junit.py,sha256=dCyS47iHOqn5AZjsRpWCsDRkxxJ67IZy3wIlE5jjhoM,10249
|
|
25
25
|
cucu/formatter/rundb.py,sha256=dKNlD-LXmrJ1Gm4OHI7Cs49eMuBGlBfwLz7NLISF5sg,7857
|
|
26
26
|
cucu/fuzzy/__init__.py,sha256=ce4JRmaBF6oab6U99Qbpt7DrD3elhH32__-ND6fw5xc,104
|
|
27
|
-
cucu/fuzzy/core.py,sha256
|
|
28
|
-
cucu/fuzzy/fuzzy.js,sha256=
|
|
27
|
+
cucu/fuzzy/core.py,sha256=-H2xL0d1LmH9G_34GvLby7fr3o2sRlXUFsDml0cSG58,3380
|
|
28
|
+
cucu/fuzzy/fuzzy.js,sha256=7ppPmR8szoEQ2rfIsyTmtYDgTrNwXrP_g11y-qEITGk,13882
|
|
29
29
|
cucu/helpers.py,sha256=l_YMmbuXjtBRo-MER-qe6soUIyjt0ey2BoSgWs4zYwA,36285
|
|
30
30
|
cucu/hooks.py,sha256=3Z1mavU42XMQ0DZ7lVWwTB-BJYHRyYUOzzOtmkdIsow,7117
|
|
31
31
|
cucu/init_data/.gitignore,sha256=FgMovmORdGgSvRH6EoFK6ch_EyCMyQof61yamXG0P50,137
|
|
@@ -88,7 +88,7 @@ cucu/steps/text_steps.py,sha256=Jj_GHoHeemNwVdUOdqcehArNp7WM-WMjljA4w0pLXuw,2576
|
|
|
88
88
|
cucu/steps/variable_steps.py,sha256=WSctH3_xcxjijGPYZlxp-foC_SIAAKtF__saNtgZJbk,2966
|
|
89
89
|
cucu/steps/webserver_steps.py,sha256=wWkpSvcSMdiskPkh4cqlepWx1nkvEpTU2tRXQmPDbyo,1410
|
|
90
90
|
cucu/utils.py,sha256=LCcs8sMzvdvH05N8P5QYO4lO6j-_PQC530mEAD96go8,10957
|
|
91
|
-
cucu-1.3.
|
|
92
|
-
cucu-1.3.
|
|
93
|
-
cucu-1.3.
|
|
94
|
-
cucu-1.3.
|
|
91
|
+
cucu-1.3.10.dist-info/WHEEL,sha256=-neZj6nU9KAMg2CnCY6T3w8J53nx1kFGw_9HfoSzM60,79
|
|
92
|
+
cucu-1.3.10.dist-info/entry_points.txt,sha256=11WRIhQM7LuUnQg1lAoZQoNvvBvYNN1maDgQS4djwJo,40
|
|
93
|
+
cucu-1.3.10.dist-info/METADATA,sha256=9dT2yBir4G_XbcEOLVUidh5wQK0ukiNvM3x4EVy-mZo,16722
|
|
94
|
+
cucu-1.3.10.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|