-
Notifications
You must be signed in to change notification settings - Fork 0
/
AOI_Law_Navigation.java
101 lines (84 loc) · 3.76 KB
/
AOI_Law_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_Law_Navigation {
WebDriver driver;
String baseUrl = "http://cmsdevmerge.ucsd.edu/courses-and-programs/law";
@Test
public void Cat_AdvancedLEgalEducation() 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/law')]"));
builder.moveToElement(AOIMenu).click().build().perform();
Thread.sleep(1000);
WebElement SubMenu = driver.findElement(By.xpath("//a[contains(@href, '/courses-and-programs/advanced-legal-education')]"));
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/advanced-legal-education";
Assert.assertEquals(CurrentURL, ExpectedCurrentURL);
}
@Test
public void Cat_IntellectualProperty() 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/law')]"));
builder.moveToElement(AOIMenu).click().build().perform();
Thread.sleep(1000);
WebElement SubMenu = driver.findElement(By.xpath("//a[contains(@href, '/courses-and-programs/intellectual-property')]"));
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/intellectual-property";
Assert.assertEquals(CurrentURL, ExpectedCurrentURL);
}
@Test
public void Cat_ParalegalStudies() 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/law')]"));
builder.moveToElement(AOIMenu).click().build().perform();
Thread.sleep(1000);
WebElement SubMenu = driver.findElement(By.xpath("//a[contains(@href, '/courses-and-programs/paralegal-studies')]"));
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/paralegal-studies";
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();
}
}