提交 72709c66 编写于 作者: 杜庆泉's avatar 杜庆泉

element takesnapshot 新增自动化测试示例

上级 911bcb59
const PAGE_PATH = "/pages/API/element-takesnapshot/element-takesnapshot";
describe("element-takesnapshot", () => {
let page;
function getData(key = '') {
return new Promise(async (resolve, reject) => {
const data = await page.data()
resolve(key ? data[key] : data)
})
}
beforeAll(async () => {
page = await program.reLaunch(PAGE_PATH)
await page.waitFor(600);
});
it("takeSnapshot", async () => {
await page.waitFor(600)
let btnTakeSnapshot = await page.$('.btn-TakeSnapshot')
await btnTakeSnapshot.tap()
page.waitFor(600)
const image = await getData('snapImage')
console.log(image)
///storage/emulated/0/Android/data/io.dcloud.uniappx/apps/__UNI__3584C99/cache/temp/screenshot/1697513148915.png
expect(image.length).toBeGreaterThan(20)
});
});
...@@ -4,14 +4,14 @@ ...@@ -4,14 +4,14 @@
<view class="uni-padding-wrap" id="snapshot-content"> <view class="uni-padding-wrap" id="snapshot-content">
<text id="text">this is text</text> <text id="text">this is text</text>
<view id="view" class="uni-common-mt" style="border: 1px solid red">this is view</view> <view id="view" class="uni-common-mt" style="border: 1px solid red">this is view</view>
<button class="uni-btn" @click="changeViewStyle">
修改 view 宽高及背景色
</button>
<button class="uni-btn" type="primary" @click="takeSnapshotClick">
点击截图
</button>
</view> </view>
<button class="uni-btn" @click="changeViewStyle">
修改 view 宽高及背景色
</button>
<button class="uni-btn btn-TakeSnapshot" type="primary" @tap="takeSnapshotClick">
点击截图
</button>
<image style="margin-top: 20px;" :src="snapImage" mode="aspectFit" @longpress="saveToAlbum"></image> <image style="margin-top: 20px;" :src="snapImage" mode="aspectFit" @longpress="saveToAlbum"></image>
</view> </view>
</template> </template>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册