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 def setUp(self) -> None: 20 self.LE = WebView() 21 self.LE.init_webview(test_package='com.example.myapplication') # 运行chromeDriver 22 23 def test_acid_001(self): 24 self.LE.init_runner('test_acid_001') # 打开runner页面 25 self.LE.click_js() # 取消勾选js 26 self.LE.click_manual() # 取消勾选manual 27 self.LE.send_path('acid/acid2/reftest.html') # 是否进入指定路径 默认是/ 即全部路径 28 self.LE.start_test() # 点击start test 按钮 29 self.LE.click_show_test() # 点击show test按钮 30 self.LE.test_screenshot('/html/body/iframe', "test") # test页面截图 31 self.LE.click_show_ref() # 点击show reference按钮 32 self.LE.ref_screenshot('/html/body/div/div[10]', "ref") # reference页面截图 33 self.LE.test_assert("test", "ref") # 断言 34 self.LE.runner_end('test_acid_001') 35 36 def test_acid_002(self): 37 self.LE.init_runner('test_acid_002') # 打开runner页面 38 self.LE.click_js() # 取消勾选js 39 self.LE.click_manual() # 取消勾选manual 40 self.LE.send_path('acid/acid3/test.html') # 是否进入指定路径 默认是/ 即全部路径 41 self.LE.start_test() # 点击start test 按钮 42 self.LE.click_show_test() # 点击show test按钮 43 self.LE.test_screenshot('//*[@id="bucket6"]', "test") # test页面截图 44 self.LE.click_show_ref() # 点击show reference按钮 45 self.LE.ref_screenshot('//*[@id="b"]', "ref") # reference页面截图 46 self.LE.test_assert("test", "ref") # 断言 47 self.LE.runner_end('test_acid_002') 48 49if __name__ == '__main__': 50 suite = unittest.TestSuite() # 实例化TestSuite 51 suite.addTest(Test("test_add_02")) # 添加测试用例 52 suite.addTest(Test("test_add_01")) 53 runner = unittest.TextTestRunner() # 实例化TextTestRunner 54 runner.run(suite) # 传入suite并执行测试用例 55