蟹老板要坚持健身
2021-08-16 23:13
采纳率: 85.7%
浏览 52
已结题

selenium自动化填充账号和密码失败

各位好,这是我的一段代码,不知道为什么进入网站后,不会自动填充账号和密码。实在是不知道问题出在哪里(有考虑过是否是节点定位的问题),麻烦大家啦!不胜感激!
img

这是报错提示:

img

下面是相关代码:

import time
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC

EMAIL = '422935573@qq.com'
PASSWORD = '123456'
url = 'https://account.geetest.com/login'
browser = webdriver.Chrome()
browser.get(url)
wait = WebDriverWait(browser, 10)
email = wait.until(EC.presence_of_element_located((By.ID, 'email')))
password = wait.until(EC.presence_of_element_located((By.ID, 'password')))
email.send_keys(EMAIL)
password.send_keys(PASSWORD)

  • 收藏

3条回答 默认 最新

  • 喜欢摸鱼的程序员 2021-08-17 10:21
    已采纳

    ???你这个等待方法有问题把 哪个站点发出来看看

    打赏 评论
    1人已打赏
  • C_Code_P 2021-08-16 23:49
    
    from time import sleep
    
    from selenium import webdriver
    
    driver = webdriver.Chrome(executable_path="./chromedriver.exe")
    driver.get('https://auth.geetest.com/login/')
    print(driver.page_source)
    sleep(0.4)
    driver.find_element_by_xpath('//div[@class="ivu-form-item-content"]/div/input[@placeholder="请输入邮箱"]').send_keys(
        '2516455367')
    sleep(0.4)
    driver.find_element_by_xpath('//div[@class="ivu-form-item-content"]/div/input[@placeholder="请输入密码"]').send_keys(
        '123456')
    driver.close()
    
    打赏 评论
  • C_Code_P 2021-08-17 16:14

    还得我活雷锋出马

    from time import sleep
    
    from selenium import webdriver
    
    driver = webdriver.Chrome(executable_path="./chromedriver.exe")
    driver.get('https://auth.geetest.com/login/')
    print(driver.page_source)
    sleep(0.4)
    driver.find_element_by_xpath('//div[@class="ivu-form-item-content"]/div/input[@placeholder="请输入邮箱"]').send_keys(
        '2516455367')
    sleep(0.4)
    driver.find_element_by_xpath('//div[@class="ivu-form-item-content"]/div/input[@placeholder="请输入密码"]').send_keys(
        '123456')
    driver.close()
    
    
    打赏 评论

相关推荐 更多相似问题