Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
aliwaleed1 authored Aug 25, 2023
1 parent 63f82d5 commit d1ec644
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 18 deletions.
4 changes: 3 additions & 1 deletion pages/login.py
Original file line number Diff line number Diff line change
@@ -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"]')
Expand Down
37 changes: 20 additions & 17 deletions tests/test_login.py
Original file line number Diff line number Diff line change
@@ -1,59 +1,62 @@
"""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("[email protected]")
# 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("[email protected]")
# 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:
assert True


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("[email protected]")
# 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

0 comments on commit d1ec644

Please sign in to comment.