擅长:python、mysql、java
<blockquote>
<p>StaleElementReferenceException: Message: stale element reference: element is not attached to the page document</p>
</blockquote>
<p>这个页面的<a href="http://docs.seleniumhq.org/exceptions/stale_element_reference.jsp" rel="nofollow noreferrer">most frequent cause</a>是元素所在的页面已经刷新,或者用户已经导航到另一个页面。你知道吗</p>
<p>正如您所说的,当单击save按钮时,页面将被刷新。因此,为了避免这种情况,您需要再次找到相同的元素(refresh element)来获得它们的值,如下所示:</p>
<pre><code>assert self.find_element(*ContractorsLocators.TWITTER).get_attribute("value") == enter_twitter
</code></pre>