I am trying to code a python program with Selenium which writes and sends a mail on the following website: http://www.laposte.net/accueil
Here is my code:
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
driver = webdriver.Chrome()
driver.get("https://www.laposte.net/accueil")
pseudo = driver.find_element_by_name("login")
mdp = driver.find_element_by_name("password")
pseudo.send_keys("testselenium@laposte.net")
mdp.send_keys("Testselenium1")
pseudo.submit()
newmess = driver.find_element_by_id("zb__NEW_MENU")
newmess.click()
destinataire = driver.find_element_by_id("zv__COMPOSE-1_to_control")
destinataire.send_keys("adress@gmail.com")
objet = driver.find_element_by_id("zv__COMPOSE-1_subject_control")
objet.send_keys("Test selenium")
texte = driver.find_element_by_xpath("//body[@class='mceContentBody']")
texte.send_keys("Test")
My code works, but I am unable to put some text in my body message.
I get this error: Unable to locate element: {"method":"xpath", "selector":"//body[@class='mceContentBody']"}
For information, the HTML code of the text box is:
<body id="tinymce" class="mceContentBody "
onload="window.parent.tinyMCE.get('DWT48_content').onLoad.dispatch();"
contenteditable="true" dir="LTR" style="font-family: "times new
roman", "new york", times, serif; font-size: 14pt; color:
rgb(0, 0, 0);"><div><br></div></body>
Would you have any idea to write some text in the mail?
Thanks.
Lcs
On the second to last line you are writing:
texte = driver.find_element_id("tinymce")
Shouldn't the method-call instead be:
texte = driver.find_element_by_id("tinymce")
(note the " by ")
是因为类属性末尾有一些额外的空间吗?
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.