2025-03-03 21:07:33 +04:00
|
|
|
|
from common_fixtures import driver, login, open_profile
|
2025-03-03 18:36:39 +04:00
|
|
|
|
from selenium.webdriver.common.by import By
|
2025-03-04 11:15:11 +04:00
|
|
|
|
from my_constants import EMAIL, PASSWORD
|
2025-03-03 18:36:39 +04:00
|
|
|
|
import time
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def switcher(driver, ind):
|
|
|
|
|
driver.find_element(
|
|
|
|
|
By.XPATH, "//*[@id='root']/div/div[1]/div[1]/div[1]/button[1]/img").click()
|
|
|
|
|
element = driver.find_element(
|
|
|
|
|
By.XPATH, f"/html/body/div[2]/nav/a[{ind}]")
|
|
|
|
|
to_check1 = element.text
|
|
|
|
|
element.click()
|
2025-03-03 20:48:09 +04:00
|
|
|
|
time.sleep(2)
|
2025-03-03 18:36:39 +04:00
|
|
|
|
to_check2 = driver.find_element(
|
|
|
|
|
By.CLASS_NAME, 'overlay-header__info-text').get_attribute("textContent")
|
|
|
|
|
res = (to_check1 == to_check2)
|
2025-03-03 19:14:40 +04:00
|
|
|
|
driver.find_element(
|
|
|
|
|
By.CSS_SELECTOR, '#root > div > div.app-page > div.auth-popup > div > div.overlay-order.overlay-sidebar-enter-done > div.overlay-header > button.popup-close-icon > svg > path').click()
|
|
|
|
|
time.sleep(2)
|
2025-03-03 18:36:39 +04:00
|
|
|
|
return res
|
|
|
|
|
|
|
|
|
|
|
2025-03-04 18:00:24 +04:00
|
|
|
|
def get_password_fields(driver):
|
2025-03-04 11:15:11 +04:00
|
|
|
|
return [driver.find_element(By.NAME, 'old_password'),
|
|
|
|
|
driver.find_element(By.NAME, 'password'),
|
|
|
|
|
driver.find_element(By.NAME, 'repeat_password')]
|
|
|
|
|
|
|
|
|
|
|
2025-03-04 18:00:24 +04:00
|
|
|
|
def password_step(driver):
|
|
|
|
|
change_password = driver.find_element(
|
|
|
|
|
By.XPATH, "//*[@id='root']/div/div[1]/div[2]/div/div[2]/div[2]/div/div/form/a[2]")
|
|
|
|
|
driver.execute_script(
|
|
|
|
|
"arguments[0].scrollIntoView(true);", change_password)
|
|
|
|
|
change_password.click()
|
|
|
|
|
time.sleep(1)
|
|
|
|
|
|
2025-03-04 21:28:20 +04:00
|
|
|
|
|
2025-03-04 18:00:24 +04:00
|
|
|
|
def password_back_step(driver):
|
|
|
|
|
driver.find_element(
|
|
|
|
|
By.CSS_SELECTOR, '#root > div > div.app-page > div.auth-popup > div > div.overlay-order.overlay-sidebar-enter-done > div.overlay-header > div.button-back > svg').click()
|
|
|
|
|
time.sleep(1)
|
|
|
|
|
|
|
|
|
|
|
2025-03-04 11:15:11 +04:00
|
|
|
|
def old_new_password(driver):
|
2025-03-04 18:00:24 +04:00
|
|
|
|
old_password, password, repeat_password = get_password_fields(driver)
|
2025-03-04 11:15:11 +04:00
|
|
|
|
old_password.send_keys(PASSWORD)
|
2025-03-04 18:00:24 +04:00
|
|
|
|
time.sleep(1)
|
2025-03-04 11:15:11 +04:00
|
|
|
|
password.send_keys(2 * PASSWORD + 'а')
|
2025-03-04 18:00:24 +04:00
|
|
|
|
time.sleep(1)
|
|
|
|
|
repeat_password.send_keys(2 * PASSWORD + 'а')
|
|
|
|
|
time.sleep(1)
|
|
|
|
|
assert driver.find_element(
|
|
|
|
|
By.XPATH, "//*[@id='root']/div/div[1]/div[2]/div/div[2]/div[2]/div/form/div[3]/div[2]/div[2]").is_displayed()
|
|
|
|
|
time.sleep(1)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def wrong_repeat_password(driver):
|
|
|
|
|
old_password, password, repeat_password = get_password_fields(driver)
|
|
|
|
|
old_password.send_keys(2 * PASSWORD)
|
|
|
|
|
time.sleep(1)
|
|
|
|
|
password.send_keys(2 * PASSWORD)
|
|
|
|
|
time.sleep(1)
|
2025-03-04 11:15:11 +04:00
|
|
|
|
repeat_password.send_keys(2 * PASSWORD + 'а')
|
2025-03-04 18:00:24 +04:00
|
|
|
|
time.sleep(1)
|
|
|
|
|
assert driver.find_element(
|
|
|
|
|
By.XPATH, "//*[@id='root']/div/div[1]/div[2]/div/div[2]/div[2]/div/form/div[4]/div[2]/div[2]").is_displayed()
|
|
|
|
|
time.sleep(1)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def wrong_old_password(driver):
|
|
|
|
|
old_password, password, repeat_password = get_password_fields(driver)
|
|
|
|
|
old_password.send_keys(2 * PASSWORD)
|
|
|
|
|
time.sleep(1)
|
|
|
|
|
password.send_keys(2 * PASSWORD + 'a')
|
|
|
|
|
time.sleep(1)
|
|
|
|
|
repeat_password.send_keys(2 * PASSWORD + 'a')
|
|
|
|
|
time.sleep(1)
|
|
|
|
|
driver.find_element(By.CLASS_NAME, 'login-form__button').click()
|
|
|
|
|
time.sleep(1)
|
|
|
|
|
assert driver.find_element(
|
|
|
|
|
By.XPATH, "//*[@id='root']/div/div[1]/div[2]/div/div[2]/div[2]/div/form/div[2]/div[2]/div[2]").is_displayed()
|
2025-03-04 11:15:11 +04:00
|
|
|
|
time.sleep(1)
|
|
|
|
|
|
|
|
|
|
|
2025-03-04 21:28:20 +04:00
|
|
|
|
|
|
|
|
|
def check_warnings(driver):
|
|
|
|
|
old_password, password, repeat_password = get_password_fields(driver)
|
|
|
|
|
old_password.send_keys(PASSWORD)
|
|
|
|
|
time.sleep(1)
|
|
|
|
|
password.send_keys(2 * PASSWORD + 'а')
|
|
|
|
|
time.sleep(1)
|
|
|
|
|
repeat_password.send_keys(2 * PASSWORD + 'а')
|
|
|
|
|
time.sleep(1)
|
|
|
|
|
assert len(driver.find_elements(
|
|
|
|
|
By.XPATH, "//div[@class='input__error']")) == 1
|
|
|
|
|
time.sleep(1)
|
|
|
|
|
|
|
|
|
|
|
2025-03-03 21:07:33 +04:00
|
|
|
|
def test_navigation(open_profile):
|
|
|
|
|
login = open_profile
|
2025-03-03 18:36:39 +04:00
|
|
|
|
profile_icon_window = login.find_element(
|
|
|
|
|
By.XPATH, "//*[@id='root']/div/div[1]/div[1]/div[1]/button[1]/img")
|
2025-03-03 21:39:06 +04:00
|
|
|
|
login = open_profile
|
2025-03-03 18:36:39 +04:00
|
|
|
|
menu_len = len(login.find_elements(By.CLASS_NAME, 'account-menu__item'))
|
|
|
|
|
profile_icon_window.click()
|
2025-03-03 20:48:09 +04:00
|
|
|
|
time.sleep(2)
|
2025-03-03 19:14:40 +04:00
|
|
|
|
|
2025-03-03 18:36:39 +04:00
|
|
|
|
res = True
|
2025-03-03 19:14:40 +04:00
|
|
|
|
for ind in range(menu_len - 1):
|
2025-03-03 18:36:39 +04:00
|
|
|
|
res = res and switcher(
|
|
|
|
|
login, ind + 1)
|
2025-03-03 19:14:40 +04:00
|
|
|
|
time.sleep(2)
|
2025-03-03 18:36:39 +04:00
|
|
|
|
login.switch_to.default_content()
|
|
|
|
|
assert res == True
|
2025-03-03 21:39:06 +04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_profile_changes(open_profile):
|
|
|
|
|
driver = open_profile
|
|
|
|
|
profile_icon_window = driver.find_element(
|
|
|
|
|
By.XPATH, "//*[@id='root']/div/div[1]/div[1]/div[1]/button[1]/img")
|
|
|
|
|
time.sleep(2)
|
|
|
|
|
driver.find_element(By.XPATH, "/html/body/div[2]/nav/a[2]").click()
|
|
|
|
|
time.sleep(1)
|
2025-03-04 11:15:11 +04:00
|
|
|
|
fields = []
|
|
|
|
|
fields.append(driver.find_element(By.NAME, "first_name"))
|
|
|
|
|
fields.append(driver.find_element(By.NAME, "last_name"))
|
|
|
|
|
fields.append(driver.find_element(By.NAME, "middle_name"))
|
|
|
|
|
fields.append(driver.find_element(By.NAME, 'birthdate'))
|
|
|
|
|
fields.append(driver.find_element(By.NAME, 'phone'))
|
|
|
|
|
time.sleep(1)
|
|
|
|
|
for i in range(len(fields)):
|
|
|
|
|
fields[i].clear()
|
|
|
|
|
fields[i].send_keys('a')
|
|
|
|
|
assert driver.find_element(
|
|
|
|
|
By.XPATH, f"//*[@id='root']/div/div[1]/div[2]/div/div[2]/div[2]/div/div/form/div[{i + 1}]/div[3]").is_displayed()
|
|
|
|
|
driver.find_element(
|
|
|
|
|
By.XPATH, "//*[@id='root']/div/div[1]/div[2]/div/div[2]/div[2]/div/div/form/a[1]").click()
|
2025-03-04 18:00:24 +04:00
|
|
|
|
time.sleep(1)
|
2025-03-04 11:15:11 +04:00
|
|
|
|
driver.find_element(
|
|
|
|
|
By.XPATH, "//*[@id='root']/div/div[1]/div[2]/div/div[2]/div[2]/div/form/div[3]/div[2]/input").send_keys('a')
|
|
|
|
|
assert driver.find_element(By.CLASS_NAME, 'disabled').is_enabled()
|
2025-03-04 18:00:24 +04:00
|
|
|
|
driver.find_element(
|
|
|
|
|
By.CSS_SELECTOR, '#root > div > div.app-page > div.auth-popup > div > div.overlay-order.overlay-sidebar-enter-done > div.overlay-header > div.button-back > svg').click()
|
|
|
|
|
time.sleep(1)
|
|
|
|
|
password_step(driver)
|
|
|
|
|
old_new_password(driver)
|
|
|
|
|
password_back_step(driver)
|
|
|
|
|
password_step(driver)
|
|
|
|
|
wrong_repeat_password(driver)
|
|
|
|
|
password_back_step(driver)
|
|
|
|
|
password_step(driver)
|
|
|
|
|
wrong_old_password(driver)
|
|
|
|
|
password_back_step(driver)
|
2025-03-04 21:28:20 +04:00
|
|
|
|
password_step(driver)
|
|
|
|
|
check_warnings(driver)
|
|
|
|
|
password_back_step(driver)
|
2025-03-03 21:39:06 +04:00
|
|
|
|
time.sleep(2)
|