🚀 Feature Request
When using page.evaluate it is possible to pass in multiple values. When using someLocator.evaluate you can only pass in SVGElement | HTMLElement. I am requesting that we update locator.evaluate to work the same way as page.evaluate
Example
const nodeId= "5";
const someLocator = this.page.frameLocator("iframe[data-test-id='someId']").locator("[data-test-id='someOtherId']");
const position = await someLocator.evaluate(
({ nodeId }) => {
const cy = window["getCy"]();
const cyElement = cy.getElementById(nodeId);
if (cyElement !== undefined && cyElement.renderedPosition !== undefined) {
const pos = cyElement.renderedPosition();
return { x: pos.x, y: pos.y };
}
throw new Error(`Node with ID ${nodeId} not found or has no rendered position.`);
},
{ nodeId }
);
return { x: Math.round(position.x), y: Math.round(position.y) };
Motivation
The product I'm testing has lots of iframes and nested iframes. I need an easy way to perform evaluate within the iframe context of a locator with the ability to optionally pass in data. My current workaround is to hard code the iframe locator and use evaluateHandle to convert back into a Frame object. The Frame object supports passing in variables to evaluate. This is harder to do when it's not easy or possible to determine the iframe locator at run-time (as far as I know there's no way to get a locator's frame). For example:
const frame = await getFrameFromLocator(this.page.locator("iframe:visible").first()));
🚀 Feature Request
When using page.evaluate it is possible to pass in multiple values. When using someLocator.evaluate you can only pass in SVGElement | HTMLElement. I am requesting that we update locator.evaluate to work the same way as page.evaluate
Example
Motivation
The product I'm testing has lots of iframes and nested iframes. I need an easy way to perform evaluate within the iframe context of a locator with the ability to optionally pass in data. My current workaround is to hard code the iframe locator and use evaluateHandle to convert back into a Frame object. The Frame object supports passing in variables to evaluate. This is harder to do when it's not easy or possible to determine the iframe locator at run-time (as far as I know there's no way to get a locator's frame). For example:
const frame = await getFrameFromLocator(this.page.locator("iframe:visible").first()));