我正在分析这样一个组织的网页:
<nav class="sidebar-main">
<div class="sidebar">Found 3 targets</div>
<ul><li><a href="#target1" class="current"><span>target1</span></a></li>
<li><a href="#target2" ><span>target2</span></a></li>
<li><a href="#target3"><span>target3</span></a></li></ul>
</nav>
我的目标是循环遍历每个列表元素,在过程中单击每个元素:
^{pr2}$我一直收到错误:
Message: The element reference of <li> stale either the element is no
longer attached to the DOM or the page has been refreshed.
现在只点击了一个链接,显然selenium无法在页面刷新时定位后续元素,我该如何解决这个问题?
单击第一个链接后,导航到新页面或刷新页面。您需要跟踪元素列表,再次找到列表元素,然后单击所需的元素。如果页面已更改,则还需要导航回原始页面。在
你可以试试下面的方法
相关问题 更多 >
编程相关推荐