-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEmail.py
69 lines (51 loc) · 2.09 KB
/
Email.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# -*- coding: utf-8 -*-
"""
Created on Sun Feb 28 19:38:28 2021
@author: rimes
"""
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from tkinter import Tk
from InputWindow import UserInputWindow
def getUserInput(title, prompt):
root = Tk()
root.geometry("250x150+300+300")
app = UserInputWindow(title, prompt)
root.mainloop()
return app.getValue()
def logIn(browser):
UserEmail = getUserInput("Email Adress", "Please enter email adress:")
email = browser.find_element_by_tag_name('input')
email.send_keys(UserEmail)
nextBttn = browser.find_element_by_class_name("VfPpkd-RLmnJb")
nextBttn.click()
password = WebDriverWait(browser,10).until(EC.element_to_be_clickable((By.XPATH,"//input[@name='password']")))
UserPassword = getUserInput("User Password", "Please enter your passoword:")
password.send_keys(UserPassword)
submit = browser.find_element_by_class_name('VfPpkd-RLmnJb')
submit.click()
def sendEmail(browser):
mail = WebDriverWait(browser,10).until(EC.element_to_be_clickable((By.CSS_SELECTOR,".gb_g")))
mail.click()
compose = WebDriverWait(browser,10).until(EC.element_to_be_clickable((By.CSS_SELECTOR,".z0")))
compose.click()
to = WebDriverWait(browser,10).until(EC.element_to_be_clickable((By.CSS_SELECTOR,".vO")))
to.send_keys("[email protected]")
subject = browser.find_element_by_class_name('aoT')
subject.send_keys("Test 3")
text = browser.find_element_by_css_selector('.Ar.Au')
text.click()
message = browser.find_element_by_css_selector('.Am.Al.editable.LW-avf.tS-tW')
message.send_keys("Test -")
send = browser.find_element_by_class_name("dC")
send.click()
if __name__ == "__main__":
browser = webdriver.Chrome()
browser.get('https://google.com/')
signIn = browser.find_element_by_link_text('Sign in')
signIn.click()
logIn(browser)
sendEmail(browser)
browser.close()