Skip to content

Commit 7dd40f0

Browse files
committed
Make improvements to "Recorder Mode"
1 parent 645ea6b commit 7dd40f0

File tree

4 files changed

+31
-1
lines changed

4 files changed

+31
-1
lines changed

help_docs/recorder_mode.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
[<img src="https://seleniumbase.io/cdn/img/super_logo_sb.png" title="SeleniumBase" width="296">](https://github.com/seleniumbase/SeleniumBase/blob/master/README.md)
1+
[<img src="https://seleniumbase.io/cdn/img/sb_logo_10t.png" title="SeleniumBase" width="260">](https://github.com/seleniumbase/SeleniumBase/blob/master/README.md)
22

33
<h2><img src="https://seleniumbase.io/img/logo6.png" title="SeleniumBase" width="32" /> Recorder Mode</h2>
44

@@ -47,6 +47,8 @@ class RecorderTest(BaseCase):
4747

4848
<p>🔴 The launch of Recorder Mode has brought a new SeleniumBase method along with it: <code>self.open_if_not_url(URL)</code>. This method will open the URL given if the browser is not currently on that page. This is used as a method in recorded scripts when SeleniumBase detects that a click action has already brought the test to the given page. This method not only prevents an extra page load if not needed, but it also lets people know the current page of the browser at that point in the test.</p>
4949

50+
<p>🔴 SeleniumBase <code>1.66.1</code> adds the ability to record changes to <i>"Choose File"</i> <code>input</code> fields. It also adds the <code>self.set_content_to_frame(frame)</code> method, which lets you record actions inside of iframes on pages. Sometimes the <i>"Choose File"</i> input field is hidden on some sites, so <code>self.show_file_choosers()</code> was also added to get around this edge case.
51+
5052
--------
5153

5254
<div>To learn more about SeleniumBase, check out the Docs Site:</div>

seleniumbase/extensions/recorder.zip

32 Bytes
Binary file not shown.

seleniumbase/fixtures/base_case.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2955,6 +2955,20 @@ def __process_recorded_actions(self):
29552955
elif '"' in action[1] and '"' in action[2]:
29562956
sb_actions.append("self.set_value('%s', '%s')" % (
29572957
action[1], action[2]))
2958+
elif action[0] == "cho_f":
2959+
action[2] = action[2].replace("\\", "\\\\")
2960+
if '"' not in action[1] and '"' not in action[2]:
2961+
sb_actions.append('self.choose_file("%s", "%s")' % (
2962+
action[1], action[2]))
2963+
elif '"' not in action[1] and '"' in action[2]:
2964+
sb_actions.append('self.choose_file("%s", \'%s\')' % (
2965+
action[1], action[2]))
2966+
elif '"' in action[1] and '"' not in action[2]:
2967+
sb_actions.append('self.choose_file(\'%s\', "%s")' % (
2968+
action[1], action[2]))
2969+
elif '"' in action[1] and '"' in action[2]:
2970+
sb_actions.append("self.choose_file('%s', '%s')" % (
2971+
action[1], action[2]))
29582972
elif action[0] == "c_box":
29592973
cb_method = "check_if_unchecked"
29602974
if action[2] == "no":

seleniumbase/js_code/recorder_js.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,9 @@
9797
non_id_attributes.push('data-test');
9898
non_id_attributes.push('data-test-id');
9999
non_id_attributes.push('data-test-selector');
100+
non_id_attributes.push('data-nav');
101+
non_id_attributes.push('data-action');
102+
non_id_attributes.push('data-target');
100103
non_id_attributes.push('alt');
101104
non_id_attributes.push('title');
102105
non_id_attributes.push('heading');
@@ -315,6 +318,17 @@
315318
value = element.value;
316319
document.recorded_actions.push(['set_v', selector, value, d_now]);
317320
}
321+
else if (tag_name === 'input' && element.type === 'file')
322+
{
323+
if (ra_len > 0 &&
324+
document.recorded_actions[ra_len-1][1] === selector)
325+
{
326+
document.recorded_actions.pop();
327+
ra_len = document.recorded_actions.length;
328+
}
329+
value = element.value;
330+
document.recorded_actions.push(['cho_f', selector, value, d_now]);
331+
}
318332
else if (ra_len > 0 &&
319333
document.recorded_actions[ra_len-1][1] === selector &&
320334
tag_name === 'input' && element.type === 'checkbox')

0 commit comments

Comments
 (0)