"Message: unknown error: cannot focus element" in python selenium driver
<p>Why does this piece of code throw an exception <code>selenium.common.exceptions.WebDriverException: Message: unknown error: cannot focus element</code>? </p>

<p>As far as I can tell, I'm choosing the right element. Googling suggested to have a <code>.click()</code> on element before sending keys but that didn't help either.</p>

<pre><code>from selenium import webdriver
from selenium.common.exceptions import TimeoutException
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.keys import Keys

driver = webdriver.Chrome()
driver.get("https://netbanking.hdfcbank.com/netbanking/")
login_wait = WebDriverWait(driver, 10)

assert "Welcome to HDFC Bank" in driver.title

frame = login_wait.until(EC.presence_of_element_located((By.NAME, 'login_page')))
driver.switch_to.frame(frame)

try:
    elem = login_wait.until(EC.presence_of_element_located((By.CLASS_NAME, 'pwd_field')))
    print("Page is ready!")
    elem.send_keys("123456")
    elem.send_keys(Keys.RETURN)
except TimeoutException:
    print("Loading took too much time!")

driver.close()
</code></pre>