<p>要使用<a href="https://stackoverflow.com/questions/54459701/what-is-selenium-and-what-is-webdriver/54482491#54482491">Selenium</a>在<strong>密码</strong>字段内发送<em>字符序列</em>,必须为<code>element_to_be_clickable()</code>导出<em>WebDriverWait</em>,并且可以使用以下任一解决方案:</p>
<ul>
<li><p>使用<code>CSS_SELECTOR</code>:</p>
<pre><code>driver.get("https://creis.fang.com/")
WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.CSS_SELECTOR, "input.loginipt.fl#cnotp"))).click()
WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.CSS_SELECTOR, "input.loginipt.fl#cnpassword"))).send_keys("Chan")
</code></pre></li>
<li><p>使用<code>XPATH</code>:</p>
<pre><code>driver.get("https://creis.fang.com/")
WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "//input[@class='loginipt fl' and @id='cnotp']"))).click()
WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "//input[@class='loginipt fl' and @id='cnpassword']"))).send_keys("Chan")
</code></pre></li>
<li><p><strong>注意</strong>:必须添加以下导入:</p>
<pre><code>from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
</code></pre></li>
<li><p>浏览器快照:</p></li>
</ul>
<p><a href="https://i.stack.imgur.com/oFZPj.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/oFZPj.png" alt="password"/></a></p>