Код: Выделить всё
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from webdriver_manager.chrome import ChromeDriverManager
import time
# Set up Chrome options
chrome_options = webdriver.ChromeOptions()
chrome_options.add_argument("user-data-dir=C:/Users/Chairte she bozo/AppData/Local/Google/Chrome/User Data")
chrome_options.add_argument("profile-directory=Profile 4")
chrome_options.add_argument("--remote-debugging-port=9222")
chrome_options.add_argument("--disable-gpu")
chrome_options.add_argument("--no-sandbox")
chrome_options.add_argument("--disable-dev-shm-usage")
# Setup ChromeDriver with options
driver = webdriver.Chrome(service=Service(ChromeDriverManager().install()), options=chrome_options)
# List of customer URLs and corresponding amounts
customer_data = [
("https://test/promocodes", 5.1),
]
# Text for promocode purpose
promocode_purpose = "test"
# Function to automate actions on each customer page
def automate_customer_page(url, amount):
try:
driver.get(url)
# Wait for the "Give Promocode" button to be clickable and click it
give_promocode_button = WebDriverWait(driver, 5).until(
EC.element_to_be_clickable((By.CSS_SELECTOR, 'button[data-testid="give-promo-button"]'))
)
give_promocode_button.click()
# Wait for the "Promocode type" dropdown to be clickable and click it
promocode_type_dropdown = WebDriverWait(driver, 5).until(
EC.element_to_be_clickable((By.CSS_SELECTOR, 'input[placeholder="Promocode type"]'))
)
promocode_type_dropdown.click()
# Wait for the "Product Balance" option to be visible and click it
product_balance_option = WebDriverWait(driver, 5).until(
EC.element_to_be_clickable((By.XPATH, '//p[text()="Product Balance"]'))
)
product_balance_option.click()
Вот изображение, на котором оно застревает, я не понимаю, что я делаю не так, может быть, что-то из проверки?
Подробнее здесь: https://stackoverflow.com/questions/786 ... ing-python