我有一个尝试与之交互的示例html对象。我当前的目标是检索ul中每个li的值。我目前正在用示例代码加载该元素,但是当我尝试遍历集合以获取每个li的价值时。我收到以下消息Message: stale element reference: element is not attached to the page document
样本HTML
<ul tabindex="-1" class="k-list k-reset" id="clientName_listbox" role="listbox" aria-hidden="true" aria-live="polite" data-role="staticlist" unselectable="on">
<li tabindex="-1" class="k-item" role="option" aria-selected="false" unselectable="on" data-offset-index="0">item1</li>
<li tabindex="-1" class="k-item" role="option" aria-selected="false" unselectable="on" data-offset-index="1">item2</li>
</ul>
示例脚本
selections = browser.find_by_id('clientName_listbox').find_by_tag('li')
counter = 0
for x in selections:
value = x.text
counter += 1
错误
Message: stale element reference: element is not attached to the page document
(Session info: chrome=73.0.3683.103)
(Driver info: chromedriver=73.0.3683.68 (47787ec04b6e38e22703e856e101e840b65afe72),platform=Windows NT 10.0.17134 x86_64)