@@ -11,7 +11,38 @@ export const { name } = packageJson
1111const __dirname = path . dirname ( fileURLToPath ( import . meta. url ) )
1212export const extensionPath = path . resolve ( __dirname , '../dist' )
1313
14- const chromeExePath = 'C:/Program Files/Google/Chrome/Application/chrome.exe'
14+ // Chrome executable path detection for different platforms
15+ function getChromeExecutablePath ( ) : string | undefined {
16+ const platform = process . platform
17+ if ( platform === 'win32' ) {
18+ const possiblePaths = [
19+ 'C:/Program Files/Google/Chrome/Application/chrome.exe' ,
20+ 'C:/Program Files (x86)/Google/Chrome/Application/chrome.exe' ,
21+ process . env . LOCALAPPDATA + '/Google/Chrome/Application/chrome.exe' ,
22+ ]
23+ for ( const chromePath of possiblePaths ) {
24+ if ( chromePath && fs . existsSync ( chromePath ) ) {
25+ return chromePath
26+ }
27+ }
28+ } else if ( platform === 'darwin' ) {
29+ return '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome'
30+ } else if ( platform === 'linux' ) {
31+ const possiblePaths = [
32+ '/usr/bin/google-chrome' ,
33+ '/usr/bin/google-chrome-stable' ,
34+ '/usr/bin/chromium-browser' ,
35+ ]
36+ for ( const chromePath of possiblePaths ) {
37+ if ( fs . existsSync ( chromePath ) ) {
38+ return chromePath
39+ }
40+ }
41+ }
42+ return undefined
43+ }
44+
45+ const chromeExePath = getChromeExecutablePath ( )
1546export const test = base . extend < {
1647 context : BrowserContext
1748 extensionId : string
@@ -34,6 +65,8 @@ export const test = base.extend<{
3465
3566 const context = await chromium . launchPersistentContext ( '' , {
3667 headless : false ,
68+ // Use Chrome executable for video codec support, fallback to Chromium if not found
69+ ...( chromeExePath ? { executablePath : chromeExePath } : { } ) ,
3770 args : [
3871 '--disable-features=DisableLoadExtensionCommandLineSwitch' ,
3972 // ...(headless ? ['--headless=new'] : []),
@@ -52,7 +85,6 @@ export const test = base.extend<{
5285 recordVideo : {
5386 dir : videoDir ,
5487 } ,
55- // executablePath: chromeExePath,
5688 } )
5789 await use ( context )
5890 // let [serviceWorker] = context.serviceWorkers()
0 commit comments