fix: Playwright API camelCase → snake_case (Python 版)

- getByPlaceholder → get_by_placeholder
- getByRole → get_by_role
- getByText → get_by_text
- getByTestId → get_by_test_id
This commit is contained in:
xst
2026-07-15 10:52:16 +08:00
parent 7b4a54f1ce
commit 7c5a4c5de7
6 changed files with 18 additions and 18 deletions
+3 -3
View File
@@ -6,8 +6,8 @@ Usage:
class LoginPage(BasePage):
def __init__(self, page):
super().__init__(page)
self.phone_input = page.getByPlaceholder("请输入用户名")
self.login_btn = page.getByRole("button", name="登录")
self.phone_input = page.get_by_placeholder("请输入用户名")
self.login_btn = page.get_by_role("button", name="登录")
"""
from datetime import datetime
@@ -38,7 +38,7 @@ class BasePage:
def wait_for_text(self, text: str, timeout_ms: Optional[int] = None) -> None:
"""等待页面上出现指定文本。"""
expect(self.page.getByText(text)).to_be_visible(timeout=timeout_ms or self.timeout)
expect(self.page.get_by_text(text)).to_be_visible(timeout=timeout_ms or self.timeout)
# ── 通用操作 ──