You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/guide/browser/locators.md
+48Lines changed: 48 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,5 +1,6 @@
1
1
---
2
2
title: Locators | Browser Mode
3
+
outline: deep
3
4
---
4
5
5
6
# Locators <Version>2.x</Version> <!-- TODO when we decide on the release -->
@@ -24,6 +25,53 @@ title: Locators | Browser Mode
24
25
### dropTo
25
26
### selectOptions
26
27
### screenshot
28
+
27
29
### element
30
+
31
+
-**Type:**`() => Element`
32
+
33
+
This method returns a single element matching the locator's selector.
34
+
35
+
If _no element_ matches the selector, an error is thrown. Consider using [`.query()`](#query) when you just need to check if the element exists.
36
+
37
+
If _multiple elements_ match the selector, an error is thrown. Use [`.elements()`](#elements) when you need all matching DOM Elements or [`.all()`](#all) if you need an array of locators matching the selector.
38
+
39
+
::: tip
40
+
This method can be useful if you need to pass it down to an external library. It is called automatically when locator is used with `expect.element` every time the assertion is [retried](/guide/browser/retry-ability):
Copy file name to clipboardExpand all lines: packages/browser/context.d.ts
+96-11Lines changed: 96 additions & 11 deletions
Original file line number
Diff line number
Diff line change
@@ -112,6 +112,7 @@ export interface UserEvent {
112
112
/**
113
113
* Types text into an element. Uses provider's API under the hood.
114
114
* **Supports** [user-event `keyboard` syntax](https://testing-library.com/docs/user-event/keyboard) (e.g., `{Shift}`) even with `playwright` and `webdriverio` providers.
115
+
* This method can be significantly slower than `userEvent.fill`, so it should be used only when necessary.
115
116
* @example
116
117
* await userEvent.type(input, 'foo') // translates to: f, o, o
117
118
* await userEvent.type(input, '{{a[[') // translates to: {, a, [
0 commit comments