Нейронка это конечно хорошо, но желательно проверять, что она пишет:
# EC.presence_of_element_located((By.CSS_SELECTOR, "product-slider__img js-product-current-img"))
EC.presence_of_element_located((By.CSS_SELECTOR, ".product-slider__img.js-product-current-img"))
Ниже код для Chrome и FF (Python 3.10, Windows 11 Pro 23H2) - все прекрасно работает, за исключением сайта-помойки, который грузится минуту:
from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.common.exceptions import TimeoutException
options = Options()
service = Service(r'D:\project\chromedriver-130.0.6723.93.exe')
driver = webdriver.Chrome(service=service, options=options)
url = 'https://superstep.ru/product/NCFSW0W288YW_GRA/#colorGRA'
driver.get(url)
try:
element = WebDriverWait(driver, 10).until(
EC.presence_of_element_located((By.CSS_SELECTOR, ".product-slider__img.js-product-current-img"))
)
page_html = driver.page_source
print(page_html)
except TimeoutException:
print("Элемент не найден")
finally:
print('Программа завершена')
driver.quit()
from selenium import webdriver
from selenium.webdriver.firefox.service import Service
from selenium.webdriver.firefox.options import Options
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.common.exceptions import TimeoutException
options = Options()
service = Service(r'D:\project\geckodriver.exe')
driver = webdriver.Firefox(service=service, options=options)
url = 'https://superstep.ru/product/NCFSW0W288YW_GRA/#colorGRA'
driver.get(url)
try:
element = WebDriverWait(driver, 10).until(
EC.presence_of_element_located((By.CSS_SELECTOR, ".product-slider__img.js-product-current-img"))
)
page_html = driver.page_source
print(page_html)
except TimeoutException:
print("Элемент не найден")
finally:
print('Программа завершена')
driver.quit()