get-element-by-id.test.js 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. const PAGE_PATH = "/pages/API/get-element-by-id/get-element-by-id";
  2. let page;
  3. describe("getElementById", () => {
  4. const platformInfo = process.env.uniTestPlatformInfo.toLocaleLowerCase()
  5. const isAndroid = platformInfo.startsWith('android')
  6. const isIOS = platformInfo.startsWith('ios')
  7. const isMP = platformInfo.startsWith('mp')
  8. const isWeb = platformInfo.startsWith('web')
  9. beforeAll(async () => {
  10. page = await program.reLaunch(PAGE_PATH);
  11. await page.waitFor('view');
  12. });
  13. it("getElementByNotExistId", async () => {
  14. const res = await page.callMethod("getElementByNotExistId");
  15. expect(res).toBe(null);
  16. });
  17. it("changeStyle", async () => {
  18. if (!isMP) {
  19. await page.callMethod("changePageHeadBackgroundColor");
  20. }
  21. await page.callMethod("changeTextColor");
  22. await page.callMethod("changeViewStyle");
  23. await page.waitFor(500);
  24. const image = await program.screenshot({fullPage: true});
  25. expect(image).toSaveImageSnapshot();
  26. });
  27. if(isMP) {
  28. return
  29. }
  30. /**
  31. * 检测元素offsetLeft属性值域
  32. */
  33. it("checkElementOffsetLeft", async() => {
  34. const res = await page.callMethod("getTextOffsetLeft");
  35. expect(res).toBe(0);
  36. })
  37. });