Skip to content
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
49 changes: 49 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,55 @@ jobs:
if: matrix.os == 'ubuntu-latest'
run: xvfb-run pytest -vv tests/async --browser=${{ matrix.browser }} --timeout 90

stable:
name: Stable
timeout-minutes: 30
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
browser-channel: [chrome]
include:
- os: windows-latest
browser-channel: msedge
- os: macos-latest
browser-channel: msedge
runs-on: ${{ matrix.os }}
steps:
- name: Install Media Pack
if: matrix.os == 'windows-latest'
shell: powershell
run: Install-WindowsFeature Server-Media-Foundation
- uses: actions/checkout@v2
- uses: microsoft/playwright-github-action@v1
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: 3.8
- name: Install dependencies
run: |
python -m pip install --upgrade pip wheel
pip install -r local-requirements.txt
pip install -e .
- name: Build package
run: python setup.py bdist_wheel
- name: Install ffmpeg
run: python -m playwright install ffmpeg
- name: Common Tests
run: pytest -vv tests/common --browser=chromium --browser-channel=${{ matrix.browser-channel }} --timeout 90
- name: Test Sync API
if: matrix.os != 'ubuntu-latest'
run: pytest -vv tests/sync --browser=chromium --browser-channel=${{ matrix.browser-channel }} --timeout 90
- name: Test Sync API
if: matrix.os == 'ubuntu-latest'
run: xvfb-run pytest -vv tests/sync --browser=chromium --browser-channel=${{ matrix.browser-channel }} --timeout 90
- name: Test Async API
if: matrix.os != 'ubuntu-latest'
run: pytest -vv tests/async --browser=chromium --browser-channel=${{ matrix.browser-channel }} --timeout 90
- name: Test Async API
if: matrix.os == 'ubuntu-latest'
run: xvfb-run pytest -vv tests/async --browser=chromium --browser-channel=${{ matrix.browser-channel }} --timeout 90

