MCPcopy Index your code
hub / github.com/codeceptjs/CodeceptJS / executeScript

Method executeScript

lib/helper/Playwright.js:2672–2681  ·  view source on GitHub ↗

* Executes a script on the page: * * ```js * I.executeScript(() => window.alert('Hello world')); * ``` * * Additional parameters of the function can be passed as an object argument: * * ```js * I.executeScript(({x, y}) => x + y, {x, y}); * ``` * You can pass only one

(fn, arg)

Source from the content-addressed store, hash-verified

2670 * @returns {Promise<any>}
2671 */
2672 async executeScript(fn, arg) {
2673 if (arg && typeof arg.getNativeElement === 'function') arg = arg.getNativeElement()
2674 if (arg && typeof arg.evaluate === 'function' && typeof arg.locator === 'function') {
2675 return arg.evaluate(fn)
2676 }
2677 if (this.context && typeof this.context.url !== 'function' && typeof this.context.innerText !== 'function') {
2678 return this.context.locator(':root').evaluate(fn, arg)
2679 }
2680 return this.page.evaluate.apply(this.page, [fn, arg])
2681 }
2682
2683 /**
2684 * Grab Locator if called within Context

Callers 6

_getPageUrlMethod · 0.95
scrollPageToTopMethod · 0.95
scrollPageToBottomMethod · 0.95
scrollToMethod · 0.95
refreshContextSessionFunction · 0.45

Calls 2

getNativeElementMethod · 0.80
evaluateMethod · 0.80

Tested by

no test coverage detected