使用Python中的Selenium登录gmail我正在尝试使用Selenium登录gmail。在新的Gmail登录中,首先键入您的电子邮件ID,然后在您输入密码的位置输入下一页。电子邮件页面和密码页面的URL都不同。因此,当我传递密码URL时,driver.get它正在重新加载页面,如果您刷新URL而不输入密码,它会重定向到电子邮件页面。因此,它缺少密码字段选择器。current_url仍然是以前的网址,即电子邮件页面的网址。这是我的代码。我正在使用chrome驱动程序和python 2.X.import osfrom selenium import webdriverfrom selenium.webdriver.common.keys import Keyschromedriver = "/Documents/chromedriver" # Path to chrome-driveros.environ["webdriver.chrome.driver"] = chromedriverdriver = webdriver.Chrome(chromedriver)# Email insert driver.get("https://accounts.google.com/signin/v2/identifier?service=mail&passive=true&rm=false&continue=https%3A%2F%2Fmail.google.com%2Fmail%2F&ss=1&scc=1<mpl=default<mplcache=2&emr=1&osid=1&flowName=GlifWebSignIn&flowEntry=ServiceLogin") #URL of email pageusername = driver.find_element_by_id("identifierId")username.send_keys("myemail")driver.find_element_by_id("identifierNext").click()# Password Insert driver.get("https://accounts.google.com/signin/v2/identifier?service=mail&passive=true&rm=false&continue=https%3A%2F%2Fmail.google.com%2Fmail%2F&ss=1&scc=1<mpl=default<mplcache=2&emr=1&osid=1&flowName=GlifWebSignIn&flowEntry=ServiceLogin") # URL of password pagepassword = driver.find_element_by_id("password")password.send_keys("mypassword")driver.find_element_by_id("passwordNext").click()#driver.quit()
添加回答
举报
0/150
提交
取消