Задать вопрос

Что за ошибка в selenium?

Странная ошибка, элемент присутствует на html странице, но selenium его не замечает.

код
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.common.by import By
import time

options = Options()
ser = Service(r"C:\Users\гыук\Desktop\Python\selenium\chromedriver\chromedriver")
driver = webdriver.Chrome(service=ser, options=options)
driver.get('https://google.com')
element = driver.find_element(By.ID, "StayFocusd-infobar")
print(element)

time.sleep(5)


ошибка
Traceback (most recent call last):
  File "C:\Users\гыук\Desktop\Python\selenium\chromedriver\main.py", line 11, in <module>
    element = driver.find_element(By.ID, "StayFocusd-infobar")
  File "C:\Users\гыук\AppData\Local\Programs\Python\Python310\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 857, in find_element
    return self.execute(Command.FIND_ELEMENT, {
  File "C:\Users\гыук\AppData\Local\Programs\Python\Python310\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 435, in execute
    self.error_handler.check_response(response)
  File "C:\Users\гыук\AppData\Local\Programs\Python\Python310\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 247, in check_response
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"css selector","selector":"[id="StayFocusd-infobar"]"}
  (Session info: chrome=104.0.5112.81)
Stacktrace:
Backtrace:
	Ordinal0 [0x005F6463+2188387]
	Ordinal0 [0x0058E461+1762401]
	Ordinal0 [0x004A3D78+802168]
	Ordinal0 [0x004D1880+989312]
	Ordinal0 [0x004D1B1B+989979]
	Ordinal0 [0x004FE912+1173778]
	Ordinal0 [0x004EC824+1099812]
	Ordinal0 [0x004FCC22+1166370]
	Ordinal0 [0x004EC5F6+1099254]
	Ordinal0 [0x004C6BE0+945120]
	Ordinal0 [0x004C7AD6+948950]
	GetHandleVerifier [0x008971F2+2712546]
	GetHandleVerifier [0x0088886D+2652765]
	GetHandleVerifier [0x0068002A+520730]
	GetHandleVerifier [0x0067EE06+516086]
	Ordinal0 [0x0059468B+1787531]
	Ordinal0 [0x00598E88+1805960]
	Ordinal0 [0x00598F75+1806197]
	Ordinal0 [0x005A1DF1+1842673]
	BaseThreadInitThunk [0x75ACFA29+25]
	RtlGetAppContainerNamedObjectPath [0x77617A9E+286]
	RtlGetAppContainerNamedObjectPath [0x77617A6E+238]
  • Вопрос задан
  • 204 просмотра
Подписаться 1 Простой 3 комментария
Помогут разобраться в теме Все курсы
  • Нетология
    Python-разработчик: расширенный курс + нейросети
    12 месяцев
    Далее
  • Академия Эдюсон
    Python-разработчик + ИИ
    9 месяцев
    Далее
  • ProductStar × РБК
    Профессия: Python-разработчик + ИИ
    8 месяцев
    Далее
Пригласить эксперта
Ответы на вопрос 1
dabudi
@dabudi
2*2=5
no such element: Unable to locate element: {"method":"css selector","selector":"[id="StayFocusd-infobar"]"}

webdriver не может найти элемент
Ответ написан
Комментировать
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Похожие вопросы