我在网页中找到了我需要的元素,并将它们分别称为适当的元素。有没有一种方法可以稍后在测试脚本中按名称调用元素并单击它,而不必再次定位该元素?你知道吗
尝试将find\u元素\u by/.click()拆分为两行,这样我知道它可以引用我分配给元素的名称。你知道吗
costs = browser.find_element_by_css_selector('g:nth-child(2) > g > circle')
costs.click()
revenue = browser.find_element_by_css_selector('#chart-div-2 g:nth-child(1) > rect')
revenue.click()
(在这些步骤和一些类似的步骤之后,我尝试添加….)
costs.click()
revenue.click()
信息:
'stale element reference: element is not attached to the page document', but I've not navigated away from the page.
我错过了什么
您只需要再次引用它们,因为元素已过时。你知道吗
所以在你的情况下:
阅读有关Stale Element Reference Exception的更多信息。你知道吗
相关问题 更多 >
编程相关推荐