forked from devansh-jain-2002/IITK-Webmail-Automation
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
45 lines (38 loc) · 1.65 KB
/
main.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
import sys
from time import sleep
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.wait import WebDriverWait
with open("cred.txt","r") as f:
cred = f.read()
with open("recv.txt","r") as f:
recv = f.read()
credarr = cred.split("\n")
name = credarr[0];
passwd = credarr[1];
recv_list = recv.split("\n")
subject = "Subject"
if (sys.argv[1] == "firefox"):
from selenium.webdriver.firefox.options import Options as FFOptions
options = FFOptions()
driver = webdriver.Firefox(options=options)
else:
from selenium.webdriver.chrome.service import Service as ChromeService
from webdriver_manager.chrome import ChromeDriverManager
driver = webdriver.Chrome(service=ChromeService(executable_path=ChromeDriverManager().install()))
driver.implicitly_wait(20)
driver.get("https://nwm.iitk.ac.in/")
driver.find_element(by = By.ID , value="rcmloginuser").send_keys(name)
driver.find_element(by = By.ID , value="rcmloginpwd").send_keys(passwd)
driver.find_element(by = By.ID , value="rcmloginsubmit").click()
for to in recv_list :
driver.find_element(by = By.ID , value="rcmbtn109").click()
driver.find_element(by = By.CSS_SELECTOR , value = "#compose_to > div > div > ul > li > input").send_keys(to)
driver.find_element(by = By.ID, value = "compose-subject").send_keys(subject)
iframe = driver.find_element(by = By.ID, value = "composebody_ifr")
driver.switch_to.frame(iframe)
driver.find_element(by = By.CSS_SELECTOR, value = "#tinymce > p").send_keys ("Hello Guys")
driver.switch_to.default_content()
driver.find_element(by = By.ID , value = "rcmbtn115" ).click()
sleep(10)
driver.quit()