-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathemail_posting.py
48 lines (39 loc) · 1.93 KB
/
email_posting.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import unittest
from selenium import webdriver
import time
import random
import string
class Test(unittest.TestCase):
def testName(self):
def randomString(stringLength=10):
letters = string.ascii_lowercase
return ''.join(random.choice(letters) for i in range(stringLength))
#create driver variable
driver = webdriver.Chrome("C:/chromedriver.exe")
#passing the link to the chrome driver
driver.get("https://www.trash-mail.com/new-address/")
#maximize the window
driver.maximize_window()
time.sleep(5)
email = driver.find_element_by_css_selector("input#form-postbox-new").send_keys(randomString(10))
password = driver.find_element_by_css_selector("input#form-password-new1").send_keys("abcd!@#$")
confirmPassword = driver.find_element_by_css_selector("input#form-password-new2").send_keys("abcd!@#$")
signUpButton = driver.find_element_by_css_selector("button#create-mail").click()
composeButton = driver.find_element_by_css_selector("a[href*='/compose-mail']").click()
time.sleep(2)
receiverEmail = driver.find_element_by_css_selector("input#form-to").send_keys("[email protected]")
time.sleep(2)
subjectOfEmail = driver.find_element_by_css_selector("input#form-subject").send_keys("Python Assignment")
time.sleep(3)
emailBody = driver.find_element_by_css_selector("div#editor") \
.send_keys("Hello\nThis is a python code\n\nThanks and Regards\nPython Team")
time.sleep(2)
attachFile = driver.find_element_by_css_selector("input[type='file']")
time.sleep(5)
attachFile.send_keys("C:/Users/Shristi/PycharmProjects/hello/email_posting.py")
time.sleep(2)
sendMailBtn = driver.find_element_by_css_selector("button#send-mails").click()
time.sleep(2)
driver.close()
if __name__ == "__main__":
unittest.main()