# -*- coding:utf-8 -*-
import unittest
import time
import uiautomation
import os
# @unittest.skip("跳过")
class TestFaultTree(unittest.TestCase):
def setUp(self) -> None:
# 初始化
os.system("calc") # 打开计算器
time.sleep(2)
self.calc = uiautomation.WindowControl(Name="计算器")
self.calc_list = ["一", "零", "乘以", "五", "二", "等于"]
self.result = "520"
def tearDown(self) -> None:
time.sleep(1)
self.calc.ButtonControl(Name="关闭 计算器").Click()
def test_toolbar(self):
time.sleep(1)
for i in range(0, len(self.calc_list)):
self.calc.ButtonControl(Name=self.calc_list[i]).Click()
calc_result = self.calc.TextControl(foundIndex=3).Name
print("计算器运行结果为:", calc_result)
print("预期结果为:", self.result)
self.assertIn(self.result, calc_result)
if __name__ == "__main__":
unittest.main()
评论