Reputation: 76
I have the following snippet of JS code in a form that I want to use Selenium to input:
<oj-input-password id="idcs-signin-basic-signin-form-password" data-idcs-placeholder-translation-id="idcs-password-placeholder" class="oj-sm-12 oj-inputpassword oj-form-control oj-component oj-complete" value="{{password}}" placeholder="[[bundle('signin.password')]]" labelled-by="ui-id-2"><input data-oj-internal="" type="password" placeholder="Password" class="oj-inputpassword-input oj-component-initnode" id="idcs-signin-basic-signin-form-password|input"></oj-input-password>
I'm trying to enter the password:
password = browser.find_element_by_id('idcs-signin-basic-signin-form-password')
password.send_keys("my_password")
But then I get the following error:
selenium.common.exceptions.ElementNotInteractableException: Message: Element <oj-input-password id="idcs-signin-basic-signin-form-password" class="oj-sm-12 oj-inputpassword oj-form-control oj-component oj-complete"> is not reachable by keyboard
Why does this happen and what's the workaround?
Upvotes: 1
Views: 571
Reputation: 29362
I would suggest you to use ActionChains
from selenium.webdriver.common.action_chains import ActionChains
ActionChains(driver).move_to_element(driver.find_elements_by_css_selector("input[type='password'][placeholder='Password']")).send_keys('your password').perform()
also make sure to launch browser in full screen mode. and if scrolling is required, I would suggest you to do that as well.
Upvotes: 1
Reputation: 4212
Import explicit wait:
from selenium.webdriver.common.by import By
from selenium.webdriver.support.wait import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
Use it this way:
wait = WebDriverWait(driver, 15)
wait.until(EC.element_to_be_clickable(
(By.CSS_SELECTOR, "#idcs-signin-basic-signin-form-password")))
And use CSS selector instead of id:
password = browser.find_element_by_css_selector("#idcs-signin-basic-signin-form-password")
password.send_keys("my_password")
#
indicates an element id.
Also, check for the conditions:
Upvotes: 2