File indexing completed on 2024-05-12 05:01:23

0001 #!/usr/bin/env python3
0002 
0003 # SPDX-License-Identifier: MIT
0004 # SPDX-FileCopyrightText: 2021-2022 Harald Sitter <sitter@kde.org>
0005 # SPDX-FileCopyrightText: 2023 Tobias Fella <tobias.fella@kde.org>
0006 
0007 import os
0008 import subprocess
0009 import sys
0010 import unittest
0011 
0012 from appium import webdriver
0013 from appium.options.common.base import AppiumOptions
0014 from appium.webdriver.common.appiumby import AppiumBy
0015 
0016 
0017 class LoginTest(unittest.TestCase):
0018 
0019     mockServerProcess: subprocess.Popen
0020 
0021     @classmethod
0022     def setUpClass(cls):
0023         options = AppiumOptions()
0024         options.set_capability("app", "neochat --ignore-ssl-errors")
0025         cls.driver = webdriver.Remote(command_executor='http://127.0.0.1:4723', options=options)
0026         cls.mockServerProcess = subprocess.Popen([sys.executable, os.path.join(os.path.dirname(__file__), "login-server.py")])
0027 
0028     def setUp(self):
0029         pass
0030 
0031     def tearDown(self):
0032         if not self._outcome.result.wasSuccessful():
0033             self.driver.get_screenshot_as_file("failed_test_shot_{}.png".format(self.id()))
0034 
0035     @classmethod
0036     def tearDownClass(self):
0037         self.mockServerProcess.terminate()
0038         self.driver.quit()
0039 
0040     def test_login(self):
0041         self.driver.find_element(by=AppiumBy.NAME, value="Login").click()
0042 
0043         self.driver.find_element(by=AppiumBy.NAME, value="Matrix ID").send_keys("@user:localhost:1234")
0044         self.driver.find_element(by=AppiumBy.NAME, value="Continue").click()
0045         self.driver.find_element(by=AppiumBy.NAME, value="Password").send_keys("1234")
0046         self.driver.find_element(by=AppiumBy.NAME, value="Login").click()
0047         self.driver.find_element(by=AppiumBy.NAME, value="Join some rooms to get started").click()
0048 
0049 
0050 if __name__ == '__main__':
0051     unittest.main()