This is documentation for the next version of Grafana k6 documentation. For the latest stable release, go to the latest version.
getByTitle(title[, options])
Returns a locator for elements with the specified title
attribute. This method is useful for locating elements that use the title
attribute to provide additional information, tooltips, or accessibility context.
Returns
Examples
Find and interact with elements by their title attribute:
Common use cases
- User interface controls:
- Toolbar buttons and action items
- Navigation controls (previous/next, pagination)
- Media player controls
- Menu and drop-down triggers
- Informational elements:
- Help icons and tooltips
- Status indicators and badges
- Progress indicators
- Warning and error messages
- Accessibility support:
- Screen reader descriptions
- Alternative text for complex elements
- Context-sensitive help
- Form field explanations
Best practices
- Meaningful titles: Ensure title attributes provide clear, helpful information about the element’s purpose or content.
- Accessibility compliance: Use titles to enhance accessibility, especially for elements that might not have clear visual labels.
- Avoid redundancy: Don’t duplicate visible text in the title attribute unless providing additional context.
- Dynamic content: When testing applications with changing title content, use flexible matching patterns or regular expressions.
- Tooltip testing: Remember that title attributes often create tooltips on hover, which can be useful for UI testing.
- Internationalization: Consider that title text may change in different language versions of your application.
Related
- page.getByRole() - Locate by ARIA role
- page.getByAltText() - Locate by alt text
- page.getByLabel() - Locate by form labels
- page.getByPlaceholder() - Locate by placeholder text
- page.getByTestId() - Locate by test ID
- page.getByText() - Locate by visible text