File indexing completed on 2024-06-23 05:23:56
0001 #!/usr/bin/env python3 0002 0003 # Execute tests with the following command: 0004 # selenium-webdriver-at-spi-run appiumtests/about_this_system.py 0005 0006 # SPDX-License-Identifier: MIT 0007 # SPDX-FileCopyrightText: 2021-2022 Harald Sitter <sitter@kde.org> 0008 # SPDX-FileCopyrightText: 2023 Alexander Wilms <f.alexander.wilms@gmail.com> 0009 0010 import logging 0011 import sys 0012 import unittest 0013 0014 from appium import webdriver 0015 from appium.options.common.base import AppiumOptions 0016 from appium.webdriver.common.appiumby import AppiumBy 0017 0018 0019 class AboutThisSystemTests(unittest.TestCase): 0020 @classmethod 0021 def setUpClass(self): 0022 options = AppiumOptions() 0023 # The app capability may be a command line or a desktop file id. 0024 options.set_capability("app", "org.kde.kinfocenter.desktop") 0025 options.set_capability("timeouts", {"implicit": 2 * 10 * 60 * 1000}) 0026 # Boilerplate, always the same 0027 self.driver = webdriver.Remote( 0028 command_executor="http://127.0.0.1:4723", options=options 0029 ) 0030 logging.getLogger().setLevel(logging.INFO) 0031 0032 @classmethod 0033 def tearDownClass(self): 0034 # Make sure to terminate the driver again, lest it dangles. 0035 self.driver.quit() 0036 0037 def setUp(self): 0038 pass 0039 0040 def tearDown(self) -> None: 0041 """ 0042 Take screenshot when the current test fails 0043 """ 0044 if not self._outcome.result.wasSuccessful(): 0045 self.driver.get_screenshot_as_file( 0046 f"failed_test_shot_kinfocenter_kcms_#{self.id()}.png" 0047 ) 0048 0049 def test_About_this_System(self): 0050 self.driver.find_element(by=AppiumBy.NAME, value="About this System").click() 0051 self.driver.find_element(by=AppiumBy.NAME, value="Copy Details").click() 0052 text = self.driver.get_clipboard_text() 0053 logging.info("▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼") 0054 logging.info("test_About_this_System():") 0055 logging.info(text) 0056 logging.info("▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲") 0057 self.driver.get_screenshot_as_file( 0058 f"appium_artifact_screenshot_{sys._getframe().f_code.co_name}.png" 0059 ) 0060 self.assertIn( 0061 "Graphics Platform: Wayland", 0062 text, 0063 "'Graphics Platform: Wayland' not found in 'Abou this System' KCM", 0064 ) 0065 0066 def test_Devices_CPU(self): 0067 self.driver.find_element(by=AppiumBy.NAME, value="Devices").click() 0068 self.driver.find_element(by=AppiumBy.NAME, value="CPU").click() 0069 self.driver.find_element(by=AppiumBy.NAME, value="Copy to Clipboard").click() 0070 clipboard_contents = self.driver.get_clipboard_text() 0071 logging.info("▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼") 0072 logging.info("test_Devices_CPU():") 0073 logging.info(clipboard_contents) 0074 logging.info("▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲") 0075 self.driver.get_screenshot_as_file( 0076 f"appium_artifact_screenshot_{sys._getframe().f_code.co_name}.png" 0077 ) 0078 self.assertIn("64-bit", clipboard_contents, "'64-bit' not found in CPU KCM") 0079 0080 def test_Graphics_Wayland(self): 0081 self.driver.find_element(by=AppiumBy.NAME, value="Graphics").click() 0082 self.driver.find_element(by=AppiumBy.NAME, value="Wayland").click() 0083 self.driver.find_element(by=AppiumBy.NAME, value="Copy to Clipboard").click() 0084 clipboard_contents = self.driver.get_clipboard_text() 0085 logging.info("▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼") 0086 logging.info("test_Graphics_Wayland():") 0087 logging.info(clipboard_contents) 0088 logging.info("▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲") 0089 self.driver.get_screenshot_as_file( 0090 f"appium_artifact_screenshot_{sys._getframe().f_code.co_name}.png" 0091 ) 0092 self.assertIn( 0093 "interface: 'wl_compositor'", 0094 clipboard_contents, 0095 "'wl_compositor' not found in Wayland KCM", 0096 ) 0097 0098 0099 if __name__ == "__main__": 0100 unittest.main()