diff --git a/sample/Tests/test/test_mac.py b/sample/Tests/test/test_mac.py index 77f85ca63..ce4203d47 100644 --- a/sample/Tests/test/test_mac.py +++ b/sample/Tests/test/test_mac.py @@ -50,19 +50,33 @@ def launch_browser(cls): break if not browser_path: - print("Brave executable not found.") + print("Brave Browser executable not found.") exit(1) subprocess.Popen([ browser_path, - "--remote-debugging-port=9222" + "--remote-debugging-port=9222", + "--no-first-run", + "--no-default-browser-check" ]) - time.sleep(5) + # Give Brave more time to fully initialize remote debugging + print("Waiting for Brave to fully initialize...") + time.sleep(10) + + # Verify remote debugging is accessible + try: + import urllib.request + with urllib.request.urlopen("http://127.0.0.1:9222/json", timeout=5) as response: + tabs = response.read() + print(f"Remote debugging verified - found {len(eval(tabs))} tabs") + except Exception as e: + print(f"Remote debugging check failed: {e}") + print("Continuing anyway...") @classmethod def stop_browser(cls): - print("Stopping Brave...") + print("Stopping Brave Browser...") try: # First try graceful shutdown using AppleScript subprocess.run([ @@ -78,24 +92,50 @@ def stop_browser(cls): # Still running, force kill subprocess.run(["pkill", "-f", "Brave Browser"], check=False, capture_output=True) + print("Killed Brave Browser processes") - print("All Brave processes have been closed.") + print("Brave Browser has been closed.") except Exception as e: - print("Brave might not be running.") + print("Brave Browser might not be running.") time.sleep(3) - print("Stopped Brave") + print("Stopped Brave Browser") @classmethod def login(cls): - print("Connect to Chrome") - # Set up Chrome options to connect to the existing Chrome instance + print("Connect to Brave Browser") + # Set up Chrome options to connect to the existing Brave instance (Brave uses Chromium engine) chrome_options = Options() chrome_options.add_experimental_option("debuggerAddress", "localhost:9222") - # Connect to the existing Chrome instance - cls.seleniumdriver = webdriver.Chrome(options=chrome_options) - print("Open a window on Chrome") + # Explicitly specify ChromeDriver path and Chrome browser path for macOS + from selenium.webdriver.chrome.service import Service + chromedriver_path = "/usr/local/bin/chromedriver" + + # Use Brave Browser only for macOS automation + brave_path = "/Applications/Brave Browser.app/Contents/MacOS/Brave Browser" + + import os + browser_path = None + if os.path.exists(brave_path): + browser_path = brave_path + print(f"Found Brave at: {browser_path}") + else: + print("Brave Browser not found - required for macOS tests") + raise FileNotFoundError("Brave Browser is required for macOS CI tests") + + # Set Brave as the browser binary if found + if browser_path: + chrome_options.binary_location = browser_path + + # Create service with explicit ChromeDriver path and bypass version checking + service_args = ["--whitelisted-ips=", "--disable-build-check"] + service = Service(executable_path=chromedriver_path, service_args=service_args) + + # Connect to the existing Brave instance + cls.seleniumdriver = webdriver.Chrome(service=service, options=chrome_options) + + print("Open a window on Brave") wait = WebDriverWait(cls.seleniumdriver, 60) diff --git a/sample/Tests/test/test_windows_helpers.py b/sample/Tests/test/test_windows_helpers.py index dbf928915..2c47f7024 100644 --- a/sample/Tests/test/test_windows_helpers.py +++ b/sample/Tests/test/test_windows_helpers.py @@ -150,8 +150,18 @@ def logout_with_controlled_browser(): chrome_options.add_experimental_option("debuggerAddress", "localhost:9222") try: - # Connect to the existing browser instance - driver = webdriver.Chrome(options=chrome_options) + # Connect to the existing browser instance with explicit paths + from selenium.webdriver.chrome.service import Service + chromedriver_path = r"C:\Users\WindowsBuildsdkServi\Development\chromedriver-win64\chromedriver-win64\chromedriver.exe" + brave_path = r"C:\Program Files\BraveSoftware\Brave-Browser\Application\brave.exe" + + # Set Brave as the browser binary + chrome_options.binary_location = brave_path + + # Create service with explicit ChromeDriver path + service = Service(executable_path=chromedriver_path) + + driver = webdriver.Chrome(service=service, options=chrome_options) print("Connected to existing browser for logout") # Monitor Unity logs for logout URL @@ -278,8 +288,20 @@ def login(): # (Brave uses Chromium engine so Chrome WebDriver works) chrome_options = Options() chrome_options.add_experimental_option("debuggerAddress", "localhost:9222") + + # Explicitly specify ChromeDriver path and Brave browser path + from selenium.webdriver.chrome.service import Service + chromedriver_path = r"C:\Users\WindowsBuildsdkServi\Development\chromedriver-win64\chromedriver-win64\chromedriver.exe" + brave_path = r"C:\Program Files\BraveSoftware\Brave-Browser\Application\brave.exe" + + # Set Brave as the browser binary + chrome_options.binary_location = brave_path + + # Create service with explicit ChromeDriver path + service = Service(executable_path=chromedriver_path) + # Connect to the existing Brave browser instance - driver = webdriver.Chrome(options=chrome_options) + driver = webdriver.Chrome(service=service, options=chrome_options) # HYBRID APPROACH: Try multi-window detection first (proven to work in CI), # then fall back to Unity log monitoring if needed diff --git a/src/Packages/Passport/Runtime/Resources/index.html b/src/Packages/Passport/Runtime/Resources/index.html index 6b03c7373..f0a72fbcb 100644 --- a/src/Packages/Passport/Runtime/Resources/index.html +++ b/src/Packages/Passport/Runtime/Resources/index.html @@ -1,4 +1,4 @@ -