playwright#Page TypeScript Examples

The following examples show how to use playwright#Page. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: has-selector-placeholder.ts    From playwright-fluent with MIT License 6 votes vote down vote up
export async function hasSelectorPlaceholder(
  selector: string,
  expectedPlaceholder: string,
  page: Page | Frame | undefined,
  options: WaitUntilOptions,
): Promise<boolean> {
  if (!page) {
    throw new Error(
      `Cannot check that '${selector}' has placeholder '${expectedPlaceholder}' because no browser has been launched`,
    );
  }

  const handle = await getHandleOf(selector, page, options);
  const result = await hasHandlePlaceholder(handle, expectedPlaceholder);
  return result;
}
Example #2
Source File: playwrightCtx.ts    From mockiavelli with MIT License 6 votes vote down vote up
function makeRequestFactory(page: Page) {
    return (
        method: string,
        url: string,
        headers?: Record<string, string>,
        body?: any,
        options?: { waitForRequestEnd: boolean }
    ): ReturnType<typeof makeRequest> =>
        page.evaluate(makeRequest, {
            url,
            method,
            headers,
            body,
            options,
        });
}
Example #3
Source File: has-selector-focus.ts    From playwright-fluent with MIT License 6 votes vote down vote up
export async function hasSelectorFocus(
  selector: string,
  page: Page | Frame | undefined,
  options: WaitUntilOptions,
): Promise<boolean> {
  if (!page) {
    throw new Error(
      `Cannot get the focus state of '${selector}' because no browser has been launched`,
    );
  }

  const handle = await getHandleOf(selector, page, options);
  const result = await hasHandleFocus(handle);
  return result;
}