我使用python脚本在Chrome中登录到gmail,但是在点击下一步代码返回错误之后,任何人都可以请帮助我什么是错误的,我是python新手。下面是我使用的代码。如何使用python在窗口中使用chrome登录到gmail
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.select import Select
import threading
import os,time,csv,datetime
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import Select
a = webdriver.Chrome()
a.get("https://accounts.google.com/")
user = a.find_element_by_id("Email")
user.send_keys('[email protected]')
login = a.find_element_by_id("next")
login.click()
pwd = WebDriverWait(a, 10).until(EC.presence_of_element_located((By.ID, "Passwd")))
pwd.send_keys('p######')
login = a.find_element_by_id("signIn")
login.click()
clk = WebDriverWait(a, 10).until(EC.presence_of_element_located((By.LINK_TEXT, 'myaccount')))
clk.click()
logout = WebDriverWait(a, 10).until(EC.presence_of_element_located((By.ID, "gb_71")))
logout.click()
下面是错误:
回溯(最近通话最后一个): 文件 “C:\用户\ mapraveenkumar \文档\ Python的\ gmail.py”,第20行,在 CLK = WebDriverWait(a,10).until(EC.presence_of_element_located((By.LINK_TEXT,'myaccount'))) 文件“C:\ Users \ mapraveenkumar \ AppData \ Local \ Programs \ Python \ Python36-32 \ lib \ site- package \ selenium \ webdriver \ support \ wait.py“,第80行,直到 raise TimeoutException(message,screen,stacktrace) selenium.common.exceptions.TimeoutException:消息:
请添加错误.. – franklinsijo
这是错误:文件 “C:/Users/mapraveenkumar/Documents/Python/gmail.py”,第12行,在 PWD = a.find_element_by_css_selector(“#Passwd”) 文件“C:\ Users \ mapraveenkumar \ AppData \ Local \ Programs \ Python \ Python36-32 \ lib \ site-packages \ selenium \ webdriver \ remote \ webdriver.py”,第437行,在find_element_by_css_selector中返回self.find_element(by = By.CSS_SELECTOR,value = css_selector) –
用错误更新帖子,不在注释中。并且您发布的错误代码不匹配 – franklinsijo