擅长:python、mysql、java
<p>将<code>xpath</code>更改为:</p>
<pre><code>//button[@class='dt-button buttons-collection buttons-page-length']//span[contains(text(),'Show 10 rows')]
</code></pre>
<p>尝试使用<code>WebDriverWait</code>确保元素存在,并添加<code>expected_conditions</code>直到元素<code>clickable</code>。在</p>
<p>导入此:</p>
^{pr2}$
<p>试试这个:</p>
<pre><code>wait = WebDriverWait(singlemeter, 10)
Show10 = wait.until(expected_conditions.element_to_be_clickable((By.XPATH, "//button[@class='dt-button buttons-collection buttons-page-length']//span[contains(text(),'Show 10 rows')]")))
Show10.click()
</code></pre>
<p>或使用<code>ActionChains</code>,导入:</p>
<pre><code>from selenium.webdriver import ActionChains
</code></pre>
<p>试试这个:</p>
<pre><code>ActionChains(singlemeter).move_to_element(Show10).click(Show10).perform()
</code></pre>