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

Commit

Permalink
Merge pull request #12 from priyaganti/master
Browse files Browse the repository at this point in the history
Added Samba test case and java version of pox.xml
  • Loading branch information
sujeetsr committed Jun 17, 2013
2 parents d7b7a14 + ddd1854 commit 095723c
Show file tree
Hide file tree
Showing 10 changed files with 1,203 additions and 1 deletion.
13 changes: 13 additions & 0 deletions java/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,18 @@
</dependency>
</dependencies>
</dependencyManagement>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.1</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
</plugins>
</build>
</project>

Original file line number Diff line number Diff line change
@@ -0,0 +1,165 @@
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 CheckDisplayPoolnameofShare {
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 testSharePoolnameValidate() 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();

//wait for pool1 to appear
WebElement poolLink = driver.findElement(By.linkText("pool1"));
poolLink.click();


///// Create a share

//Shares navigation bar
WebElement shareNav = driver.findElement(By.id("shares_nav"));
shareNav.click();

//Add share
WebElement addShareButton = driver.findElement(By.id("add_share"));
addShareButton.click();

WebElement shareName = driver.findElement(By.id("share_name"));
shareName.sendKeys("share1");

Select selectPoolDroplist = new Select(driver.findElement(
By.id("pool_name")));
selectPoolDroplist.selectByIndex(0);

WebElement shareSize = driver.findElement(By.id("share_size"));
shareSize.sendKeys("100");

Select selectSizeDroplist = new Select(driver.findElement(
By.id("size_format")));
selectSizeDroplist.selectByIndex(0);//Index 0 is KB

// Submit button to create share
WebElement shareSubmitButton = driver.findElement(
By.id("create_share"));
shareSubmitButton.click();

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

//check for pool name
WebElement validatePoolName = driver.findElement(By.xpath("//div/a[contains(.,'pool')]"));
assertTrue(validatePoolName.getText(),true);

//Delete share
WebElement sharesNav = driver.findElement(By.id("shares_nav"));
sharesNav.click();

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

// Delete Pool
poolsNav = driver.findElement(By.id("pools_nav"));
poolsNav.click();

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,172 @@
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 CheckShareUsedandFreeSpace {

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 testShareUsedandFreeSpace() 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();

//wait for pool1 to appear
WebElement poolLink = driver.findElement(By.linkText("pool1"));
poolLink.click();


///// Create a share

//Shares navigation bar
WebElement shareNav = driver.findElement(By.id("shares_nav"));
shareNav.click();

//Add share
WebElement addShareButton = driver.findElement(By.id("add_share"));
addShareButton.click();

WebElement shareName = driver.findElement(By.id("share_name"));
shareName.sendKeys("share1");

Select selectPoolDroplist = new Select(driver.findElement(
By.id("pool_name")));
selectPoolDroplist.selectByIndex(0);

WebElement shareSize = driver.findElement(By.id("share_size"));
shareSize.sendKeys("100");

Select selectSizeDroplist = new Select(driver.findElement(
By.id("size_format")));
selectSizeDroplist.selectByIndex(0);//Index 0 is KB

// Submit button to create share
WebElement shareSubmitButton = driver.findElement(
By.id("create_share"));
shareSubmitButton.click();

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();

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

// Delete Pool
poolsNav = driver.findElement(By.id("pools_nav"));
poolsNav.click();

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();
}

}


Loading

0 comments on commit 095723c

Please sign in to comment.