element-takesnapshot.test.js 834 字节
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
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)
16
    await page.waitFor(1200);
17 18 19 20
  });


  it("takeSnapshot", async () => {
21
    await page.waitFor(1200)
22 23
    let btnTakeSnapshot = await page.$('.btn-TakeSnapshot')
    await btnTakeSnapshot.tap()
24
    await page.waitFor(1200)
25 26 27 28 29 30
    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)
  });
});