Skip to content

Commit 8daba92

Browse files
authored
chore: roll to the new driver (microsoft#415)
1 parent e5dc9b1 commit 8daba92

File tree

5 files changed

+36
-29
lines changed

5 files changed

+36
-29
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Playwright is a Python library to automate [Chromium](https://www.chromium.org/H
88
| :--- | :---: | :---: | :---: |
99
| Chromium <!-- GEN:chromium-version -->89.0.4344.0<!-- GEN:stop --> ||||
1010
| WebKit <!-- GEN:webkit-version -->14.1<!-- GEN:stop --> ||||
11-
| Firefox <!-- GEN:firefox-version -->84.0b9<!-- GEN:stop --> ||||
11+
| Firefox <!-- GEN:firefox-version -->85.0b1<!-- GEN:stop --> ||||
1212

1313
Headless execution is supported for all browsers on all platforms.
1414

playwright/_impl/_driver.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ def compute_driver_executable() -> Path:
2525
package_path = Path(inspect.getfile(playwright)).parent
2626
platform = sys.platform
2727
if platform == "win32":
28-
return package_path / "driver" / "playwright-cli.exe"
29-
return package_path / "driver" / "playwright-cli"
28+
return package_path / "driver" / "playwright.cmd"
29+
return package_path / "driver" / "playwright.sh"
3030

3131

3232
if sys.version_info.major == 3 and sys.version_info.minor == 7:

playwright/async_api/_generated.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2320,7 +2320,7 @@ async def wait_for_element_state(
23202320
) -> NoneType:
23212321
"""ElementHandle.wait_for_element_state
23222322
2323-
Returns the element satisfies the `state`.
2323+
Returns when the element satisfies the `state`.
23242324
23252325
Depending on the `state` parameter, this method waits for one of the [actionability](./actionability.md) checks to pass.
23262326
This method throws when the element is detached while waiting, unless waiting for the `"hidden"` state.
@@ -2362,7 +2362,8 @@ async def wait_for_selector(
23622362
) -> typing.Union["ElementHandle", NoneType]:
23632363
"""ElementHandle.wait_for_selector
23642364
2365-
Returns element specified by selector satisfies `state` option. Returns `null` if waiting for `hidden` or `detached`.
2365+
Returns element specified by selector when it satisfies `state` option. Returns `null` if waiting for `hidden` or
2366+
`detached`.
23662367
23672368
Wait for the `selector` relative to the element handle to satisfy `state` option (either appear/disappear from dom, or
23682369
become visible/hidden). If at the moment of calling the method `selector` already satisfies the condition, the method

playwright/sync_api/_generated.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2372,7 +2372,7 @@ def wait_for_element_state(
23722372
) -> NoneType:
23732373
"""ElementHandle.wait_for_element_state
23742374
2375-
Returns the element satisfies the `state`.
2375+
Returns when the element satisfies the `state`.
23762376
23772377
Depending on the `state` parameter, this method waits for one of the [actionability](./actionability.md) checks to pass.
23782378
This method throws when the element is detached while waiting, unless waiting for the `"hidden"` state.
@@ -2416,7 +2416,8 @@ def wait_for_selector(
24162416
) -> typing.Union["ElementHandle", NoneType]:
24172417
"""ElementHandle.wait_for_selector
24182418
2419-
Returns element specified by selector satisfies `state` option. Returns `null` if waiting for `hidden` or `detached`.
2419+
Returns element specified by selector when it satisfies `state` option. Returns `null` if waiting for `hidden` or
2420+
`detached`.
24202421
24212422
Wait for the `selector` relative to the element handle to satisfy `state` option (either appear/disappear from dom, or
24222423
become visible/hidden). If at the moment of calling the method `selector` already satisfies the condition, the method

setup.py

Lines changed: 27 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -15,20 +15,31 @@
1515
import glob
1616
import os
1717
import shutil
18-
import stat
1918
import subprocess
2019
import sys
20+
import typing
2121
import zipfile
2222

2323
import setuptools
2424
from wheel.bdist_wheel import bdist_wheel as BDistWheelCommand
2525

26-
driver_version = "0.170.0-next.1608058598043"
26+
driver_version = "1.8.0-next-1609895143000"
2727

2828

2929
with open("README.md", "r", encoding="utf-8") as fh:
3030
long_description = fh.read()
3131

32+
NoneType = type(None)
33+
34+
35+
def extractall(zip: typing.Any, path: str) -> NoneType:
36+
for name in zip.namelist():
37+
member = zip.getinfo(name)
38+
extracted_path = zip._extract_member(member, path, None)
39+
attr = member.external_attr >> 16
40+
if attr != 0:
41+
os.chmod(extracted_path, attr)
42+
3243

3344
class PlaywrightBDistWheelCommand(BDistWheelCommand):
3445
def run(self) -> None:
@@ -42,9 +53,12 @@ def run(self) -> None:
4253
os.makedirs("driver", exist_ok=True)
4354
os.makedirs("playwright/driver", exist_ok=True)
4455
for platform in ["mac", "linux", "win32", "win32_x64"]:
45-
zip_file = f"playwright-cli-{driver_version}-{platform}.zip"
56+
zip_file = f"playwright-{driver_version}-{platform}.zip"
4657
if not os.path.exists("driver/" + zip_file):
47-
url = "https://playwright.azureedge.net/builds/cli/next/" + zip_file
58+
url = "https://playwright.azureedge.net/builds/driver/"
59+
if "-next" in driver_version:
60+
url = url + "next/"
61+
url = url + zip_file
4862
print("Fetching ", url)
4963
subprocess.check_call(
5064
["curl", "--http1.1", url, "-o", "driver/" + zip_file]
@@ -57,19 +71,12 @@ def run(self) -> None:
5771
"win32": "win32_x64" if sys.maxsize > 2 ** 32 else "win32",
5872
}
5973
for platform in ["mac", "linux", "win32", "win32_x64"]:
60-
zip_file = f"driver/playwright-cli-{driver_version}-{platform}.zip"
74+
zip_file = f"driver/playwright-{driver_version}-{platform}.zip"
6175
with zipfile.ZipFile(zip_file, "r") as zip:
62-
zip.extractall(f"driver/{platform}")
76+
extractall(zip, f"driver/{platform}")
6377
if platform_map[sys.platform] == platform:
6478
with zipfile.ZipFile(zip_file, "r") as zip:
65-
zip.extractall("playwright/driver")
66-
for file in os.listdir("playwright/driver"):
67-
if file == "playwright-cli" or file.startswith("ffmpeg"):
68-
print(f"playwright/driver/{file}")
69-
os.chmod(
70-
f"playwright/driver/{file}",
71-
os.stat(f"playwright/driver/{file}").st_mode | stat.S_IEXEC,
72-
)
79+
extractall(zip, "playwright/driver")
7380
wheel = ""
7481
if platform == "mac":
7582
wheel = "macosx_10_13_x86_64.whl"
@@ -82,14 +89,12 @@ def run(self) -> None:
8289
wheel_location = without_platform + wheel
8390
shutil.copy(base_wheel_location, wheel_location)
8491
with zipfile.ZipFile(wheel_location, "a") as zip:
85-
for file in os.listdir(f"driver/{platform}"):
86-
from_location = f"driver/{platform}/{file}"
87-
to_location = f"playwright/driver/{file}"
88-
if file == "playwright-cli" or file.startswith("ffmpeg"):
89-
os.chmod(
90-
from_location, os.stat(from_location).st_mode | stat.S_IEXEC
91-
)
92-
zip.write(from_location, to_location)
92+
driver_root = os.path.abspath(f"driver/{platform}")
93+
for dir_path, dirs, files in os.walk(driver_root):
94+
for file in files:
95+
from_path = os.path.join(dir_path, file)
96+
to_path = os.path.relpath(from_path, driver_root)
97+
zip.write(from_path, f"playwright/driver/{to_path}")
9398
os.remove(base_wheel_location)
9499

95100

0 commit comments

Comments
 (0)