style: normalize code formatting across the codebase

- Standardize quote style (single to double quotes)
- Improve code formatting consistency
- Apply formatting to utilities, GUI components, and tools
- Update imports and docstrings for consistency

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
Misaka_Company
2026-02-05 14:56:35 +08:00
parent c34a300f0b
commit 2ca53f6a55
27 changed files with 693 additions and 385 deletions

View File

@@ -1,6 +1,7 @@
"""
元素定位辅助工具 - 用于快速验证定位是否有效
"""
from playwright.sync_api import Page, Frame, Locator
@@ -38,7 +39,9 @@ def debug_locator(frame: Frame, locator: Locator, timeout: int = 5000):
try:
if element.is_visible(timeout=1000):
text = element.inner_text(timeout=1000)
print(f" 元素{i + 1}文本: {text[:100] if len(text) > 100 else text}")
print(
f" 元素{i + 1}文本: {text[:100] if len(text) > 100 else text}"
)
else:
print(f" 元素{i + 1}: 存在但不可见")
except:
@@ -53,7 +56,9 @@ def debug_locator(frame: Frame, locator: Locator, timeout: int = 5000):
return False
def try_multiple_locators(frame: Frame, selectors: list[str], timeout: int = 5000) -> Locator:
def try_multiple_locators(
frame: Frame, selectors: list[str], timeout: int = 5000
) -> Locator:
"""
尝试多个选择器,返回第一个有效的定位器
@@ -73,7 +78,9 @@ def try_multiple_locators(frame: Frame, selectors: list[str], timeout: int = 500
try:
locator = frame.locator(selector)
count = locator.count()
visible_count = sum(1 for j in range(count) if locator.nth(j).is_visible(timeout=1000))
visible_count = sum(
1 for j in range(count) if locator.nth(j).is_visible(timeout=1000)
)
print(f" 找到 {count} 个元素,其中 {visible_count} 个可见")
@@ -101,7 +108,7 @@ def interactive_locate(frame: Frame):
selector = input("\n>>> ")
selector = selector.strip()
if selector.lower() in ('q', 'quit'):
if selector.lower() in ("q", "quit"):
break
if not selector:
@@ -128,7 +135,9 @@ if __name__ == "__main__":
page = context.new_page()
# 登录
page.goto("https://68.11.34.30:8082/yonbip/resources/uap/rbac/login/main/index.html")
page.goto(
"https://68.11.34.30:8082/yonbip/resources/uap/rbac/login/main/index.html"
)
main_frame = page.locator("#forwardFrame").content_frame
main_frame.get_by_role("textbox", name="用户名").fill("BLDpengqiangqiang")
main_frame.get_by_role("textbox", name="密码").fill("Cqbld123456.")
@@ -158,10 +167,10 @@ if __name__ == "__main__":
# 询问是否继续
choice = input("\n是否继续下一轮调试?(y/n/q): ").strip().lower()
if choice in ('n', 'q', 'quit'):
if choice in ("n", "q", "quit"):
print("退出程序")
break
elif choice in ('y', ''): # 默认继续
elif choice in ("y", ""): # 默认继续
continue
else:
print("未知选项,退出程序")