我有一个 python 函数,应该点击产品的所有选项:
submit_button = driver.find_element_by_id('quantityactionbox')
elementList = submit_button.find_elements_by_tag_name("option")
for x in elementList:
x.click()
单击 2 个元素后出现此错误:
selenium.common.exceptions.StaleElementReferenceException: Message: stale element reference: element is not attached to the page document
你能告诉我为什么会出现这个错误吗?我该怎么做才能成功通过所有元素?
原文由 Flex Texmex 发布,翻译遵循 CC BY-SA 4.0 许可协议
您有关于 The Element is not Attached to the DOM 的解释和解决方案: