提交 46988b0e 编写于 作者: shutao-dc's avatar shutao-dc

补充元素校验offsetLeft属性值测试例

上级 a08ce462
......@@ -18,4 +18,11 @@ describe("getElementById", () => {
const image = await program.screenshot({fullPage: true});
expect(image).toSaveImageSnapshot();
});
/**
* 检测元素offsetLeft属性值域
*/
it("checkElementOffsetLeft", async() => {
const res = await page.callMethod("getTextOffsetLeft");
expect(res).toBe(0);
})
});
<template>
<page-head id="page-head" title="getElementById"></page-head>
<view class="uni-padding-wrap">
<view style="margin: 0 15px;">
<text id="text">this is text</text>
<view id="view" class="uni-common-mt" style="border: 1px solid red">this is view</view>
<button class="uni-btn" @click="changePageHeadBackgroundColor">
......@@ -26,7 +26,7 @@
homePagePath: '/pages/tabBar/component',
launchOptionsPath: '',
}
},
},
methods: {
getElementByNotExistId() : Element | null {
return uni.getElementById('not-exist-id')
......@@ -49,6 +49,11 @@
},
goMultipleRootNode() {
uni.navigateTo({ url: '/pages/API/get-element-by-id/get-element-by-id-multiple-root-node' })
},
//自动化测试获取text元素的offsetLeft属性值
getTextOffsetLeft(): number {
const text = uni.getElementById('text')!
return text.offsetLeft
}
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册