Error: element not interactable while using Selenium when sending keys to a textbox
Error: element not interactable while using Selenium when sending keys to a textbox
我正在使用 Selenium 尝试登录网站,但是当我尝试发送密钥时,出现以下错误:selenium.common.exceptions.ElementNotInteractableException: Message: element not interactable
。该网站是:website。
我希望有人能帮助我。
我的代码是:
buttom = browser.find_element_by_class_name("loginInputs").find_element_by_class_name("passwordInput")
buttom.send_keys("password")
它不起作用,因为具有 class 名称 passwordInput
的元素是 <div>
。你想要的是 <input>
元素,所以使用:
password = browser.find_element_by_class_name("loginInputs").find_element_by_class_name("passwordInput").find_element_by_css_selector("input")
password.send_keys("password")
实际上不需要使用嵌套的父子关系来获取登录名-用户名和密码字段,使用 Selenium 填充
username = browser.find_element_by_css_selector("input[placeholder='Username']")
username.send_keys("username")
password = browser.find_element_by_css_selector("input[placeholder='Password']")
password.send_keys("password")
login_btn = browser.find_element_by_css_selector(".loginButton.button.submitButton")
login_btn.click()
完美地完成了输入和提交登录按钮的工作 - 在 Mac 机器上使用 Selenium 4 进行了测试。
网站有两种语言,input
标签的属性值发生变化。最好尝试使用此 xpath 并应用显式等待。
# Import Required:
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.support.wait import WebDriverWait
driver.get("https://betway.es/es/sports/cpn/tennis/231")
wait = WebDriverWait(driver,30)
username = wait.until(EC.element_to_be_clickable((By.XPATH,"//div[contains(@class,'usernameInput')]/input")))
username.send_keys("Sample Text")
password = wait.until(EC.element_to_be_clickable((By.XPATH,"//div[contains(@class,'passwordInput')]/input")))
password.send_keys("Sample Text")
我正在使用 Selenium 尝试登录网站,但是当我尝试发送密钥时,出现以下错误:selenium.common.exceptions.ElementNotInteractableException: Message: element not interactable
。该网站是:website。
我希望有人能帮助我。
我的代码是:
buttom = browser.find_element_by_class_name("loginInputs").find_element_by_class_name("passwordInput")
buttom.send_keys("password")
它不起作用,因为具有 class 名称 passwordInput
的元素是 <div>
。你想要的是 <input>
元素,所以使用:
password = browser.find_element_by_class_name("loginInputs").find_element_by_class_name("passwordInput").find_element_by_css_selector("input")
password.send_keys("password")
实际上不需要使用嵌套的父子关系来获取登录名-用户名和密码字段,使用 Selenium 填充
username = browser.find_element_by_css_selector("input[placeholder='Username']")
username.send_keys("username")
password = browser.find_element_by_css_selector("input[placeholder='Password']")
password.send_keys("password")
login_btn = browser.find_element_by_css_selector(".loginButton.button.submitButton")
login_btn.click()
完美地完成了输入和提交登录按钮的工作 - 在 Mac 机器上使用 Selenium 4 进行了测试。
网站有两种语言,input
标签的属性值发生变化。最好尝试使用此 xpath 并应用显式等待。
# Import Required:
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.support.wait import WebDriverWait
driver.get("https://betway.es/es/sports/cpn/tennis/231")
wait = WebDriverWait(driver,30)
username = wait.until(EC.element_to_be_clickable((By.XPATH,"//div[contains(@class,'usernameInput')]/input")))
username.send_keys("Sample Text")
password = wait.until(EC.element_to_be_clickable((By.XPATH,"//div[contains(@class,'passwordInput')]/input")))
password.send_keys("Sample Text")