Skip to content

Commit 717b6d0

Browse files
authored
Merge pull request #1911 from seleniumbase/update-recorder-mode-and-dependencies
Update recorder mode and dependencies
2 parents 3ee1d43 + 620a29b commit 717b6d0

File tree

7 files changed

+37
-32
lines changed

7 files changed

+37
-32
lines changed

mkdocs_build/requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ lunr==0.6.2
2121
nltk==3.8.1
2222
tornado==6.3.2
2323
watchdog==3.0.0
24-
cairocffi==1.5.1
24+
cairocffi==1.6.0
2525
cairosvg==2.7.0
2626
cssselect2==0.7.0
2727
tinycss2==1.2.1

requirements.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ attrs>=23.1.0;python_version>="3.7"
1717
PyYAML>=6.0
1818
certifi>=2023.5.7
1919
filelock>=3.4.1;python_version<"3.7"
20-
filelock>=3.12.1;python_version>="3.7"
20+
filelock>=3.12.2;python_version>="3.7"
2121
platformdirs>=2.4.0;python_version<"3.7"
2222
platformdirs>=3.5.3;python_version>="3.7"
2323
pyparsing>=3.0.7;python_version<"3.7"
@@ -95,10 +95,10 @@ pyotp==2.8.0;python_version>="3.7"
9595
cffi==1.15.1
9696
typing-extensions==4.1.1;python_version<"3.7"
9797
commonmark==0.9.1;python_version<"3.7"
98-
markdown-it-py==2.2.0;python_version>="3.7"
98+
markdown-it-py==3.0.0;python_version>="3.8"
9999
mdurl==0.1.2;python_version>="3.7"
100100
rich==12.6.0;python_version<"3.7"
101-
rich==13.4.1;python_version>="3.7"
101+
rich==13.4.2;python_version>="3.7"
102102

103103
# --- Testing Requirements --- #
104104
# ("pip install -r requirements.txt" also installs this, but "pip install -e ." won't.)

seleniumbase/__version__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
# seleniumbase package
2-
__version__ = "4.15.2"
2+
__version__ = "4.15.3"

seleniumbase/extensions/recorder.zip

1 Byte
Binary file not shown.

seleniumbase/fixtures/base_case.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4351,7 +4351,7 @@ def __process_recorded_actions(self):
43514351
(
43524352
srt_actions[n - 1][0] == "click"
43534353
and int(srt_actions[n][3]) - int(srt_actions[n - 1][3])
4354-
< 5
4354+
< 16
43554355
)
43564356
or (
43574357
srt_actions[n - 1][0] == "js_cl"
@@ -4366,6 +4366,8 @@ def __process_recorded_actions(self):
43664366
)
43674367
):
43684368
srt_actions[n][0] = "_skip"
4369+
if srt_actions[n - 1][0] == "click":
4370+
srt_actions[n - 1][0] = "ch_cl"
43694371
for n in range(len(srt_actions)):
43704372
if (
43714373
n > 0
@@ -4376,7 +4378,7 @@ def __process_recorded_actions(self):
43764378
or srt_actions[n][0] == "jq_cl"
43774379
)
43784380
and (
4379-
int(srt_actions[n][3]) - int(srt_actions[n - 1][3]) < 5
4381+
int(srt_actions[n][3]) - int(srt_actions[n - 1][3]) < 16
43804382
)
43814383
):
43824384
srt_actions[n - 1][0] = "_skip"
@@ -4809,6 +4811,9 @@ def __process_recorded_actions(self):
48094811
and srt_actions[n][2] == srt_actions[n - 1][2]
48104812
):
48114813
srt_actions[n][0] = "_skip"
4814+
for n in range(len(srt_actions)):
4815+
if srt_actions[n][0] == "ch_cl":
4816+
srt_actions[n][0] = "js_cl"
48124817

48134818
# Generate the script from processed actions
48144819
sb_actions = recorder_helper.generate_sbase_code(srt_actions)