test-package-installations:
name: Test package installations
runs-on: ubuntu-latest
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ Playwright is a Python library to automate [Chromium](https://www.chromium.org/H

| | Linux | macOS | Windows |
| :--- | :---: | :---: | :---: |
| Chromium <!-- GEN:chromium-version -->90.0.4421.0<!-- GEN:stop --> | ✅ | ✅ | ✅ |
| WebKit <!-- GEN:webkit-version -->14.1<!-- GEN:stop --> | ✅ | ✅ | ✅ |
| Firefox <!-- GEN:firefox-version -->86.0b10<!-- GEN:stop --> | ✅ | ✅ | ✅ |
| Chromium <!-- GEN:chromium-version -->90.0.4430.0<!-- GEN:stop --> | ✅ | ✅ | ✅ |
| WebKit <!-- GEN:webkit-version -->14.2<!-- GEN:stop --> | ✅ | ✅ | ✅ |
| Firefox <!-- GEN:firefox-version -->87.0b10<!-- GEN:stop --> | ✅ | ✅ | ✅ |

Headless execution is supported for all browsers on all platforms.

Expand Down
2 changes: 2 additions & 0 deletions playwright/_impl/_browser_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ def executable_path(self) -> str:
async def launch(
self,
executablePath: Union[str, Path] = None,
channel: str = None,
args: List[str] = None,
ignoreDefaultArgs: Union[bool, List[str]] = None,
handleSIGINT: bool = None,
Expand Down Expand Up @@ -76,6 +77,7 @@ async def launch(
async def launch_persistent_context(
self,
userDataDir: Union[str, Path],
channel: str = None,
executablePath: Union[str, Path] = None,
args: List[str] = None,
ignoreDefaultArgs: Union[bool, List[str]] = None,
Expand Down
58 changes: 46 additions & 12 deletions playwright/async_api/_generated.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ def resource_type(self) -> str:
following: `document`, `stylesheet`, `image`, `media`, `font`, `script`, `texttrack`, `xhr`, `fetch`, `eventsource`,
`websocket`, `manifest`, `other`.

> NOTE: The resource types are available as constants in [ResourceTypes].

Returns
-------
str
Expand Down Expand Up @@ -2837,7 +2839,7 @@ async def evaluate_handle(
Returns the return value of `expression` as a `JSHandle`.

The only difference between `frame.evaluate()` and `frame.evaluate_handle()` is that
[method: Frame.evaluateHandle`] returns `JSHandle`.
`frame.evaluate_handle()` returns `JSHandle`.

If the function, passed to the `frame.evaluate_handle()`, returns a [Promise], then
`frame.evaluate_handle()` would wait for the promise to resolve and return its value.
Expand Down Expand Up @@ -4359,7 +4361,7 @@ async def evaluate(self, expression: str, arg: typing.Any = None) -> typing.Any:
wait for the promise to resolve and return its value.

If the function passed to the `worker.evaluate()` returns a non-[Serializable] value, then
`worker.evaluate()` returns `undefined`. Playwright also supports transferring some additional values that are
`worker.evaluate()` returns `undefined`. Playwright also supports transferring some additional values that are
not serializable by `JSON`: `-0`, `NaN`, `Infinity`, `-Infinity`.

Parameters
Expand Down Expand Up @@ -4629,7 +4631,7 @@ def suggested_filename(self) -> str:
async def delete(self) -> NoneType:
"""Download.delete

Deletes the downloaded file.
Deletes the downloaded file. Will wait for the download to finish if necessary.
"""

return mapping.from_maybe_impl(
Expand All @@ -4639,7 +4641,7 @@ async def delete(self) -> NoneType:
async def failure(self) -> typing.Optional[str]:
"""Download.failure

Returns download error if any.
Returns download error if any. Will wait for the download to finish if necessary.

Returns
-------
Expand All @@ -4653,7 +4655,8 @@ async def failure(self) -> typing.Optional[str]:
async def path(self) -> typing.Optional[pathlib.Path]:
"""Download.path

Returns path to the downloaded file in case of successful download.
Returns path to the downloaded file in case of successful download. The method will wait for the download to finish if
necessary.

Returns
-------
Expand All @@ -4667,7 +4670,7 @@ async def path(self) -> typing.Optional[pathlib.Path]:
async def save_as(self, path: typing.Union[str, pathlib.Path]) -> NoneType:
"""Download.save_as

Saves the download to a user-specified path.
Saves the download to a user-specified path. It is safe to call this method while the download is still in progress.

Parameters
----------
Expand Down Expand Up @@ -7666,9 +7669,16 @@ def expect_response(
Returns the matched response.

```py
first_response = await page.wait_for_response(\"https://example.com/resource\")
final_response = await page.wait_for_response(lambda response: response.url == \"https://example.com\" and response.status === 200)
return final_response.ok
async with page.expect_response(\"https://example.com/resource\") as response_info:
await page.click(\"input\")
response = response_info.value
return response.ok

# or with a lambda
async with page.expect_response(lambda response: response.url == \"https://example.com\" and response.status === 200) as response_info:
await page.click(\"input\")
response = response_info.value
return response.ok
```

Parameters
Expand Down Expand Up @@ -8623,7 +8633,7 @@ async def new_context(
Specifies if viewport supports touch events. Defaults to false.
color_scheme : Union["dark", "light", "no-preference", NoneType]
Emulates `'prefers-colors-scheme'` media feature, supported values are `'light'`, `'dark'`, `'no-preference'`. See
`page.emulate_media()` for more details. Defaults to '`light`'.
`page.emulate_media()` for more details. Defaults to `'light'`.
accept_downloads : Union[bool, NoneType]
Whether to automatically download all the attachments. Defaults to `false` where all the downloads are canceled.
proxy : Union[{server: str, bypass: Union[str, NoneType], username: Union[str, NoneType], password: Union[str, NoneType]}, NoneType]
Expand Down Expand Up @@ -8760,7 +8770,7 @@ async def new_page(
Specifies if viewport supports touch events. Defaults to false.
color_scheme : Union["dark", "light", "no-preference", NoneType]
Emulates `'prefers-colors-scheme'` media feature, supported values are `'light'`, `'dark'`, `'no-preference'`. See
`page.emulate_media()` for more details. Defaults to '`light`'.
`page.emulate_media()` for more details. Defaults to `'light'`.
accept_downloads : Union[bool, NoneType]
Whether to automatically download all the attachments. Defaults to `false` where all the downloads are canceled.
proxy : Union[{server: str, bypass: Union[str, NoneType], username: Union[str, NoneType], password: Union[str, NoneType]}, NoneType]
Expand Down Expand Up @@ -8872,6 +8882,7 @@ async def launch(
self,
*,
executable_path: typing.Union[str, pathlib.Path] = None,
channel: str = None,
args: typing.List[str] = None,
ignore_default_args: typing.Union[bool, typing.List[str]] = None,
handle_sigint: bool = None,
Expand Down Expand Up @@ -8922,6 +8933,16 @@ async def launch(
Path to a browser executable to run instead of the bundled one. If `executablePath` is a relative path, then it is
resolved relative to the current working directory. Note that Playwright only works with the bundled Chromium, Firefox
or WebKit, use at your own risk.
channel : Union[str, NoneType]
Chromium distribution channel, one of
- chrome
- chrome-beta
- chrome-dev
- chrome-canary
- msedge
- msedge-beta
- msedge-dev
- msedge-canary
args : Union[List[str], NoneType]
Additional arguments to pass to the browser instance. The list of Chromium flags can be found
[here](http://peter.sh/experiments/chromium-command-line-switches/).
Expand Down Expand Up @@ -8970,6 +8991,7 @@ async def launch(
"browser_type.launch",
self._impl_obj.launch(
executablePath=executable_path,
channel=channel,
args=args,
ignoreDefaultArgs=ignore_default_args,
handleSIGINT=handle_sigint,
Expand All @@ -8992,6 +9014,7 @@ async def launch_persistent_context(
self,
user_data_dir: typing.Union[str, pathlib.Path],
*,
channel: str = None,
executable_path: typing.Union[str, pathlib.Path] = None,
args: typing.List[str] = None,
ignore_default_args: typing.Union[bool, typing.List[str]] = None,
Expand Down Expand Up @@ -9043,6 +9066,16 @@ async def launch_persistent_context(
[Chromium](https://chromium.googlesource.com/chromium/src/+/master/docs/user_data_dir.md#introduction) and
[Firefox](https://developer.mozilla.org/en-US/docs/Mozilla/Command_Line_Options#User_Profile). Note that Chromium's user
data directory is the **parent** directory of the "Profile Path" seen at `chrome://version`.
channel : Union[str, NoneType]
Chromium distribution channel, one of
- chrome
- chrome-beta
- chrome-dev
- chrome-canary
- msedge
- msedge-beta
- msedge-dev
- msedge-canary
executable_path : Union[pathlib.Path, str, NoneType]
Path to a browser executable to run instead of the bundled one. If `executablePath` is a relative path, then it is
resolved relative to the current working directory. **BEWARE**: Playwright is only guaranteed to work with the bundled
Expand Down Expand Up @@ -9118,7 +9151,7 @@ async def launch_persistent_context(
Specifies if viewport supports touch events. Defaults to false.
color_scheme : Union["dark", "light", "no-preference", NoneType]
Emulates `'prefers-colors-scheme'` media feature, supported values are `'light'`, `'dark'`, `'no-preference'`. See
`page.emulate_media()` for more details. Defaults to '`light`'.
`page.emulate_media()` for more details. Defaults to `'light'`.
accept_downloads : Union[bool, NoneType]
Whether to automatically download all the attachments. Defaults to `false` where all the downloads are canceled.
chromium_sandbox : Union[bool, NoneType]
Expand All @@ -9144,6 +9177,7 @@ async def launch_persistent_context(
"browser_type.launch_persistent_context",
self._impl_obj.launch_persistent_context(
userDataDir=user_data_dir,
channel=channel,
executablePath=executable_path,
args=args,
ignoreDefaultArgs=ignore_default_args,
Expand Down
Loading