1. 新增 Joyhub_ui_auto_test/ 目录: - tests/ - 测试用例目录 - pages/ - 页面元素定位 - config/ - 配置文件 - utils/ - 工具类 - test_data/ - 测试数据 - reports/ - 测试报告 - webapp-testing/ - WebApp测试相关 2. 配置文件: - pytest.ini - pytest配置 - requirements.txt - 依赖列表 - README.md - 项目说明
39 lines
1.3 KiB
Python
39 lines
1.3 KiB
Python
from playwright.sync_api import sync_playwright
|
||
|
||
base = 'https://joyhub-website-frontend-test.best-envision.com'
|
||
countries = [
|
||
'Kenya',
|
||
'Côte d’ivoire',
|
||
'South Korea',
|
||
'Great Britain (United Kingdom; England)',
|
||
'Vatican City (The Holy See)',
|
||
'Singapore',
|
||
'Sweden',
|
||
'Poland',
|
||
'Netherlands',
|
||
'Japan',
|
||
'Italy',
|
||
'Spain',
|
||
'Germany',
|
||
'Canada',
|
||
'Australia',
|
||
'France',
|
||
]
|
||
|
||
with sync_playwright() as p:
|
||
browser = p.chromium.launch(headless=True)
|
||
page = browser.new_page(viewport={'width': 1920, 'height': 1080})
|
||
for country in countries:
|
||
try:
|
||
page.goto(base + '/points-redemption', wait_until='domcontentloaded')
|
||
page.wait_for_timeout(1500)
|
||
page.locator('header .relative.inline-block').nth(5).click(force=True)
|
||
page.wait_for_timeout(500)
|
||
page.get_by_text(country, exact=True).first.click(force=True, timeout=5000)
|
||
page.wait_for_timeout(2500)
|
||
body = page.locator('body').inner_text()
|
||
print(country, '| url=', page.url, '| redeem=', 'Redeem' in body, '| unsupported=', 'currently do not support delivery' in body, '| sample=', body[:300].replace('\n', ' | '))
|
||
except Exception as exc:
|
||
print(country, '| ERROR=', type(exc).__name__, str(exc)[:200])
|
||
browser.close()
|