[kde-linux/os-autoinst-distri-kdelinux] extensions/openqa/usr/lib/kde-linux-openqa/tests: Write a robust plasma_setup test implementation
Thomas Duckworth <[email protected]>
| Newsgroups | gmane.comp.kde.cvs |
|---|---|
| Message-ID | <[email protected]> |
Git commit adb859bbe02d7387631788cfda311eb62909ac34 by Thomas Duckworth.
Committed on 23/07/2026 at 08:12.
Pushed by bshah into branch 'master'.
Write a robust plasma_setup test implementation
Ensure we're checking for the presence of each expected page, while also
avoiding any animation races - poll for the next expected page, and if
it isn't present, click again assuming the previous click was dropped.
M +58 -37 extensions/openqa/usr/lib/kde-linux-openqa/tests/plasma_setup.py
https://invent.kde.org/kde-linux/os-autoinst-distri-kdelinux/-/commit/adb859bbe02d7387631788cfda311eb62909ac34
diff --git a/extensions/openqa/usr/lib/kde-linux-openqa/tests/plasma_setup.py b/extensions/openqa/usr/lib/kde-linux-openqa/tests/plasma_setup.py
index 5a0e7b7..a2ba97b 100644
--- a/extensions/openqa/usr/lib/kde-linux-openqa/tests/plasma_setup.py
+++ b/extensions/openqa/usr/lib/kde-linux-openqa/tests/plasma_setup.py
@@ -5,20 +5,14 @@ import unittest
from appium import webdriver
from appium.webdriver.common.appiumby import AppiumBy
from appium.options.common.base import AppiumOptions
-import selenium.common.exceptions
-from selenium.webdriver.common.action_chains import ActionChains
-from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as ec
from lib.sut import openqa_junit_xml
from lib.sut.atspi import find_pid_on_atspi_bus
from lib import user_manager
-import sys
-import time
-import subprocess
# Walks through the Plasma Setup wizard to set up the SUT.
-# Fatal test as it's necessary for the system to work in later testing.
+# Fatal test - it's necessary for the system to work in later testing.
class PlasmaSetupTests(unittest.TestCase):
@@ -27,44 +21,71 @@ class PlasmaSetupTests(unittest.TestCase):
options = AppiumOptions()
options.set_capability("app", str(find_pid_on_atspi_bus('plasma-setup')))
self.driver = webdriver.Remote(command_executor="http://127.0.0.1:4723", options=options)
- self.driver.implicitly_wait = 10
+ self.driver.implicitly_wait(0)
+ self.wait = WebDriverWait(self.driver, 10)
@classmethod
def tearDownClass(self):
self.driver.quit()
- pass
- def _fill_account(self, form):
- """Fill the account page's form."""
- form.find_elements(AppiumBy.CLASS_NAME, '[text | ]')[0].send_keys('Testy McTestface')
- username = form.find_elements(AppiumBy.CLASS_NAME, '[text | ]')[1]
- username.clear()
- username.send_keys(user_manager.installed().name)
- for field in form.find_elements(AppiumBy.CLASS_NAME, '[password text | ]'):
- field.send_keys(user_manager.installed().pw)
+
+ def _next_page(self, current_page_title, next_page_title):
+ # Ensure we reliably start from the page we expect.
+ self.wait.until(
+ ec.presence_of_element_located(
+ (AppiumBy.NAME, current_page_title)
+ )
+ )
+
+ def reached_next_page(driver):
+ # A prior click was accepted once the heading changes.
+ if driver.find_elements(AppiumBy.NAME, next_page_title):
+ return True
+ driver.find_element(AppiumBy.NAME, "Next").click()
+ return False
+
+ self.wait.until(reached_next_page)
+
def test_setup(self):
"""Go through and set up the system through Plasma Setup."""
- wait = WebDriverWait(self.driver, 60)
- wait.until(ec.element_to_be_clickable((AppiumBy.NAME, "Begin Setup"))).click()
-
- account_filled = False
- while True:
- # We're on the final page, so finish up.
- finish = self.driver.find_elements(AppiumBy.NAME, "Finish")
- if finish and finish[0].is_displayed():
- wait.until(ec.element_to_be_clickable((AppiumBy.NAME, "Finish"))).click()
- return
-
- # The account page is the only step that disables Next until we input something into it (for obvious reasons), so fill it out.
- if not account_filled:
- form = self.driver.find_elements(AppiumBy.CLASS_NAME, '[form | ]')
- if form:
- self._fill_account(form[0])
- account_filled = True
-
- # Now just keep spamming next after all these checks to progress quickly.
- wait.until(ec.element_to_be_clickable((AppiumBy.NAME, "Next"))).click()
+ # Welcome page
+ setup_button = self.driver.find_element(AppiumBy.NAME, 'Begin Setup')
+ setup_button.click()
+
+ # Language page
+ self._next_page("Language", "Keyboard Layout")
+
+ # Keyboard layout page
+ self._next_page("Keyboard Layout", "Before we get started…")
+
+ # Dark mode page
+ self._next_page("Before we get started…", "About You")
+
+ # User account page
+ form = self.driver.find_element(AppiumBy.CLASS_NAME, '[form | ]')
+
+ form.find_elements(AppiumBy.CLASS_NAME, '[text | ]')[0].send_keys('Testy McTestface')
+ # clear out auto-generated username testymctestface
+ form.find_elements(AppiumBy.CLASS_NAME, '[text | ]')[1].clear()
+ form.find_elements(AppiumBy.CLASS_NAME, '[text | ]')[1].send_keys(user_manager.installed().name)
+ form.find_elements(AppiumBy.CLASS_NAME, '[password text | ]')[0].send_keys(user_manager.installed().pw)
+ form.find_elements(AppiumBy.CLASS_NAME, '[password text | ]')[1].send_keys(user_manager.installed().pw)
+
+ self._next_page("About You", "Hostname")
+
+ # Hostname page
+ self._next_page("Hostname", "Time and Date")
+
+ # Timezone page
+ # Timezone is pre-set because the TZ page is very flaky and hard to code around. Just skip it.
+ self._next_page("Time and Date", "Completed!")
+
+ # Finished page
+ finish_button = self.wait.until(
+ ec.element_to_be_clickable((AppiumBy.NAME, "Finish"))
+ )
+ finish_button.click()
if __name__ == "__main__":