Ich versuche, eine automatische E-Mail von Gmail mit Bcc zu erstellen. Ich habe einen Code mit Python 2.7 erstellt, um eine automatische Email zu erstellen, aber ohne die bcc's. Ich weiß nicht, wie ich es machen soll.XPath Selen automatische E-Mail Python
Das Problem ist, wenn ich versuche, den Code auszuführen. Ich extrahiere den Xpath-Code für bcc auf meiner E-Mail und dann lege ich ihn auf den Python-Code. Wenn ich das täte, erhalte ich diesen Fehler:
selenium.common.exceptions.StaleElementReferenceException: Message: stale element reference: element is not attached to the page document
import time
from selenium import webdriver
#Cargar Chrome Driver
driver = webdriver.Chrome('/Users/Martin/Desktop/chromedriver')
#Cargar direccion a la que queremos acceder
driver.get("https://www.google.com/gmail/")
#Usuario
email = driver.find_element_by_xpath('//*[@id="identifierId"]')
email.send_keys("usr")
#Next
l_button = driver.find_element_by_xpath('//*[@id="identifierNext"]/content/span')
l_button.click()
time.sleep(1)
#Contraseña
passwd = driver.find_element_by_xpath('//*[@id="password"]/div[1]/div/div[1]/input')
passwd.send_keys("pass")
#Login
l_button = driver.find_element_by_xpath('//*[@id="passwordNext"]/content/span')
l_button.click()
time.sleep(1)
#Nuevo Email
l_button = driver.find_element_by_xpath('//*[@id=":3z"]/div/div')
l_button.click()
l_button = driver.find_element_by_xpath('//*[@id=":1k6"]')
l_button.click()
time.sleep(1)
#Direcciones
redactar = driver.find_element_by_xpath('//*[@id=":u7"]')
redactar.send_keys("[email protected] ", " [email protected] ")
dank
Oh mein - warum sind Sie nicht nur mit [ 'smtplib'] (https://docs.python.org/2/library/smtplib.html) und Senden Sie Ihre E-Mails direkt über die SMTP-Server von Google Mail? –
Ich werde versuchen, aber wie kann ich die ID-E-Mails in BBC hinzufügen ?? @LukasGraf –
Sie haben den Fehler nicht veröffentlicht. – JeffC