xts_tools/reftest/dom.py
openharmony_ci a9d8c01623 !237 新建UI自动化对比工具代码仓
Merge pull request !237 from zhangshuang-xiaohuihui/master
2023-06-14 16:02:29 +08:00

76 lines
4.0 KiB
Python

"""
* Copyright (c) 2023 iSoftStone Information Technology (Group) Co.,Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
"""
import unittest
from Tool import WebView
class Test(unittest.TestCase):
@classmethod # 初始化测试环境且只会执行一次
def setUp(self) -> None:
self.LE = WebView()
self.LE.init_webview(test_package='com.example.myapplication') # 运行chromeDriver
def test_dom_001(self):
self.LE.init_runner('test_dom_001') # 打开runner页面
self.LE.click_js() # 取消勾选js
self.LE.click_manual() # 取消勾选manual
self.LE.send_path('dom/nodes/remove-from-shadow-host-and-adopt-into-iframe.html') # 是否进入指定路径 默认是/ 即全部路径
self.LE.start_test() # 点击start test 按钮
self.LE.click_show_test() # 点击show test按钮
self.LE.test_screenshot('//*[@id="iframe"]', "test") # test页面截图
self.LE.click_show_ref() # 点击show reference按钮
self.LE.ref_screenshot('/html/body/div', "ref") # reference页面截图
self.LE.test_assert("test", "ref") # 断言
self.LE.runner_end('test_dom_001')
def test_dom_002(self):
self.LE.init_runner('test_dom_002') # 打开runner页面
self.LE.click_js() # 取消勾选js
self.LE.click_manual() # 取消勾选manual
self.LE.send_path('dom/slot-recalc.html') # 是否进入指定路径 默认是/ 即全部路径
self.LE.start_test() # 点击start test 按钮
self.LE.click_show_test() # 点击show test按钮
self.LE.test_screenshot('/html/body/div', "test") # test页面截图
self.LE.click_show_ref() # 点击show reference按钮
self.LE.ref_screenshot('/html/body/div/p[1]', "ref") # reference页面截图
self.LE.ref_screenshot('/html/body/div/p[2]', "ref") # reference页面截图
self.LE.test_assert("test", "ref") # 断言
self.LE.runner_end('test_dom_002')
def test_dom_003(self):
self.LE.init_runner('test_dom_003') # 打开runner页面
self.LE.click_js() # 取消勾选js
self.LE.click_manual() # 取消勾选manual
self.LE.send_path('dom/xslt/sort.html') # 是否进入指定路径 默认是/ 即全部路径
self.LE.start_test() # 点击start test 按钮
self.LE.click_show_test() # 点击show test按钮
self.LE.test_screenshot('//*[@id="container"]/div[1]', "test") # test页面截图
self.LE.test_screenshot('//*[@id="container"]/div[2]', "test") # test页面截图
self.LE.test_screenshot('//*[@id="container"]/div[3]', "test") # test页面截图
self.LE.test_screenshot('//*[@id="container"]/div[4]', "test") # test页面截图
self.LE.click_show_ref() # 点击show reference按钮
self.LE.ref_screenshot('/html/body/div/div[1]', "ref") # reference页面截图
self.LE.ref_screenshot('/html/body/div/div[2]', "ref") # reference页面截图
self.LE.ref_screenshot('/html/body/div/div[3]', "ref") # reference页面截图
self.LE.ref_screenshot('/html/body/div/div[4]', "ref") # reference页面截图
self.LE.test_assert("test", "ref") # 断言
self.LE.runner_end('test_dom_003')
if __name__ == '__main__':
suite = unittest.TestSuite() # 实例化TestSuite
suite.addTest(Test("test_add_02")) # 添加测试用例
suite.addTest(Test("test_add_01"))
runner = unittest.TextTestRunner() # 实例化TextTestRunner
runner.run(suite) # 传入suite并执行测试用例