-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEmailSender.java
More file actions
84 lines (62 loc) · 2.8 KB
/
Copy pathEmailSender.java
File metadata and controls
84 lines (62 loc) · 2.8 KB
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
package SeleniumProj;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
/**
* Sends an email to the requested email once the course is ready.
*
* @author Aniruthan Ramadoss
*
*/
public class EmailSender {
public static WebDriver driver = null;
/**
* Put the login info of username and password of any yahoomail account as
* the fields. This email will be used to send you the email. I used my own
* to test, but I am not disclosing that info.
*/
private String username =
"Replace this with the yahoo mail username or email you will use to send yourself an email.";
private String password =
"Replace this with the yahoo mail password of the account you will use to send yourself an email.";
private ClassChecker classChecker;
public EmailSender(ClassChecker classChecker) {
this.classChecker = classChecker;
System.setProperty("webdriver.chrome.driver",
"C:\\Users\\Aniruthan Ramadoss\\chromedriver.exe");
driver = new ChromeDriver();
driver.manage().timeouts().implicitlyWait(15, TimeUnit.SECONDS);
sendEmail();
}
private void sendEmail() {
driver.navigate().to("https://yahoomail.com/");
driver.manage().window().maximize();
driver.findElement(By.xpath(
"//*[@id=\"signin-main\"]/div[1]/a[2]/span")).click();
driver.findElement(By.xpath("//*[@id=\"login-username\"]")).sendKeys(
username);
driver.findElement(By.xpath("//*[@id=\"login-signin\"]")).click();
driver.findElement(By.xpath("//*[@id=\"login-passwd\"]")).sendKeys(
password);
driver.findElement(By.xpath("//*[@id=\"login-signin\"]")).click();
driver.findElement(By.xpath(
"//*[@id=\"app\"]/div[2]/div/div[1]/nav/div/div[1]/a")).click();
driver.findElement(By.xpath("//*[@id=\"message-to-field\"]")).sendKeys(
classChecker.getEmail());
driver.findElement(By.xpath(
"//*[@id=\"mail-app-component\"]/div/div/div[1]/div[3]/div/div/input"))
.sendKeys("Your course was found!");
driver.findElement(By.xpath("//*[@id=\"editor-container\"]/div[1]"))
.sendKeys("Your course \nCourse Department: " + classChecker
.getClassDepartment() + "\nCourse Tag: " + classChecker
.getClassNumber() + "\nCRN (if requested): " + classChecker
.getCourseRegistrationNumber() + "\nwas found!");
driver.findElement(By.xpath(
"//*[@id=\"mail-app-component\"]/div/div/div[2]/div[2]/div/button/span"))
.click();
}
public ClassChecker getClassCheckerObject() {
return classChecker;
}
}