From d1ec6440c6dd61e730737e5186801d41a0748490 Mon Sep 17 00:00:00 2001 From: aliwaleed1 <138436398+aliwaleed1@users.noreply.github.com> Date: Fri, 25 Aug 2023 04:15:15 +0300 Subject: [PATCH] Add files via upload --- pages/login.py | 4 +++- tests/test_login.py | 37 ++++++++++++++++++++----------------- 2 files changed, 23 insertions(+), 18 deletions(-) diff --git a/pages/login.py b/pages/login.py index 327f950d..4854c9d5 100644 --- a/pages/login.py +++ b/pages/login.py @@ -1,7 +1,9 @@ +"""page objects.""" from selenium.webdriver.common.by import By -class login: +class Login: + """class Login.""" email = (By.XPATH, '//*[@type="email"]') password = (By.XPATH, '//*[@type="password"]') login_button = (By.XPATH, '//button[text()="Login"]') diff --git a/tests/test_login.py b/tests/test_login.py index 63353cc8..fdeb38b1 100644 --- a/tests/test_login.py +++ b/tests/test_login.py @@ -1,46 +1,49 @@ +"""Module to test login page.""" import time -from pages.login import login -import pytest from selenium import webdriver +import pytest +from pages.login import Login +from utils.base import BASEURL -@pytest.fixture -def driver1(): +@pytest.fixture(name="driver1") +def driver1_fixture(): + """Function to save driver fixture.""" driver = webdriver.Edge() - driver.get("https://cshr.gent01.dev.grid.tf") + driver.get(BASEURL) yield driver driver.quit() def test_user_login(driver1): - login_instance = login() + """test for login.""" # Enter email - email_input = driver1.find_element(*login_instance.email) + email_input = driver1.find_element(*Login.email) email_input.send_keys("A@test.cs") # Enter password - password_input = driver1.find_element(*login_instance.password) + password_input = driver1.find_element(*Login.password) password_input.send_keys("123456789") # Click on Login button - login_button = driver1.find_element(*login_instance.login_button) + login_button = driver1.find_element(*Login.login_button) login_button.click() time.sleep(2) # Get the profile - profile = driver1.find_element(*login_instance.profile) + profile = driver1.find_element(*Login.profile) # Assert that the element includes the text "AW" assert "aw" in profile.text.lower() def test_invalid_login(driver1): - login_instance = login() + """test for invalid login.""" # Enter email invalid email - email_input = driver1.find_element(*login_instance.email) + email_input = driver1.find_element(*Login.email) email_input.send_keys("invalid@email.com") # Enter invalid password - password_input = driver1.find_element(*login_instance.password) + password_input = driver1.find_element(*Login.password) password_input.send_keys("123456789") # Click on Login button - login_button = driver1.find_element(*login_instance.login_button) + login_button = driver1.find_element(*Login.login_button) try: login_button.click() except ImportError: @@ -48,12 +51,12 @@ def test_invalid_login(driver1): def test_email_validation(driver1): - login_instance = login() + """test for email validation.""" # Enter email invalid email - email_input = driver1.find_element(*login_instance.email) + email_input = driver1.find_element(*Login.email) email_input.send_keys("invalid@email.com") # get the error message - undefined_message = driver1.find_element(*login_instance.undefined_message) + undefined_message = driver1.find_element(*Login.undefined_message) actual_text = undefined_message.text expected_text = "undefined" assert actual_text == expected_text