Skip to content

chore: roll driver, fix real bugs #740

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

Merged
merged 1 commit into from
Jun 4, 2021
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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Playwright is a Python library to automate [Chromium](https://www.chromium.org/H

| | Linux | macOS | Windows |
| :--- | :---: | :---: | :---: |
| Chromium <!-- GEN:chromium-version -->92.0.4513.0<!-- GEN:stop --> | ✅ | ✅ | ✅ |
| Chromium <!-- GEN:chromium-version -->93.0.4530.0<!-- GEN:stop --> | ✅ | ✅ | ✅ |
| WebKit <!-- GEN:webkit-version -->14.2<!-- GEN:stop --> | ✅ | ✅ | ✅ |
| Firefox <!-- GEN:firefox-version -->89.0b15<!-- GEN:stop --> | ✅ | ✅ | ✅ |

Expand Down
4 changes: 2 additions & 2 deletions playwright/_impl/_browser_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ async def launch(
proxy: ProxySettings = None,
downloadsPath: Union[str, Path] = None,
slowMo: float = None,
traceDir: Union[pathlib.Path, str] = None,
tracesDir: Union[pathlib.Path, str] = None,
chromiumSandbox: bool = None,
firefoxUserPrefs: Dict[str, Union[str, float, bool]] = None,
) -> Browser:
Expand Down Expand Up @@ -126,7 +126,7 @@ async def launch_persistent_context(
colorScheme: ColorScheme = None,
reducedMotion: ReducedMotion = None,
acceptDownloads: bool = None,
traceDir: Union[pathlib.Path, str] = None,
tracesDir: Union[pathlib.Path, str] = None,
chromiumSandbox: bool = None,
recordHarPath: Union[Path, str] = None,
recordHarOmitContent: bool = None,
Expand Down
20 changes: 10 additions & 10 deletions playwright/_impl/_tracing.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,21 +28,21 @@ def __init__(self, context: "BrowserContext") -> None:
self._context = context
self._channel = context._channel
self._loop = context._loop
self._dispatcher_fiber = context._channel._connection._dispatcher_fiber

async def start(
self, name: str = None, snapshots: bool = None, screenshots: bool = None
) -> None:
params = locals_to_params(locals())
await self._channel.send("tracingStart", params)

async def stop(self) -> None:
async def stop(self, path: Union[pathlib.Path, str] = None) -> None:
await self._channel.send("tracingStop")

async def export(self, path: Union[pathlib.Path, str]) -> None:
artifact = cast(
Artifact, from_channel(await self._channel.send("tracingExport"))
)
if self._context._browser:
artifact._is_remote = self._context._browser._is_remote
await artifact.save_as(path)
await artifact.delete()
if path:
artifact = cast(
Artifact, from_channel(await self._channel.send("tracingExport"))
)
if self._context._browser:
artifact._is_remote = self._context._browser._is_remote
await artifact.save_as(path)
await artifact.delete()
56 changes: 23 additions & 33 deletions playwright/async_api/_generated.py
Original file line number Diff line number Diff line change
Expand Up @@ -5748,27 +5748,27 @@ async def expose_function(self, name: str, callback: typing.Callable) -> NoneTyp

> NOTE: Functions installed via `page.expose_function()` survive navigations.

An example of adding an `sha1` function to the page:
An example of adding a `sha256` function to the page:

```py
import asyncio
import hashlib
from playwright.async_api import async_playwright

async def sha1(text):
m = hashlib.sha1()
def sha256(text):
m = hashlib.sha256()
m.update(bytes(text, \"utf8\"))
return m.hexdigest()

async def run(playwright):
webkit = playwright.webkit
browser = await webkit.launch(headless=False)
page = await browser.new_page()
await page.expose_function(\"sha1\", sha1)
await page.expose_function(\"sha256\", sha256)
await page.set_content(\"\"\"
<script>
async function onClick() {
document.querySelector('div').textContent = await window.sha1('PLAYWRIGHT');
document.querySelector('div').textContent = await window.sha256('PLAYWRIGHT');
}
</script>
<button onclick=\"onClick()\">Click me</button>
Expand Down Expand Up @@ -8531,28 +8531,28 @@ async def expose_function(self, name: str, callback: typing.Callable) -> NoneTyp

See `page.expose_function()` for page-only version.

An example of adding an `md5` function to all pages in the context:
An example of adding a `sha256` function to all pages in the context:

```py
import asyncio
import hashlib
from playwright.async_api import async_playwright

async def sha1(text):
m = hashlib.sha1()
def sha256(text):
m = hashlib.sha256()
m.update(bytes(text, \"utf8\"))
return m.hexdigest()

async def run(playwright):
webkit = playwright.webkit
browser = await webkit.launch(headless=False)
context = await browser.new_context()
await context.expose_function(\"sha1\", sha1)
await context.expose_function(\"sha256\", sha256)
page = await context.new_page()
await page.set_content(\"\"\"
<script>
async function onClick() {
document.querySelector('div').textContent = await window.sha1('PLAYWRIGHT');
document.querySelector('div').textContent = await window.sha256('PLAYWRIGHT');
}
</script>
<button onclick=\"onClick()\">Click me</button>
Expand Down Expand Up @@ -9393,7 +9393,7 @@ async def launch(
proxy: ProxySettings = None,
downloads_path: typing.Union[str, pathlib.Path] = None,
slow_mo: float = None,
trace_dir: typing.Union[str, pathlib.Path] = None,
traces_dir: typing.Union[str, pathlib.Path] = None,
chromium_sandbox: bool = None,
firefox_user_prefs: typing.Optional[
typing.Dict[str, typing.Union[str, float, bool]]
Expand Down Expand Up @@ -9468,7 +9468,7 @@ async def launch(
deleted when browser is closed.
slow_mo : Union[float, NoneType]
Slows down Playwright operations by the specified amount of milliseconds. Useful so that you can see what is going on.
trace_dir : Union[pathlib.Path, str, NoneType]
traces_dir : Union[pathlib.Path, str, NoneType]
If specified, traces are saved into this directory.
chromium_sandbox : Union[bool, NoneType]
Enable Chromium sandboxing. Defaults to `false`.
Expand Down Expand Up @@ -9499,7 +9499,7 @@ async def launch(
proxy=proxy,
downloadsPath=downloads_path,
slowMo=slow_mo,
traceDir=trace_dir,
tracesDir=traces_dir,
chromiumSandbox=chromium_sandbox,
firefoxUserPrefs=mapping.to_impl(firefox_user_prefs),
),
Expand Down Expand Up @@ -9544,7 +9544,7 @@ async def launch_persistent_context(
color_scheme: Literal["dark", "light", "no-preference"] = None,
reduced_motion: Literal["no-preference", "reduce"] = None,
accept_downloads: bool = None,
trace_dir: typing.Union[str, pathlib.Path] = None,
traces_dir: typing.Union[str, pathlib.Path] = None,
chromium_sandbox: bool = None,
record_har_path: typing.Union[str, pathlib.Path] = None,
record_har_omit_content: bool = None,
Expand Down Expand Up @@ -9652,7 +9652,7 @@ async def launch_persistent_context(
`page.emulate_media()` for more details. Defaults to `'no-preference'`.
accept_downloads : Union[bool, NoneType]
Whether to automatically download all the attachments. Defaults to `false` where all the downloads are canceled.
trace_dir : Union[pathlib.Path, str, NoneType]
traces_dir : Union[pathlib.Path, str, NoneType]
If specified, traces are saved into this directory.
chromium_sandbox : Union[bool, NoneType]
Enable Chromium sandboxing. Defaults to `false`.
Expand Down Expand Up @@ -9714,7 +9714,7 @@ async def launch_persistent_context(
colorScheme=color_scheme,
reducedMotion=reduced_motion,
acceptDownloads=accept_downloads,
traceDir=trace_dir,
tracesDir=traces_dir,
chromiumSandbox=chromium_sandbox,
recordHarPath=record_har_path,
recordHarOmitContent=record_har_omit_content,
Expand Down Expand Up @@ -9944,14 +9944,14 @@ async def start(
await context.tracing.start(name=\"trace\", screenshots=True, snapshots=True)
await page.goto(\"https://playwright.dev\")
await context.tracing.stop()
await context.tracing.export(\"trace.zip\")
await context.tracing.stop(path = \"trace.zip\")
```

Parameters
----------
name : Union[str, NoneType]
If specified, the trace is going to be saved into the file with the given name inside the `traceDir` folder specified in
`browser_type.launch()`.
If specified, the trace is going to be saved into the file with the given name inside the `tracesDir` folder specified
in `browser_type.launch()`.
snapshots : Union[bool, NoneType]
Whether to capture DOM snapshot on every action.
screenshots : Union[bool, NoneType]
Expand All @@ -9967,29 +9967,19 @@ async def start(
)
)

async def stop(self) -> NoneType:
async def stop(self, *, path: typing.Union[str, pathlib.Path] = None) -> NoneType:
"""Tracing.stop

Stop tracing.
"""

return mapping.from_maybe_impl(
await self._async("tracing.stop", self._impl_obj.stop())
)

async def export(self, path: typing.Union[pathlib.Path, str]) -> NoneType:
"""Tracing.export

Export trace into the file with the given name. Should be called after the tracing has stopped.

Parameters
----------
path : Union[pathlib.Path, str]
File to save the trace into.
path : Union[pathlib.Path, str, NoneType]
Export trace into the file with the given name.
"""

return mapping.from_maybe_impl(
await self._async("tracing.export", self._impl_obj.export(path=path))
await self._async("tracing.stop", self._impl_obj.stop(path=path))
)


Expand Down
Loading