UNPKG

@scraping.house/commons

Version:
84 lines 3.94 kB
import { Browser, BrowserContext, ElementHandle, Page } from 'playwright-core'; export default class BrowserHelpers { private page; constructor(page: Page); /** * Function clicks on the selector until it disappears * @param selector The selector to click on to expand */ clickUntilElementDissapears(selector: string, element?: ElementHandle): Promise<void>; /** * Function returns the scollable height of the current page * @returns The scrollable height of the current page */ private getScrollableHeight; /** * Function scrolls the given height * @param p The given height to scroll to */ scroll(p: number): Promise<void>; /** * Function scrolls to the top of the page */ scrollToTop(): Promise<void>; /** * Function scrolls the page until the givne element appears on the page. * @param selector The selector of the element to check * @throws If the selector does not exists on the current page */ scrollUntilElementAppears(selector: string): Promise<void>; /** * Returns the text content of the selector if exists. An empty string if not * @param selector The selector of the element * @param element The element from which we will search the selector. * @returns Text content of the selected element if exists, or an empty string */ safeTextContent(selector: string, element?: ElementHandle): Promise<string>; /** * Returns the text content of the element without text content of the ignored element * @param selector The XPath selector for the description * @param element The element on which the path selector will be searched * @returns The description of the experience */ filteredTextContent(selector: string, ignoredElementSelector: string, element?: ElementHandle): Promise<string>; /** * Returns the attribute of the given element, if not exists an empty string * @param selector The selector of the element * @param attributeName The name of the attribute * @param element The element on which we will run the element search * @returns The content of the attribute of the given element */ getAttributeSafe(selector: string, attributeName: string, element?: ElementHandle): Promise<string>; /** * Checks if the selector is present in the current page or on the current element * @param selector The selector to check if present * @param element The parent element to evaluate the selector * @returns True if the selector is present on the current element or on the current page */ isElementPresent(selector: string, element?: ElementHandle): Promise<boolean>; /** * Scroll the given element * @param element The element to scroll */ scrollElement(element: ElementHandle<SVGElement | HTMLElement>): Promise<void>; /** * Checks if the given element is completely scrolled or not * @param element The element to verify * @returns True if the given element is completely scrolled, false if not */ elementCompletelyScrolled(element: ElementHandle<SVGElement | HTMLElement>): Promise<boolean>; } /** * Save the given browser context to the given file path * @param context The current browser context * @param filePath The filePath to save the authenticated browser context */ export declare function saveBrowserContext(context: BrowserContext, filePath: string): Promise<void>; /** * Loads a previously saved browser context in a new browser context * @param browser The browser to which we want to load authenticated context * @param filePath The file path of the authenticated context * @returns Returns the browser context created from the saved context */ export declare function loadBrowserContext(browser: Browser, filePath: string): Promise<BrowserContext>; //# sourceMappingURL=browser-helpers.d.ts.map