import { ClickOptions, ElementHandle, KeyInput } from 'puppeteer'; import { EventSpy } from './events.ts'; import { E2EPage, FindSelector, SerializedEvent } from './types.ts'; /** * This file is part of the puppeteerTesting bundle. That bundle may be * imported even before happy-dom is setup. */ declare const Superclass: { new (): HTMLElement; prototype: HTMLElement; }; export declare class E2EElement extends Superclass { /** * The '2500' value that we default to is the value of `jasmine.DEFAULT_TIMEOUT_INTERVAL` (5000) divided by 2. */ static defaultTimeout: number; private static _page; private static _handle; /** * We can't directly call `new E22Element()` since it extends HTMLElement * which is not directly constructable. Instead, we register it as a custom * element. */ static create(page: E2EPage, handle: ElementHandle): E2EElement; private _queuedActions; private _temporaryDisableValidation; private _page; handle: ElementHandle; constructor(_page?: E2EPage, handle?: ElementHandle); /** * Find a child element that matches the selector, which is the same as * `element.querySelector(selector)`. Use `>>>` within the * selector to find an element within a host element's shadow root. * For example, to select the first `div` inside of the component * `my-cmp`, which is a child of this element, the call would be * `element.find('my-cmp >>> div')`. Returns `null` if no * elements were found. */ find(selector: FindSelector): Promise; /** * Find all child elements that match the selector, which is the same as * `element.querySelectorAll(selector)`. Use `>>>` within the * selector to find elements within a host element's shadow root. * For example, to select all `li` elements inside of the component * `my-cmp`, which is a child of this element, the call would be * `element.findAll('my-cmp >>> li')`. Returns an empty array if * no elements were found. */ findAll(selector: FindSelector): Promise; /** * Used to call a method on a component. For example, if a component * has the method `cmp.myMethod(arg1, arg2)`, calling this method * from a e2e test could be `cmp.callMethod('myMethod', arg1, arg2)`. */ callMethod(methodName: string, ...methodArgs: unknown[]): Promise; /** * This is a convenience method to easily create a `CustomEvent`, * and dispatch it from the element, to include any custom event * `detail` data as the second argument. */ triggerEvent(eventName: string, eventInitDict?: EventInit): void; /** * Used to test if an event was, or was not dispatched. This method * returns a promise, that resolves with an EventSpy. The EventSpy * can be used along with `expect(spy).toHaveReceivedEvent()`, * `expect(spy).toHaveReceivedEventTimes(x)` and * `expect(spy).toHaveReceivedEventDetail({...})`. */ spyOnEvent(eventName: string): Promise>; /** * Calling `click()` on an element scrolls it into view if needed, and * then uses `page.mouse` to click in the center of the element. * Please see the puppeteer docs for more information. */ click(options?: ClickOptions): Promise; /** * Sets focus on the element. */ focus(): Promise; /** * Sets hover on the element. */ hover(): Promise; /** * Resolves `true` when the element's style is `display !== 'none'`, * `visibility !== 'hidden'` and `opacity !== '0'`. */ isVisible(): Promise; /** * Waits until the given event is listened in the element. */ waitForEvent(eventName: string): Promise>; /** * Waits until the element's style is `display !== 'none'`, * `visibility !== 'hidden'`, `opacity !== '0'` and the element * is connected to the document. */ waitForVisible(): Promise; /** * Waits until the element's style is `display === 'none'`, or * `visibility === 'hidden'`, or `opacity === '0'`, or the element * is no longer connected to the document. */ waitForNotVisible(): Promise; awaitVisibility(waitForVisible?: boolean): Promise; /** * Resolves to true if the element is visible in the current viewport. */ isIntersectingViewport(): Promise; /** * Focuses the element, and then uses `keyboard.down` and `keyboard.up`. * If key is a single character and no modifier keys besides Shift are * being held down, a keypress/input event will also be generated. The * text option can be specified to force an input event to be generated. * Note: Modifier keys DO effect `elementHandle.press`. Holding down Shift * will type the text in upper case. * Key names: https://github.com/puppeteer/puppeteer/blob/main/src/common/USKeyboardLayout.ts */ press(key: KeyInput, options?: { text?: string; delay?: number; }): Promise; /** * This method scrolls the element it into view if needed, * and then uses `page.touchscreen` to tap in the center of the element. */ tap(): Promise; /** * Sends a keydown, keypress/input, and keyup event for each character in the text. * To press a special key, like Control or ArrowDown, use `keyboard.press`. */ type(text: string, options?: { delay: number; }): Promise; /** * Returns the value of a specified attribute on the element. If the * given attribute does not exist, the value returned will be null. */ getProperty(propertyName: string): Promise; /** * Used to set a property set on a component. For example, if a * component has the property `elm.myProp`, then calling * `elm.setProperty('myProp', 88)` would set the value `88` to * the `myProp` property on the component. */ setProperty(propertyName: string, value: unknown): void; /** * Returns the value of a specified attribute on the element. If the * given attribute does not exist, the value returned will be null. */ getAttribute(name: string): string | null; /** * Removes the attribute on the specified element. Note that * `await page.waitForChanges()` must be called before reading * the value if content has changed. */ setAttribute(name: string, value: string): void; /** * Removes the attribute on the specified element. Note that * `await page.waitForChanges()` must be called before reading * the value if content has changed. */ removeAttribute(name: string): void; /** * Toggles a `boolean` attribute (removing it if it is present and adding * it if it is not present) on the given element. Note that * `await page.waitForChanges()` must be called before reading * the value if content has changed. The optional `force` argument is a * `boolean` value to determine whether the attribute should be added or * removed, no matter whether the attribute is present or not at the moment. */ toggleAttribute(name: string, force?: boolean): boolean; /** * Gets and sets `innerHTML` property of the element. * Note that `await page.waitForChanges()` must be called before reading * the value if content has changed. */ get innerHTML(): string; set innerHTML(value: string); /** * Gets and sets `innerText` property of the element. * Note that `await page.waitForChanges()` must be called before reading * the value if content has changed. */ get innerText(): string; set innerText(value: string); get nodeValue(): string | null; set nodeValue(value: string | null); /** * Gets the element's `outerHTML. This is a read-only property and will * throw an error if set. */ get outerHTML(): string; set outerHTML(_: never); /** * The `textContent` property represents the text content of a node * and its descendants. Note that `await page.waitForChanges()` must * be called before reading the value if content has changed. */ get textContent(): string; set textContent(value: string); /** * Returns an object that reports the values of all CSS properties of this * element after applying active stylesheets and resolving any basic computation * those values may contain. Individual CSS property values are accessed by * simply indexing with CSS property names. The method is shortcut and an async * version of using `window.getComputedStyle(element)` directly. */ getComputedStyle(pseudoElement?: string | null): Promise; e2eRunActions(): Promise; e2eSync(): Promise; private _moveChildren; private _parseHtmlToFragment; private _validate; e2eDispose(): Promise; cloneNode(deep?: boolean): Node; } export declare function find(page: E2EPage, rootHandle: ElementHandle, selector: FindSelector): Promise; export declare function findAll(page: E2EPage, rootHandle: ElementHandle, selector: FindSelector): Promise; export {};