擅长:python、mysql、java
<p>在你的问题中:</p>
<blockquote>
<p><em>"I think I need to put a delay or something in 3 that activates 4 when the element is found."</em></p>
</blockquote>
<p>我认为正确的选择是第二个:“或者别的什么”。您应该了解如何等待元素,并引用<a href="https://selenium-python.readthedocs.io/waits.html" rel="nofollow noreferrer">Selenium Wait docs</a>:</p>
<blockquote>
<p>if an element is not yet present in the DOM, a locate function will raise an ElementNotVisibleException exception. Using waits, we can solve this issue. Waiting provides some slack between actions performed - mostly locating an element or any other operation with the element.</p>
</blockquote>
<p>这个网站上的一个例子:<a href="https://stackoverflow.com/a/25851841">https://stackoverflow.com/a/25851841</a></p>