python selenium-元素当前不可交互,并且可能无法操纵 [英] python selenium - Element is not currently interactable and may not be manipulated
本文介绍了python selenium-元素当前不可交互,并且可能无法操纵的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试通过python中的硒填充表单字段:
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")
但这会失败,但例外:
元素当前不可交互,并且可能无法操纵
Element is not currently interactable and may not be manipulated
为什么会发生这种情况,并且要解决此问题?
Why this happens and gow to fix this?
网络驱动程序__version__ = '2.45.0'
.
推荐答案
问题是还有另外两个input
元素,其中placeholder="Логин"
和placeholder="Пароль"
是不可见的.使您的 CSS选择器专用于登录表单:
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="Пароль"')
这篇关于python selenium-元素当前不可交互,并且可能无法操纵的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文