ui测试前后端问题修复
This commit is contained in:
@@ -1,9 +1,11 @@
|
||||
package com.test.test.controller;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.test.common.utils.SeleniumUtils;
|
||||
import com.test.test.domain.UiAutomation;
|
||||
import com.test.test.domain.UiReport;
|
||||
import com.test.test.domain.qo.UiAutomationDataQO;
|
||||
import com.test.test.domain.qo.UiAutomationQO;
|
||||
import com.test.test.service.IUiAutomationService;
|
||||
|
||||
@@ -50,10 +50,10 @@ public class UiSceneStepsQO extends BaseEntity
|
||||
private String operateObject;
|
||||
|
||||
/** 元素库名称 */
|
||||
private Integer operateGroupId;
|
||||
private Long operateGroupId;
|
||||
|
||||
/** 元素id */
|
||||
private Integer operateElementId;
|
||||
private Long operateElementId;
|
||||
|
||||
/** 元素定位类型 */
|
||||
private String operateLocType;
|
||||
|
||||
@@ -44,10 +44,10 @@ public class UiSceneStepsVO
|
||||
private String operateObject;
|
||||
|
||||
/** 元素库名称 */
|
||||
private Integer operateGroupId;
|
||||
private Long operateGroupId;
|
||||
|
||||
/** 元素id */
|
||||
private Integer operateElementId;
|
||||
private Long operateElementId;
|
||||
|
||||
/** 元素定位类型 */
|
||||
private String operateLocType;
|
||||
|
||||
@@ -99,18 +99,19 @@ public class UiSceneStepsServiceImpl implements IUiSceneStepsService {
|
||||
createSceneStepsReport(orderNumber, step, reportId);
|
||||
}
|
||||
System.setProperty("webdriver.chrome.driver", chromeDriverPath);
|
||||
// 2. 创建一个临时目录作为 user-data-dir
|
||||
String uniqueUserDataDir="/tmp/chrome-"+ UUID.randomUUID();
|
||||
|
||||
// 3. 配置 ChromeOptions
|
||||
|
||||
// 配置 ChromeOptions
|
||||
ChromeOptions options = new ChromeOptions();
|
||||
options.addArguments("--headless"); // 改用传统无头模式(非 `--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=" + uniqueUserDataDir); // 关键:唯一目录
|
||||
// 4. 启动 Chrome
|
||||
options.addArguments("--headless");
|
||||
options.addArguments("--no-sandbox");
|
||||
options.addArguments("--disable-dev-shm-usage");
|
||||
options.addArguments("--remote-allow-origins=*");
|
||||
options.addArguments("--disable-gpu");
|
||||
options.addArguments("--disable-extensions");
|
||||
options.addArguments("--disable-plugins");
|
||||
options.addArguments("--disable-software-rasterizer");
|
||||
|
||||
// 创建 ChromeDriver
|
||||
WebDriver driver = new ChromeDriver(options);
|
||||
|
||||
SeleniumUtils seleniumUtils = new SeleniumUtils(driver);
|
||||
|
||||
Reference in New Issue
Block a user