Skip to content

Commit 4f0a7ba

Browse files
committed
ci: delete brave session and tabs
1 parent 3e06334 commit 4f0a7ba

1 file changed

Lines changed: 14 additions & 12 deletions

File tree

sample/Tests/test/test_mac.py

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,25 @@ def launch_browser(cls):
5454
print("Brave Browser executable not found.")
5555
exit(1)
5656

57+
# Delete session/tab restore files so Brave starts with a clean slate
58+
brave_profile = os.path.expanduser(
59+
"~/Library/Application Support/BraveSoftware/Brave-Browser/Default"
60+
)
61+
for session_file in ["Current Session", "Current Tabs", "Last Session", "Last Tabs"]:
62+
path = os.path.join(brave_profile, session_file)
63+
try:
64+
if os.path.exists(path):
65+
os.remove(path)
66+
print(f"Removed {session_file}")
67+
except OSError:
68+
pass
69+
5770
subprocess.Popen([
5871
browser_path,
5972
"--remote-debugging-port=9222",
6073
"--no-first-run",
6174
"--no-default-browser-check",
62-
"--restore-last-session=false"
75+
"--disable-session-crashed-bubble"
6376
])
6477

6578
# Give Brave more time to fully initialize remote debugging
@@ -78,16 +91,6 @@ def launch_browser(cls):
7891
'end tell'
7992
], check=False, capture_output=True, timeout=5)
8093
time.sleep(1)
81-
82-
# Close any restored tabs/windows from a previous session
83-
print("Clearing any restored tabs...")
84-
subprocess.run([
85-
"osascript", "-e",
86-
'tell application "Brave Browser" to repeat while (count of windows) > 0\n'
87-
'tell front window to close\n'
88-
'end repeat'
89-
], check=False, capture_output=True, timeout=10)
90-
time.sleep(1)
9194

9295
# Verify remote debugging is accessible
9396
try:
@@ -247,7 +250,6 @@ def test_1_login(self):
247250
self.altdriver.wait_for_current_scene_to_be("AuthenticatedScene")
248251
print("Re-logged in")
249252

250-
# Logout
251253
self.logout()
252254
print("Logged out and successfully reset app")
253255
time.sleep(2)

0 commit comments

Comments
 (0)