Я работаю над Python с Selenium, и я создал экземпляр веб-драйвера со следующей командой driver = webdriver.Firefox()
, и экземпляр веб-драйвера создан правильно.find_element_by_id не может найти элементы
После этого я пытаюсь получить элемент с идентификатором: str_title = driver.find_element_by_id("banner-section-title")
. Но я получаю следующую ошибку:
NoSuchElementException: Message: Unable to locate element: {"method":"id","selector":"banner-section-title"}
Stacktrace:
at FirefoxDriver.prototype.findElementInternal_ (file:///tmp/tmpR0IR8T/extensions/[email protected]/components/driver-component.js:10299)
at FirefoxDriver.prototype.findElement (file:///tmp/tmpR0IR8T/extensions/[email protected]/components/driver-component.js:10308)
at DelayedCommand.prototype.executeInternal_/h (file:///tmp/tmpR0IR8T/extensions/[email protected]/components/command-processor.js:12282)
at DelayedCommand.prototype.executeInternal_ (file:///tmp/tmpR0IR8T/extensions/[email protected]/components/command-processor.js:12287)
at DelayedCommand.prototype.execute/< (file:///tmp/tmpR0IR8T/extensions/[email protected]/components/command-processor.js:12229)
Вы уверены, что элемент с 'ид =' баннер-раздел-заголовка '' существует на странице? –
Да, он присутствует, и когда я пытаюсь щелкнуть ссылку из моей тестовой таблицы, используя «Click Link id = banner-section-title», он работает нормально. Но когда я пытаюсь сделать то же самое из файла ключевых слов, который находится из .py-файла, я получаю вышеуказанную ошибку. – Madhuri