-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAOI_EnvironmentSustainability_Navigation.java
101 lines (84 loc) · 3.88 KB
/
AOI_EnvironmentSustainability_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
package UCSD;
import org.openqa.selenium.By;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.NoSuchElementException;
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.Test;
public class AOI_EnvironmentSustainability_Navigation {
WebDriver driver;
String baseUrl = "http://cmsdevmerge.ucsd.edu/courses-and-programs/environment-and-sustainability";
@Test
public void Cat_EnvironmentManagement() 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/environment-and-sustainability')]"));
builder.moveToElement(AOIMenu).click().build().perform();
Thread.sleep(1000);
WebElement SubMenu = driver.findElement(By.xpath("//a[contains(@href, '/courses-and-programs/environmental-management')]"));
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/environmental-management";
Assert.assertEquals(CurrentURL, ExpectedCurrentURL);
}
@Test
public void Cat_Sustainibility() 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/environment-and-sustainability')]"));
builder.moveToElement(AOIMenu).click().build().perform();
Thread.sleep(1000);
WebElement SubMenu = driver.findElement(By.xpath("//a[contains(@href, '/courses-and-programs/sustainability')]"));
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/sustainability";
Assert.assertEquals(CurrentURL, ExpectedCurrentURL);
}
@Test
public void Cat_UrbanPlanningAndPreservation() 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/environment-and-sustainability')]"));
builder.moveToElement(AOIMenu).click().build().perform();
Thread.sleep(1000);
WebElement SubMenu = driver.findElement(By.xpath("//a[contains(@href, '/courses-and-programs/urban-planning-courses')]"));
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/urban-planning-courses";
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();
}
}