Skip to content
This repository has been archived by the owner on Apr 4, 2023. It is now read-only.

Solves issue #13 (create share test suite) #21 (share test suite) and #3(create pool test suite) #23

Merged
merged 5 commits into from
Jun 20, 2013
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -114,19 +114,19 @@ public void testShareUsedandFreeSpace() throws Exception {

WebElement shareLink = driver.findElement(By.linkText("share1"));
shareLink.click();


// check for Free and Used Space in the share size graph
WebElement checkShareFreeSpace =driver.findElement(
By.xpath("//*[name()='svg']/*[name()='g']/*[name()='text' and contains(.,'% free')]"));

assertTrue(checkShareFreeSpace.getText(), true);

WebElement checkShareUsedSpace =driver.findElement(
By.xpath("//*[name()='svg']/*[name()='g']/*[name()='text' and contains(.,'% used')]"));

assertTrue(checkShareUsedSpace.getText(), true);

//Delete share
WebElement sharesNav = driver.findElement(By.id("shares_nav"));
sharesNav.click();
Expand Down
131 changes: 131 additions & 0 deletions java/src/main/java/com/rockstor/test/webdriver/CreateAPool.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
package com.rockstor.test.webdriver;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import org.junit.Test;
import org.junit.Ignore;
import org.junit.BeforeClass;
import org.junit.AfterClass;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.apache.commons.io.FileUtils; // Screenshots
import org.openqa.selenium.OutputType;
import org.openqa.selenium.TakesScreenshot;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.Select; // Dropdown menu
import org.openqa.selenium.support.ui.WebDriverWait;
import java.io.File;
import java.io.IOException;
import java.util.Properties;
import java.util.concurrent.TimeUnit;
import java.util.List;
import com.rockstor.test.util.RSProps;


public class CreateAPool {

private static WebDriver driver;

@BeforeClass
public static void setUpBeforeClass() throws Exception {
driver = new FirefoxDriver();
driver.manage().timeouts().implicitlyWait(
Integer.parseInt(RSProps.getProperty("waitTimeout")),
TimeUnit.SECONDS);
}

@Test
public void testSimpleCreatePool() throws Exception {
try{

driver.get(RSProps.getProperty("RockstorVm"));

// Login
WebElement username = driver.findElement(By.id("inputUsername"));
username.sendKeys("admin");

WebElement password = driver.findElement(By.id("inputPassword"));
password.sendKeys("admin");

WebElement submit = driver.findElement(By.id("sign_in"));
submit.click();


// Add Pool with Raid 0
WebElement poolsNav = driver.findElement(By.id("pools_nav"));
poolsNav.click();

WebElement addPool = driver.findElement(By.id("add_pool"));
addPool.click();

WebElement poolname = driver.findElement(By.id("pool_name"));
poolname.sendKeys("pool1");

// Raid Configuration Dropdown box
Select raidConfigDroplist = new Select(driver.findElement(
By.id("raid_level")));
raidConfigDroplist.selectByIndex(0);

//Select Disks CheckBox
WebElement diskCheckBox1 = driver.findElement(By.id("sdb"));
diskCheckBox1.click();
WebElement diskCheckBox2 = driver.findElement(By.id("sdc"));
diskCheckBox2.click();


// Create Pool
WebElement createPool = driver.findElement(By.id("create_pool"));
createPool.click();

//Check for the newly created pool
WebElement poolRow = driver.findElement(
By.xpath("//*[@id='pools-table']/tbody/tr[td[contains(.,'1') or contains(.,'pool1') or contains(.,'3.55 Gb') or contains(.,'raid0')]]"));
assertTrue(poolRow.getText(),true);


//Delete Pool

WebElement poolRowToDelete = driver.findElement(By.xpath("//*[@id='pools-table']/tbody/tr[td[contains(.,'pool1')]]"));
WebElement deletePool = poolRowToDelete.findElement(By.xpath("td/button[contains(@data-name,'pool1') and contains(@data-action,'delete')]"));
deletePool.click();


// Logout
WebElement logoutSubmit = driver.findElement(
By.id("logout_user"));

logoutSubmit.click();

}
catch(Exception e){
File screenshotFile = ((TakesScreenshot)driver)
.getScreenshotAs(OutputType.FILE);
FileUtils.copyFile(screenshotFile,
new File(RSProps.getProperty("screenshotDir")
+ "/" + this.getClass().getName()+".png"));
throw e;

}

}

@AfterClass
public static void tearDownAfterClass() throws Exception {
driver.quit();
}


}









124 changes: 124 additions & 0 deletions java/src/main/java/com/rockstor/test/webdriver/CreatePoolRaid0.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
package com.rockstor.test.webdriver;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import org.junit.Test;
import org.junit.Ignore;
import org.junit.BeforeClass;
import org.junit.AfterClass;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.apache.commons.io.FileUtils; // Screenshots
import org.openqa.selenium.OutputType;
import org.openqa.selenium.TakesScreenshot;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.Select; // Dropdown menu
import org.openqa.selenium.support.ui.WebDriverWait;
import java.io.File;
import java.io.IOException;
import java.util.Properties;
import java.util.concurrent.TimeUnit;
import java.util.List;
import com.rockstor.test.util.RSProps;


public class CreatePoolRaid0 {

private static WebDriver driver;

@BeforeClass
public static void setUpBeforeClass() throws Exception {
driver = new FirefoxDriver();
driver.manage().timeouts().implicitlyWait(
Integer.parseInt(RSProps.getProperty("waitTimeout")),
TimeUnit.SECONDS);
}

@Test
public void testPoolRaid0() throws Exception {
try{

driver.get(RSProps.getProperty("RockstorVm"));

// Login
WebElement username = driver.findElement(By.id("inputUsername"));
username.sendKeys("admin");

WebElement password = driver.findElement(By.id("inputPassword"));
password.sendKeys("admin");

WebElement submit = driver.findElement(By.id("sign_in"));
submit.click();

///Create 1st Pool

// Add Pool with Raid 0
WebElement poolsNav = driver.findElement(By.id("pools_nav"));
poolsNav.click();

WebElement addPool = driver.findElement(By.id("add_pool"));
addPool.click();

WebElement poolname = driver.findElement(By.id("pool_name"));
poolname.sendKeys("pool1");

// Raid Configuration Dropdown box
Select raidConfigDroplist = new Select(driver.findElement(
By.id("raid_level")));
raidConfigDroplist.selectByIndex(0);

//Select Disks CheckBox
WebElement diskCheckBox1 = driver.findElement(By.id("sdb"));
diskCheckBox1.click();
WebElement diskCheckBox2 = driver.findElement(By.id("sdc"));
diskCheckBox2.click();

// Create Pool
WebElement createPool = driver.findElement(By.id("create_pool"));
createPool.click();

WebElement poolRowToCheckSize = driver.findElement(
By.xpath("//*[@id='pools-table']/tbody/tr[td[contains(.,'pool1')]]"));
assertTrue(poolRowToCheckSize.getText(),true);


//Delete Pool

WebElement poolRow = driver.findElement(By.xpath("//*[@id='pools-table']/tbody/tr[td[contains(.,'pool1')]]"));
WebElement deletePool = poolRow.findElement(By.xpath("td/button[contains(@data-name,'pool1') and contains(@data-action,'delete')]"));
deletePool.click();


// Logout
WebElement logoutSubmit = driver.findElement(
By.id("logout_user"));

logoutSubmit.click();

}
catch(Exception e){
File screenshotFile = ((TakesScreenshot)driver)
.getScreenshotAs(OutputType.FILE);
FileUtils.copyFile(screenshotFile,
new File(RSProps.getProperty("screenshotDir")
+ "/" + this.getClass().getName()+".png"));
throw e;

}

}

@AfterClass
public static void tearDownAfterClass() throws Exception {
driver.quit();
}


}



Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
package com.rockstor.test.webdriver;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import org.junit.Test;
import org.junit.Ignore;
import org.junit.BeforeClass;
import org.junit.AfterClass;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.apache.commons.io.FileUtils; // Screenshots
import org.openqa.selenium.OutputType;
import org.openqa.selenium.TakesScreenshot;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.Select; // Dropdown menu
import org.openqa.selenium.support.ui.WebDriverWait;
import java.io.File;
import java.io.IOException;
import java.util.Properties;
import java.util.concurrent.TimeUnit;
import java.util.List;
import com.rockstor.test.util.RSProps;


public class CreatePoolRaid0with0Disks {

private static WebDriver driver;

@BeforeClass
public static void setUpBeforeClass() throws Exception {
driver = new FirefoxDriver();
driver.manage().timeouts().implicitlyWait(
Integer.parseInt(RSProps.getProperty("waitTimeout")),
TimeUnit.SECONDS);
}

@Test
public void testPoolRaid0Disks0() throws Exception {
try{

driver.get(RSProps.getProperty("RockstorVm"));

// Login
WebElement username = driver.findElement(By.id("inputUsername"));
username.sendKeys("admin");

WebElement password = driver.findElement(By.id("inputPassword"));
password.sendKeys("admin");

WebElement submit = driver.findElement(By.id("sign_in"));
submit.click();

///Create 1st Pool

// Add Pool with Raid 0
WebElement poolsNav = driver.findElement(By.id("pools_nav"));
poolsNav.click();

WebElement addPool = driver.findElement(By.id("add_pool"));
addPool.click();

WebElement poolname = driver.findElement(By.id("pool_name"));
poolname.sendKeys("pool1");

// Raid Configuration Dropdown box
Select raidConfigDroplist = new Select(driver.findElement(
By.id("raid_level")));
raidConfigDroplist.selectByIndex(0);


// Create Pool
WebElement createPool = driver.findElement(By.id("create_pool"));
createPool.click();

// Look up for the error message to be displayed.
WebElement verifyErrorMsg = driver.findElement(
By.xpath("//div/form/label[text()='Raid0 requires at least 2 disks to be selected']"));
assertTrue(verifyErrorMsg.getText(),true);


// Logout
WebElement logoutSubmit = driver.findElement(
By.id("logout_user"));

logoutSubmit.click();

}
catch(Exception e){
File screenshotFile = ((TakesScreenshot)driver)
.getScreenshotAs(OutputType.FILE);
FileUtils.copyFile(screenshotFile,
new File(RSProps.getProperty("screenshotDir")
+ "/" + this.getClass().getName()+".png"));
throw e;

}

}

@AfterClass
public static void tearDownAfterClass() throws Exception {
driver.quit();
}


}




Loading