Warning, file /plasma/plasma-workspace/appiumtests/lock_logouttest.py was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001 #!/usr/bin/env python3 0002 0003 # SPDX-FileCopyrightText: 2023 Fushan Wen <qydwhotmail@gmail.com> 0004 # SPDX-License-Identifier: MIT 0005 0006 import unittest 0007 from typing import Final 0008 0009 from appium import webdriver 0010 from appium.options.common.base import AppiumOptions 0011 from appium.webdriver.common.appiumby import AppiumBy 0012 0013 WIDGET_ID: Final = "org.kde.plasma.lock_logout" 0014 0015 0016 class LockLogoutTest(unittest.TestCase): 0017 """ 0018 Tests for the lock/logout widget 0019 """ 0020 0021 driver: webdriver.Remote 0022 0023 @classmethod 0024 def setUpClass(cls) -> None: 0025 """ 0026 Opens the widget and initialize the webdriver 0027 """ 0028 options = AppiumOptions() 0029 options.set_capability("app", f"plasmawindowed -p org.kde.plasma.nano {WIDGET_ID}") 0030 options.set_capability("timeouts", {'implicit': 10000}) 0031 cls.driver = webdriver.Remote(command_executor='http://127.0.0.1:4723', options=options) 0032 0033 def tearDown(self) -> None: 0034 """ 0035 Take screenshot when the current test fails 0036 """ 0037 if not self._outcome.result.wasSuccessful(): 0038 self.driver.get_screenshot_as_file(f"failed_test_shot_{WIDGET_ID}_#{self.id()}.png") 0039 0040 @classmethod 0041 def tearDownClass(cls) -> None: 0042 """ 0043 Make sure to terminate the driver again, lest it dangles. 0044 """ 0045 cls.driver.quit() 0046 0047 def test_0_open(self) -> None: 0048 """ 0049 Tests the widget can be opened 0050 """ 0051 self.driver.find_element(AppiumBy.NAME, "Lock") 0052 self.driver.find_element(AppiumBy.NAME, "Shutdown…") 0053 0054 0055 if __name__ == '__main__': 0056 unittest.main()