Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion seleniumbase/__version__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# seleniumbase package
__version__ = "4.44.15"
__version__ = "4.44.16"
20 changes: 20 additions & 0 deletions seleniumbase/console_scripts/sb_mkrec.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,10 @@ def main():
error_msg = None
invalid_cmd = None
use_edge = False
use_opera = False
use_brave = False
use_comet = False
use_atlas = False
use_uc = False
esc_end = False
start_page = None
Expand Down Expand Up @@ -138,6 +142,14 @@ def main():
help_me = True
elif option.lower() == "--edge":
use_edge = True
elif option.lower() == "--opera":
use_opera = True
elif option.lower() == "--brave":
use_brave = True
elif option.lower() == "--comet":
use_comet = True
elif option.lower() == "--atlas":
use_atlas = True
elif option.lower() == "--ee":
esc_end = True
elif option.lower() in ("--gui", "--headed"):
Expand Down Expand Up @@ -275,6 +287,14 @@ def main():
)
if use_edge:
run_cmd += " --edge"
elif use_opera:
run_cmd += " --opera"
elif use_brave:
run_cmd += " --brave"
elif use_comet:
run_cmd += " --comet"
elif use_atlas:
run_cmd += " --atlas"
if force_gui:
run_cmd += " --gui"
if use_uc:
Expand Down
41 changes: 38 additions & 3 deletions seleniumbase/console_scripts/sb_recorder.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,14 @@ def do_recording(file_name, url, overwrite_enabled, use_chrome, window):
)
if not use_chrome:
command += " --edge"
elif "--opera" in command_args:
command += " --opera"
elif "--brave" in command_args:
command += " --brave"
elif "--comet" in command_args:
command += " --comet"
elif "--atlas" in command_args:
command += " --atlas"
if (
"--uc" in command_args
or "--cdp" in command_args
Expand Down Expand Up @@ -226,10 +234,37 @@ def create_tkinter_gui():
chk = tk.Checkbutton(window, text="Overwrite existing files", variable=cbx)
chk.pack()
chk.select()
use_stealth = False
command_args = sys.argv[2:]
if (
"--uc" in command_args
or "--cdp" in command_args
or "--undetected" in command_args
or "--undetectable" in command_args
):
use_stealth = True
browser_display = "Use Chrome over Edge"
if "--opera" in command_args:
browser_display = "Use Opera over Edge"
elif "--brave" in command_args:
browser_display = "Use Brave over Edge"
elif "--comet" in command_args:
browser_display = "Use Comet over Edge"
elif "--atlas" in command_args:
browser_display = "Use Atlas over Edge"
cbb = tk.IntVar()
chkb = tk.Checkbutton(window, text="Use Chrome over Edge", variable=cbb)
chkb.pack()
chkb.select()
if not use_stealth:
chkb = tk.Checkbutton(window, text=browser_display, variable=cbb)
chkb.pack()
if "--edge" not in command_args:
chkb.select()
else:
chkb = tk.Checkbutton(
window, text="Stealthy Chrome Mode", variable=cbb
)
chkb.pack()
chkb.select()
chkb.config(state=tk.DISABLED)
tk.Label(window, text="").pack()
url = tk.StringVar()
tk.Label(window, text="Enter the URL to start recording on:").pack()
Expand Down
8 changes: 4 additions & 4 deletions seleniumbase/fixtures/base_case.py
Original file line number Diff line number Diff line change
Expand Up @@ -5063,8 +5063,7 @@ def activate_cdp_mode(self, url=None, **kwargs):
self.undetectable = True

def activate_recorder(self):
"""Activate Recorder Mode on the current tab/window.
For persistent Recorder Mode, use the extension instead."""
"""Activate Recorder Mode on the newest tab / window."""
from seleniumbase.js_code.recorder_js import recorder_js

if not self.is_chromium():
Expand All @@ -5077,16 +5076,17 @@ def activate_recorder(self):
"The %s Recorder is for Chromium only!\n"
" (Supported browsers: Chrome and Edge)" % sc
)
url = self.driver.current_url
url = self.get_current_url()
if url.startswith(("data:", "about:", "chrome:", "edge:")):
message = (
"The URL in Recorder-Mode cannot start with: "
'"data:", "about:", "chrome:", or "edge:"!'
)
print("\n" + message)
return
if self.recorder_ext:
if self.recorder_ext and not self.undetectable:
return # The Recorder extension is already active
self.switch_to_newest_tab()
with suppress(Exception):
recorder_on = self.get_session_storage_item("recorder_activated")
if not recorder_on == "yes":
Expand Down
6 changes: 4 additions & 2 deletions seleniumbase/plugins/pytest_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -1622,10 +1622,12 @@ def pytest_addoption(parser):
if (
using_recorder
and browser_changes == 1
and browser_text not in ["chrome", "edge"]
and browser_text not in [
"chrome", "edge", "opera", "brave", "comet", "atlas"
]
):
message = (
"\n Recorder Mode ONLY supports Chrome and Edge!"
"\n Recorder Mode ONLY supports Chromium browsers!"
'\n (Your browser choice was: "%s")\n' % browser_list[0]
)
raise Exception(message)
Expand Down
28 changes: 26 additions & 2 deletions seleniumbase/undetected/cdp_driver/browser.py
Original file line number Diff line number Diff line change
Expand Up @@ -469,13 +469,37 @@ async def get(
frame_id, loader_id, *_ = await connection.send(
cdp.page.navigate(url)
)
if _cdp_recorder:
major_browser_version = None
try:
major_browser_version = (
int(self.info["Browser"].split("/")[-1].split(".")[0])
)
except Exception:
pass
if (
_cdp_recorder
and (
not hasattr(sb_config, "browser")
or (
sb_config.browser == "chrome"
and (
not major_browser_version
or major_browser_version >= 142
)
)
)
):
# (The code below is for the Chrome 142 extension fix)
from seleniumbase.js_code.recorder_js import recorder_js
recorder_code = (
"""window.onload = function() { %s };""" % recorder_js
)
await connection.send(cdp.runtime.evaluate(recorder_code))
await connection.send(
cdp.page.add_script_to_evaluate_on_new_document(recorder_code)
)
await connection.sleep(0.25)
await self.wait(0.05)
await connection.send(cdp.runtime.evaluate(recorder_js))
# Update the frame_id on the tab
connection.frame_id = frame_id
connection.browser = self
Expand Down