Повторил XPATH, люто нафигачил первый тест сьют

This commit is contained in:
Oleja123 2025-03-03 10:44:48 +04:00
parent 834f8f0649
commit 2040b61349
2 changed files with 50 additions and 42 deletions

42
common_fixtures.py Normal file
View File

@ -0,0 +1,42 @@
import pytest
from selenium import webdriver
from selenium.webdriver.common.by import By
import time
EMAIL = 'jediforce82@gmail.com'
PASSWORD = 'aboba123'
@pytest.mark.order(1)
@pytest.fixture()
def driver():
driver = webdriver.Chrome()
driver.maximize_window()
driver.get('https://luna73.ru/')
time.sleep(2)
yield driver
driver.close()
@pytest.mark.order(2)
@pytest.fixture()
def login(driver):
login_button = driver.find_element(By.CLASS_NAME, 'widget-overlay')
driver.execute_script("arguments[0].scrollIntoView(true);", login_button)
login_button.click()
time.sleep(3)
the_iframe = driver.find_element(By.ID, "kw-iframe")
driver.switch_to.frame(the_iframe)
email_field = driver.find_element(By.NAME, 'email')
password_field = driver.find_element(By.NAME, 'password')
email_field.send_keys(EMAIL)
password_field.send_keys(PASSWORD)
enter_button = driver.find_element(By.CLASS_NAME, 'login-form__button')
enter_button.click()
time.sleep(2)
close_button = driver.find_element(By.CLASS_NAME, 'popup-close-icon')
close_button.click()
time.sleep(2)
driver.switch_to.default_content()
yield driver

View File

@ -1,46 +1,7 @@
import pytest
from selenium import webdriver
from common_fixtures import driver, login
from selenium.webdriver.common.by import By
import time
EMAIL = 'jediforce82@gmail.com'
PASSWORD = 'aboba123'
@pytest.mark.order(1)
@pytest.fixture()
def driver():
driver = webdriver.Chrome()
driver.maximize_window()
driver.get('https://luna73.ru/')
time.sleep(2)
yield driver
driver.close()
@pytest.mark.order(2)
@pytest.fixture()
def login(driver):
login_button = driver.find_element(By.CLASS_NAME, 'widget-overlay')
driver.execute_script("arguments[0].scrollIntoView(true);", login_button)
login_button.click()
time.sleep(3)
the_iframe = driver.find_element(By.ID, "kw-iframe")
driver.switch_to.frame(the_iframe)
email_field = driver.find_element(By.NAME, 'email')
password_field = driver.find_element(By.NAME, 'password')
email_field.send_keys(EMAIL)
password_field.send_keys(PASSWORD)
enter_button = driver.find_element(By.CLASS_NAME, 'login-form__button')
enter_button.click()
time.sleep(2)
close_button = driver.find_element(By.CLASS_NAME, 'popup-close-icon')
close_button.click()
time.sleep(2)
driver.switch_to.default_content()
yield driver
def test_header_len(driver):
header = driver.find_elements(By.CLASS_NAME, 'menu__item')
assert len(header) > 0
@ -59,9 +20,14 @@ def test_header_navigation(driver):
def test_feedback(login):
feedback_button = login.find_element(By.CLASS_NAME, 'feedback')
feedback_button = login.find_element(By.XPATH, "//*[@id='root']/div/div/nav/div/div[2]/button")
login.execute_script("arguments[0].scrollIntoView(true);", feedback_button)
feedback_button.click()
time.sleep(2)
textarea = login.find_element(By.CLASS_NAME, 'textarea')
textarea.text = 'a'
textarea.send_keys('a')
send_button = login.find_element(By.XPATH, '/html/body/div[3]/div/div[2]/div/div/div/div[3]/button')
send_button.click()
time.sleep(1)
success_img = login.find_element(By.XPATH, '/html/body/div[3]/div/div[2]/div/div/div/div[2]/div/img')
assert success_img is not None