Options
All
  • Public
  • Public/Protected
  • All
Menu

Module toHaveText

Index

Functions

Functions

toHaveText

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

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

    Parameters

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

    Returns Promise<SyncExpectationResult>

Generated using TypeDoc