fix(playwright): 确保浏览器 headless 模式参数为布尔类型

- 在启动浏览器时,检查 headless 参数的类型
- 如果 headless 参数为字符串类型,将其转换为布尔类型
- 支持 "true", "1", "yes", "on"
This commit is contained in:
danial
2025-09-18 01:48:42 +08:00
parent 3cc172a14a
commit 99d9ee503a

View File

@@ -152,6 +152,14 @@ class DistributedPlaywrightManager:
launch_options = cls._get_k8s_optimized_launch_options()
launch_options.update(kwargs) # 允许外部覆盖参数
# 确保headless参数是布尔类型
if "headless" in launch_options:
headless_value = launch_options["headless"]
if isinstance(headless_value, str):
launch_options["headless"] = headless_value.lower() in ("true", "1", "yes", "on")
elif not isinstance(headless_value, bool):
launch_options["headless"] = bool(headless_value)
logger.info("启动参数", launch_options=launch_options)
# 启动Chromium浏览器