import pytest import allure from selenium import webdriver from selenium.webdriver.common.by import By from selenium.webdriver.support.ui import WebDriverWait from selenium.webdriver.support import expected_conditions as EC
@allure.title("Test for deleting a book from the cart") def test_delete_book_from_cart(): # Open the website driver = webdriver.Chrome() driver.get("https://www.chitai-gorod.ru/")
try:
# Add a book to the cart
search_input = driver.find_element(By.NAME, "search")
search_input.send_keys("Harry Potter")
search_input.submit()
WebDriverWait(driver, 10).until(
EC.presence_of_element_located((By.CLASS_NAME, "product-card__title"))
)
book_title = driver.find_element(By.CLASS_NAME, "product-card__title")
book_title.click()
add_to_cart_button = driver.find_element(By.CLASS_NAME, "buy-button")
add_to_cart_button.click()
# Go to the cart
cart_button = driver.find_element(By.CLASS_NAME, "header-cart__link")
cart_button.click()
# Delete the book from the cart
delete_button = driver.find_element(By.CLASS_NAME, "cart-product__delete")
delete_button.click()
# Verify that the book is removed from the cart
assert "Корзина пуста" in driver.page_source
finally:
driver.quit()
Обратите внимание: ответы, предоставляемые искусственным интеллектом, могут не всегда быть точными. Не рассчитывайте на них в критически важных областях, таких как медицина, юриспруденция, финансы или в вопросах, связанных с безопасностью. Для важных решений всегда обращайтесь к квалифицированным специалистам. Администрация сайта не несет ответственности за контент, сгенерированный автоматически.