from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
class BasePage:
def __init__(self, driver):
self.driver = driver
def find_element(self, locator, timeout=10):
return WebDriverWait(self.driver, timeout).until(EC.presence_of_element_located(locator))
def find_elements(self, locator, timeout=10):
return WebDriverWait(self.driver, timeout).until(EC.presence_of_all_elements_located(locator))
def click(self, locator, timeout=10):
self.find_element(locator, timeout).click()
def send_keys(self, locator, text, timeout=10):
element = self.find_element(locator, timeout)
element.clear()
element.send_keys(text)
def get_text(self, locator, timeout=10):
return self.find_element(locator, timeout).text
import pytest
from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.chrome.options import Options
@pytest.fixture(scope="module")
def browser():
# Путь к драйверу Yandex
service = Service('C:/Users/djuli/yandexdriver/yandexdriver-24.10.1.598-win64/yandexdriver.exe')
options = Options()
options.binary_location = 'C:/Users/djuli/AppData/Local/Yandex/YandexBrowser/Application/browser.exe'
options.add_argument('--start-maximized')
# Инициализация WebDriver
driver = webdriver.Chrome(service=service, options=options)
driver.get('https://arnypraht.com') # Адрес вашего сайта
yield driver # Возвращаем драйвер
driver.quit() # Закрываем драйвер после завершения тестов