Smartui fetchScreenshotStatus with playwright - missing misMatchPercentage & sometimes no result

I’m using playwright and the smartui extension to automatically take screenshots, like here:

I have 2 problems:

  • How long do I have to wait to fetch the result with “smartui.fetchScreenshotStatus”? Because if I do this immediately after saving it (with await, I do wait until it has finished), I will get an error that the screenshot could not be found.
  • When I wait about 10-20 seconds and do get a result, the misMatchPercentage is missing in the data. Do I have to wait even longer? Have I missed something else?

This way I only get basic data I already know:

						const screenshotName = siteName + "screenshot" + i;

						await page.evaluate((_) => {
							},
							`lambdatest_action: ${JSON.stringify({action: "smartui.takeScreenshot", arguments: {fullPage: true, screenshotName}})}`); // Add a relevant screenshot name here

						console.log("Waiting like 20 seconds...");
						await new Promise((resolve) => setTimeout(resolve, 20000))

						const data = await page.evaluate(_ => {
						}, `lambdatest_action: ${JSON.stringify({action: 'smartui.fetchScreenshotStatus', arguments: {screenshotName}})}`)
						console.log("Result from Comparison:", JSON.parse(data));

Well I found out why “matchPercentage” was missing. I still had “smartUIBaseline” enabled in the capabilities, of course there is nothing to compare yet, when this is set to true.

Still I wonder how long to wait. Sometimes even 5 seconds are too short.