Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

python selenium - Element is not currently interactable and may not be manipulated

I am trying to populate form fields via selenium in python:

from selenium import webdriver
from selenium.webdriver.common.action_chains import ActionChains

driver = webdriver.Firefox()        
driver.get("http://www.miralinks.ru/")
driver.implicitly_wait(30)
login = driver.find_element_by_css_selector('input[placeholder="Логин"]')
hov = ActionChains(driver).move_to_element(login)
hov.perform()
login.clear()
login.send_keys("login")
pwd = driver.find_element_by_css_selector('input[placeholder="Пароль"]')
pwd.clear()
pwd.send_keys("pass")

but this fails with exception:

Element is not currently interactable and may not be manipulated

Why this happens and gow to fix this?

webdriver __version__ = '2.45.0'.

like image 387
Evg Avatar asked Mar 30 '15 12:03

Evg


2 Answers

Use a wait function before the element that gave the error.

The webdriver is trying to interact with an element not completely loaded.

like image 200
Kolapo Avatar answered Sep 21 '22 18:09

Kolapo


The problem is that there are two other input elements with placeholder="Логин" and placeholder="Пароль" which are invisible. Make your CSS selectors specific to the login form:

login = driver.find_element_by_css_selector('form#loginForm input[placeholder="Логин"]')
pwd = driver.find_element_by_css_selector('form#loginForm input[placeholder="Пароль"')
like image 21
alecxe Avatar answered Sep 22 '22 18:09

alecxe