Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[pull] main from microsoft:main #5

Merged
merged 4 commits into from
Jun 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions .github/actions/download-artifact/action.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: 'Download blob report'
description: 'Download blob report from GitHub artifacts'
name: 'Download artifact'
description: 'Download artifact from GitHub'
inputs:
name:
description: 'Name of the artifact to download'
Expand All @@ -10,11 +10,11 @@ inputs:
description: 'Directory with downloaded artifacts'
required: true
type: string
default: 'blob-report'
default: '.'
runs:
using: "composite"
steps:
- name: Download blob report
- name: Download artifact
uses: actions/github-script@v6
with:
script: |
Expand All @@ -35,6 +35,6 @@ runs:
console.log('download result', result);
const fs = require('fs');
fs.writeFileSync(`${name}.zip`, Buffer.from(result.data));
- name: Unzip blob report
- name: Unzip artifact
shell: bash
run: unzip ${{ inputs.name }}.zip -d ${{ inputs.path }}
16 changes: 14 additions & 2 deletions .github/workflows/tests_primary.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,18 @@ jobs:
- name: Upload blob report to Azure
if: always() && github.event_name == 'push'
run: az storage blob upload-batch -s test-results/blob-report -d '$web/run-${{ github.run_id }}-${{ github.run_attempt }}-${{ github.sha }}' --connection-string "${{ secrets.AZURE_CONNECTION_STRING_FOR_BLOB_REPORT }}"
- name: Zip blob report
if: always() && github.event_name == 'pull_request'
shell: bash
run: |
cd test-results
zip -r ${{ github.workspace }}/blob-report.zip blob-report
- name: Upload blob report to GitHub
uses: actions/upload-artifact@v3
if: always() && github.event_name == 'pull_request'
with:
name: blob-report-${{ github.run_attempt }}
path: test-results/blob-report
path: blob-report.zip
retention-days: 30
- name: Write the pull request number in an file
if: always() && github.event_name == 'pull_request'
Expand Down Expand Up @@ -154,12 +160,18 @@ jobs:
- name: Upload blob report to Azure
if: always() && github.event_name == 'push'
run: az storage blob upload-batch -s test-results/blob-report -d '$web/run-${{ github.run_id }}-${{ github.run_attempt }}-${{ github.sha }}' --connection-string "${{ secrets.AZURE_CONNECTION_STRING_FOR_BLOB_REPORT }}"
- name: Zip blob report
if: always() && github.event_name == 'pull_request'
shell: bash
run: |
cd test-results
zip -r ${{ github.workspace }}/blob-report.zip blob-report
- name: Upload blob report to GitHub
uses: actions/upload-artifact@v3
if: always() && github.event_name == 'pull_request'
with:
name: blob-report-${{ github.run_attempt }}
path: test-results/blob-report
path: blob-report.zip
retention-days: 30
- name: Write the pull request number in an file
if: always() && github.event_name == 'pull_request'
Expand Down
8 changes: 7 additions & 1 deletion .github/workflows/tests_secondary.yml
Original file line number Diff line number Diff line change
Expand Up @@ -211,12 +211,18 @@ jobs:
- name: Upload blob report to Azure
if: always() && github.event_name == 'push'
run: az storage blob upload-batch -s test-results/blob-report -d '$web/run-${{ github.run_id }}-${{ github.run_attempt }}-${{ github.sha }}' --connection-string "${{ secrets.AZURE_CONNECTION_STRING_FOR_BLOB_REPORT }}"
- name: Zip blob report
if: always() && github.event_name == 'pull_request'
shell: bash
run: |
cd test-results
zip -r ${{ github.workspace }}/blob-report.zip blob-report
- name: Upload blob report to GitHub
uses: actions/upload-artifact@v3
if: always() && github.event_name == 'pull_request'
with:
name: blob-report-${{ github.run_attempt }}
path: test-results/blob-report
path: blob-report.zip
retention-days: 30
- name: Write the pull request number in an file
if: always() && github.event_name == 'pull_request'
Expand Down
23 changes: 23 additions & 0 deletions docs/src/release-notes-csharp.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,29 @@ title: "Release notes"
toc_max_heading_level: 2
---

## Version 1.35

### Highlights

* New option `maskColor` for methods [`method: Page.screenshot`] and [`method: Locator.screenshot`] to change default masking color.

* New `uninstall` CLI command to uninstall browser binaries:
```bash
$ pwsh bin/Debug/netX/playwright.ps1 uninstall # remove browsers installed by this installation
$ pwsh bin/Debug/netX/playwright.ps1 uninstall --all # remove all ever-install Playwright browsers
```

### Browser Versions

* Chromium 115.0.5790.13
* Mozilla Firefox 113.0
* WebKit 16.4

This version was also tested against the following stable channels:

* Google Chrome 114
* Microsoft Edge 114

## Version 1.34

