场景执行bug修改
This commit is contained in:
@@ -100,20 +100,16 @@ public class UiSceneStepsServiceImpl implements IUiSceneStepsService {
|
||||
}
|
||||
System.setProperty("webdriver.chrome.driver", chromeDriverPath);
|
||||
// 2. 创建一个临时目录作为 user-data-dir
|
||||
Path tempDir = null;
|
||||
try {
|
||||
tempDir = Files.createTempDirectory("chrome-profile-");
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
String uniqueUserDataDir="/tmp/chrome-"+ UUID.randomUUID();
|
||||
|
||||
// 3. 配置 ChromeOptions
|
||||
ChromeOptions options = new ChromeOptions();
|
||||
options.addArguments("--headless=new"); // 无头模式(可选)
|
||||
options.addArguments("--incognito"); // 无痕模式,不使用 user-data-dir
|
||||
options.addArguments("--no-sandbox"); // Docker/Linux 可能需要
|
||||
options.addArguments("--disable-dev-shm-usage"); // 避免 /dev/shm 不足
|
||||
options.addArguments("--remote-allow-origins=*"); // Chrome 11+ 需要
|
||||
options.addArguments("--user-data-dir=" + tempDir.toAbsolutePath()); // 关键:唯一目录
|
||||
// options.addArguments("--user-data-dir=" + uniqueUserDataDir); // 关键:唯一目录
|
||||
// 4. 启动 Chrome
|
||||
WebDriver driver = new ChromeDriver(options);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user