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: dotnet/docs/api/class-locator.mdx
+52
Original file line number
Diff line number
Diff line change
@@ -44,6 +44,10 @@ foreach (var li in await page.GetByRole("listitem").AllAsync())
44
44
45
45
Returns an array of `node.innerText` values for all matching nodes.
46
46
47
+
:::caution Asserting text
48
+
If you need to assert text on the page, prefer [Expect(Locator).ToHaveTextAsync()](/api/class-locatorassertions.mdx#locator-assertions-to-have-text) with `useInnerText` option to avoid flakiness. See [assertions guide](../test-assertions.mdx) for more details.
49
+
:::
50
+
47
51
**Usage**
48
52
49
53
```csharp
@@ -61,6 +65,10 @@ var texts = await page.GetByRole(AriaRole.Link).AllInnerTextsAsync();
61
65
62
66
Returns an array of `node.textContent` values for all matching nodes.
63
67
68
+
:::caution Asserting text
69
+
If you need to assert text on the page, prefer [Expect(Locator).ToHaveTextAsync()](/api/class-locatorassertions.mdx#locator-assertions-to-have-text) to avoid flakiness. See [assertions guide](../test-assertions.mdx) for more details.
70
+
:::
71
+
64
72
**Usage**
65
73
66
74
```csharp
@@ -322,6 +330,10 @@ When all steps combined have not finished during the specified `timeout`, this m
322
330
323
331
Returns the number of elements matching the locator.
324
332
333
+
:::caution Asserting count
334
+
If you need to assert the number of elements on the page, prefer [Expect(Locator).ToHaveCountAsync()](/api/class-locatorassertions.mdx#locator-assertions-to-have-count) to avoid flakiness. See [assertions guide](../test-assertions.mdx) for more details.
335
+
:::
336
+
325
337
**Usage**
326
338
327
339
```csharp
@@ -766,6 +778,10 @@ await locator.ClickAsync();
766
778
767
779
Returns the matching element's attribute value.
768
780
781
+
:::caution Asserting attributes
782
+
If you need to assert an element's attribute, prefer [Expect(Locator).ToHaveAttributeAsync()](/api/class-locatorassertions.mdx#locator-assertions-to-have-attribute) to avoid flakiness. See [assertions guide](../test-assertions.mdx) for more details.
Returns the [`element.innerText`](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/innerText).
1210
1226
1227
+
:::caution Asserting text
1228
+
If you need to assert text on the page, prefer [Expect(Locator).ToHaveTextAsync()](/api/class-locatorassertions.mdx#locator-assertions-to-have-text) with `useInnerText` option to avoid flakiness. See [assertions guide](../test-assertions.mdx) for more details.
Returns the value for the matching `<input>` or `<textarea>` or `<select>` element.
1233
1253
1254
+
:::caution Asserting value
1255
+
If you need to assert input value, prefer [Expect(Locator).ToHaveValueAsync()](/api/class-locatorassertions.mdx#locator-assertions-to-have-value) to avoid flakiness. See [assertions guide](../test-assertions.mdx) for more details.
1256
+
:::
1257
+
1234
1258
**Usage**
1235
1259
1236
1260
```csharp
@@ -1258,6 +1282,10 @@ Throws elements that are not an input, textarea or a select. However, if the ele
1258
1282
1259
1283
Returns whether the element is checked. Throws if the element is not a checkbox or radio input.
1260
1284
1285
+
:::caution Asserting checked state
1286
+
If you need to assert that checkobx is checked, prefer [Expect(Locator).ToBeCheckedAsync()](/api/class-locatorassertions.mdx#locator-assertions-to-be-checked) to avoid flakiness. See [assertions guide](../test-assertions.mdx) for more details.
1287
+
:::
1288
+
1261
1289
**Usage**
1262
1290
1263
1291
```csharp
@@ -1281,6 +1309,10 @@ var isChecked = await page.GetByRole(AriaRole.Checkbox).IsCheckedAsync();
1281
1309
1282
1310
Returns whether the element is disabled, the opposite of [enabled](../actionability.mdx#enabled).
1283
1311
1312
+
:::caution Asserting disabled state
1313
+
If you need to assert that an element is disabled, prefer [Expect(Locator).ToBeDisabledAsync()](/api/class-locatorassertions.mdx#locator-assertions-to-be-disabled) to avoid flakiness. See [assertions guide](../test-assertions.mdx) for more details.
Returns whether the element is [editable](../actionability.mdx#editable).
1306
1338
1339
+
:::caution Asserting editable state
1340
+
If you need to assert that an element is editable, prefer [Expect(Locator).ToBeEditableAsync()](/api/class-locatorassertions.mdx#locator-assertions-to-be-editable) to avoid flakiness. See [assertions guide](../test-assertions.mdx) for more details.
Returns whether the element is [enabled](../actionability.mdx#enabled).
1329
1365
1366
+
:::caution Asserting enabled state
1367
+
If you need to assert that an element is enabled, prefer [Expect(Locator).ToBeEnabledAsync()](/api/class-locatorassertions.mdx#locator-assertions-to-be-enabled) to avoid flakiness. See [assertions guide](../test-assertions.mdx) for more details.
Returns whether the element is hidden, the opposite of [visible](../actionability.mdx#visible).
1352
1392
1393
+
:::caution Asserting visibility
1394
+
If you need to assert that element is hidden, prefer [Expect(Locator).ToBeHiddenAsync()](/api/class-locatorassertions.mdx#locator-assertions-to-be-hidden) to avoid flakiness. See [assertions guide](../test-assertions.mdx) for more details.
Returns whether the element is [visible](../actionability.mdx#visible).
1378
1422
1423
+
:::caution Asserting visibility
1424
+
If you need to assert that element is visible, prefer [Expect(Locator).ToBeVisibleAsync()](/api/class-locatorassertions.mdx#locator-assertions-to-be-visible) to avoid flakiness. See [assertions guide](../test-assertions.mdx) for more details.
1425
+
:::
1426
+
1379
1427
**Usage**
1380
1428
1381
1429
```csharp
@@ -1960,6 +2008,10 @@ When all steps combined have not finished during the specified `timeout`, this m
1960
2008
1961
2009
Returns the [`node.textContent`](https://developer.mozilla.org/en-US/docs/Web/API/Node/textContent).
1962
2010
2011
+
:::caution Asserting text
2012
+
If you need to assert text on the page, prefer [Expect(Locator).ToHaveTextAsync()](/api/class-locatorassertions.mdx#locator-assertions-to-have-text) to avoid flakiness. See [assertions guide](../test-assertions.mdx) for more details.
Copy file name to clipboardExpand all lines: java/docs/api/class-locator.mdx
+52
Original file line number
Diff line number
Diff line change
@@ -44,6 +44,10 @@ for (Locator li : page.getByRole('listitem').all())
44
44
45
45
Returns an array of `node.innerText` values for all matching nodes.
46
46
47
+
:::caution Asserting text
48
+
If you need to assert text on the page, prefer [assertThat(locator).hasText()](/api/class-locatorassertions.mdx#locator-assertions-to-have-text) with `useInnerText` option to avoid flakiness. See [assertions guide](../test-assertions.mdx) for more details.
Returns an array of `node.textContent` values for all matching nodes.
63
67
68
+
:::caution Asserting text
69
+
If you need to assert text on the page, prefer [assertThat(locator).hasText()](/api/class-locatorassertions.mdx#locator-assertions-to-have-text) to avoid flakiness. See [assertions guide](../test-assertions.mdx) for more details.
70
+
:::
71
+
64
72
**Usage**
65
73
66
74
```java
@@ -322,6 +330,10 @@ When all steps combined have not finished during the specified `timeout`, this m
322
330
323
331
Returns the number of elements matching the locator.
324
332
333
+
:::caution Asserting count
334
+
If you need to assert the number of elements on the page, prefer [assertThat(locator).hasCount()](/api/class-locatorassertions.mdx#locator-assertions-to-have-count) to avoid flakiness. See [assertions guide](../test-assertions.mdx) for more details.
335
+
:::
336
+
325
337
**Usage**
326
338
327
339
```java
@@ -766,6 +778,10 @@ locator.click();
766
778
767
779
Returns the matching element's attribute value.
768
780
781
+
:::caution Asserting attributes
782
+
If you need to assert an element's attribute, prefer [assertThat(locator).hasAttribute()](/api/class-locatorassertions.mdx#locator-assertions-to-have-attribute) to avoid flakiness. See [assertions guide](../test-assertions.mdx) for more details.
Returns the [`element.innerText`](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/innerText).
1210
1226
1227
+
:::caution Asserting text
1228
+
If you need to assert text on the page, prefer [assertThat(locator).hasText()](/api/class-locatorassertions.mdx#locator-assertions-to-have-text) with `useInnerText` option to avoid flakiness. See [assertions guide](../test-assertions.mdx) for more details.
Returns the value for the matching `<input>` or `<textarea>` or `<select>` element.
1234
1254
1255
+
:::caution Asserting value
1256
+
If you need to assert input value, prefer [assertThat(locator).hasValue()](/api/class-locatorassertions.mdx#locator-assertions-to-have-value) to avoid flakiness. See [assertions guide](../test-assertions.mdx) for more details.
1257
+
:::
1258
+
1235
1259
**Usage**
1236
1260
1237
1261
```java
@@ -1259,6 +1283,10 @@ Throws elements that are not an input, textarea or a select. However, if the ele
1259
1283
1260
1284
Returns whether the element is checked. Throws if the element is not a checkbox or radio input.
1261
1285
1286
+
:::caution Asserting checked state
1287
+
If you need to assert that checkobx is checked, prefer [assertThat(locator).isChecked()](/api/class-locatorassertions.mdx#locator-assertions-to-be-checked) to avoid flakiness. See [assertions guide](../test-assertions.mdx) for more details.
Returns whether the element is disabled, the opposite of [enabled](../actionability.mdx#enabled).
1284
1312
1313
+
:::caution Asserting disabled state
1314
+
If you need to assert that an element is disabled, prefer [assertThat(locator).isDisabled()](/api/class-locatorassertions.mdx#locator-assertions-to-be-disabled) to avoid flakiness. See [assertions guide](../test-assertions.mdx) for more details.
Returns whether the element is [editable](../actionability.mdx#editable).
1307
1339
1340
+
:::caution Asserting editable state
1341
+
If you need to assert that an element is editable, prefer [assertThat(locator).isEditable()](/api/class-locatorassertions.mdx#locator-assertions-to-be-editable) to avoid flakiness. See [assertions guide](../test-assertions.mdx) for more details.
Returns whether the element is [enabled](../actionability.mdx#enabled).
1330
1366
1367
+
:::caution Asserting enabled state
1368
+
If you need to assert that an element is enabled, prefer [assertThat(locator).isEnabled()](/api/class-locatorassertions.mdx#locator-assertions-to-be-enabled) to avoid flakiness. See [assertions guide](../test-assertions.mdx) for more details.
Returns whether the element is hidden, the opposite of [visible](../actionability.mdx#visible).
1353
1393
1394
+
:::caution Asserting visibility
1395
+
If you need to assert that element is hidden, prefer [assertThat(locator).isHidden()](/api/class-locatorassertions.mdx#locator-assertions-to-be-hidden) to avoid flakiness. See [assertions guide](../test-assertions.mdx) for more details.
Returns whether the element is [visible](../actionability.mdx#visible).
1379
1423
1424
+
:::caution Asserting visibility
1425
+
If you need to assert that element is visible, prefer [assertThat(locator).isVisible()](/api/class-locatorassertions.mdx#locator-assertions-to-be-visible) to avoid flakiness. See [assertions guide](../test-assertions.mdx) for more details.
1426
+
:::
1427
+
1380
1428
**Usage**
1381
1429
1382
1430
```java
@@ -1960,6 +2008,10 @@ When all steps combined have not finished during the specified `timeout`, this m
1960
2008
1961
2009
Returns the [`node.textContent`](https://developer.mozilla.org/en-US/docs/Web/API/Node/textContent).
1962
2010
2011
+
:::caution Asserting text
2012
+
If you need to assert text on the page, prefer [assertThat(locator).hasText()](/api/class-locatorassertions.mdx#locator-assertions-to-have-text) to avoid flakiness. See [assertions guide](../test-assertions.mdx) for more details.
0 commit comments