fix 截图动作放到后置操作结束后截图

This commit is contained in:
2025-06-06 11:22:44 +08:00
parent 74457d2c81
commit eee51078b5

View File

@@ -25,6 +25,7 @@ import com.test.test.mapper.UiAutomationMapper;
import com.test.test.mapper.UiSceneStepsMapper; import com.test.test.mapper.UiSceneStepsMapper;
import com.test.test.mapper.UiSceneStepsReportMapper; import com.test.test.mapper.UiSceneStepsReportMapper;
import com.test.test.service.*; import com.test.test.service.*;
import io.github.bonigarcia.wdm.WebDriverManager;
import jakarta.annotation.Resource; import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.checkerframework.checker.units.qual.C; import org.checkerframework.checker.units.qual.C;
@@ -433,15 +434,12 @@ public class UiSceneStepsServiceImpl implements IUiSceneStepsService {
// 3. 执行具体步骤 // 3. 执行具体步骤
stepExecution.execute(step, seleniumUtils); stepExecution.execute(step, seleniumUtils);
if (screenshotConfiguration == 1) {
report.setScreenshot(seleniumUtils.takeScreenshotAsFile(TestConfig.getProfile()));
log.info("截图成功,路径:{}", seleniumUtils.takeScreenshotAsFile(TestConfig.getProfile()));
}
// 执行后置等待 // 执行后置等待
if (afterAwaitTime > 0) { if (afterAwaitTime > 0) {
log.info("执行后置等待: {}ms", afterAwaitTime); log.info("执行后置等待: {}ms", afterAwaitTime);
Thread.sleep(afterAwaitTime); Thread.sleep(afterAwaitTime);
} }
report.setLogInfo("OK"); report.setLogInfo("OK");
report.setExecutionFlag("1"); report.setExecutionFlag("1");
} catch (Exception e) { } catch (Exception e) {
@@ -458,6 +456,10 @@ public class UiSceneStepsServiceImpl implements IUiSceneStepsService {
} }
log.error("步骤执行失败: {}", e.getMessage()); log.error("步骤执行失败: {}", e.getMessage());
} finally { } finally {
if (screenshotConfiguration == 1) {
report.setScreenshot(seleniumUtils.takeScreenshotAsFile(TestConfig.getProfile()));
log.info("截图成功,路径:{}", seleniumUtils.takeScreenshotAsFile(TestConfig.getProfile()));
}
//获取后置操作数据集合 //获取后置操作数据集合
Map<String, Object> afterData = CollectionUtils.isEmpty(afterSettingList) Map<String, Object> afterData = CollectionUtils.isEmpty(afterSettingList)
? new HashMap<>() ? new HashMap<>()