diff --git a/java/pom.xml b/java/pom.xml index ca41998..dd3132b 100644 --- a/java/pom.xml +++ b/java/pom.xml @@ -37,5 +37,18 @@ + + + + org.apache.maven.plugins + maven-compiler-plugin + 2.3.1 + + 1.6 + 1.6 + + + + diff --git a/java/src/main/java/com/rockstor/test/webdriver/CheckDisplayPoolnameofShare.java b/java/src/main/java/com/rockstor/test/webdriver/CheckDisplayPoolnameofShare.java new file mode 100644 index 0000000..4820b3b --- /dev/null +++ b/java/src/main/java/com/rockstor/test/webdriver/CheckDisplayPoolnameofShare.java @@ -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(); + } + +} + + + + diff --git a/java/src/main/java/com/rockstor/test/webdriver/CheckShareUsedandFreeSpace.java b/java/src/main/java/com/rockstor/test/webdriver/CheckShareUsedandFreeSpace.java new file mode 100644 index 0000000..f77fd21 --- /dev/null +++ b/java/src/main/java/com/rockstor/test/webdriver/CheckShareUsedandFreeSpace.java @@ -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(); + } + +} + + diff --git a/java/src/main/java/com/rockstor/test/webdriver/DeleteShareFromSharesDetailPage.java b/java/src/main/java/com/rockstor/test/webdriver/DeleteShareFromSharesDetailPage.java new file mode 100644 index 0000000..23eeda4 --- /dev/null +++ b/java/src/main/java/com/rockstor/test/webdriver/DeleteShareFromSharesDetailPage.java @@ -0,0 +1,154 @@ +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 DeleteShareFromSharesDetailPage { + + 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 testDeleteShare() 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(); + + // Delete Share + WebElement shareDelete =driver.findElement(By.id("js-delete")); + shareDelete.click(); + + WebElement sharesNav = driver.findElement(By.linkText("shares_nav")); + sharesNav.click(); + + WebElement textVerification = driver.findElement( + By.xpath("//[h4/text()='No shares have been created']")); + assertTrue(textVerification.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(); + } + +} + diff --git a/java/src/main/java/com/rockstor/test/webdriver/DeleteShareandPool.java b/java/src/main/java/com/rockstor/test/webdriver/DeleteShareandPool.java new file mode 100644 index 0000000..2f528e5 --- /dev/null +++ b/java/src/main/java/com/rockstor/test/webdriver/DeleteShareandPool.java @@ -0,0 +1,102 @@ +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 junit.framework.Assert; + +import com.rockstor.test.util.RSProps; + +public class DeleteShareandPool { + + 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(); + + //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 + WebElement 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(); + } + +} + + + diff --git a/java/src/main/java/com/rockstor/test/webdriver/PoolRaid0ShareSamba.java b/java/src/main/java/com/rockstor/test/webdriver/PoolRaid0ShareSamba.java new file mode 100644 index 0000000..1de7288 --- /dev/null +++ b/java/src/main/java/com/rockstor/test/webdriver/PoolRaid0ShareSamba.java @@ -0,0 +1,198 @@ +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 PoolRaid0ShareSamba { + 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 testShareSamba() 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(); + + + ///// Samba + + // Share link + WebElement shareLink = driver.findElement(By.linkText("share1")); + shareLink.click(); + + WebElement addSamba = driver.findElement(By.id("add-smb-share")); + addSamba.click(); + + //Browsable + Select browsable = new Select (driver.findElement(By.id("browsable"))); + browsable.selectByIndex(0); + + // Guest Ok + Select guestOk = new Select(driver.findElement(By.id("guest_ok"))); + guestOk.selectByIndex(0); + + // Read only + Select readOnly = new Select(driver.findElement(By.id("read_only"))); + readOnly.selectByIndex(0); + + //Comment + WebElement comment = driver.findElement(By.id("comment")); + comment.sendKeys(""); + + //Actions + WebElement saveButton = driver.findElement(By.xpath("//*[@id='smb-shares-table']/tbody/tr/td/button[contains(@id,'create')]")); + saveButton.click(); + + WebElement delSambaButton = driver.findElement( + By.xpath("//*[@id='smb-shares-table']/tbody/tr/td/button[contains(@id,'delete')]")); + + // check for add button to disappear + List addButtonDisappear = driver.findElements(By.id("add-smb-share")); + assertTrue(addButtonDisappear.isEmpty()); + + // Delete Samba + delSambaButton.click(); + + + // 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(); + } + +} + + + diff --git a/java/src/main/java/com/rockstor/test/webdriver/PoolRaid0ShareSnapshot.java b/java/src/main/java/com/rockstor/test/webdriver/PoolRaid0ShareSnapshot.java new file mode 100644 index 0000000..d17900c --- /dev/null +++ b/java/src/main/java/com/rockstor/test/webdriver/PoolRaid0ShareSnapshot.java @@ -0,0 +1,197 @@ +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 PoolRaid0ShareSnapshot { + + 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 testShareSnapshot() 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 and check for pool1 to appear + WebElement poolLink = driver.findElement(By.linkText("pool1")); + + ///// 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(); + + //Shares Detail page + WebElement shareLink = driver.findElement(By.linkText("share1")); + shareLink.click(); + + /// Snapshot + WebElement snapshotButton = driver.findElement( + By.id("js-snapshot-popup")); + snapshotButton.click(); + + //Snapshot name input form + WebElement snapshotName = driver.findElement(By.id("snapshot-name")); + snapshotName.sendKeys("snapshot1"); + + // Create snapshot + WebElement snapshotSubmitButton = driver.findElement( + By.id("create-snapshot")); + snapshotSubmitButton.click(); + + // test if the row got created + List newSnapshotRow = driver.findElements( + By.xpath("//*[@id='snapshots-table']/tbody/tr[td[contains(.,'snapshot1')]]")); + assertEquals(newSnapshotRow.size(), 1); + + + // Delete snapshot + WebElement snapshotRow = driver.findElement( + By.xpath("//*[@id='snapshots-table']/tbody/tr[td[contains(.,'snapshot1')]]")); + WebElement deleteSnapshot = snapshotRow.findElement( + By.xpath("td/button[contains(@data-name,'snapshot1') and contains(@data-action,'delete')]")); + deleteSnapshot.click(); + + + // check for the text present after delete snapshots + WebElement lookForText = driver.findElement( + By.xpath("//div/*[@id='snapshots-table']/tbody/tr/td[h4/text()='No snapshots have been created']")); + assertTrue(lookForText.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(); + } + +} + diff --git a/java/src/main/java/com/rockstor/test/webdriver/RockStorSuite.java b/java/src/main/java/com/rockstor/test/webdriver/RockStorSuite.java index cf2265f..421989e 100644 --- a/java/src/main/java/com/rockstor/test/webdriver/RockStorSuite.java +++ b/java/src/main/java/com/rockstor/test/webdriver/RockStorSuite.java @@ -5,7 +5,7 @@ import org.junit.runners.Suite.SuiteClasses; @RunWith(Suite.class) -@SuiteClasses({PoolRaid0ShareNFS.class}) +@SuiteClasses({ShareDetailsSuite.class}) public class RockStorSuite { } diff --git a/java/src/main/java/com/rockstor/test/webdriver/ShareDetailsSuite.java b/java/src/main/java/com/rockstor/test/webdriver/ShareDetailsSuite.java new file mode 100644 index 0000000..e15a1a3 --- /dev/null +++ b/java/src/main/java/com/rockstor/test/webdriver/ShareDetailsSuite.java @@ -0,0 +1,15 @@ +package com.rockstor.test.webdriver; +import org.junit.runner.RunWith; +import org.junit.runners.Suite; +import org.junit.runners.Suite.SuiteClasses; + +@RunWith(Suite.class) +@SuiteClasses({PoolRaid0ShareNFS.class,PoolRaid0ShareSamba.class, + PoolRaid0ShareSnapshot.class, CheckDisplayPoolnameofShare.class, CheckShareUsedandFreeSpace.class, + DeleteShareFromSharesDetailPage.class,DeleteShareandPool.class,ShareResize.class, + DeleteShareandPool.class}) + +public class ShareDetailsSuite { + +} + diff --git a/java/src/main/java/com/rockstor/test/webdriver/ShareResize.java b/java/src/main/java/com/rockstor/test/webdriver/ShareResize.java new file mode 100644 index 0000000..832db4b --- /dev/null +++ b/java/src/main/java/com/rockstor/test/webdriver/ShareResize.java @@ -0,0 +1,186 @@ +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 ShareResize { + 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 testShareResize() 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(); + + // Resize share to 100 Mb + WebElement shareResize = driver.findElement(By.id("js-resize")); + shareResize.click(); + + WebElement newShareSize = driver.findElement(By.id("new-size")); + newShareSize.clear(); + newShareSize.sendKeys("100"); + + Select selectResizeShareDroplist = new Select(driver.findElement( + By.id("size_format"))); + selectResizeShareDroplist.selectByIndex(1); //Mb + + WebElement resizeShareSubmit =driver.findElement(By.id("resize-share")); + resizeShareSubmit.click(); + + //check for the size update on shares page + WebElement sharesNav = driver.findElement(By.id("shares_nav")); + sharesNav.click(); + + WebElement shareRowToCheckSize = driver.findElement( + By.xpath("//*[@id='shares-table']/tbody/tr[td[contains(.,'100.00 Mb')]]")); + assertTrue(shareRowToCheckSize.getText(),true); + + //Delete share + 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(); + } + +} + + + + +