i'm facing a small (i hope) issue, for personal purpose i need to migrate from protractor to playwright, i add a lot of steps working well without any issues, but now i'm stuck, the migrate protactor's code using executeScript() and accessign scope.
Here is what i had in Protractor :
browser.executeScript(element => $(element).scope().$ctrl.myFunction(), finder.getWebElement());
in Playwright i tried that (with console.log to for debugging) :
const elementHandle: ElementHandle | null = await this.button.elementHandle();
await this.page.evaluate(
({ element, functionName }) => {
const angularElement = (window as any).angular.element(element);
const scope = angularElement.scope();
console.log("", scope); // returns undefined
console.log("",scope.$ctrl); // returns also undefined of course
scope.$ctrl[myFunction]();
},
{ element: elementHandle, functionName }
);
i'm completely lost, i don't see how can i achieve this, thanks in advance for your help !
Finally found out !
In Angular to access scope you're apparently need to be in debug mode, so In case of using Playwright I've just created a method to do it and called it in the Cucumber's "Before" Hook :