Python 我能';不进行基本登录-可以';我找不到目标
我正在尝试对网站进行基本登录,但无法访问2个对象: 密码字段和按钮 网址为: 我试图通过Python 我能';不进行基本登录-可以';我找不到目标,python,python-3.x,selenium,authentication,selenium-webdriver,Python,Python 3.x,Selenium,Authentication,Selenium Webdriver,我正在尝试对网站进行基本登录,但无法访问2个对象: 密码字段和按钮 网址为: 我试图通过id或class或XPATH查找元素,我找到的是“login”文本框,而不是“password” 我已检查属性的名称: print(driver.find_element_by_css_selector("input#password.top_field.w-input").get_attribute("name")) driver = webdriver.Chrome() driver.get(LOGIN
id
或class
或XPATH
查找元素,我找到的是“login”
文本框,而不是“password”
我已检查属性的名称:
print(driver.find_element_by_css_selector("input#password.top_field.w-input").get_attribute("name"))
driver = webdriver.Chrome()
driver.get(LOGIN_URL)
driver.find_element_by_id("login").clear()
driver.find_element_by_id("login").send_keys(login)
driver.find_element_by_id("password").click()
driver.find_element_by_class_name("top_field w-input").click()
此外,我还想尝试一下:
driver.find_element_by_css_selector("input#password.top_field.w-input").send_keys(password)
驱动程序。按类名称(“顶部按钮.w按钮”)查找元素。单击()
但它仍然无法到达密码字段
我做错了什么?元素有两个类,因此必须用替换空格。在你的代码中 你必须使用下面的一行
# password
driver.find_element_by_css_selector("input#password.top_field.w-input").send_keys('hello')
# click on button
driver.find_element_by_class_name("top_button.w-button").click()
屏幕截图:
解决了它!:)
嗨-我收到错误:selenium.common.exceptions.elementnotinteractitableexception:Message:element notinteractitable(会话信息:chrome=76.0.3809.132)我的代码是:driver=webdriver.chrome()driver.get(LOGIN\u URL)driver.get(LOGIN\u URL)driver.find\u element\u by\u id(“LOGIN”).clear()driver.find\u element\u-by\u-id(“LOGIN”).send\u-key(LOGIN)driver.find_element_by_id(“login”)。send_keys(keys.TAB)driver.find_element_by_css_selector('input#password.top_field.w-input哪一行给出了
elementnotinteractiableexception
)?尽量不要在代码中使用休眠。最好使用显式等待。
driver = webdriver.Chrome()
driver.get(LOGIN_URL)
driver.find_element_by_id("login").clear()
driver.find_element_by_id("login").send_keys(login)
driver.find_element_by_id("login").send_keys(Keys.TAB)
time.sleep(3)
actions = ActionChains(driver)
actions.send_keys(password)
actions.perform()
driver.find_element_by_class_name("top_button.w-button").click()