Options
All
  • Public
  • Public/Protected
  • All
Menu

Module toMatchText

Index

Functions

Functions

toMatchText

  • toMatchText(element: UIElement, expectedPattern: string, options?: Options): Promise<SyncExpectationResult>
  • Use toMatchText function when you want to check that an element's text matches the expected text with regular expression

    example
    // could be used with Promise<ElementHandle>
    await expect(page.$('.alert')).toMatchText(/[S|s]uccess/);
    
    // or with ElementHandle
    const toastElement = await page.$('.alert);
    await expect(toastElement).toMatchText(/[S|s]uccess/);
    
    // or using an array of page and selector
    await expect([page, '.alert']).toMatchText(/[S|s]uccess/);
    

    Parameters

    • element: UIElement
    • expectedPattern: string
    • Optional options: Options

    Returns Promise<SyncExpectationResult>

Generated using TypeDoc