File indexing completed on 2024-04-21 16:29:27

0001 #!/usr/bin/env python3
0002 
0003 # SPDX-License-Identifier: MIT
0004 # SPDX-FileCopyrightText: 2023 Harald Sitter <sitter@kde.org>
0005 
0006 import os
0007 import unittest
0008 from appium import webdriver
0009 from appium.options.common.base import AppiumOptions
0010 
0011 
0012 class ScreenshotTest(unittest.TestCase):
0013 
0014     @classmethod
0015     def setUpClass(self):
0016         options = AppiumOptions()
0017         options.set_capability("app", f"{os.getenv('QML_EXEC')} {os.path.dirname(os.path.realpath(__file__))}/value.qml")
0018         self.driver = webdriver.Remote(command_executor='http://127.0.0.1:4723', options=options)
0019 
0020     @classmethod
0021     def tearDownClass(self):
0022         self.driver.quit()
0023 
0024     def test_initialize(self):
0025         self.assertIsNotNone(self.driver.get_screenshot_as_png())
0026         self.driver.get_screenshot_as_file("appium_artifact_{}.png".format(self.id()))
0027         st = os.stat("appium_artifact_{}.png".format(self.id()))
0028         self.assertGreater(st.st_size, 1000)
0029 
0030 
0031 if __name__ == '__main__':
0032     unittest.main()