### Highlights
Expand Down
23 changes: 23 additions & 0 deletions docs/src/release-notes-java.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,29 @@ toc_max_heading_level: 2

import LiteYouTube from '@site/src/components/LiteYouTube';

## Version 1.35

### Highlights

* New option `maskColor` for methods [`method: Page.screenshot`] and [`method: Locator.screenshot`] to change default masking color.

* New `uninstall` CLI command to uninstall browser binaries:
```bash
$ mvn exec:java -e -D exec.mainClass=com.microsoft.playwright.CLI -D exec.args="uninstall" # remove browsers installed by this installation
$ mvn exec:java -e -D exec.mainClass=com.microsoft.playwright.CLI -D exec.args="uninstall --all" # remove all ever-install Playwright browsers
```

### Browser Versions

* Chromium 115.0.5790.13
* Mozilla Firefox 113.0
* WebKit 16.4

This version was also tested against the following stable channels:

* Google Chrome 114
* Microsoft Edge 114

## Version 1.34

### Highlights
Expand Down
23 changes: 23 additions & 0 deletions docs/src/release-notes-python.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,29 @@ title: "Release notes"
toc_max_heading_level: 2
---

## Version 1.35

### Highlights

* New option `maskColor` for methods [`method: Page.screenshot`] and [`method: Locator.screenshot`] to change default masking color.

* New `uninstall` CLI command to uninstall browser binaries:
```bash
$ playwright uninstall # remove browsers installed by this installation
$ playwright uninstall --all # remove all ever-install Playwright browsers
```

### Browser Versions

* Chromium 115.0.5790.13
* Mozilla Firefox 113.0
* WebKit 16.4

This version was also tested against the following stable channels:

* Google Chrome 114
* Microsoft Edge 114

## Version 1.34

### Highlights
Expand Down
4 changes: 0 additions & 4 deletions packages/playwright-core/src/utils/isomorphic/locatorUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,10 @@ export type ByRoleOptions = {
};

function getByAttributeTextSelector(attrName: string, text: string | RegExp, options?: { exact?: boolean }): string {
if (!isString(text))
return `internal:attr=[${attrName}=${text}]`;
return `internal:attr=[${attrName}=${escapeForAttributeSelector(text, options?.exact || false)}]`;
}

export function getByTestIdSelector(testIdAttributeName: string, testId: string | RegExp): string {
if (!isString(testId))
return `internal:testid=[${testIdAttributeName}=${testId}]`;
return `internal:testid=[${testIdAttributeName}=${escapeForAttributeSelector(testId, true)}]`;
}

