diff --git a/pages/webview-screenshot/webview-screenshot.test.js b/pages/webview-screenshot/webview-screenshot.test.js
index 34d23bed25f23d20aae73e21a540bd8a2ea6b695..30c6f35e322dffff229b9446e40a7e703aca9a5e 100644
--- a/pages/webview-screenshot/webview-screenshot.test.js
+++ b/pages/webview-screenshot/webview-screenshot.test.js
@@ -255,6 +255,13 @@ describe("shot-compare", () => {
let pageIndex = 0;
let baseSrc = "";
beforeAll(async () => {
+ // 获取导航栏+状态栏高度
+ page = await program.reLaunch('/pages/API/get-window-info/get-window-info')
+ await page.callMethod('getWindowInfo')
+ // 获取设备像素比
+ page = await program.reLaunch('/pages/API/get-device-info/get-device-info')
+ await page.callMethod('getDeviceInfo')
+
page = await program.reLaunch(PAGE_PATH);
await page.waitFor(500);
@@ -279,7 +286,7 @@ describe("shot-compare", () => {
const isNeedAdbScreenshot = needAdbScreenshot(pages[pageIndex]);
const isCustomNavigation = customNavigationPages.includes(pages[pageIndex]);
const {
- headerHeight,
+ statusBarHeight,
devicePixelRatio
} = await page.data();
const screenshotParams = {
@@ -288,7 +295,7 @@ describe("shot-compare", () => {
// deviceShot 截图时跳过状态栏
area: {
x: 0,
- y: (headerHeight - 44) * devicePixelRatio,
+ y: (statusBarHeight - 44) * devicePixelRatio,
},
}
const screenshotPath = `__webview-shot__/${pages[pageIndex].replace(/\//g, "-")}`;
@@ -326,7 +333,7 @@ describe("shot-compare", () => {
// web 端非 deviceShot 截图时设置 offsetY 移除导航栏
const webSnapshot = await program.screenshot({
...screenshotParams,
- offsetY: `${isCustomNavigation ? 0 : headerHeight}`
+ offsetY: `${isCustomNavigation ? 0 : statusBarHeight + 44}`
});
expect(webSnapshot).toSaveImageSnapshot({
customSnapshotIdentifier() {
diff --git a/pages/webview-screenshot/webview-screenshot.uvue b/pages/webview-screenshot/webview-screenshot.uvue
index e7dab64e6946d3b7f0de078ca34ecd7a0d5f4205..8c8c3507d0f2eb625757b4899d33ee98afe5016c 100644
--- a/pages/webview-screenshot/webview-screenshot.uvue
+++ b/pages/webview-screenshot/webview-screenshot.uvue
@@ -1,15 +1,22 @@
-
-
+
+
+
+
+