Commit 05d3ddb3 by comeback01

fix(test): Make language verification script more robust

This addresses feedback from CodeRabbitAI by using a regular expression for the language button's aria-label. This ensures the test can run regardless of the browser's default language.
parent 91ea2754
from playwright.sync_api import sync_playwright, expect
import time
import re
def run(playwright):
browser = playwright.chromium.launch(headless=True)
......@@ -10,8 +11,11 @@ def run(playwright):
page.goto("http://localhost:5173", wait_until="networkidle")
print("Page loaded")
# The aria-label is in Chinese in the source, so we use that.
language_button = page.get_by_role("button", name="切换语言")
# Use a regex to find the button by its aria-label in either Chinese or English.
language_button = page.get_by_role(
"button",
name=re.compile(r"(切换语言|Change Language)", re.IGNORECASE),
)
# Wait for the button to be visible
expect(language_button).to_be_visible()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment