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 24, 2023
1 parent 73d0da5 commit 63f82d5
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 0 deletions.
10 changes: 10 additions & 0 deletions pages/login.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from selenium.webdriver.common.by import By


class login:
email = (By.XPATH, '//*[@type="email"]')
password = (By.XPATH, '//*[@type="password"]')
login_button = (By.XPATH, '//button[text()="Login"]')
xpath_profile = '//span[@class="user-profile-image rounded-circle svelte-1'
profile = (By.XPATH, xpath_profile + '8t1c4h" and contains(text(), "AW")]')
undefined_message = (By.XPATH, '//*[@id="liveToast"]/div[2]')
59 changes: 59 additions & 0 deletions tests/test_login.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
import time
from pages.login import login
import pytest
from selenium import webdriver


@pytest.fixture
def driver1():
driver = webdriver.Edge()
driver.get("https://cshr.gent01.dev.grid.tf")
yield driver
driver.quit()


def test_user_login(driver1):
login_instance = login()
# Enter email
email_input = driver1.find_element(*login_instance.email)
email_input.send_keys("[email protected]")
# Enter password
password_input = driver1.find_element(*login_instance.password)
password_input.send_keys("123456789")
# Click on Login button
login_button = driver1.find_element(*login_instance.login_button)
login_button.click()

time.sleep(2)
# Get the profile
profile = driver1.find_element(*login_instance.profile)
# Assert that the element includes the text "AW"
assert "aw" in profile.text.lower()


def test_invalid_login(driver1):
login_instance = login()
# Enter email invalid email
email_input = driver1.find_element(*login_instance.email)
email_input.send_keys("[email protected]")
# Enter invalid password
password_input = driver1.find_element(*login_instance.password)
password_input.send_keys("123456789")
# Click on Login button
login_button = driver1.find_element(*login_instance.login_button)
try:
login_button.click()
except ImportError:
assert True


def test_email_validation(driver1):
login_instance = login()
# Enter email invalid email
email_input = driver1.find_element(*login_instance.email)
email_input.send_keys("[email protected]")
# get the error message
undefined_message = driver1.find_element(*login_instance.undefined_message)
actual_text = undefined_message.text
expected_text = "undefined"
assert actual_text == expected_text
2 changes: 2 additions & 0 deletions utils/base.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
"""base URL"""
BASEURL = "https://cshr.gent01.dev.grid.tf/"

0 comments on commit 63f82d5

Please sign in to comment.