-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAOI_DigitalArts_Navigation.java
144 lines (120 loc) · 5.44 KB
/
AOI_DigitalArts_Navigation.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
package UCSD;
import org.openqa.selenium.By;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.StaleElementReferenceException;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.interactions.Actions;
import org.testng.Assert;
import org.testng.annotations.AfterClass;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.BeforeSuite;
import org.testng.annotations.Test;
public class AOI_DigitalArts_Navigation {
WebDriver driver;
String baseUrl = "http://cmsdevmerge.ucsd.edu";
@Test
public void Cat_CAD_BIM() throws InterruptedException {
driver.findElement(By.xpath("//ul[@id='main-menu']/li/a")).click();
Actions builder = new Actions(driver);
try {
Thread.sleep(2000);
WebElement AOIMenu = driver.findElement(By.xpath("//a[contains(@href, '/courses-and-programs/digital-arts')]"));
builder.moveToElement(AOIMenu).click().build().perform();
Thread.sleep(1000);
WebElement SubMenu = driver.findElement(By.xpath("//a[contains(@href, '/courses-and-programs/cad')]"));
builder.moveToElement(SubMenu).build().perform();
SubMenu.click();
SubMenu.click();
}catch(StaleElementReferenceException e){};
String CurrentURL = driver.getCurrentUrl();
String ExpectedCurrentURL = "http://cmsdevmerge.ucsd.edu/courses-and-programs/cad";
Assert.assertEquals(CurrentURL, ExpectedCurrentURL);
}
@Test
public void Cat_GraphicWebDesign() throws InterruptedException {
driver.findElement(By.xpath("//ul[@id='main-menu']/li/a")).click();
Actions builder = new Actions(driver);
try {
Thread.sleep(2000);
WebElement AOIMenu = driver.findElement(By.xpath("//a[contains(@href, '/courses-and-programs/digital-arts')]"));
builder.moveToElement(AOIMenu).click().build().perform();
Thread.sleep(1000);
WebElement SubMenu = driver.findElement(By.xpath("//a[contains(@href, '/courses-and-programs/graphic-and-web-design')]"));
builder.moveToElement(SubMenu).build().perform();
SubMenu.click();
SubMenu.click();
}catch(StaleElementReferenceException e){};
String CurrentURL = driver.getCurrentUrl();
String ExpectedCurrentURL = "http://cmsdevmerge.ucsd.edu/courses-and-programs/graphic-and-web-design";
Assert.assertEquals(CurrentURL, ExpectedCurrentURL);
}
@Test
public void Cat_Photography() throws InterruptedException {
driver.findElement(By.xpath("//ul[@id='main-menu']/li/a")).click();
Actions builder = new Actions(driver);
try {
Thread.sleep(2000);
WebElement AOIMenu = driver.findElement(By.xpath("//a[contains(@href, '/courses-and-programs/digital-arts')]"));
builder.moveToElement(AOIMenu).click().build().perform();
Thread.sleep(1000);
WebElement SubMenu = driver.findElement(By.xpath("(//a[contains(text(),'Photography')])[2]"));
builder.moveToElement(SubMenu).build().perform();
SubMenu.click();
SubMenu.click();
}catch(StaleElementReferenceException e){};
String CurrentURL = driver.getCurrentUrl();
String ExpectedCurrentURL = "http://cmsdevmerge.ucsd.edu/courses-and-programs/photography";
Assert.assertEquals(CurrentURL, ExpectedCurrentURL);
}
@Test
public void Cat_UserExperienceDesign() throws InterruptedException {
driver.findElement(By.xpath("//ul[@id='main-menu']/li/a")).click();
Actions builder = new Actions(driver);
try {
Thread.sleep(2000);
WebElement AOIMenu = driver.findElement(By.xpath("//a[contains(@href, '/courses-and-programs/digital-arts')]"));
builder.moveToElement(AOIMenu).click().build().perform();
Thread.sleep(1000);
WebElement SubMenu = driver.findElement(By.xpath("//a[contains(@href, '/courses-and-programs/ux-design')]"));
builder.moveToElement(SubMenu).build().perform();
SubMenu.click();
SubMenu.click();
}catch(StaleElementReferenceException e){};
String CurrentURL = driver.getCurrentUrl();
String ExpectedCurrentURL = "http://cmsdevmerge.ucsd.edu/courses-and-programs/ux-design";
Assert.assertEquals(CurrentURL, ExpectedCurrentURL);
}
@Test
public void Cat_VideoEditing() throws InterruptedException {
driver.findElement(By.xpath("//ul[@id='main-menu']/li/a")).click();
Actions builder = new Actions(driver);
try {
Thread.sleep(2000);
WebElement AOIMenu = driver.findElement(By.xpath("//a[contains(@href, '/courses-and-programs/digital-arts')]"));
builder.moveToElement(AOIMenu).click().build().perform();
Thread.sleep(1000);
WebElement SubMenu = driver.findElement(By.xpath("//a[contains(@href, '/courses-and-programs/video-and-editing')]"));
builder.moveToElement(SubMenu).build().perform();
SubMenu.click();
SubMenu.click();
}catch(StaleElementReferenceException e){};
String CurrentURL = driver.getCurrentUrl();
String ExpectedCurrentURL = "http://cmsdevmerge.ucsd.edu/courses-and-programs/video-and-editing";
Assert.assertEquals(CurrentURL, ExpectedCurrentURL);
}
@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();
}
}