Skip to content

chore: roll Playwright to 1.7.0-next.1607623793189 #362

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
Dec 11, 2020
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
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 -->88.0.4316.0<!-- GEN:stop --> | ✅ | ✅ | ✅ |
| WebKit <!-- GEN:webkit-version -->14.0<!-- GEN:stop --> | ✅ | ✅ | ✅ |
| Firefox <!-- GEN:firefox-version -->83.0<!-- GEN:stop --> | ✅ | ✅ | ✅ |
| Chromium <!-- GEN:chromium-version -->89.0.4344.0<!-- GEN:stop --> | ✅ | ✅ | ✅ |
| WebKit <!-- GEN:webkit-version -->14.1<!-- GEN:stop --> | ✅ | ✅ | ✅ |
| Firefox <!-- GEN:firefox-version -->84.0b9<!-- GEN:stop --> | ✅ | ✅ | ✅ |

Headless execution is supported for all browsers on all platforms.

Expand Down
1,222 changes: 726 additions & 496 deletions playwright/async_api.py

Large diffs are not rendered by default.

1,222 changes: 726 additions & 496 deletions playwright/sync_api.py

Large diffs are not rendered by default.

33 changes: 18 additions & 15 deletions scripts/documentation_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,25 +106,28 @@ def print_entry(
args = method["args"]
args_with_expanded_options: Dict[str, Any] = dict()
for name, value in args.items():
expand = False
if name == "options":
for opt_name, opt_value in args["options"]["type"][
"properties"
].items():
expand = True
if fqname == "Page.frame" and name == "frameSelector":
expand = True
if ".addStyleTag" in fqname and name == "style":
expand = True
if ".addScriptTag" in fqname and name == "script":
expand = True
if fqname == "Page.emulateMedia" and name == "params":
expand = True
if fqname == "Route.fulfill" and name == "response":
expand = True
if fqname == "Route.continue" and name == "overrides":
expand = True
if fqname == "Page.setViewportSize" and name == "viewportSize":
expand = True
if expand:
for opt_name, opt_value in args[name]["type"]["properties"].items():
args_with_expanded_options[opt_name] = opt_value
else:
args_with_expanded_options[name] = value
if fqname == "Route.fulfill":
for name, value in args["response"]["type"]["properties"].items():
args_with_expanded_options[name] = value
del args_with_expanded_options["response"]
if fqname == "Route.continue":
for name, value in args["overrides"]["type"]["properties"].items():
args_with_expanded_options[name] = value
del args_with_expanded_options["overrides"]
if fqname == "Page.setViewportSize":
for name, value in args["viewportSize"]["type"]["properties"].items():
args_with_expanded_options[name] = value
del args_with_expanded_options["viewportSize"]

if signature and signature_no_return:
print("")
Expand Down
2 changes: 1 addition & 1 deletion scripts/expected_api_mismatch.txt
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ Parameter type mismatch in Page.route(url=): documented as Union[str, RegExp, fu
Parameter type mismatch in Page.unroute(url=): documented as Union[str, RegExp, function(URL):boolean], code has Union[str, Pattern, typing.Callable[[str], bool]]
Parameter type mismatch in Page.waitForNavigation(url=): documented as Union[str, RegExp, Function, NoneType], code has Union[str, Pattern, typing.Callable[[str], bool], NoneType]
Parameter type mismatch in Page.waitForRequest(urlOrPredicate=): documented as Union[str, RegExp, Function], code has Union[str, Pattern, typing.Callable[[str], bool], NoneType]
Parameter type mismatch in Page.waitForResponse(urlOrPredicate=): documented as Union[str, RegExp, Function], code has Union[str, Pattern, typing.Callable[[str], bool], NoneType]
Parameter type mismatch in Page.waitForResponse(urlOrPredicate=): documented as Union[str, RegExp, function(Response):boolean], code has Union[str, Pattern, typing.Callable[[str], bool], NoneType]

# Add init script
Parameter type mismatch in Page.addInitScript(script=): documented as Union[Callable, str, Dict], code has Optional[str]
Expand Down
13 changes: 7 additions & 6 deletions scripts/update_api.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,14 @@ function update_api {
generate_script="$2"
git checkout HEAD -- "$file_name"

python "$generate_script" > .x

mv .x "$file_name"
pre-commit run --files $file_name
if python "$generate_script" > .x; then
mv .x "$file_name"
pre-commit run --files $file_name
echo "Regenerated APIs"
else
echo "Exited due to errors"
fi
}

update_api "playwright/sync_api.py" "scripts/generate_sync_api.py"
update_api "playwright/async_api.py" "scripts/generate_async_api.py"

echo "Regenerated APIs"
11 changes: 10 additions & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,16 @@ markers =
only_platform
junit_family=xunit2
[mypy]
ignore_errors = True
ignore_missing_imports = True
python_version = 3.7
warn_unused_ignores = False
warn_redundant_casts = True
warn_unused_configs = True
check_untyped_defs = True
disallow_untyped_defs = True
[mypy-tests.*]
check_untyped_defs = False
disallow_untyped_defs = False
[flake8]
ignore =
E501
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import setuptools
from wheel.bdist_wheel import bdist_wheel as BDistWheelCommand

driver_version = "0.170.0-next.1605573954344"
driver_version = "0.170.0-next.1607623793189"


with open("README.md", "r", encoding="utf-8") as fh:
Expand Down
1 change: 1 addition & 0 deletions tests/async/test_interception.py
Original file line number Diff line number Diff line change
Expand Up @@ -533,6 +533,7 @@ async def test_page_route_should_intercept_main_resource_during_cross_process_na
assert len(intercepted) == 1


@pytest.mark.skip_browser("webkit")
async def test_page_route_should_create_a_redirect(page, server):
await page.goto(server.PREFIX + "/empty.html")

Expand Down
11 changes: 10 additions & 1 deletion tests/async/test_page.py
Original file line number Diff line number Diff line change
Expand Up @@ -954,7 +954,16 @@ async def test_fill_should_fill_input(page, server):

async def test_fill_should_throw_on_unsupported_inputs(page, server):
await page.goto(server.PREFIX + "/input/textarea.html")
for type in ["color", "file"]:
for type in [
"button",
"checkbox",
"file",
"image",
"radio",
"range",
"reset",
"submit",
]:
await page.evalOnSelector(
"input", "(input, type) => input.setAttribute('type', type)", type
)
Expand Down
51 changes: 30 additions & 21 deletions tests/async/test_queryselector.py
Original file line number Diff line number Diff line change
@@ -1,39 +1,48 @@
from typing import Any, cast

import pytest

from playwright import Error
from playwright.async_api import Page


async def test_selectors_register_should_work(selectors, page: Page, utils):
await utils.register_selector_engine(
selectors,
"tag",
"""{
create(root, target) {
return target.nodeName;
},
query(root, selector) {
return root.querySelector(selector);
},
queryAll(root, selector) {
return Array.from(root.querySelectorAll(selector));
}
}""",
)
async def test_selectors_register_should_work(selectors, browser):
tag_selector = """
{
create(root, target) {
return target.nodeName;
},
query(root, selector) {
return root.querySelector(selector);
},
queryAll(root, selector) {
return Array.from(root.querySelectorAll(selector));
}
}"""

# Register one engine before creating context.
await selectors.register("tag", tag_selector)

context = await browser.newContext()
# Register another engine after creating context.
await selectors.register("tag2", tag_selector)

page = await context.newPage()
await page.setContent("<div><span></span></div><div></div>")
element_handle_impl = cast(Any, (await page.querySelector("div")))._impl_obj
assert await element_handle_impl._createSelectorForTest("tag") == "DIV"

assert await page.evalOnSelector("tag=DIV", "e => e.nodeName") == "DIV"
assert await page.evalOnSelector("tag=SPAN", "e => e.nodeName") == "SPAN"
assert await page.evalOnSelectorAll("tag=DIV", "es => es.length") == 2

assert await page.evalOnSelector("tag2=DIV", "e => e.nodeName") == "DIV"
assert await page.evalOnSelector("tag2=SPAN", "e => e.nodeName") == "SPAN"
assert await page.evalOnSelectorAll("tag2=DIV", "es => es.length") == 2

# Selector names are case-sensitive.
with pytest.raises(Error) as exc:
await page.querySelector("tAG=DIV")
assert 'Unknown engine "tAG" while parsing selector tAG=DIV' in exc.value.message

await context.close()


async def test_selectors_register_should_work_with_path(
selectors, page: Page, utils, assetdir
Expand All @@ -54,7 +63,7 @@ async def test_selectors_register_should_work_in_main_and_isolated_world(
return window.__answer;
},
queryAll(root, selector) {
return [document.body, document.documentElement, window.__answer];
return window['__answer'] ? [window['__answer'], document.body, document.documentElement] : [];
}
}"""

Expand Down
Empty file added tests/common/__init__.py
Empty file.