Добрый день, помогите решить проблему начинающему автоматизатору.
Есть выпадающее меню со многими субменю.
Использую webdriver, Python and pytest
def menu_menu1_menu2_menu3(self):
menu = driver.find_element_by_css_selector(‘a.main-menu[title=“main-menu”]’)
actions = ActionChains(driver)
# place the cursor on menu and click menu1
menu1 = driver.find_element_by_css_selector(’#menu1’)
actions.move_to_element(menu).click(menu1).perform()
# place the cursor on menu and click menu2
menu2 = driver.find_element_by_css_selector(’#menu2’)
actions.move_to_element(menu).click(menu2).perform()
# place the cursor on menu and click menu3
menu3 = driver.find_element_by_css_selector(’#menu3’)
actions.move_to_element(menu).click(menu3).perform()
Курсор наводится на меню и кликает меню1. Открывается нужная страница, после этого курсор больше не наводится на menu и появляется ошибка:
Chrome: selenium.common.exceptions.StaleElementReferenceException:
Message: stale element reference: element is not attached to the page document
Firefox: selenium.common.exceptions.StaleElementReferenceException:
Message: Element not found in the cache - perhaps the page has changed since it was looked up
Селекторы не меняются, они статические.