fix and add som usecases
This commit is contained in:
102
tests/test_home/test_dashboard.py
Normal file
102
tests/test_home/test_dashboard.py
Normal file
@@ -0,0 +1,102 @@
|
||||
import time
|
||||
import pytest
|
||||
from selenium.webdriver.support.ui import WebDriverWait
|
||||
from page_objects.home_dashboard_page import HomeDashboardPage
|
||||
from page_objects.profile_editor_page import ProfileEditorPage
|
||||
from page_objects.settings_panel_page import SettingsPanelPage
|
||||
from page_objects.danger_zone_page import DangerZonePage
|
||||
|
||||
@pytest.mark.regression
|
||||
@pytest.mark.usefixtures("logged_in_driver")
|
||||
class TestDashboard:
|
||||
"""
|
||||
Test suite for the Home page and its nested pages (Dashboard).
|
||||
Requires user to be logged in.
|
||||
"""
|
||||
|
||||
def test_navigation_between_pages(self, logged_in_driver):
|
||||
"""
|
||||
Tests that the user can successfully navigate between the Profile,
|
||||
Settings, and Danger Zone pages.
|
||||
"""
|
||||
# Arrange
|
||||
dashboard_page = HomeDashboardPage(logged_in_driver)
|
||||
settings_page = SettingsPanelPage(logged_in_driver)
|
||||
danger_zone_page = DangerZonePage(logged_in_driver)
|
||||
profile_page = ProfileEditorPage(logged_in_driver)
|
||||
|
||||
# Act & Assert: Navigate back to dashborade and verify
|
||||
text = dashboard_page.verify_title_is_dashboarde()
|
||||
assert text == 'Test Cases' , 'error switch to dashhoard tab'
|
||||
|
||||
# Act & Assert: Navigate to Settings tab and verify
|
||||
dashboard_page.navigate_to_settings()
|
||||
text = settings_page.verify_title_is_settings()
|
||||
assert text == 'Application Settings' , 'error switch to settings tab'
|
||||
|
||||
# Act & Assert: Danger Zone and verify
|
||||
|
||||
text = danger_zone_page.verify_danger_zone_exist()
|
||||
assert text == 'Danger Zone' , 'no exists Danger Zone '
|
||||
|
||||
# Act & Assert: Navigate back to Profile and verify
|
||||
dashboard_page.navigate_to_profile()
|
||||
print(text)
|
||||
text = profile_page.verify_title_is_profile()
|
||||
assert text == 'Personal Information' , 'error switch to profile tab'
|
||||
|
||||
def test_profile_editor_interaction(self, logged_in_driver):
|
||||
"""
|
||||
Tests basic interaction with the profile editor form.
|
||||
"""
|
||||
# Arrange
|
||||
dashboard_page = HomeDashboardPage(logged_in_driver)
|
||||
profile_page = ProfileEditorPage(logged_in_driver)
|
||||
|
||||
# Act: Ensure we are on the profile page and update username
|
||||
dashboard_page.navigate_to_profile()
|
||||
new_username = "Automation Tester"
|
||||
profile_page.set_username(new_username)
|
||||
# self.profile_page.click_save_changes() # This action is commented out as it might not have a real backend effect
|
||||
|
||||
# Assert: Check if the value was updated in the input field
|
||||
updated_value = profile_page.find_element(profile_page.USERNAME_INPUT).get_attribute("value")
|
||||
assert updated_value == new_username
|
||||
|
||||
def test_danger_zone_dialog_flow(self, logged_in_driver):
|
||||
"""
|
||||
Tests that the 'Delete Account' button shows a confirmation dialog
|
||||
and that the cancel button closes it.
|
||||
"""
|
||||
# Arrange
|
||||
danger_zone_page = DangerZonePage(logged_in_driver)
|
||||
|
||||
# Act: Click the delete button
|
||||
danger_zone_page.click_delete_account()
|
||||
|
||||
# # Assert: The confirmation dialog is visible
|
||||
# assert danger_zone_page.verify_confirmation_dialog_exist(), \
|
||||
# "Confirmation dialog should be visible after clicking 'Delete Account'."
|
||||
|
||||
# Act: Click the cancel button
|
||||
time.sleep(1)
|
||||
danger_zone_page.click_cancel_in_dialog()
|
||||
text = danger_zone_page.verify_confirmation_dialog_exist()
|
||||
# Assert: The dialog is no longer visible
|
||||
assert text == 'Are you absolutely sure?', \
|
||||
"Confirmation dialog should not be visible after clicking 'Cancel'."
|
||||
|
||||
# Act: Click the delete button
|
||||
time.sleep(1)
|
||||
danger_zone_page.click_delete_account()
|
||||
danger_zone_page.set_dialog_input()
|
||||
danger_zone_page.click_confirm_in_dialog()
|
||||
# 等待跳转到登录页
|
||||
WebDriverWait(logged_in_driver, 5).until(
|
||||
lambda driver: '/login' in driver.current_url
|
||||
)
|
||||
|
||||
# 断言当前 URL
|
||||
current_url = logged_in_driver.current_url
|
||||
assert current_url.endswith('/login'), f"Expected to be on /login, but got {current_url}"
|
||||
|
||||
Reference in New Issue
Block a user