Expand Down
6 changes: 4 additions & 2 deletions packages/playwright-core/src/utils/isomorphic/stringUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,13 @@ export function normalizeWhiteSpace(text: string): string {

export function escapeForTextSelector(text: string | RegExp, exact: boolean): string {
if (typeof text !== 'string')
return String(text);
return String(text).replace(/>>/g, '\\>\\>');
return `${JSON.stringify(text)}${exact ? 's' : 'i'}`;
}

export function escapeForAttributeSelector(value: string, exact: boolean): string {
export function escapeForAttributeSelector(value: string | RegExp, exact: boolean): string {
if (typeof value !== 'string')
return String(value).replace(/>>/g, '\\>\\>');
// TODO: this should actually be
// cssEscape(value).replace(/\\ /g, ' ')
// However, our attribute selectors do not conform to CSS parsing spec,
Expand Down
1 change: 0 additions & 1 deletion packages/playwright-test/types/test.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4786,7 +4786,6 @@ export type Expect = {
message?: string,
timeout?: number,
soft?: boolean,
poll?: boolean | { timeout?: number, intervals?: number[] },
}) => Expect;
getState(): {
expand?: boolean;
Expand Down
43 changes: 31 additions & 12 deletions tests/page/selectors-get-by.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -177,12 +177,12 @@ wo"rld</label><input id=control />`);
input.setAttribute('title', 'hello my\nwo"rld');
input.setAttribute('alt', 'hello my\nwo"rld');
});
await expect(page.getByText('hello my\nwo"rld')).toHaveAttribute('id', 'label');
await expect(page.getByText('hello my wo"rld')).toHaveAttribute('id', 'label');
await expect(page.getByLabel('hello my\nwo"rld')).toHaveAttribute('id', 'control');
await expect(page.getByPlaceholder('hello my\nwo"rld')).toHaveAttribute('id', 'control');
await expect(page.getByAltText('hello my\nwo"rld')).toHaveAttribute('id', 'control');
await expect(page.getByTitle('hello my\nwo"rld')).toHaveAttribute('id', 'control');
await expect.soft(page.getByText('hello my\nwo"rld')).toHaveAttribute('id', 'label');
await expect.soft(page.getByText('hello my wo"rld')).toHaveAttribute('id', 'label');
await expect.soft(page.getByLabel('hello my\nwo"rld')).toHaveAttribute('id', 'control');
await expect.soft(page.getByPlaceholder('hello my\nwo"rld')).toHaveAttribute('id', 'control');
await expect.soft(page.getByAltText('hello my\nwo"rld')).toHaveAttribute('id', 'control');
await expect.soft(page.getByTitle('hello my\nwo"rld')).toHaveAttribute('id', 'control');

await page.setContent(`<label id=label for=control>Hello my
world</label><input id=control />`);
Expand All @@ -191,19 +191,38 @@ world</label><input id=control />`);
input.setAttribute('title', 'hello my\nworld');
input.setAttribute('alt', 'hello my\nworld');
});
await expect(page.getByText('hello my\nworld')).toHaveAttribute('id', 'label');
await expect(page.getByText('hello my world')).toHaveAttribute('id', 'label');
await expect(page.getByLabel('hello my\nworld')).toHaveAttribute('id', 'control');
await expect(page.getByPlaceholder('hello my\nworld')).toHaveAttribute('id', 'control');
await expect(page.getByAltText('hello my\nworld')).toHaveAttribute('id', 'control');
await expect(page.getByTitle('hello my\nworld')).toHaveAttribute('id', 'control');
await expect.soft(page.getByText('hello my\nworld')).toHaveAttribute('id', 'label');
await expect.soft(page.getByText('hello my world')).toHaveAttribute('id', 'label');
await expect.soft(page.getByLabel('hello my\nworld')).toHaveAttribute('id', 'control');
await expect.soft(page.getByPlaceholder('hello my\nworld')).toHaveAttribute('id', 'control');
await expect.soft(page.getByAltText('hello my\nworld')).toHaveAttribute('id', 'control');
await expect.soft(page.getByTitle('hello my\nworld')).toHaveAttribute('id', 'control');

await page.setContent(`<div id=target title="my title">Text here</div>`);
await expect.soft(page.getByTitle('my title', { exact: true })).toHaveCount(1, { timeout: 500 });
await expect.soft(page.getByTitle('my t\itle', { exact: true })).toHaveCount(1, { timeout: 500 });
await expect.soft(page.getByTitle('my t\\itle', { exact: true })).toHaveCount(0, { timeout: 500 });
await expect.soft(page.getByTitle('my t\\\itle', { exact: true })).toHaveCount(0, { timeout: 500 });
await expect.soft(page.getByTitle('my t\\\\itle', { exact: true })).toHaveCount(0, { timeout: 500 });

await page.setContent(`<label for=target>foo &gt;&gt; bar</label><input id=target>`);
await page.$eval('input', input => {
input.setAttribute('placeholder', 'foo >> bar');
input.setAttribute('title', 'foo >> bar');
input.setAttribute('alt', 'foo >> bar');
});
expect.soft(await page.getByText('foo >> bar').textContent()).toBe('foo >> bar');
await expect.soft(page.locator('label')).toHaveText('foo >> bar');
await expect.soft(page.getByText('foo >> bar')).toHaveText('foo >> bar');
expect.soft(await page.getByText(/foo >> bar/).textContent()).toBe('foo >> bar');
await expect.soft(page.getByLabel('foo >> bar')).toHaveAttribute('id', 'target');
await expect.soft(page.getByLabel(/foo >> bar/)).toHaveAttribute('id', 'target');
await expect.soft(page.getByPlaceholder('foo >> bar')).toHaveAttribute('id', 'target');
await expect.soft(page.getByAltText('foo >> bar')).toHaveAttribute('id', 'target');
await expect.soft(page.getByTitle('foo >> bar')).toHaveAttribute('id', 'target');
await expect.soft(page.getByPlaceholder(/foo >> bar/)).toHaveAttribute('id', 'target');
await expect.soft(page.getByAltText(/foo >> bar/)).toHaveAttribute('id', 'target');
await expect.soft(page.getByTitle(/foo >> bar/)).toHaveAttribute('id', 'target');
});

it('getByRole escaping', async ({ page }) => {
Expand Down
1 change: 1 addition & 0 deletions tests/page/selectors-text.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ it('should work @smoke', async ({ page }) => {

await page.setContent(`<div>Hi&gt;&gt;<span></span></div>`);
expect(await page.$eval(`text="Hi>>">>span`, e => e.outerHTML)).toBe(`<span></span>`);
expect(await page.$eval(`text=/Hi\\>\\>/ >> span`, e => e.outerHTML)).toBe(`<span></span>`);

await page.setContent(`<div>a<br>b</div><div>a</div>`);
expect(await page.$eval(`text=a`, e => e.outerHTML)).toBe('<div>a<br>b</div>');
Expand Down
1 change: 0 additions & 1 deletion utils/generate_types/overrides-test.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,6 @@ export type Expect = {
message?: string,
timeout?: number,
soft?: boolean,
poll?: boolean | { timeout?: number, intervals?: number[] },
}) => Expect;
getState(): {
expand?: boolean;
Expand Down