@@ -8,7 +8,12 @@ import { browserSupportsHeadless } from "../lib/getBrowserString.js";
8
8
// Set script timeout to 10min
9
9
const DRIVER_SCRIPT_TIMEOUT = 1000 * 60 * 10 ;
10
10
11
- export default async function createDriver ( { browserName, headless, url, verbose } ) {
11
+ export default async function createDriver ( {
12
+ browserName,
13
+ headless,
14
+ url,
15
+ verbose
16
+ } ) {
12
17
const capabilities = Capabilities [ browserName ] ( ) ;
13
18
14
19
// Support: IE 11+
@@ -23,7 +28,12 @@ export default async function createDriver( { browserName, headless, url, verbos
23
28
24
29
const chromeOptions = new Chrome . Options ( ) ;
25
30
chromeOptions . addArguments ( "--enable-chrome-browser-cloud-management" ) ;
26
- chromeOptions . addArguments ( "--no-sandbox" ) ;
31
+
32
+ // Create temp dir for user data
33
+ // to avoid conflicts with other instances
34
+ // Use the OS-specific temp dir
35
+ const tempDir = process . platform === "win32" ? "C:/Temp" : "/tmp" ;
36
+ chromeOptions . addArguments ( `--user-data-dir=${ tempDir } /chrome-user-data` ) ;
27
37
28
38
// Alter the chrome binary path if
29
39
// the CHROME_BIN environment variable is set
@@ -58,7 +68,9 @@ export default async function createDriver( { browserName, headless, url, verbos
58
68
59
69
const ieOptions = new IE . Options ( ) ;
60
70
ieOptions . setEdgeChromium ( true ) ;
61
- ieOptions . setEdgePath ( "C:/Program Files (x86)/Microsoft/Edge/Application/msedge.exe" ) ;
71
+ ieOptions . setEdgePath (
72
+ "C:/Program Files (x86)/Microsoft/Edge/Application/msedge.exe"
73
+ ) ;
62
74
63
75
if ( headless ) {
64
76
chromeOptions . addArguments ( "--headless=new" ) ;
@@ -72,7 +84,8 @@ export default async function createDriver( { browserName, headless, url, verbos
72
84
}
73
85
}
74
86
75
- const driver = new Builder ( ) . withCapabilities ( capabilities )
87
+ const driver = new Builder ( )
88
+ . withCapabilities ( capabilities )
76
89
. setChromeOptions ( chromeOptions )
77
90
. setFirefoxOptions ( firefoxOptions )
78
91
. setEdgeOptions ( edgeOptions )
0 commit comments