Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Employees test #195

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
107 changes: 107 additions & 0 deletions pages/Employees.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
"""page objects."""
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC


class Login:
"""login class."""
email = (By.XPATH, '//*[@type="email"]')
password = (By.XPATH, '//*[@type="password"]')
login_button = (By.XPATH, '//button[text()="Login"]')
undefined_message = (By.XPATH, '//*[@id="liveToast"]/div[2]')
my_email = "[email protected]"

def __init__(self, browser):
self.browser = browser

def enter_email(self, email):
email_input = self.browser.find_element(*self.email)
email_input.clear()
email_input.send_keys(email)

def enter_password(self, password):
password_input = self.browser.find_element(*self.password)
password_input.clear()
password_input.send_keys(password)

def click_login_button(self):
return self.browser.find_element(*self.login_button)


class Employees:
"""Employees class."""
xpath1 = 'svg.bi.bi-microsoft-teams.nav_icon'
employees_button = (By.CSS_SELECTOR, xpath1)
parent_element = (By.CLASS_NAME, "row.justify-content-between")
profile_links = (By.TAG_NAME, "a")
profile_text_element = (By.CLASS_NAME, "user-profile-image")
profile_names = ["AD", "MR", "AW", "TB"]
xpath_random_profile1 = '//*[@id="body-pd"]/div[2]/div/div/div'
xpath_random_profile2 = '/div/div/div[1]/a/div/p'
random_profile_xpath = xpath_random_profile1+xpath_random_profile2
random_profile = (By.XPATH, random_profile_xpath)
random_prfile_email = (By.XPATH, random_profile_xpath + '/small[2]/cite')
xpath_email_profile1 = '//*[@id="body-pd"]/div[2]/section/div/div'
xpath_email_profile2 = '/div[2]/div[1]/div/div[2]/div[2]/p'
email_profile = (By.XPATH, xpath_email_profile1+xpath_email_profile2)
xpath_my_profile1 = '//*[@id="body-pd"]/div[2]/div/div/div/div/div/div[3]'
my_profile = (By.XPATH, xpath_my_profile1 + '/a/div')
xpath_pr_email = '//*[@id="body-pd"]/div[2]/section/div/div/div[2]/div[1]'
my_profile_email = (By.XPATH, xpath_pr_email + '/div/div[2]/div[2]/p')

def __init__(self, browser):
self.browser = browser

def click_dashboard_button(self):
wait = WebDriverWait(self.browser, 30)
wait.until(EC.visibility_of_element_located(self.employees_button))
dashboard_button = self.browser.find_element(*self.employees_button)
dashboard_button.click()

def get_parent_element(self):
wait = WebDriverWait(self.browser, 30)
wait.until(EC.visibility_of_element_located(self.parent_element))
return self.browser.find_element(*Employees.parent_element)

def get_profile_links(self):
parent_element = self.get_parent_element()
return parent_element.find_elements(*Employees.profile_links)

def is_profile_present(self, profile_text):
profile_presence = {}
for name in Employees.profile_names:
profile_presence[name] = False

profile_links = self.get_profile_links()
for link in profile_links:
profil_element = link.find_element(*Employees.profile_text_element)
profile_text = profil_element.text
profile_presence[profile_text] = True

return all(value for value in profile_presence.values())

def click_random_profile(self):
wait = WebDriverWait(self.browser, 30)
wait.until(EC.visibility_of_element_located(self.random_profile))
self.browser.find_element(*Employees.random_profile).click()

def get_random_prfile_email(self):
wait = WebDriverWait(self.browser, 30)
wait.until(EC.visibility_of_element_located(self.random_prfile_email))
return self.browser.find_element(*Employees.random_prfile_email)

def get_profile_email(self):
wait = WebDriverWait(self.browser, 30)
wait.until(EC.visibility_of_element_located(self.email_profile))
return self.browser.find_element(*Employees.email_profile)

def click_my_profile(self):
wait = WebDriverWait(self.browser, 30)
wait.until(EC.visibility_of_element_located(self.my_profile))
self.browser.find_element(*Employees.my_profile).click()

def get_my_profile_email(self):
wait = WebDriverWait(self.browser, 30)
wait.until(EC.visibility_of_element_located(self.my_profile_email))
return self.browser.find_element(*Employees.my_profile_email)
12 changes: 12 additions & 0 deletions tests/contest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
from selenium import webdriver
import pytest
from utils.base import BASEURL


@pytest.fixture(name="browse", scope="function")
def browsee():
"""Function to save driver fixture."""
driver = webdriver.Edge()
driver.get(BASEURL)
yield driver
driver.quit()
43 changes: 43 additions & 0 deletions tests/test_employees.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
"""Module to test meeting page."""
from pages.Employees import Login, Employees


def to_login(browse):
"""Function to login in tests."""
login_page = Login(browse)
login_page.enter_email(login_page.my_email)
login_page.enter_password("123456789")
login_button = login_page.click_login_button()
login_button.click()


def test_employees_displayed_on_page(browse):
"""test for all Employees ."""
to_login(browse)
employees_page = Employees(browse)
employees_page.click_dashboard_button()
all_present = employees_page.is_profile_present(Employees.profile_names)
assert all_present


def test_employee_information_displayed(browse):
"""test for employee information ."""
to_login(browse)
employees_page = Employees(browse)
employees_page.click_dashboard_button()
random_profile_email = employees_page.get_random_prfile_email().text
employees_page.click_random_profile()
profile = employees_page.get_profile_email()
assert profile.text == random_profile_email


def test_employee_information_accuracy(browse):
"""test for my profile ."""
to_login(browse)
login_page = Login(browse)
my_login_email = login_page.my_email
employees_page = Employees(browse)
employees_page.click_dashboard_button()
employees_page.click_my_profile()
my_profile_email = employees_page.get_my_profile_email()
assert my_profile_email.text == my_login_email
1 change: 0 additions & 1 deletion utils/Base.py

This file was deleted.

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/"
Loading