Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
81 changes: 81 additions & 0 deletions src/AddImageAccount.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
package tests;

import java.awt.Toolkit;
import java.awt.datatransfer.Clipboard;
import java.awt.datatransfer.StringSelection;
import java.util.List;
import java.util.concurrent.TimeUnit;

import org.junit.*;

import static org.junit.Assert.*;

import org.openqa.selenium.*;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.interactions.Actions;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;

public class AddImageAccount {
private WebDriver driver;
private String baseUrl;
private StringBuffer verificationErrors = new StringBuffer();
private String imageToRemove;

@Before
public void setUp() throws Exception {
driver = new FirefoxDriver();
baseUrl = "http://imgur.com";
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
login();
}

@Test
public void testAddImageAccount() throws Exception {
StringSelection selection = new StringSelection("http://i.imgur.com/xY3TaEV.png");
Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
clipboard.setContents(selection, selection);

driver.findElement(By.className("upload-button")).click();
WebElement textArea = driver.findElement(By.id("upload-global-link-input"));
new Actions( driver ).contextClick(textArea).sendKeys( "p" ).perform();
driver.findElement(By.id("upload-global-start-button")).submit();
WebElement nicetime = (new WebDriverWait(driver, 10)).until(ExpectedConditions.presenceOfElementLocated(By.id("nicetime")));
String code = driver.getCurrentUrl().substring(17);
imageToRemove = code;
driver.get("http://cs1699testing.imgur.com/all");
List<WebElement> list = driver.findElements(By.id(imageToRemove));
assertTrue(list.size() > 0);
logout();
}

@After
public void tearDown() throws Exception {
login();
driver.get("http://cs1699testing.imgur.com/all/");
WebElement hoverElement = driver.findElement(By.id(imageToRemove));
Actions builder = new Actions(driver);
builder.moveToElement(hoverElement).perform();
driver.findElement(By.cssSelector("#" + imageToRemove + " > div:nth-child(3) > div:nth-child(2)")).click();
driver.findElement(By.id("delete-button")).click();
driver.quit();
String verificationErrorString = verificationErrors.toString();
if (!"".equals(verificationErrorString)) {
fail(verificationErrorString);
}
}

private void login() {
driver.get(baseUrl + "/signin");
driver.findElement(By.id("username")).sendKeys("cs1699testing");
driver.findElement(By.id("password")).sendKeys("laboontesting");
driver.findElement(By.name("submit")).click();
}

public void logout() {
WebElement hoverElement = driver.findElement(By.id("secondary-nav"));
Actions builder = new Actions(driver);
builder.moveToElement(hoverElement).perform();
driver.findElement(By.xpath("//div[@class='dropdown-footer']//a[contains(text(),'logout')]")).click();
}
}
90 changes: 90 additions & 0 deletions src/AddToAlbum.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
package tests;

import java.util.List;
import java.util.concurrent.TimeUnit;

import org.junit.*;

import static org.junit.Assert.*;

import org.openqa.selenium.*;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.interactions.Actions;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;

public class AddToAlbum {
private WebDriver driver;
private String baseUrl;
private StringBuffer verificationErrors = new StringBuffer();

@Before
public void setUp() throws Exception {
driver = new FirefoxDriver();
baseUrl = "http://imgur.com";
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
login();
}



@Test
public void testAddToAlbum() throws Exception {
// Get the album page
driver.get("http://cs1699testing.imgur.com/");
WebElement hoverElement = driver.findElement(By.xpath("//div[@data-title='Test Album']"));
Actions builder = new Actions(driver);
builder.moveToElement(hoverElement).perform();
driver.findElement(By.xpath("//div[@data-title='Test Album']/div[4]")).click();
new WebDriverWait(driver, 10).until(ExpectedConditions.visibilityOf(driver
.findElement(By.xpath("//div[@data-title='Test Album']//div[@class='item album-images-link']"))));
driver.findElement(By.xpath("//div[@data-title='Test Album']//div[@class='item album-images-link']")).click();
driver.findElement(By.xpath("//div[@id='images-menu']/div[2]")).click();
driver.findElement(By.id("MNhewWN")).click();
driver.findElement(By.name("submit")).click();
driver.get("http://imgur.com/a/Yexh0");
//driver.findElement(By.xpath("//div[@data-title='Test Album']/div[@class='cover']/a")).click();
List<WebElement> list = driver.findElements(By.id("MNhewWN"));
assertTrue(list.size() > 0);
logout();
}

@After
public void tearDown() throws Exception {
login();
driver.get("http://cs1699testing.imgur.com/");
WebElement hoverElement = driver.findElement(By.xpath("//div[@data-title='Test Album']"));

Actions builder = new Actions(driver);
builder.moveToElement(hoverElement).perform();
driver.findElement(By.xpath("//div[@data-title='Test Album']/div[4]")).click();
new WebDriverWait(driver, 10).until(ExpectedConditions.visibilityOf(driver
.findElement(By.xpath("//div[@data-title='Test Album']//div[@class='item album-images-link']"))));
System.out.println(7);
driver.findElement(By.xpath("//div[@data-title='Test Album']//div[@class='item album-images-link']")).click();
driver.findElement(By.xpath("//div[@id='images-menu']/div[1]")).click();
driver.findElement(By.id("MNhewWN")).click();
driver.findElement(By.name("submit")).click();
driver.quit();
String verificationErrorString = verificationErrors.toString();
if (!"".equals(verificationErrorString)) {
fail(verificationErrorString);
}
}


private void login() {
driver.get(baseUrl + "/signin");
driver.findElement(By.id("username")).sendKeys("cs1699testing");
driver.findElement(By.id("password")).sendKeys("laboontesting");
driver.findElement(By.name("submit")).click();
}

public void logout() {
WebElement hoverElement = driver.findElement(By.id("secondary-nav"));
Actions builder = new Actions(driver);
builder.moveToElement(hoverElement).perform();
driver.findElement(By.xpath("//div[@class='dropdown-footer']//a[contains(text(),'logout')]")).click();
}

}
80 changes: 80 additions & 0 deletions src/DeleteImage.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
package tests;

