Tuesday, February 25, 2025

How to implement screen shot comaprison with WebdriverIO

 Get the Visual service to your wdio.conf file.

 services: [

    [

      "visual",

      {

        baselineFolder: path.join(process.cwd(), "snapshot", "baseline"),

        formatImageName: "{tag}-{width}x{height}",

        screenshotPath: path.join(process.cwd(), "screenshot"),

        savePerInstance: true,

        addIOSBezelCorners: true,

      },

    ],

  ],


Then use below code to validate.

It will be something like:

  const element = WishlistScreen.EllipsisItemList();

  const formattedElementName = elementName.replace(/ /g, "-").toLowerCase();

  // Verify the snapshot of the element

  await expect(element).toMatchElementSnapshot(`${global.brand.toLowerCase()}-${formattedElementName}`, 8);


No comments:

Post a Comment