• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1"""
2 * Copyright (c) 2023 iSoftStone Information Technology (Group) Co.,Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 *     http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14"""
15import unittest
16from Tool import WebView
17
18class Test(unittest.TestCase):
19    @classmethod  # 初始化测试环境且只会执行一次
20    def setUp(self) -> None:
21        self.LE = WebView()
22        self.LE.init_webview(test_package='com.example.myapplication')  # 运行chromeDriver
23
24    def test_selection_001(self):
25            self.LE.init_runner('test_selection_001')  # 打开runner页面
26            self.LE.click_js()  # 取消勾选js
27            self.LE.click_manual()  # 取消勾选manual
28            self.LE.send_path('selection/caret/collapse-pre-linestart-1.html')  # 是否进入指定路径 默认是/ 即全部路径
29            self.LE.start_test()  # 点击start test 按钮
30            self.LE.click_show_test()  # 点击show test按钮
31            self.LE.test_screenshot('//*[@id="target"]', "test")  # test页面截图
32            self.LE.click_show_ref()  # 点击show reference按钮
33            self.LE.ref_screenshot('//*[@id="target"]', "ref")  # reference页面截图
34            self.LE.test_assert("test", "ref")  # 断言
35            self.LE.runner_end('test_selection_001')
36
37    def test_selection_002(self):
38        self.LE.init_runner('test_selection_002')  # 打开runner页面
39        self.LE.click_js()  # 取消勾选js
40        self.LE.click_manual()  # 取消勾选manual
41        self.LE.send_path('selection/caret/collapse-pre-linestart-2.html')  # 是否进入指定路径 默认是/ 即全部路径
42        self.LE.start_test()  # 点击start test 按钮
43        self.LE.click_show_test()  # 点击show test按钮
44        self.LE.test_screenshot('//*[@id="target"]', "test")  # test页面截图
45        self.LE.click_show_ref()  # 点击show reference按钮
46        self.LE.ref_screenshot('//*[@id="target"]', "ref")  # reference页面截图
47        self.LE.test_assert("test", "ref")  # 断言
48        self.LE.runner_end('test_selection_002')
49
50if __name__ == '__main__':
51    suite = unittest.TestSuite()  # 实例化TestSuite
52    suite.addTest(Test("test_add_02"))  # 添加测试用例
53    suite.addTest(Test("test_add_01"))
54    runner = unittest.TextTestRunner()  # 实例化TextTestRunner
55    runner.run(suite)  # 传入suite并执行测试用例
56