Options
All
  • Public
  • Public/Protected
  • All
Menu

Module toContainText

Index

Functions

Functions

toContainText

  • toContainText(element: UIElement, expectedText: string, options?: Options): Promise<SyncExpectationResult>
  • Use toContainText function when you want to check that an element's text contains the expected string or substring

    example
    // could be used with Promise<ElementHandle>
    await expect(page.$('.alert')).toContainText('Success');
    
    // or with ElementHandle
    const toastElement = await page.$('.alert);
    await expect(toastElement).toContainText('Success');
    
    // or using an array of page and selector
    await expect([page, '.alert']).toHaveText('Success');
    
    // also you can check text ignoring case sensitive
    await expect(page.$('.alert')).toHaveText('success', {ignoreCase: true})
    

    Parameters

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

    Returns Promise<SyncExpectationResult>

Generated using TypeDoc