Skip to content

Commit 0c5867d

Browse files
authored
Merge pull request #4404 from seleniumbase/improved-recorder-app-and-bug-fixes
Improved Recorder App and Bug Fixes
2 parents dd5454f + a5ac4e8 commit 0c5867d

22 files changed

Lines changed: 739 additions & 229 deletions

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -823,6 +823,8 @@ pytest test_coffee_cart.py --trace
823823
--verify-delay=SECONDS # (The delay before MasterQA verification checks.)
824824
--ee | --esc-end # (Lets the user end the current test via the ESC key.)
825825
--recorder # (Enables the Recorder for turning browser actions into code.)
826+
--rec-sb-mgr # (A Recorder Mode that generates SB() context manager code.)
827+
--rec-sb-cdp # (A Recorder Mode that generates Pure CDP Mode sb_cdp code.)
826828
--rec-behave # (Same as Recorder Mode, but also generates behave-gherkin.)
827829
--rec-sleep # (If the Recorder is enabled, also records self.sleep calls.)
828830
--rec-print # (If the Recorder is enabled, prints output after tests end.)

examples/cdp_mode/ReadMe.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -367,6 +367,7 @@ sb.get(url, **kwargs)
367367
sb.open(url, **kwargs) # Same as sb.get(url, **kwargs) in CDP Mode
368368
sb.goto(url, **kwargs) # Same as sb.get(url, **kwargs) in CDP Mode
369369
sb.reload(ignore_cache=True, script_to_evaluate_on_load=None)
370+
sb.goto_if_not_url(url)
370371
sb.refresh(*args, **kwargs)
371372
sb.get_event_loop()
372373
sb.get_rd_host() # Returns the remote-debugging host

examples/cdp_mode/raw_idealista.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
sb.sleep(1.5)
99
sb.solve_captcha()
1010
sb.sleep(2)
11-
sb.click("button#didomi-notice-agree-button")
11+
sb.click_if_visible("button#didomi-notice-agree-button", timeout=3)
1212
print("*** " + sb.get_text("h1"))
1313
items = sb.find_elements("div.item-info-container")
1414
for item in items:

examples/raw_parameter_script.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,8 @@
103103
sb.recorder_ext = False
104104
sb.record_sleep = False
105105
sb.rec_behave = False
106+
sb.rec_sb_mgr = False
107+
sb.rec_sb_cdp = False
106108
sb.rec_print = False
107109
sb.report_on = False
108110
sb.is_pytest = False

help_docs/cdp_mode_methods.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ sb.open(url, **kwargs) # Same as sb.get(url, **kwargs) in CDP Mode
1212
sb.goto(url, **kwargs) # Same as sb.get(url, **kwargs) in CDP Mode
1313
sb.reload(ignore_cache=True, script_to_evaluate_on_load=None)
1414
sb.refresh(*args, **kwargs)
15+
sb.goto_if_not_url(url)
1516
sb.get_event_loop()
1617
sb.get_rd_host() # Returns the remote-debugging host
1718
sb.get_rd_port() # Returns the remote-debugging port

help_docs/customizing_test_runs.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,8 @@ pytest my_first_test.py --settings-file=custom_settings.py
192192
--verify-delay=SECONDS # (The delay before MasterQA verification checks.)
193193
--ee | --esc-end # (Lets the user end the current test via the ESC key.)
194194
--recorder # (Enables the Recorder for turning browser actions into code.)
195+
--rec-sb-mgr # (A Recorder Mode that generates SB() context manager code.)
196+
--rec-sb-cdp # (A Recorder Mode that generates Pure CDP Mode sb_cdp code.)
195197
--rec-behave # (Same as Recorder Mode, but also generates behave-gherkin.)
196198
--rec-sleep # (If the Recorder is enabled, also records self.sleep calls.)
197199
--rec-print # (If the Recorder is enabled, prints output after tests end.)

help_docs/recorder_mode.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,17 @@
77

88
🔴 <b>SeleniumBase Recorder Mode</b> lets you record & export browser actions into test automation scripts.<br>
99

10-
<img src="https://seleniumbase.github.io/cdn/img/sb_recorder_notification.png" title="SeleniumBase" width="380">
10+
⏺️ Recorder Mode can be activated from the command-line interface or the desktop Recorder App. To launch the desktop app, run: `sbase recorder`:
1111

12-
⏺️ Recorder Mode can be activated from the command-line interface or the Recorder Desktop App.
12+
<img src="https://seleniumbase.github.io/cdn/img/recorder_desktop_4.png" title="SeleniumBase Recorder App" width="340">
1313

14-
⏺️ To make a new recording from the command-line interface, use `sbase mkrec`, `sbase codegen`, or `sbase record`:
14+
⏺️ To make a new recording from the command-line interface, use `sbase mkrec`:
1515

1616
```zsh
1717
sbase mkrec TEST_NAME.py --url=URL
1818
```
1919

