From a5e2fc49a1bad46e205f31cc13f98d257fdf90db Mon Sep 17 00:00:00 2001 From: Oleja123 Date: Tue, 4 Mar 2025 11:15:11 +0400 Subject: [PATCH] one more cummit --- common_fixtures.py | 8 ++----- my_constants.py | 2 ++ test_profile_module.py | 47 +++++++++++++++++++++++++++++++++--------- 3 files changed, 41 insertions(+), 16 deletions(-) create mode 100644 my_constants.py diff --git a/common_fixtures.py b/common_fixtures.py index 1161644..034b125 100644 --- a/common_fixtures.py +++ b/common_fixtures.py @@ -1,11 +1,8 @@ import pytest +import time from selenium import webdriver from selenium.webdriver.common.by import By -import time - - -EMAIL = 'jediforce82@gmail.com' -PASSWORD = 'aboba123' +from my_constants import EMAIL, PASSWORD @pytest.mark.order(1) @@ -58,5 +55,4 @@ def open_profile(login): By.XPATH, "//*[@id='root']/div/div[1]/div[1]/div[1]/button[1]/img") profile_icon_window.click() time.sleep(2) - yield login diff --git a/my_constants.py b/my_constants.py new file mode 100644 index 0000000..c0efa95 --- /dev/null +++ b/my_constants.py @@ -0,0 +1,2 @@ +EMAIL = 'jediforce82@gmail.com' +PASSWORD = 'aboba123' \ No newline at end of file diff --git a/test_profile_module.py b/test_profile_module.py index 6c7aaa7..e1eec93 100644 --- a/test_profile_module.py +++ b/test_profile_module.py @@ -1,5 +1,6 @@ from common_fixtures import driver, login, open_profile from selenium.webdriver.common.by import By +from my_constants import EMAIL, PASSWORD import time @@ -20,6 +21,21 @@ def switcher(driver, ind): return res +def get_password_fields(): + return [driver.find_element(By.NAME, 'old_password'), + driver.find_element(By.NAME, 'password'), + driver.find_element(By.NAME, 'repeat_password')] + + +def old_new_password(driver): + old_password, password, repeat_password = get_password_fields() + old_password.send_keys(PASSWORD) + password.send_keys(2 * PASSWORD + 'а') + repeat_password.send_keys(2 * PASSWORD + 'а') + assert not 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 test_navigation(open_profile): login = open_profile profile_icon_window = login.find_element( @@ -45,14 +61,25 @@ def test_profile_changes(open_profile): time.sleep(2) driver.find_element(By.XPATH, "/html/body/div[2]/nav/a[2]").click() time.sleep(1) - name_field = driver.find_element(By.NAME, "first_name") - surname_field = driver.find_element(By.NAME, "last_name") - father_name = driver.find_element(By.NAME, "middle_name") - name_field.clear() - surname_field.clear() - father_name.clear() - name_field.send_keys('a') - surname_field.send_keys('a') - father_name.send_keys('a') + 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() + 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() + 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(2) -