Skip to content

Commit a697431

Browse files
authored
chore: update game bridge to 2.7.0 (#582)
* chore: update game bridge to 2.7.0
1 parent 06acfbd commit a697431

3 files changed

Lines changed: 178 additions & 50 deletions

File tree

sample/Tests/test/test_mac.py

Lines changed: 52 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -50,19 +50,33 @@ def launch_browser(cls):
5050
break
5151

5252
if not browser_path:
53-
print("Brave executable not found.")
53+
print("Brave Browser executable not found.")
5454
exit(1)
5555

5656
subprocess.Popen([
5757
browser_path,
58-
"--remote-debugging-port=9222"
58+
"--remote-debugging-port=9222",
59+
"--no-first-run",
60+
"--no-default-browser-check"
5961
])
6062

61-
time.sleep(5)
63+
# Give Brave more time to fully initialize remote debugging
64+
print("Waiting for Brave to fully initialize...")
65+
time.sleep(10)
66+
67+
# Verify remote debugging is accessible
68+
try:
69+
import urllib.request
70+
with urllib.request.urlopen("http://127.0.0.1:9222/json", timeout=5) as response:
71+
tabs = response.read()
72+
print(f"Remote debugging verified - found {len(eval(tabs))} tabs")
73+
except Exception as e:
74+
print(f"Remote debugging check failed: {e}")
75+
print("Continuing anyway...")
6276

6377
@classmethod
6478
def stop_browser(cls):
65-
print("Stopping Brave...")
79+
print("Stopping Brave Browser...")
6680
try:
6781
# First try graceful shutdown using AppleScript
6882
subprocess.run([
@@ -78,24 +92,50 @@ def stop_browser(cls):
7892
# Still running, force kill
7993
subprocess.run(["pkill", "-f", "Brave Browser"],
8094
check=False, capture_output=True)
95+
print("Killed Brave Browser processes")
8196

82-
print("All Brave processes have been closed.")
97+
print("Brave Browser has been closed.")
8398
except Exception as e:
84-
print("Brave might not be running.")
99+
print("Brave Browser might not be running.")
85100

86101
time.sleep(3)
87-
print("Stopped Brave")
102+
print("Stopped Brave Browser")
88103

89104
@classmethod
90105
def login(cls):
91-
print("Connect to Chrome")
92-
# Set up Chrome options to connect to the existing Chrome instance
106+
print("Connect to Brave Browser")
107+
# Set up Chrome options to connect to the existing Brave instance (Brave uses Chromium engine)
93108
chrome_options = Options()
94109
chrome_options.add_experimental_option("debuggerAddress", "localhost:9222")
95-
# Connect to the existing Chrome instance
96-
cls.seleniumdriver = webdriver.Chrome(options=chrome_options)
97110

98-
print("Open a window on Chrome")
111+
# Explicitly specify ChromeDriver path and Chrome browser path for macOS
112+
from selenium.webdriver.chrome.service import Service
113+
chromedriver_path = "/usr/local/bin/chromedriver"
114+
115+
# Use Brave Browser only for macOS automation
116+
brave_path = "/Applications/Brave Browser.app/Contents/MacOS/Brave Browser"
117+
118+
import os
119+
browser_path = None
120+
if os.path.exists(brave_path):
121+
browser_path = brave_path
122+
print(f"Found Brave at: {browser_path}")
123+
else:
124+
print("Brave Browser not found - required for macOS tests")
125+
raise FileNotFoundError("Brave Browser is required for macOS CI tests")
126+
127+
# Set Brave as the browser binary if found
128+
if browser_path:
129+
chrome_options.binary_location = browser_path
130+
131+
# Create service with explicit ChromeDriver path and bypass version checking
132+
service_args = ["--whitelisted-ips=", "--disable-build-check"]
133+
service = Service(executable_path=chromedriver_path, service_args=service_args)
134+
135+
# Connect to the existing Brave instance
136+
cls.seleniumdriver = webdriver.Chrome(service=service, options=chrome_options)
137+
138+
print("Open a window on Brave")
99139

100140
wait = WebDriverWait(cls.seleniumdriver, 60)
101141

sample/Tests/test/test_windows_helpers.py

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -150,8 +150,18 @@ def logout_with_controlled_browser():
150150
chrome_options.add_experimental_option("debuggerAddress", "localhost:9222")
151151

152152
try:
153-
# Connect to the existing browser instance
154-
driver = webdriver.Chrome(options=chrome_options)
153+
# Connect to the existing browser instance with explicit paths
154+
from selenium.webdriver.chrome.service import Service
155+
chromedriver_path = r"C:\Users\WindowsBuildsdkServi\Development\chromedriver-win64\chromedriver-win64\chromedriver.exe"
156+
brave_path = r"C:\Program Files\BraveSoftware\Brave-Browser\Application\brave.exe"
157+
158+
# Set Brave as the browser binary
159+
chrome_options.binary_location = brave_path
160+
161+
# Create service with explicit ChromeDriver path
162+
service = Service(executable_path=chromedriver_path)
163+
164+
driver = webdriver.Chrome(service=service, options=chrome_options)
155165
print("Connected to existing browser for logout")
156166

157167
# Monitor Unity logs for logout URL
@@ -278,8 +288,20 @@ def login():
278288
# (Brave uses Chromium engine so Chrome WebDriver works)
279289
chrome_options = Options()
280290
chrome_options.add_experimental_option("debuggerAddress", "localhost:9222")
291+
292+
# Explicitly specify ChromeDriver path and Brave browser path
293+
from selenium.webdriver.chrome.service import Service
294+
chromedriver_path = r"C:\Users\WindowsBuildsdkServi\Development\chromedriver-win64\chromedriver-win64\chromedriver.exe"
295+
brave_path = r"C:\Program Files\BraveSoftware\Brave-Browser\Application\brave.exe"
296+
297+
# Set Brave as the browser binary
298+
chrome_options.binary_location = brave_path
299+
300+
# Create service with explicit ChromeDriver path
301+
service = Service(executable_path=chromedriver_path)
302+
281303
# Connect to the existing Brave browser instance
282-
driver = webdriver.Chrome(options=chrome_options)
304+
driver = webdriver.Chrome(service=service, options=chrome_options)
283305

284306
# HYBRID APPROACH: Try multi-window detection first (proven to work in CI),
285307
# then fall back to Unity log monitoring if needed

0 commit comments

Comments
 (0)