Enhance order number input with retry logic for improved reliability
This commit is contained in:
17
main.py
17
main.py
@@ -133,8 +133,21 @@ def main():
|
||||
inner_frame.get_by_text("订单号查询").click()
|
||||
inner_frame.get_by_role("tab", name="全部").click()
|
||||
|
||||
inner_frame.locator("#rc_select_0").fill("5000")
|
||||
inner_frame.locator("#rc_select_0").press("Enter")
|
||||
# 填充并验证,如果失败则重试
|
||||
max_retries = 3
|
||||
expected_value = "5000"
|
||||
for attempt in range(max_retries):
|
||||
inner_frame.locator("#rc_select_0").fill(expected_value)
|
||||
inner_frame.locator("#rc_select_0").press("Enter")
|
||||
# 检查填充是否成功
|
||||
actual_value = inner_frame.locator("#rc_select_0").input_value()
|
||||
if actual_value == expected_value:
|
||||
print(f"文本框填充成功: {expected_value}")
|
||||
break
|
||||
else:
|
||||
print(f"第 {attempt + 1} 次填充失败,实际值: {actual_value},重试...")
|
||||
if attempt == max_retries - 1:
|
||||
print(f"警告: {max_retries} 次尝试后仍未成功填充,继续执行...")
|
||||
|
||||
# 读取订单号文件
|
||||
order_id_file = os.path.join(os.path.dirname(__file__), "orderID.txt")
|
||||
|
||||
Reference in New Issue
Block a user