-
Notifications
You must be signed in to change notification settings - Fork 0
/
Cat_CreativeWriting.java
168 lines (142 loc) · 7.38 KB
/
Cat_CreativeWriting.java
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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
package UCSD;
import org.openqa.selenium.By;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.testng.Assert;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
public class Cat_CreativeWriting {
WebDriver driver;
String baseUrl = "http://cmsdevmerge.ucsd.edu/courses-and-programs/creative-writing";
@Test
public void PageTitle() {
String expectedTitle = "Creative Writing | UCSD Extension";
String actualTitle = "";
actualTitle = driver.getTitle();
Assert.assertEquals(actualTitle, expectedTitle);
}
@Test
public void Hero_size() {
int height = driver.findElement(By.xpath("html/body/form/main/section[1]/div/div/div/div[1]")).getSize().getHeight();
int width = driver.findElement(By.xpath("html/body/form/main/section[1]/div/div/div/div[1]")).getSize().getWidth();
System.out.print("height: "+height);
System.out.println(", width: "+width);
if(height >= 449 && width >=1291){
System.out.println("Test - 2 : Passed \n");
} else {
System.out.println("Test - 2 : Failed \n");
}
}
@Test
public void Hero_Label() {
String expectedLabel = "Creative Writing";
String Label = driver.findElement(By.xpath("html/body/form/main/section/div/div/div/div/div/h1")).getText();
System.out.println("Hero label: "+Label);
Assert.assertEquals(Label, expectedLabel);
}
@Test
public void Breadcrumb() {
String expectedBreadCrumb = "Home / Courses and Programs / Creative Writing";
String BreadCrumb = driver.findElement(By.xpath("html/body/form/main/div[2]/div/div/section/div[1]")).getText();
System.out.println("BreadCrumb on AOI - Writing: "+BreadCrumb);
Assert.assertEquals(BreadCrumb, expectedBreadCrumb);
}
@Test
public void CertificateList() {
String Certificate[] = new String[20];
String ExpectedCertificate[] = new String[20];
ExpectedCertificate[1] = "Creative Writing certificate";
ExpectedCertificate[2] = "Digital Media Content Creation certificate";
for(int i=1; i<3; i++){
Certificate[i] = driver.findElement(By.xpath("html/body/form/main/section[3]/div/div/div/div/div[1]/div[2]/ul[1]/li[" + i + "]/a/div/h4")).getText();
System.out.println("Certificate -" + i + " : " + Certificate[i]);
}
Assert.assertEquals(Certificate, ExpectedCertificate);
}
@Test
public void CertificateURL() {
String CertificateURL[] = new String[20];
String ExpectedCertificateURL[] = new String[20];
ExpectedCertificateURL[1] = "http://cmsdevmerge.ucsd.edu/courses-and-programs/creative-writing-certificate";
ExpectedCertificateURL[2] = "http://cmsdevmerge.ucsd.edu/courses-and-programs/digital-media-content-creation";
for(int i=1; i<3; i++){
CertificateURL[i] = driver.findElement(By.xpath("html/body/form/main/section[3]/div/div/div/div/div[1]/div[2]/ul[1]/li[" + i + "]/a")).getAttribute("href");
System.out.println("Certificate URL -" + i + " : " + CertificateURL[i]);
}
Assert.assertEquals(CertificateURL, ExpectedCertificateURL);
}
@Test
public void CourseList() {
String Course[] = new String[30];
String ExpectedCourse[] = new String[30];
ExpectedCourse[1] = "Developing Unforgettable Characters (WCWP-40245)";
ExpectedCourse[2] = "Finding Our Voices, Telling Our Stories (WCWP-40142)";
ExpectedCourse[3] = "Food Writing With Bite (WCWP-40295)";
ExpectedCourse[4] = "Forms of Fiction (WCWP-40189)";
ExpectedCourse[5] = "Forms of Poetry (WCWP-40308)";
ExpectedCourse[6] = "How to Start a Novel (WCWP-40259)";
ExpectedCourse[7] = "Meet the Editors (WCWP-40324)";
ExpectedCourse[8] = "Memoir Writing I (WCWP-40200)";
ExpectedCourse[9] = "Novel Writing I (WCWP-40187)";
ExpectedCourse[10] = "Novel Writing II (WCWP-40297)";
ExpectedCourse[11] = "Screenwriting I (WCWP-40184)";
ExpectedCourse[12] = "The Art and Craft of Creative Writing (WCWP-40107)";
ExpectedCourse[13] = "The Writer's Art of Interviewing (WCWP-40123)";
ExpectedCourse[14] = "Voice and Craft in Writing Poetry (WCWP-40079)";
ExpectedCourse[15] = "Write the Journey: Introduction to the Travel Narrative (WCWP-40132)";
ExpectedCourse[16] = "Writers Workshop: Read and Critique (WCWP-40252)";
ExpectedCourse[17] = "Writing Narrative Non-Fiction (WCWP-40269)";
for(int i=1; i<18; i++){
Course[i] = driver.findElement(By.xpath("html/body/form/main/section[3]/div/div/div/div/div[1]/div[2]/ul[2]/li[" + i + "]/a/div/h4")).getText();
System.out.println("Course -" + i + " : " + Course[i]);
}
Assert.assertEquals(Course, ExpectedCourse);
}
@Test
public void CourseURL() {
String CourseURL[] = new String[30];
String ExpectedCourseURL[] = new String[30];
ExpectedCourseURL[1] = "http://cmsdevmerge.ucsd.edu/courses-and-programs/developing-unforgettable-characters";
ExpectedCourseURL[2] = "http://cmsdevmerge.ucsd.edu/courses-and-programs/finding-our-voices-telling-our-stories";
ExpectedCourseURL[3] = "http://cmsdevmerge.ucsd.edu/courses-and-programs/food-writing-with-bite";
ExpectedCourseURL[4] = "http://cmsdevmerge.ucsd.edu/courses-and-programs/forms-of-fiction";
ExpectedCourseURL[5] = "http://cmsdevmerge.ucsd.edu/courses-and-programs/forms-of-poetry";
ExpectedCourseURL[6] = "http://cmsdevmerge.ucsd.edu/courses-and-programs/how-to-start-a-novel";
ExpectedCourseURL[7] = "http://cmsdevmerge.ucsd.edu/courses-and-programs/meet-the-editors";
ExpectedCourseURL[8] = "http://cmsdevmerge.ucsd.edu/courses-and-programs/memoir-writing-i";
ExpectedCourseURL[9] = "http://cmsdevmerge.ucsd.edu/courses-and-programs/novel-writing-i";
ExpectedCourseURL[10] = "http://cmsdevmerge.ucsd.edu/courses-and-programs/novel-writing-ii";
ExpectedCourseURL[11] = "http://cmsdevmerge.ucsd.edu/courses-and-programs/screenwriting-i";
ExpectedCourseURL[12] = "http://cmsdevmerge.ucsd.edu/courses-and-programs/the-art-and-craft-of-creative-writing";
ExpectedCourseURL[13] = "http://cmsdevmerge.ucsd.edu/courses-and-programs/the-writers-art-of-interviewing";
ExpectedCourseURL[14] = "http://cmsdevmerge.ucsd.edu/courses-and-programs/voice-and-craft-in-writing-poetry";
ExpectedCourseURL[15] = "http://cmsdevmerge.ucsd.edu/courses-and-programs/write-the-journey-introduction-to-the-travel-narrative";
ExpectedCourseURL[16] = "http://cmsdevmerge.ucsd.edu/courses-and-programs/writers-workshop-read-and-critique";
ExpectedCourseURL[17] = "http://cmsdevmerge.ucsd.edu/courses-and-programs/writing-narrative-non-fiction";
for(int i=1; i<18; i++){
CourseURL[i] = driver.findElement(By.xpath("html/body/form/main/section[3]/div/div/div/div/div[1]/div[2]/ul[2]/li[" + i + "]/a")).getAttribute("href");
System.out.println("CourseURL -" + i + " : " + CourseURL[i]);
}
Assert.assertEquals(CourseURL, ExpectedCourseURL);
}
@Test
public void BlogLabel() {
String expectedBlogLabel ="From the Blog";
String BlogLabel = driver.findElement(By.xpath("//*[@id='coursesPrograms']/div/div/div/div/div[2]/h3")).getText();
Assert.assertEquals(BlogLabel, expectedBlogLabel);
}
@BeforeClass
public void beforeMethod() {
System.setProperty("webdriver.chrome.driver", "/home/opendatalabs/tools/selenium/chromedriver");
driver =new ChromeDriver();
driver.get(baseUrl);
}
@AfterClass
public void afterMethod() {
driver.quit();
}
}