20-
If the file already exists, you'll get an error. If no URL is provided, you'll start on a blank page and will need to navigate somewhere for the Recorder to activate. (The Recorder captures events on URLs that start with `https`, `http`, or `file`.) The command above runs an empty test that stops at a breakpoint so that you can perform manual browser actions for the Recorder. When you have finished recording, type "`c`" on the command-line and press `[ENTER]` to continue from the breakpoint. The test will complete and a file called `TEST_NAME_rec.py` will be automatically created in the `./recordings` folder. That file will get copied back to the original folder with the name you gave it. (You can run with Edge instead of Chrome by adding `--edge` to the command above. For headed Linux machines, add `--gui` to prevent the default headless mode on Linux.)
20+
If the file already exists, you'll get an error. If no URL is provided, you'll start on a blank page and will need to navigate somewhere for the Recorder to activate. (The Recorder captures events on URLs that start with `https`, `http`, or `file`.) The command above runs an empty test that stops at a breakpoint so that you can perform manual browser actions for the Recorder. When you have finished recording, type "`c`" on the command-line and press `[ENTER]` to continue from the breakpoint. The test will complete and a file called `TEST_NAME_rec.py` will be automatically created in the `./recordings` folder. That file will get copied back to the original folder with the name you gave it. (For headed Linux machines, add `--gui` to prevent the default headless mode on Linux.)
2121

2222
Example:
2323

@@ -55,7 +55,7 @@ sbase recorder
5555
* Starting the SeleniumBase Recorder Desktop App...
5656
```
5757
58-
<img src="https://seleniumbase.github.io/cdn/img/recorder_desktop_2.png" title="SeleniumBase" width="340">
58+
<img src="https://seleniumbase.github.io/cdn/img/sb_recorder_notification.png" title="SeleniumBase Recorder Notification" width="380">
5959
6060
⏺️ While a recording is in progress, you can press the `[ESC]` key to pause the Recorder. To resume the recording, you can hit the `[~`]` key, which is located directly below the `[ESC]` key on most keyboards.
6161

@@ -115,7 +115,7 @@ pytest TEST_NAME.py --trace --rec -s
115115
116116
⏺️ Additionally, the SeleniumBase <code>self.goto(URL)</code> method will also open a new tab for you in Recorder Mode if the domain/origin is different from the current URL. If you need to navigate to a different domain/origin from within the same tab, call <code>self.save_recorded_actions()</code> first, which saves the recorded data for later. When a recorded test completes, SeleniumBase scans the sessionStorage data of all open browser tabs for generating the completed script.
117117
118-
⏺️ As an alternative to activating Recorder Mode with the <code>--rec</code> command-line arg, you can also call <code>self.activate_recorder()</code> from your tests. Using the Recorder this way is only useful for tests that stay on the same URL. This is because the standard Recorder Mode functions as a Chrome extension and persists wherever the browser goes. (This version only stays on the page where called.)
118+
⏺️ As an alternative to activating Recorder Mode with the <code>\-\-rec</code> command-line arg, you can also call <code>self.activate_recorder()</code> from your tests. Using the Recorder this way is only useful for tests that stay on the same URL. This is because the standard Recorder Mode functions as a Chrome extension and persists wherever the browser goes. (This version only stays on the page where called.)
119119
120120
⏺️ (Note that <b>same domain/origin</b> is not the same as <b>same URL</b>. Example: <a href="https://xkcd.com/353/" target="_blank">https://xkcd.com/353</a> and <a href="https://xkcd.com/1537/" target="_blank">https://xkcd.com/1537</a> are two different URLs with the <b>same domain/origin</b>. That means both URLs share the same sessionStorage, and that changes persist to different URLs of the same domain/origin. If you want to find out a website's origin during a test, just call: <code>self.get_origin()</code>, which returns the value of <code>window.location.origin</code> from the browser's console.)
121121

requirements.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ setuptools~=70.2;python_version<"3.10"
55
setuptools>=82.0.1;python_version>="3.10"
66
wheel>=0.47.0
77
attrs>=26.1.0
8-
certifi>=2026.5.20
8+
certifi>=2026.6.17
99
exceptiongroup>=1.3.1
1010
websockets~=15.0.1;python_version<"3.10"
1111
websockets>=16.0;python_version>="3.10"
@@ -46,7 +46,7 @@ wsproto==1.2.0;python_version<"3.10"
4646
wsproto~=1.3.2;python_version>="3.10"
4747
websocket-client~=1.9.0
4848
selenium==4.32.0;python_version<"3.10"
49-
selenium==4.44.0;python_version>="3.10"
49+
selenium==4.45.0;python_version>="3.10"
5050
cssselect==1.3.0;python_version<"3.10"
5151
cssselect>=1.4.0,<2;python_version>="3.10"
5252
sortedcontainers==2.4.0

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.49.14"
2+
__version__ = "4.50.0"

seleniumbase/console_scripts/ReadMe.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,8 @@ that are available when using SeleniumBase.
153153
--help / -h (Display list of all available pytest options.)
154154
--final-debug (Enter Final Debug Mode after each test ends.)
155155
--recorder / --rec (Save browser actions as Python scripts.)
156+
--rec-sb-mgr (Save Recorder actions as SB() context manager.)
157+
--rec-sb-cdp (Save Recorder actions as Pure CDP Mode sb_cdp.)
156158
--rec-behave / --rec-gherkin (Save actions as Gherkin code.)
157159
--rec-print (Display recorded scripts when they are created.)
158160
--save-screenshot (Save a screenshot at the end of each test.)

0 commit comments

Comments
 (0)