audoWin/tests/main.py
2025-12-31 13:51:54 +08:00

31 lines
883 B
Python

from selenium import webdriver
from engine import DSLEngine
import os
def main():
# 1. 设置 WebDriver (这里以 Chrome 为例)
options = webdriver.ChromeOptions()
# options.add_argument('--headless') # 如果需要无头模式可开启
driver = webdriver.Chrome(options=options)
try:
# 2. 初始化 DSL 引擎
engine = DSLEngine(driver)
# 3. 指定 YAML 文件路径并运行
yaml_file = "test_case.yaml"
if os.path.exists(yaml_file):
engine.run_yaml(yaml_file)
else:
print(f"找不到文件: {yaml_file}")
except Exception as e:
print("测试过程中发生严重错误。")
finally:
# 4. 清理环境
# time.sleep(3) # 调试时可以暂停一下看结果
driver.quit()
if __name__ == "__main__":
main()