fix and add som usecases
This commit is contained in:
53
page_objects/profile_editor_page.py
Normal file
53
page_objects/profile_editor_page.py
Normal file
@@ -0,0 +1,53 @@
|
||||
from selenium.webdriver.common import by
|
||||
from selenium.webdriver.common.by import By
|
||||
from page_objects.base_page import BasePage
|
||||
|
||||
class ProfileEditorPage(BasePage):
|
||||
"""
|
||||
Page object for the Profile Editor page.
|
||||
"""
|
||||
|
||||
# Locators
|
||||
USERNAME_INPUT = (By.ID, "name")
|
||||
EMAIL_INPUT = (By.ID, "email")
|
||||
SAVE_BUTTON = (By.XPATH, "//button[text()='Save Changes']")
|
||||
SUCCESS_MESSAGE = (By.XPATH, "//*[contains(text(), 'Profile updated successfully')]") # Assuming a success message appears
|
||||
_PROFILE_TITLE = (By.XPATH,'//*[contains(@id,"content-profile")]//h3')
|
||||
|
||||
def get_page_header(self):
|
||||
"""
|
||||
Gets the header text of the page.
|
||||
Assumes the header is an h1 element.
|
||||
"""
|
||||
return self.get_text((By.TAG_NAME, "h1"))
|
||||
|
||||
def set_username(self, username: str):
|
||||
"""
|
||||
Enters the given username into the username input field.
|
||||
"""
|
||||
self.send_keys(self.USERNAME_INPUT, username)
|
||||
|
||||
def set_email(self, email: str):
|
||||
"""
|
||||
Enters the given email into the email input field.
|
||||
"""
|
||||
self.send_keys(self.EMAIL_INPUT, email)
|
||||
|
||||
def click_save_changes(self):
|
||||
"""
|
||||
Clicks the 'Save Changes' button.
|
||||
"""
|
||||
self.click(self.SAVE_BUTTON)
|
||||
|
||||
def is_success_message_displayed(self) -> bool:
|
||||
"""
|
||||
Checks if the success message is visible.
|
||||
"""
|
||||
try:
|
||||
return self.find_visible_element(self.SUCCESS_MESSAGE).is_displayed()
|
||||
except:
|
||||
return False
|
||||
|
||||
|
||||
def verify_title_is_profile(self):
|
||||
return self.get_text(self._PROFILE_TITLE)
|
||||
Reference in New Issue
Block a user