DEV Community

Indira
Indira

Posted on

Project 2

from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
import time

Initialize the WebDriver

driver = webdriver.Chrome()

OrangeHRM URL

ORANGE_HRM_URL = "https://opensource-demo.orangehrmlive.com/web/index.php/auth/login"

Credentials

VALID_USERNAME = "Admin"

VALID_PASSWORD = "admin123"
INVALID_USERNAME = "wrong_user"
INVALID_PASSWORD = "wrong_pass"

def validate_forgot_password_link():

# Navigate to OrangeHRM login page
driver.get(ORANGE_HRM_URL)
driver.maximize_window()
time.sleep(2)

# Click on the "Forgot Password" link
try:
    forgot_password_link = driver.find_element(By.LINK_TEXT, "Forgot your password?") 
    forgot_password_link.click()
    time.sleep(2)

    # Verify if the forgot password page or functionality loads
    page_header = driver.find_element(By.XPATH, "//h1[text()='Forgot Your Password?']") 
    if page_header.is_displayed():
        print("Forgot Password link works correctly and navigates to the correct page.")
    else:
        print("Forgot Password page did not load correctly.")
Enter fullscreen mode Exit fullscreen mode

Top comments (0)