Files
Aniworld/tests/robot/resources/ui_keywords.resource
2026-06-21 12:32:44 +02:00

205 lines
7.9 KiB
Plaintext

*** Settings ***
Documentation UI-specific keywords for Aniworld Robot Framework tests.
... Wraps Browser library interactions for page navigation, form filling,
... and common UI assertions.
Resource ${CURDIR}/common.resource
*** Keywords ***
# ---------------------------------------------------------------------------
# Navigation
# ---------------------------------------------------------------------------
Navigate To
[Arguments] ${path}
[Documentation] Navigate the browser to the given path relative to BASE_URL.
Go To ${BASE_URL}${path}
Reload Page
[Documentation] Reload the current page.
Reload
# ---------------------------------------------------------------------------
# Authentication UI Flows
# ---------------------------------------------------------------------------
Perform Login
[Arguments] ${password}=${SETUP_PASSWORD}
[Documentation] Fill the login form and submit it.
Fill Text id=password-input ${password}
Click id=login-submit-btn
Wait For Elements State id=search-input visible timeout=5s
Perform Logout
[Documentation] Click the logout button and wait for redirect to login.
Click id=logout-btn
Wait For Elements State id=password-input visible timeout=5s
# ---------------------------------------------------------------------------
# Setup UI Flow
# ---------------------------------------------------------------------------
Complete Setup Flow
[Arguments] ${password}=${SETUP_PASSWORD}
... ${anime_dir}=/tmp/aniworld_test_anime
... ${app_name}=AniworldTest
[Documentation] Fill the entire setup form and submit it.
# General section
Fill Text id=app-name-input ${app_name}
Fill Text id=data-dir-input data
Fill Text id=anime-directory-input ${anime_dir}
# Security section
Fill Text id=master-password-input ${password}
Fill Text id=confirm-password-input ${password}
# Scheduler section
Uncheck Checkbox id=scheduler-enabled
# Submit
Click id=setup-submit-btn
Wait For Elements State id=search-input visible timeout=10s
# ---------------------------------------------------------------------------
# Settings Modal
# ---------------------------------------------------------------------------
Open Settings Modal
[Documentation] Click the config button and wait for the modal to appear.
Click id=config-btn
Wait For Elements State id=config-modal visible timeout=5s
Close Settings Modal
[Documentation] Click the close button and wait for the modal to disappear.
Click id=close-config
Wait For Elements State id=config-modal hidden timeout=5s
Save Settings
[Documentation] Click the save button inside the settings modal.
Click id=save-main-config
Wait For Elements State .toast, .notification visible timeout=5s
Fill General Settings
[Arguments] ${app_name} ${data_dir} ${anime_dir}
[Documentation] Fill the general settings section in the modal.
Fill Text id=app-name-input ${app_name}
Fill Text id=data-dir-input ${data_dir}
Fill Text id=anime-directory-input ${anime_dir}
Fill Scheduler Settings
[Arguments] ${enabled}=False ${time}=03:00 @{days}
[Documentation] Fill the scheduler settings section.
IF ${enabled}
Check Checkbox id=scheduled-rescan-enabled
ELSE
Uncheck Checkbox id=scheduled-rescan-enabled
END
Fill Text id=scheduler-time-input ${time}
# Days selection would be handled by multi-select UI elements
Fill NFO Settings
[Arguments] ${tmdb_key}=${EMPTY} ${auto_create}=False
[Documentation] Fill the NFO settings section.
Fill Text id=tmdb-api-key-input ${tmdb_key}
IF ${auto_create}
Check Checkbox id=nfo-auto-create
ELSE
Uncheck Checkbox id=nfo-auto-create
END
# ---------------------------------------------------------------------------
# Search
# ---------------------------------------------------------------------------
Search For Anime
[Arguments] ${query}
[Documentation] Type a query into the search box and submit.
Fill Text id=search-input ${query}
Click id=search-btn
Wait For Elements State id=search-results visible timeout=5s
Clear Search
[Documentation] Click the clear search button.
Click id=clear-search
Wait For Elements State id=search-results hidden timeout=3s
# ---------------------------------------------------------------------------
# Theme
# ---------------------------------------------------------------------------
Toggle Theme
[Documentation] Click the theme toggle button.
Click id=theme-toggle
Get Current Theme
[Documentation] Return the current theme attribute from the HTML element.
${theme}= Get Attribute html data-theme
RETURN ${theme}
# ---------------------------------------------------------------------------
# Queue Page
# ---------------------------------------------------------------------------
Navigate To Queue Page
[Documentation] Navigate to the download queue page.
Navigate To /queue
Wait For Elements State id=pending-queue visible timeout=5s
Start Queue From UI
[Documentation] Click the start queue button on the queue page.
Click id=start-queue-btn
Stop Queue From UI
[Documentation] Click the stop queue button on the queue page.
Click id=stop-queue-btn
Clear Completed From UI
[Documentation] Click clear completed and confirm the modal.
Click id=clear-completed-btn
Wait For Elements State id=confirm-modal visible timeout=3s
Click id=confirm-ok
Wait For Elements State id=confirm-modal hidden timeout=3s
Clear Failed From UI
[Documentation] Click clear failed and confirm the modal.
Click id=clear-failed-btn
Wait For Elements State id=confirm-modal visible timeout=3s
Click id=confirm-ok
Wait For Elements State id=confirm-modal hidden timeout=3s
# ---------------------------------------------------------------------------
# Common UI Assertions
# ---------------------------------------------------------------------------
Page Title Should Contain
[Arguments] ${text}
[Documentation] Assert that the page title contains the given text.
${title}= Get Title
Should Contain ${title} ${text}
Element Should Be Visible
[Arguments] ${selector}
[Documentation] Assert that the element matching the selector is visible.
Wait For Elements State ${selector} visible timeout=5s
Element Should Be Hidden
[Arguments] ${selector}
[Documentation] Assert that the element matching the selector is hidden.
Wait For Elements State ${selector} hidden timeout=5s
Element Text Should Contain
[Arguments] ${selector} ${text}
[Documentation] Assert that the element's text contains the given substring.
${element_text}= Get Text ${selector}
Should Contain ${element_text} ${text}
Toast Should Contain
[Arguments] ${text}
[Documentation] Assert that a toast/notification contains the given text.
${toast}= Get Text .toast, .notification
Should Contain ${toast} ${text}
# ---------------------------------------------------------------------------
# Responsive Helpers
# ---------------------------------------------------------------------------
Set Mobile Viewport
[Documentation] Resize the browser viewport to mobile dimensions.
Set Viewport Size 375 667
Set Tablet Viewport
[Documentation] Resize the browser viewport to tablet dimensions.
Set Viewport Size 768 1024
Set Desktop Viewport
[Documentation] Resize the browser viewport to desktop dimensions.
Set Viewport Size 1280 720