mirror of
https://github.com/microsoft/playwright.git
synced 2024-11-28 01:15:10 +03:00
This PR cherry-picks the following commits:
- 6968b61fdc
Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
This commit is contained in:
parent
1aabc97379
commit
8da3502df5
@ -13,21 +13,21 @@ toc_max_heading_level: 2
|
||||
In this case, you can wait for either a "New email" button, or a dialog and act accordingly:
|
||||
|
||||
```csharp
|
||||
var newEmail = page.GetByRole(AriaRole.Button, new() { Name = "New" });
|
||||
var dialog = page.GetByText("Confirm security settings");
|
||||
var newEmail = Page.GetByRole(AriaRole.Button, new() { Name = "New email" });
|
||||
var dialog = Page.GetByText("Confirm security settings");
|
||||
await Expect(newEmail.Or(dialog)).ToBeVisibleAsync();
|
||||
if (await dialog.IsVisibleAsync())
|
||||
await page.GetByRole(AriaRole.Button, new () { Name = "Dismiss" }).ClickAsync();
|
||||
await Page.GetByRole(AriaRole.Button, new() { Name = "Dismiss" }).ClickAsync();
|
||||
await newEmail.ClickAsync();
|
||||
```
|
||||
* Use new options [`option: hasNot`] and [`option: hasNotText`] in [`method: Locator.filter`]
|
||||
to find elements that **do not match** certain conditions.
|
||||
|
||||
```csharp
|
||||
var rowLocator = page.Locator("tr");
|
||||
var rowLocator = Page.Locator("tr");
|
||||
await rowLocator
|
||||
.Filter(new () { HasNotText = "text in column 1" })
|
||||
.Filter(new () { HasNot = page.GetByRole(AriaRole.Button, new () { Name = "column 2 button" }))
|
||||
.Filter(new() { HasNotText = "text in column 1" })
|
||||
.Filter(new() { HasNot = Page.GetByRole(AriaRole.Button, new() { Name = "column 2 button" })})
|
||||
.ScreenshotAsync();
|
||||
```
|
||||
* Use new web-first assertion [`method: LocatorAssertions.toBeAttached`] to ensure that the element
|
||||
|
@ -9,11 +9,11 @@ toc_max_heading_level: 2
|
||||
### Locators Update
|
||||
|
||||
* Use [`method: Locator.or`] to create a locator that matches either of the two locators.
|
||||
Consider a scenario where you'd like to click on a "New email" button, but sometimes a security settings dialog shows up instead.
|
||||
Consider a scenario where you'd like to click on a "New email" button, but sometimes a security settings dialog shows up instead.
|
||||
In this case, you can wait for either a "New email" button, or a dialog and act accordingly:
|
||||
|
||||
```java
|
||||
Locator newEmail = page.getByRole(AriaRole.BUTTON, new Page.GetByRoleOptions().setName("New"));
|
||||
Locator newEmail = page.getByRole(AriaRole.BUTTON, new Page.GetByRoleOptions().setName("New email"));
|
||||
Locator dialog = page.getByText("Confirm security settings");
|
||||
assertThat(newEmail.or(dialog)).isVisible();
|
||||
if (dialog.isVisible())
|
||||
|
@ -11,11 +11,11 @@ import LiteYouTube from '@site/src/components/LiteYouTube';
|
||||
### Locators Update
|
||||
|
||||
* Use [`method: Locator.or`] to create a locator that matches either of the two locators.
|
||||
Consider a scenario where you'd like to click on a "New email" button, but sometimes a security settings dialog shows up instead.
|
||||
Consider a scenario where you'd like to click on a "New email" button, but sometimes a security settings dialog shows up instead.
|
||||
In this case, you can wait for either a "New email" button, or a dialog and act accordingly:
|
||||
|
||||
```js
|
||||
const newEmail = page.getByRole('button', { name: 'New' });
|
||||
const newEmail = page.getByRole('button', { name: 'New email' });
|
||||
const dialog = page.getByText('Confirm security settings');
|
||||
await expect(newEmail.or(dialog)).toBeVisible();
|
||||
if (await dialog.isVisible())
|
||||
|
@ -9,26 +9,26 @@ toc_max_heading_level: 2
|
||||
### Locators Update
|
||||
|
||||
* Use [`method: Locator.or`] to create a locator that matches either of the two locators.
|
||||
Consider a scenario where you'd like to click on a "New email" button, but sometimes a security settings dialog shows up instead.
|
||||
Consider a scenario where you'd like to click on a "New email" button, but sometimes a security settings dialog shows up instead.
|
||||
In this case, you can wait for either a "New email" button, or a dialog and act accordingly:
|
||||
|
||||
```python
|
||||
const newEmail = page.get_by_role('button', name='New );
|
||||
const dialog = page.get_by_text('Confirm security settings');
|
||||
expect(newEmail.or_(dialog)).is_visible();
|
||||
new_email = page.get_by_role("button", name="New email")
|
||||
dialog = page.get_by_text("Confirm security settings")
|
||||
expect(new_email.or_(dialog)).is_visible()
|
||||
if (dialog.is_visible())
|
||||
page.get_by_role('button', name='Dismiss').click();
|
||||
newEmail.click();
|
||||
page.get_by_role("button", name="Dismiss").click()
|
||||
new_email.click()
|
||||
```
|
||||
* Use new options [`option: hasNot`] and [`option: hasNotText`] in [`method: Locator.filter`]
|
||||
to find elements that **do not match** certain conditions.
|
||||
|
||||
```python
|
||||
const rowLocator = page.locator('tr');
|
||||
rowLocator
|
||||
.filter(has_not_text='text in column 1')
|
||||
.filter(has_not=page.get_by_role('button', name='column 2 button'))
|
||||
.screenshot();
|
||||
row_locator = page.locator("tr")
|
||||
row_locator
|
||||
.filter(has_not_text="text in column 1")
|
||||
.filter(has_not=page.get_by_role("button", name="column 2 button"))
|
||||
.screenshot()
|
||||
```
|
||||
* Use new web-first assertion [`method: LocatorAssertions.toBeAttached`] to ensure that the element
|
||||
is present in the page's DOM. Do not confuse with the [`method: LocatorAssertions.toBeVisible`] that ensures that
|
||||
|
Loading…
Reference in New Issue
Block a user