seleniumbase/js_code/recorder_js.py

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
if (el.id) {
1212
elid = el.id;
1313
if (elid.includes(',') || elid.includes('.') ||
14-
elid.includes('(') || elid.includes(')') || hasNumber(elid[0]))
14+
elid.includes('(') || elid.includes(')') || hasDigit(elid[0]))
1515
return cssPathByAttribute(el, 'id');
1616
selector += '#' + elid;
1717
path.unshift(selector);
@@ -87,8 +87,6 @@
8787
return path.join(' > ');
8888
};
8989
var ssOccurrences = function(string, subString, allowOverlapping) {
90-
string += '';
91-
subString += '';
9290
if (subString.length <= 0)
9391
return (string.length + 1);
9492
var n = 0;
@@ -101,9 +99,12 @@
10199
}
102100
return n;
103101
};
104-
function hasNumber(str) {
102+
function hasDigit(str) {
105103
return /\d/.test(str);
106104
};
105+
function isGen(str) {
106+
return /[_-]\d/.test(str);
107+
};
107108
function tagName(el) {
108109
return el.tagName.toLowerCase();
109110
};
@@ -121,10 +122,9 @@
121122
var getBestSelector = function(el) {
122123
if (!(el instanceof Element)) return;
123124
el = turnIntoParentAsNeeded(el);
124-
child_sep = ' > ';
125-
selector_by_id = cssPathById(el);
126-
if (!selector_by_id.includes(child_sep)) return selector_by_id;
127-
child_count_by_id = ssOccurrences(selector_by_id, child_sep);
125+
sel_by_id = cssPathById(el);
126+
if (!sel_by_id.includes(' > ') && !isGen(sel_by_id)) return sel_by_id;
127+
child_count_by_id = ssOccurrences(sel_by_id, ' > ');
128128
selector_by_class = cssPathByClass(el);
129129
tag_name = tagName(el);
130130
non_id_attributes = [];
@@ -145,7 +145,6 @@
145145
non_id_attributes.push('data-cy');
146146
non_id_attributes.push('data-action');
147147
non_id_attributes.push('data-target');
148-
non_id_attributes.push('data-content');
149148
non_id_attributes.push('data-tooltip');
150149
non_id_attributes.push('alt');
151150
non_id_attributes.push('title');
@@ -157,6 +156,7 @@
157156
non_id_attributes.push('ng-href');
158157
non_id_attributes.push('href');
159158
non_id_attributes.push('label');
159+
non_id_attributes.push('data-content');
160160
non_id_attributes.push('class');
161161
non_id_attributes.push('for');
162162
non_id_attributes.push('placeholder');
@@ -175,15 +175,15 @@
175175
else selector_by_attr[i] = cssPathByAttribute(el, n_i_attr);
176176
all_by_attr[i] = document.querySelectorAll(selector_by_attr[i]);
177177
num_by_attr[i] = all_by_attr[i].length;
178-
if (!selector_by_attr[i].includes(child_sep) &&
178+
if (!selector_by_attr[i].includes(' > ') &&
179179
((num_by_attr[i] == 1) || (el == all_by_attr[i][0])))
180180
{
181181
if (n_i_attr == 'aria-label' || n_i_attr == 'for')
182-
if (hasNumber(selector_by_attr[i]))
182+
if (hasDigit(selector_by_attr[i]))
183183
continue;
184184
return selector_by_attr[i];
185185
}
186-
child_count_by_attr[i] = ssOccurrences(selector_by_attr[i], child_sep);
186+
child_count_by_attr[i] = ssOccurrences(selector_by_attr[i], ' > ');
187187
}
188188
basic_tags = [];
189189
basic_tags.push('h1');
@@ -201,23 +201,24 @@
201201
contains_tags = [];
202202
contains_tags.push('a');
203203
contains_tags.push('b');
204-
contains_tags.push('i');
205204
contains_tags.push('h1');
206205
contains_tags.push('h2');
207206
contains_tags.push('h3');
208207
contains_tags.push('h4');
209208
contains_tags.push('h5');
210-
contains_tags.push('li');
211-
contains_tags.push('td');
212-
contains_tags.push('th');
213209
contains_tags.push('code');
214210
contains_tags.push('mark');
215-
contains_tags.push('label');
216-
contains_tags.push('small');
217211
contains_tags.push('button');
212+
contains_tags.push('label');
218213
contains_tags.push('legend');
214+
contains_tags.push('li');
215+
contains_tags.push('td');
216+
contains_tags.push('th');
217+
contains_tags.push('i');
218+
contains_tags.push('small');
219219
contains_tags.push('strong');
220220
contains_tags.push('summary');
221+
contains_tags.push('span');
221222
all_by_tag = [];
222223
text_content = '';
223224
if (el.textContent)
@@ -239,9 +240,9 @@
239240
}
240241
}
241242
}
242-
best_selector = selector_by_id;
243+
best_selector = sel_by_id;
243244
lowest_child_count = child_count_by_id;
244-
child_count_by_class = ssOccurrences(selector_by_class, child_sep);
245+
child_count_by_class = ssOccurrences(selector_by_class, ' > ');
245246
if (child_count_by_class < lowest_child_count) {
246247
best_selector = selector_by_class;
247248
lowest_child_count = child_count_by_class;
@@ -622,8 +623,7 @@
622623
href = grand_el.href; origin = grand_el.origin;
623624
}
624625
document.recorded_actions.pop();
625-
child_sep = ' > ';
626-
child_count = ssOccurrences(selector, child_sep);
626+
child_count = ssOccurrences(selector, ' > ');
627627
if ((tag_name === "a" && !el.hasAttribute('onclick') &&
628628
child_count > 0 && href.length > 0) ||
629629
(parent_tag_name === "a" && href.length > 0 &&

setup.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@
141141
"PyYAML>=6.0",
142142
"certifi>=2023.5.7",
143143
'filelock>=3.4.1;python_version<"3.7"',
144-
'filelock>=3.12.1;python_version>="3.7"',
144+
'filelock>=3.12.2;python_version>="3.7"',
145145
'platformdirs>=2.4.0;python_version<"3.7"',
146146
'platformdirs>=3.5.3;python_version>="3.7"',
147147
'pyparsing>=3.0.7;python_version<"3.7"',
@@ -219,10 +219,10 @@
219219
"cffi==1.15.1",
220220
'typing-extensions==4.1.1;python_version<"3.7"',
221221
'commonmark==0.9.1;python_version<"3.7"', # For old "rich"
222-
'markdown-it-py==2.2.0;python_version>="3.7"', # For new "rich"
222+
'markdown-it-py==3.0.0;python_version>="3.8"', # For new "rich"
223223
'mdurl==0.1.2;python_version>="3.7"', # For new "rich"
224224
'rich==12.6.0;python_version<"3.7"',
225-
'rich==13.4.1;python_version>="3.7"',
225+
'rich==13.4.2;python_version>="3.7"',
226226
],
227227
extras_require={
228228
# pip install -e .[allure]

0 commit comments

Comments
 (0)