import java.awt.Toolkit;
import java.awt.datatransfer.Clipboard;
import java.awt.datatransfer.StringSelection;
import java.util.List;
import java.util.concurrent.TimeUnit;

import org.junit.*;

import static org.junit.Assert.*;

import org.openqa.selenium.*;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.interactions.Actions;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;

public class DeleteImage {
private WebDriver driver;
private String baseUrl;
private StringBuffer verificationErrors = new StringBuffer();
private String imageToRemove;

@Before
public void setUp() throws Exception {
driver = new FirefoxDriver();
baseUrl = "http://imgur.com";
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
login();
StringSelection selection = new StringSelection("http://i.imgur.com/xY3TaEV.png");
Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
clipboard.setContents(selection, selection);

driver.findElement(By.className("upload-button")).click();
WebElement textArea = driver.findElement(By.id("upload-global-link-input"));
new Actions( driver ).contextClick(textArea).sendKeys( "p" ).perform();
driver.findElement(By.id("upload-global-start-button")).submit();
WebElement nicetime = (new WebDriverWait(driver, 10)).until(ExpectedConditions.presenceOfElementLocated(By.id("nicetime")));
String code = driver.getCurrentUrl().substring(17);
imageToRemove = code;
driver.get("http://cs1699testing.imgur.com/all");
}

@Test
public void testDeleteImage() throws Exception {
driver.get("http://cs1699testing.imgur.com/all/");
WebElement hoverElement = driver.findElement(By.id(imageToRemove));
Actions builder = new Actions(driver);
builder.moveToElement(hoverElement).perform();
driver.findElement(By.cssSelector("#" + imageToRemove + " > div:nth-child(3) > div:nth-child(2)")).click();
driver.findElement(By.id("delete-button")).click();
driver.get("http://cs1699testing.imgur.com/all/");
List<WebElement> list = driver.findElements(By.id(imageToRemove));
assertTrue(list.size() == 0);
}

@After
public void tearDown() throws Exception {
driver.quit();
String verificationErrorString = verificationErrors.toString();
if (!"".equals(verificationErrorString)) {
fail(verificationErrorString);
}
}

private void login() {
driver.get(baseUrl + "/signin");
driver.findElement(By.id("username")).sendKeys("cs1699testing");
driver.findElement(By.id("password")).sendKeys("laboontesting");
driver.findElement(By.name("submit")).click();
}

public void logout() {
WebElement hoverElement = driver.findElement(By.id("secondary-nav"));
Actions builder = new Actions(driver);
builder.moveToElement(hoverElement).perform();
driver.findElement(By.xpath("//div[@class='dropdown-footer']//a[contains(text(),'logout')]")).click();
}
}
61 changes: 61 additions & 0 deletions src/Favorites.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
package tests;

import java.util.List;
import java.util.concurrent.TimeUnit;

import org.junit.*;

import static org.junit.Assert.*;

import org.openqa.selenium.*;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.interactions.Actions;

public class Favorites {
private WebDriver driver;
private String baseUrl;
private StringBuffer verificationErrors = new StringBuffer();

@Before
public void setUp() throws Exception {
driver = new FirefoxDriver();
baseUrl = "http://imgur.com";
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
}

@Test
public void testFavorite() throws Exception {
login();
driver.get("http://imgur.com/HegrNXq");
driver.findElement(By.cssSelector(".favorite-image")).click();
driver.get("https://imgur.com/user/cs1699testing/favorites");
List<WebElement> list = driver.findElements(By.xpath("//a[@href='/user/cs1699testing/favorites/HegrNXq']"));
assertTrue(list.size() > 0);
logout();
}
@After
public void tearDown() throws Exception {
login();
driver.get("http://imgur.com/HegrNXq");
driver.findElement(By.cssSelector(".favorite-image")).click();
driver.quit();
String verificationErrorString = verificationErrors.toString();
if (!"".equals(verificationErrorString)) {
fail(verificationErrorString);
}
}

private void login() {
driver.get(baseUrl + "/signin");
driver.findElement(By.id("username")).sendKeys("cs1699testing");
driver.findElement(By.id("password")).sendKeys("laboontesting");
driver.findElement(By.name("submit")).click();
}

public void logout() {
WebElement hoverElement = driver.findElement(By.id("secondary-nav"));
Actions builder = new Actions(driver);
builder.moveToElement(hoverElement).perform();
driver.findElement(By.xpath("//div[@class='dropdown-footer']//a[contains(text(),'logout')]")).click();
}
}
Loading