From 5a03710bfad8319751588d560c766fb4a72fc51d Mon Sep 17 00:00:00 2001 From: Priyanka Ganti Date: Tue, 18 Jun 2013 11:24:44 -0700 Subject: [PATCH 1/5] Create Pool test suite and corresponding test cases as stated on wiki page. --- .../rockstor/test/webdriver/CreateAPool.java | 131 +++++++++++++++ .../test/webdriver/CreatePoolRaid0.java | 124 ++++++++++++++ .../webdriver/CreatePoolRaid0with0Disks.java | 114 +++++++++++++ .../webdriver/CreatePoolRaid0with1Disk.java | 120 +++++++++++++ .../webdriver/CreatePoolRaid0with5Disks.java | 134 +++++++++++++++ .../test/webdriver/CreatePoolRaid1.java | 123 ++++++++++++++ .../test/webdriver/CreatePoolRaid10.java | 128 ++++++++++++++ .../webdriver/CreatePoolRaid10with0Disks.java | 114 +++++++++++++ .../CreatePoolRaid10with10Disks.java | 144 ++++++++++++++++ .../webdriver/CreatePoolRaid10with1Disk.java | 119 +++++++++++++ .../webdriver/CreatePoolRaid10with3Disks.java | 123 ++++++++++++++ .../webdriver/CreatePoolRaid1with0Disks.java | 112 ++++++++++++ .../webdriver/CreatePoolRaid1with1Disk.java | 119 +++++++++++++ .../webdriver/CreatePoolRaid1with5Disks.java | 134 +++++++++++++++ .../test/webdriver/CreatePoolTestSuite.java | 16 ++ .../NoDisplayofDisksAlreadyinUse.java | 141 ++++++++++++++++ .../test/webdriver/TwoPoolsWithSameName.java | 159 ++++++++++++++++++ 17 files changed, 2055 insertions(+) create mode 100644 java/src/main/java/com/rockstor/test/webdriver/CreateAPool.java create mode 100644 java/src/main/java/com/rockstor/test/webdriver/CreatePoolRaid0.java create mode 100644 java/src/main/java/com/rockstor/test/webdriver/CreatePoolRaid0with0Disks.java create mode 100644 java/src/main/java/com/rockstor/test/webdriver/CreatePoolRaid0with1Disk.java create mode 100644 java/src/main/java/com/rockstor/test/webdriver/CreatePoolRaid0with5Disks.java create mode 100644 java/src/main/java/com/rockstor/test/webdriver/CreatePoolRaid1.java create mode 100644 java/src/main/java/com/rockstor/test/webdriver/CreatePoolRaid10.java create mode 100644 java/src/main/java/com/rockstor/test/webdriver/CreatePoolRaid10with0Disks.java create mode 100644 java/src/main/java/com/rockstor/test/webdriver/CreatePoolRaid10with10Disks.java create mode 100644 java/src/main/java/com/rockstor/test/webdriver/CreatePoolRaid10with1Disk.java create mode 100644 java/src/main/java/com/rockstor/test/webdriver/CreatePoolRaid10with3Disks.java create mode 100644 java/src/main/java/com/rockstor/test/webdriver/CreatePoolRaid1with0Disks.java create mode 100644 java/src/main/java/com/rockstor/test/webdriver/CreatePoolRaid1with1Disk.java create mode 100644 java/src/main/java/com/rockstor/test/webdriver/CreatePoolRaid1with5Disks.java create mode 100644 java/src/main/java/com/rockstor/test/webdriver/CreatePoolTestSuite.java create mode 100644 java/src/main/java/com/rockstor/test/webdriver/NoDisplayofDisksAlreadyinUse.java create mode 100644 java/src/main/java/com/rockstor/test/webdriver/TwoPoolsWithSameName.java diff --git a/java/src/main/java/com/rockstor/test/webdriver/CreateAPool.java b/java/src/main/java/com/rockstor/test/webdriver/CreateAPool.java new file mode 100644 index 0000000..90d1866 --- /dev/null +++ b/java/src/main/java/com/rockstor/test/webdriver/CreateAPool.java @@ -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(); + } + + +} + + + + + + + + + diff --git a/java/src/main/java/com/rockstor/test/webdriver/CreatePoolRaid0.java b/java/src/main/java/com/rockstor/test/webdriver/CreatePoolRaid0.java new file mode 100644 index 0000000..4c69f4c --- /dev/null +++ b/java/src/main/java/com/rockstor/test/webdriver/CreatePoolRaid0.java @@ -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(); + } + + +} + + + diff --git a/java/src/main/java/com/rockstor/test/webdriver/CreatePoolRaid0with0Disks.java b/java/src/main/java/com/rockstor/test/webdriver/CreatePoolRaid0with0Disks.java new file mode 100644 index 0000000..dd6cc0f --- /dev/null +++ b/java/src/main/java/com/rockstor/test/webdriver/CreatePoolRaid0with0Disks.java @@ -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(); + } + + +} + + + + diff --git a/java/src/main/java/com/rockstor/test/webdriver/CreatePoolRaid0with1Disk.java b/java/src/main/java/com/rockstor/test/webdriver/CreatePoolRaid0with1Disk.java new file mode 100644 index 0000000..b3cc392 --- /dev/null +++ b/java/src/main/java/com/rockstor/test/webdriver/CreatePoolRaid0with1Disk.java @@ -0,0 +1,120 @@ +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 CreatePoolRaid0with1Disk { + + 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 testPoolRaid0Disk1() 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("sdd")); + diskCheckBox1.click(); + + // 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(); + } + + +} + + + + + + + diff --git a/java/src/main/java/com/rockstor/test/webdriver/CreatePoolRaid0with5Disks.java b/java/src/main/java/com/rockstor/test/webdriver/CreatePoolRaid0with5Disks.java new file mode 100644 index 0000000..980c530 --- /dev/null +++ b/java/src/main/java/com/rockstor/test/webdriver/CreatePoolRaid0with5Disks.java @@ -0,0 +1,134 @@ +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 CreatePoolRaid0with5Disks { + + 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 testPoolRaid0Disks5() 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(); + WebElement diskCheckBox3 = driver.findElement(By.id("sdd")); + diskCheckBox3.click(); + WebElement diskCheckBox4 = driver.findElement(By.id("sde")); + diskCheckBox4.click(); + WebElement diskCheckBox5 = driver.findElement(By.id("sdf")); + diskCheckBox5.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(); + } + + +} + + + + + + + + diff --git a/java/src/main/java/com/rockstor/test/webdriver/CreatePoolRaid1.java b/java/src/main/java/com/rockstor/test/webdriver/CreatePoolRaid1.java new file mode 100644 index 0000000..ad38a89 --- /dev/null +++ b/java/src/main/java/com/rockstor/test/webdriver/CreatePoolRaid1.java @@ -0,0 +1,123 @@ +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 CreatePoolRaid1 { + + 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 testPoolRaid1() 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 1 + 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(1); + + //Select Disks CheckBox + WebElement diskCheckBox1 = driver.findElement(By.id("sdd")); + diskCheckBox1.click(); + WebElement diskCheckBox2 = driver.findElement(By.id("sde")); + 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(); + } + + +} + + + diff --git a/java/src/main/java/com/rockstor/test/webdriver/CreatePoolRaid10.java b/java/src/main/java/com/rockstor/test/webdriver/CreatePoolRaid10.java new file mode 100644 index 0000000..5b077ec --- /dev/null +++ b/java/src/main/java/com/rockstor/test/webdriver/CreatePoolRaid10.java @@ -0,0 +1,128 @@ +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 CreatePoolRaid10 { + + 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 testPoolRaid10() 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 10 + 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(2); + + //Select Disks CheckBox + WebElement diskCheckBox1 = driver.findElement(By.id("sdg")); + diskCheckBox1.click(); + WebElement diskCheckBox2 = driver.findElement(By.id("sdh")); + diskCheckBox2.click(); + WebElement diskCheckBox3 = driver.findElement(By.id("sdi")); + diskCheckBox3.click(); + WebElement diskCheckBox4 = driver.findElement(By.id("sdj")); + diskCheckBox4.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(); + } + + +} + + + diff --git a/java/src/main/java/com/rockstor/test/webdriver/CreatePoolRaid10with0Disks.java b/java/src/main/java/com/rockstor/test/webdriver/CreatePoolRaid10with0Disks.java new file mode 100644 index 0000000..eb19e3b --- /dev/null +++ b/java/src/main/java/com/rockstor/test/webdriver/CreatePoolRaid10with0Disks.java @@ -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 CreatePoolRaid10with0Disks { + + 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 testPoolRaid10Disks0() 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 10 + 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(2); + + // 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()='Raid10 requires at least 4 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(); + } + + +} + + + + + + + diff --git a/java/src/main/java/com/rockstor/test/webdriver/CreatePoolRaid10with10Disks.java b/java/src/main/java/com/rockstor/test/webdriver/CreatePoolRaid10with10Disks.java new file mode 100644 index 0000000..653ef3d --- /dev/null +++ b/java/src/main/java/com/rockstor/test/webdriver/CreatePoolRaid10with10Disks.java @@ -0,0 +1,144 @@ +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 CreatePoolRaid10with10Disks { + + 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 testPoolRaid10Disks10() 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 10 + 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(2); + + //Select Disks CheckBox + WebElement diskCheckBox1 = driver.findElement(By.id("sdb")); + diskCheckBox1.click(); + WebElement diskCheckBox2 = driver.findElement(By.id("sdc")); + diskCheckBox2.click(); + WebElement diskCheckBox3 = driver.findElement(By.id("sdd")); + diskCheckBox3.click(); + WebElement diskCheckBox4 = driver.findElement(By.id("sde")); + diskCheckBox4.click(); + WebElement diskCheckBox5 = driver.findElement(By.id("sdf")); + diskCheckBox5.click(); + WebElement diskCheckBox6 = driver.findElement(By.id("sdg")); + diskCheckBox6.click(); + WebElement diskCheckBox7 = driver.findElement(By.id("sdh")); + diskCheckBox7.click(); + WebElement diskCheckBox8 = driver.findElement(By.id("sdi")); + diskCheckBox8.click(); + WebElement diskCheckBox9 = driver.findElement(By.id("sdj")); + diskCheckBox9.click(); + WebElement diskCheckBox10 = driver.findElement(By.id("sdk")); + diskCheckBox10.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(); + } + + +} + + + + + + + diff --git a/java/src/main/java/com/rockstor/test/webdriver/CreatePoolRaid10with1Disk.java b/java/src/main/java/com/rockstor/test/webdriver/CreatePoolRaid10with1Disk.java new file mode 100644 index 0000000..2feaa26 --- /dev/null +++ b/java/src/main/java/com/rockstor/test/webdriver/CreatePoolRaid10with1Disk.java @@ -0,0 +1,119 @@ +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 CreatePoolRaid10with1Disk { + + 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 testPoolRaid10Disk1() 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 10 + 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(2); + + //Select Disks CheckBox + WebElement diskCheckBox1 = driver.findElement(By.id("sdd")); + diskCheckBox1.click(); + + // 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()='Raid10 requires at least 4 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(); + } + + +} + + + + + + + diff --git a/java/src/main/java/com/rockstor/test/webdriver/CreatePoolRaid10with3Disks.java b/java/src/main/java/com/rockstor/test/webdriver/CreatePoolRaid10with3Disks.java new file mode 100644 index 0000000..531c355 --- /dev/null +++ b/java/src/main/java/com/rockstor/test/webdriver/CreatePoolRaid10with3Disks.java @@ -0,0 +1,123 @@ +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 CreatePoolRaid10with3Disks { + + 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 testPoolRaid10Disks3() 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 10 + 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(2); + + //Select Disks CheckBox + WebElement diskCheckBox1 = driver.findElement(By.id("sdd")); + diskCheckBox1.click(); + WebElement diskCheckBox2 = driver.findElement(By.id("sde")); + diskCheckBox2.click(); + WebElement diskCheckBox3 = driver.findElement(By.id("sdf")); + diskCheckBox3.click(); + + + // 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()='Raid10 requires at least 4 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(); + } + + +} + + + + + + + diff --git a/java/src/main/java/com/rockstor/test/webdriver/CreatePoolRaid1with0Disks.java b/java/src/main/java/com/rockstor/test/webdriver/CreatePoolRaid1with0Disks.java new file mode 100644 index 0000000..5800c33 --- /dev/null +++ b/java/src/main/java/com/rockstor/test/webdriver/CreatePoolRaid1with0Disks.java @@ -0,0 +1,112 @@ +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 CreatePoolRaid1with0Disks { + + 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 testPoolRaid1Disks0() 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 1 + 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(1); + + + // 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()='Raid1 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(); + } + + +} + + + + diff --git a/java/src/main/java/com/rockstor/test/webdriver/CreatePoolRaid1with1Disk.java b/java/src/main/java/com/rockstor/test/webdriver/CreatePoolRaid1with1Disk.java new file mode 100644 index 0000000..69a261b --- /dev/null +++ b/java/src/main/java/com/rockstor/test/webdriver/CreatePoolRaid1with1Disk.java @@ -0,0 +1,119 @@ +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 CreatePoolRaid1with1Disk { + + 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 testPoolRaid1Disk1() 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 1 + 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(1); + + //Select Disks CheckBox + WebElement diskCheckBox1 = driver.findElement(By.id("sdd")); + diskCheckBox1.click(); + + // 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()='Raid1 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(); + } + + +} + + + + + + + diff --git a/java/src/main/java/com/rockstor/test/webdriver/CreatePoolRaid1with5Disks.java b/java/src/main/java/com/rockstor/test/webdriver/CreatePoolRaid1with5Disks.java new file mode 100644 index 0000000..43f6e11 --- /dev/null +++ b/java/src/main/java/com/rockstor/test/webdriver/CreatePoolRaid1with5Disks.java @@ -0,0 +1,134 @@ +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 CreatePoolRaid1with5Disks { + + 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 testPoolRaid1Disks5() 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 1 + 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(1); + + //Select Disks CheckBox + WebElement diskCheckBox1 = driver.findElement(By.id("sdb")); + diskCheckBox1.click(); + WebElement diskCheckBox2 = driver.findElement(By.id("sdc")); + diskCheckBox2.click(); + WebElement diskCheckBox3 = driver.findElement(By.id("sdd")); + diskCheckBox3.click(); + WebElement diskCheckBox4 = driver.findElement(By.id("sde")); + diskCheckBox4.click(); + WebElement diskCheckBox5 = driver.findElement(By.id("sdf")); + diskCheckBox5.click(); + + // Create Pool + WebElement createPool = driver.findElement(By.id("create_pool")); + createPool.click(); + + WebElement poolRowToCheckName = driver.findElement( + By.xpath("//*[@id='pools-table']/tbody/tr[td[contains(.,'pool1')]]")); + assertTrue(poolRowToCheckName.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(); + } + + +} + + + + + + + + diff --git a/java/src/main/java/com/rockstor/test/webdriver/CreatePoolTestSuite.java b/java/src/main/java/com/rockstor/test/webdriver/CreatePoolTestSuite.java new file mode 100644 index 0000000..5ad1818 --- /dev/null +++ b/java/src/main/java/com/rockstor/test/webdriver/CreatePoolTestSuite.java @@ -0,0 +1,16 @@ +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({CreateAPool.class,CreatePoolRaid0.class,CreatePoolRaid1.class, + CreatePoolRaid10.class, CreatePoolRaid0with0Disks.class, CreatePoolRaid1with0Disks.class, + CreatePoolRaid1with1Disk.class,CreatePoolRaid1with1Disk.class,CreatePoolRaid10with1Disk.class, + CreatePoolRaid10with0Disks.class,CreatePoolRaid10with3Disks.class, + CreatePoolRaid0with5Disks.class,CreatePoolRaid1with5Disks.class,CreatePoolRaid10with10Disks.class, + NoDisplayofDisksAlreadyinUse.class,TwoPoolsWithSameName.class}) + +public class CreatePoolTestSuite { + +} diff --git a/java/src/main/java/com/rockstor/test/webdriver/NoDisplayofDisksAlreadyinUse.java b/java/src/main/java/com/rockstor/test/webdriver/NoDisplayofDisksAlreadyinUse.java new file mode 100644 index 0000000..df54e20 --- /dev/null +++ b/java/src/main/java/com/rockstor/test/webdriver/NoDisplayofDisksAlreadyinUse.java @@ -0,0 +1,141 @@ +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 NoDisplayofDisksAlreadyinUse { + + 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 testDisplayUsedDisks() 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(); + + WebElement poolRowToCheckSize = driver.findElement( + By.xpath("//*[@id='pools-table']/tbody/tr[td[contains(.,'pool1')]]")); + assertTrue(poolRowToCheckSize.getText(),true); + + + // Open the pools page + WebElement addPool2 = driver.findElement(By.id("add_pool")); + addPool2.click(); + + + // Check if used disks in pool1 are still displayed in available disks + WebElement disksRow = driver.findElement( + By.xpath("//*[@id='disks-table']/tbody/tr[td[not(contains(.,'sdb')) or not(contains(.,'sdc'))]]")); + assertTrue(disksRow.getText(),true); + + + // Go back to page with pool to delete. + WebElement poolsNav2 = driver.findElement(By.id("pools_nav")); + poolsNav2.click(); + + + //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(); + } + + +} + + + + + diff --git a/java/src/main/java/com/rockstor/test/webdriver/TwoPoolsWithSameName.java b/java/src/main/java/com/rockstor/test/webdriver/TwoPoolsWithSameName.java new file mode 100644 index 0000000..b46f5d4 --- /dev/null +++ b/java/src/main/java/com/rockstor/test/webdriver/TwoPoolsWithSameName.java @@ -0,0 +1,159 @@ +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 TwoPoolsWithSameName { + + 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 testSamePoolName() 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); + + + ///Create 2nd Pool + + WebElement addPool2 = driver.findElement(By.id("add_pool")); + addPool2.click(); + + WebElement poolname2 = driver.findElement(By.id("pool_name")); + poolname2.sendKeys("pool1"); + + // Raid Configuration Dropdown box + Select raidConfigDroplist2 = new Select(driver.findElement( + By.id("raid_level"))); + raidConfigDroplist2.selectByIndex(0); + + //Select Disks CheckBox + WebElement diskCheckBox3 = driver.findElement(By.id("sdd")); + diskCheckBox3.click(); + WebElement diskCheckBox4 = driver.findElement(By.id("sde")); + diskCheckBox4.click(); + + // Create Pool + WebElement createPool2 = driver.findElement(By.id("create_pool")); + createPool2.click(); + + WebElement poolRowToCheckSize2 = driver.findElement( + By.xpath("//*[@id='pools-table']/tbody/tr[td[contains(.,'pool1')]]")); + assertTrue(poolRowToCheckSize2.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(); + } + + +} From 8d78637a5b4bfb830a41f34eabd289ab5d1bd064 Mon Sep 17 00:00:00 2001 From: Priyanka Ganti Date: Tue, 18 Jun 2013 13:12:49 -0700 Subject: [PATCH 2/5] Create Share test suite and corresponding test cases --- .../test/webdriver/CreateShareTestSuite.java | 14 ++ .../test/webdriver/CreateShareinGb.java | 161 +++++++++++++ .../test/webdriver/CreateShareinKb.java | 161 +++++++++++++ .../test/webdriver/CreateShareinMb.java | 159 +++++++++++++ .../test/webdriver/CreateShareinTb.java | 162 +++++++++++++ .../SharewithSameNameinDiffPools.java | 223 ++++++++++++++++++ .../SharewithSameNameinSamePool.java | 195 +++++++++++++++ 7 files changed, 1075 insertions(+) create mode 100644 java/src/main/java/com/rockstor/test/webdriver/CreateShareTestSuite.java create mode 100644 java/src/main/java/com/rockstor/test/webdriver/CreateShareinGb.java create mode 100644 java/src/main/java/com/rockstor/test/webdriver/CreateShareinKb.java create mode 100644 java/src/main/java/com/rockstor/test/webdriver/CreateShareinMb.java create mode 100644 java/src/main/java/com/rockstor/test/webdriver/CreateShareinTb.java create mode 100644 java/src/main/java/com/rockstor/test/webdriver/SharewithSameNameinDiffPools.java create mode 100644 java/src/main/java/com/rockstor/test/webdriver/SharewithSameNameinSamePool.java diff --git a/java/src/main/java/com/rockstor/test/webdriver/CreateShareTestSuite.java b/java/src/main/java/com/rockstor/test/webdriver/CreateShareTestSuite.java new file mode 100644 index 0000000..98bb886 --- /dev/null +++ b/java/src/main/java/com/rockstor/test/webdriver/CreateShareTestSuite.java @@ -0,0 +1,14 @@ +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({ShareSelectPool.class,CreateShareinKb.class,CreateShareinMb.class, + CreateShareinGb.class, CreateShareinTb.class, SharewithSameNameinSamePool.class, + SharewithSameNameinDiffPools.class}) + +public class CreateShareTestSuite { + +} + diff --git a/java/src/main/java/com/rockstor/test/webdriver/CreateShareinGb.java b/java/src/main/java/com/rockstor/test/webdriver/CreateShareinGb.java new file mode 100644 index 0000000..23e643b --- /dev/null +++ b/java/src/main/java/com/rockstor/test/webdriver/CreateShareinGb.java @@ -0,0 +1,161 @@ +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 CreateShareinGb { + 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 testShareSizeGb() 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(2); // 2 is GB + + + //Submit button to create share + WebElement shareSubmitButton = driver.findElement(By.id("create_share")); + shareSubmitButton.click(); + + //check for the text + WebElement shareRowToCheckSize = driver.findElement( + By.xpath("//*[@id='shares-table']/tbody/tr[td[contains(.,'100.00 Gb')]]")); + assertTrue(shareRowToCheckSize.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/CreateShareinKb.java b/java/src/main/java/com/rockstor/test/webdriver/CreateShareinKb.java new file mode 100644 index 0000000..cfdffa3 --- /dev/null +++ b/java/src/main/java/com/rockstor/test/webdriver/CreateShareinKb.java @@ -0,0 +1,161 @@ +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 CreateShareinKb { + 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 testShareSizeKb() 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); // 0 is KB + + + //Submit button to create share + WebElement shareSubmitButton = driver.findElement(By.id("create_share")); + shareSubmitButton.click(); + + + //Check for the text + WebElement shareRowToCheckSize = driver.findElement( + By.xpath("//*[@id='shares-table']/tbody/tr[td[contains(.,'100.00 Kb')]]")); + assertTrue(shareRowToCheckSize.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/CreateShareinMb.java b/java/src/main/java/com/rockstor/test/webdriver/CreateShareinMb.java new file mode 100644 index 0000000..e4a6a24 --- /dev/null +++ b/java/src/main/java/com/rockstor/test/webdriver/CreateShareinMb.java @@ -0,0 +1,159 @@ +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 CreateShareinMb { + 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 testShareSizeMb() 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(1); // 1 is MB + + + //Submit button to create share + WebElement shareSubmitButton = driver.findElement(By.id("create_share")); + shareSubmitButton.click(); + + //check for the text + WebElement shareRowToCheckSize = driver.findElement( + By.xpath("//*[@id='shares-table']/tbody/tr[td[contains(.,'100.00 Mb')]]")); + assertTrue(shareRowToCheckSize.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/CreateShareinTb.java b/java/src/main/java/com/rockstor/test/webdriver/CreateShareinTb.java new file mode 100644 index 0000000..8732389 --- /dev/null +++ b/java/src/main/java/com/rockstor/test/webdriver/CreateShareinTb.java @@ -0,0 +1,162 @@ +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 CreateShareinTb { + 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 testShareSizeTb() 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(3); // 3 is GB + + + //Submit button to create share + WebElement shareSubmitButton = driver.findElement(By.id("create_share")); + shareSubmitButton.click(); + + //check for the text + WebElement shareRowToCheckSize = driver.findElement( + By.xpath("//*[@id='shares-table']/tbody/tr[td[contains(.,'100.00 Tb')]]")); + assertTrue(shareRowToCheckSize.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/SharewithSameNameinDiffPools.java b/java/src/main/java/com/rockstor/test/webdriver/SharewithSameNameinDiffPools.java new file mode 100644 index 0000000..dc9883a --- /dev/null +++ b/java/src/main/java/com/rockstor/test/webdriver/SharewithSameNameinDiffPools.java @@ -0,0 +1,223 @@ +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 SharewithSameNameinDiffPools { + + 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 testShareSizeTb() 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(); + + ///Create 2nd pool + + WebElement addPool2 = driver.findElement(By.id("add_pool")); + addPool2.click(); + + WebElement poolname2 = driver.findElement(By.id("pool_name")); + poolname2.sendKeys("pool2"); + + // Raid Configuration Dropdown box + Select raidConfigDroplist2 = new Select(driver.findElement( + By.id("raid_level"))); + raidConfigDroplist2.selectByIndex(0); + + //Select Disks CheckBox + WebElement diskCheckBox3 = driver.findElement(By.id("sdd")); + diskCheckBox3.click(); + WebElement diskCheckBox4 = driver.findElement(By.id("sde")); + diskCheckBox4.click(); + + // Create Pool + WebElement createPool2 = driver.findElement(By.id("create_pool")); + createPool2.click(); + + //wait for pool2 to appear + WebElement poolLink2 = driver.findElement(By.linkText("pool2")); + poolLink2.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); // 0 is KB + + + //Submit button to create share + WebElement shareSubmitButton = driver.findElement(By.id("create_share")); + shareSubmitButton.click(); + + //check for the text + WebElement shareRowToCheckSize = driver.findElement( + By.xpath("//*[@id='shares-table']/tbody/tr[td[contains(.,'100.00 Kb')]]")); + assertTrue(shareRowToCheckSize.getText(),true); + + /// create 2nd share + + //Add share + WebElement addShareButton2 = driver.findElement(By.id("add_share")); + addShareButton2.click(); + + WebElement shareName2 = driver.findElement(By.id("share_name")); + shareName2.sendKeys("share1"); + + Select selectPoolDroplist2 = new Select(driver.findElement(By.id("pool_name"))); + selectPoolDroplist2.selectByIndex(1); + + + WebElement shareSize2 = driver.findElement(By.id("share_size")); + shareSize2.sendKeys("100"); + + + Select selectSizeDroplist2 = new Select(driver.findElement(By.id("size_format"))); + selectSizeDroplist2.selectByIndex(0); // 0 is KB + + + //Submit button to create share + WebElement shareSubmitButton2 = driver.findElement(By.id("create_share")); + shareSubmitButton2.click(); + + + //See if 2nd share with same name is created + WebElement shareRowToCheckSize2 = driver.findElement( + By.xpath("//*[@id='shares-table']/tbody/tr[td[contains(.,'100.00 Kb')]]")); + assertTrue(shareRowToCheckSize2.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/SharewithSameNameinSamePool.java b/java/src/main/java/com/rockstor/test/webdriver/SharewithSameNameinSamePool.java new file mode 100644 index 0000000..eac7ad5 --- /dev/null +++ b/java/src/main/java/com/rockstor/test/webdriver/SharewithSameNameinSamePool.java @@ -0,0 +1,195 @@ +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 SharewithSameNameinSamePool { + 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 testSameShareNamePool() 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); // 0 is KB + + + //Submit button to create share + WebElement shareSubmitButton = driver.findElement(By.id("create_share")); + shareSubmitButton.click(); + + //check for the text + WebElement shareRowToCheckSize = driver.findElement( + By.xpath("//*[@id='shares-table']/tbody/tr[td[contains(.,'100.00 Kb')]]")); + assertTrue(shareRowToCheckSize.getText(),true); + + // create 2nd share + //Add share + WebElement addShareButton2 = driver.findElement(By.id("add_share")); + addShareButton2.click(); + + WebElement shareName2 = driver.findElement(By.id("share_name")); + shareName2.sendKeys("share1"); + + Select selectPoolDroplist2 = new Select(driver.findElement(By.id("pool_name"))); + selectPoolDroplist2.selectByIndex(0); + + + WebElement shareSize2 = driver.findElement(By.id("share_size")); + shareSize2.sendKeys("100"); + + + Select selectSizeDroplist2 = new Select(driver.findElement(By.id("size_format"))); + selectSizeDroplist2.selectByIndex(0); // 0 is KB + + + //Submit button to create share + WebElement shareSubmitButton2 = driver.findElement(By.id("create_share")); + shareSubmitButton2.click(); + + //See if 2nd share with same name is created + WebElement shareRowToCheckSize2 = driver.findElement( + By.xpath("//*[@id='shares-table']/tbody/tr[td[contains(.,'100.00 Kb')]]")); + assertTrue(shareRowToCheckSize2.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(); + } + +} + + + + + + From e4dc308d8444a5e4b9cadd768bd6d634fc40ab2b Mon Sep 17 00:00:00 2001 From: Priyanka Ganti Date: Tue, 18 Jun 2013 13:18:24 -0700 Subject: [PATCH 3/5] Add ShareSelectPool test case to CreateShare test suite. --- .../rockstor/test/webdriver/ShareResize.java | 1 + .../test/webdriver/ShareSelectPool.java | 205 ++++++++++++++++++ 2 files changed, 206 insertions(+) create mode 100644 java/src/main/java/com/rockstor/test/webdriver/ShareSelectPool.java diff --git a/java/src/main/java/com/rockstor/test/webdriver/ShareResize.java b/java/src/main/java/com/rockstor/test/webdriver/ShareResize.java index 832db4b..2977203 100644 --- a/java/src/main/java/com/rockstor/test/webdriver/ShareResize.java +++ b/java/src/main/java/com/rockstor/test/webdriver/ShareResize.java @@ -133,6 +133,7 @@ public void testShareResize() throws Exception { 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); diff --git a/java/src/main/java/com/rockstor/test/webdriver/ShareSelectPool.java b/java/src/main/java/com/rockstor/test/webdriver/ShareSelectPool.java new file mode 100644 index 0000000..4093ca7 --- /dev/null +++ b/java/src/main/java/com/rockstor/test/webdriver/ShareSelectPool.java @@ -0,0 +1,205 @@ +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 ShareSelectPool { + + 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 testSelectPoolInShare() 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(); + + + //Create 2nd Pool + + // Add Pool with Raid 0 + WebElement addPool2 = driver.findElement(By.id("add_pool")); + addPool2.click(); + + WebElement poolname2 = driver.findElement(By.id("pool_name")); + poolname2.sendKeys("pool2"); + + // Raid Configuration Dropdown box + Select raidConfigDroplist2 = new Select(driver.findElement( + By.id("raid_level"))); + raidConfigDroplist2.selectByIndex(0); + + //Select Disks CheckBox + WebElement diskCheckBox3 = driver.findElement(By.id("sdd")); + diskCheckBox3.click(); + WebElement diskCheckBox4 = driver.findElement(By.id("sde")); + diskCheckBox4.click(); + + // Create Pool + WebElement createPool2 = driver.findElement(By.id("create_pool")); + createPool2.click(); + + //wait for the pool to get created + WebElement poolPage = driver.findElement(By.linkText("pool2")); + poolPage.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"))); + + WebElement verifyPoolSelect = driver. findElement( + By.xpath("//div/form/select/option[contains(.,'pool1') or contains(.,'pool2')]")); + assertTrue(verifyPoolSelect.getText(),true); + 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); // 0 is KB + + + //Submit button to create share + WebElement shareSubmitButton = driver.findElement(By.id("create_share")); + shareSubmitButton.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 poolsNav2 = driver.findElement(By.id("pools_nav")); + poolsNav2.click(); + + 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(); + + + WebElement poolRow2ToDelete = driver.findElement(By.xpath("//*[@id='pools-table']/tbody/tr[td[contains(.,'pool2')]]")); + WebElement deletePool2 = poolRow2ToDelete.findElement(By.xpath("td/button[contains(@data-name,'pool2') and contains(@data-action,'delete')]")); + deletePool2.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(); + } + + +} + + + + + + + + + From 1e84c28adf5ad4cda6edb08b849d4f83b7170b09 Mon Sep 17 00:00:00 2001 From: Priyanka Ganti Date: Tue, 18 Jun 2013 16:58:53 -0700 Subject: [PATCH 4/5] Shares test suite and test cases. --- .../rockstor/test/webdriver/DeleteShare.java | 168 ++++++++++++ .../test/webdriver/LinkToSharePage.java | 184 +++++++++++++ .../test/webdriver/ListSharesWithSizes.java | 164 ++++++++++++ .../webdriver/MultipleSharesinSamePool.java | 242 ++++++++++++++++++ .../test/webdriver/SharesTestSuite.java | 13 + 5 files changed, 771 insertions(+) create mode 100644 java/src/main/java/com/rockstor/test/webdriver/DeleteShare.java create mode 100644 java/src/main/java/com/rockstor/test/webdriver/LinkToSharePage.java create mode 100644 java/src/main/java/com/rockstor/test/webdriver/ListSharesWithSizes.java create mode 100644 java/src/main/java/com/rockstor/test/webdriver/MultipleSharesinSamePool.java create mode 100644 java/src/main/java/com/rockstor/test/webdriver/SharesTestSuite.java diff --git a/java/src/main/java/com/rockstor/test/webdriver/DeleteShare.java b/java/src/main/java/com/rockstor/test/webdriver/DeleteShare.java new file mode 100644 index 0000000..f5d2124 --- /dev/null +++ b/java/src/main/java/com/rockstor/test/webdriver/DeleteShare.java @@ -0,0 +1,168 @@ +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 DeleteShare { + + 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(); + + //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(); + + //wait for the pool to get created + WebElement poolPage = driver.findElement(By.linkText("pool1")); + poolPage.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); // 0 is KB + + + //Submit button to create share + WebElement shareSubmitButton = driver.findElement(By.id("create_share")); + shareSubmitButton.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(); + + // verify if all shares are deleted + WebElement verifyTextPresent = driver.findElement( + By.xpath("//div/h4[text()='No shares have been created']")); + assertTrue(verifyTextPresent.getText(), true); + + ///Also delete the pool + + WebElement poolsNav2 = driver.findElement(By.id("pools_nav")); + poolsNav2.click(); + + 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(); + } +} + + diff --git a/java/src/main/java/com/rockstor/test/webdriver/LinkToSharePage.java b/java/src/main/java/com/rockstor/test/webdriver/LinkToSharePage.java new file mode 100644 index 0000000..1675d04 --- /dev/null +++ b/java/src/main/java/com/rockstor/test/webdriver/LinkToSharePage.java @@ -0,0 +1,184 @@ + +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 LinkToSharePage { + + 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 testLinkforSharePage() 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(); + + //wait for the pool to get created + WebElement poolPage = driver.findElement(By.linkText("pool1")); + poolPage.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); // 0 is KB + + + //Submit button to create share + WebElement shareSubmitButton = driver.findElement(By.id("create_share")); + shareSubmitButton.click(); + + // verify the presence of link to share details page + WebElement verifyLinkPresent = driver. findElement( + By.xpath("//*[@id='shares-table']/tbody/tr/td/a[contains(@href,'share1')]")); + assertTrue(verifyLinkPresent.getText(),true); + verifyLinkPresent.click(); + + + WebElement shareDetailsPageText = driver.findElement( + By.xpath("//div/span[text()='Share share1']")); + assertTrue(shareDetailsPageText.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 + + WebElement poolsNav2 = driver.findElement(By.id("pools_nav")); + poolsNav2.click(); + + 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(); + } + + +} + + + + + + + + + diff --git a/java/src/main/java/com/rockstor/test/webdriver/ListSharesWithSizes.java b/java/src/main/java/com/rockstor/test/webdriver/ListSharesWithSizes.java new file mode 100644 index 0000000..f9dbd64 --- /dev/null +++ b/java/src/main/java/com/rockstor/test/webdriver/ListSharesWithSizes.java @@ -0,0 +1,164 @@ +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 ListSharesWithSizes { + + 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 testSharesandSize() 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(); + + WebElement shareRowNameSize = driver.findElement( + By.xpath("//*[@id='shares-table']/tbody/tr/td/a[contains(.,'share1') or contains(.,'100.00 Kb')]")); + assertTrue(shareRowNameSize.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/MultipleSharesinSamePool.java b/java/src/main/java/com/rockstor/test/webdriver/MultipleSharesinSamePool.java new file mode 100644 index 0000000..e602457 --- /dev/null +++ b/java/src/main/java/com/rockstor/test/webdriver/MultipleSharesinSamePool.java @@ -0,0 +1,242 @@ +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 MultipleSharesinSamePool { + 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 testMultipleSharesSamePool() 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(); + + //1st Share + + //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 shareRow1ToCheckName = driver.findElement( + By.xpath("//*[@id='shares-table']/tbody/tr[td[contains(.,'share1')]]")); + assertTrue(shareRow1ToCheckName.getText(),true); + + + // 2nd Share + + WebElement addShareButton2 = driver.findElement(By.id("add_share")); + addShareButton2.click(); + + WebElement shareName2 = driver.findElement(By.id("share_name")); + shareName2.sendKeys("share2"); + + Select selectPoolDroplist2 = new Select(driver.findElement( + By.id("pool_name"))); + selectPoolDroplist2.selectByIndex(0); + + WebElement shareSize2 = driver.findElement(By.id("share_size")); + shareSize2.sendKeys("1000"); + + Select selectSizeDroplist2 = new Select(driver.findElement( + By.id("size_format"))); + selectSizeDroplist2.selectByIndex(0);//Index 0 is KB + + // Submit button to create share + WebElement shareSubmitButton2 = driver.findElement( + By.id("create_share")); + shareSubmitButton2.click(); + + WebElement shareRow2ToCheckName = driver.findElement( + By.xpath("//*[@id='shares-table']/tbody/tr[td[contains(.,'share2')]]")); + assertTrue(shareRow2ToCheckName.getText(),true); + + + // 3rd Share + + WebElement addShareButton3 = driver.findElement(By.id("add_share")); + addShareButton3.click(); + + WebElement shareName3 = driver.findElement(By.id("share_name")); + shareName3.sendKeys("share3"); + + Select selectPoolDroplist3 = new Select(driver.findElement( + By.id("pool_name"))); + selectPoolDroplist3.selectByIndex(0); + + WebElement shareSize3 = driver.findElement(By.id("share_size")); + shareSize3.sendKeys("10000"); + + Select selectSizeDroplist3 = new Select(driver.findElement( + By.id("size_format"))); + selectSizeDroplist3.selectByIndex(0);//Index 0 is KB + + // Submit button to create share + WebElement shareSubmitButton3 = driver.findElement( + By.id("create_share")); + shareSubmitButton3.click(); + + WebElement shareRow3ToCheckName = driver.findElement( + By.xpath("//*[@id='shares-table']/tbody/tr[td[contains(.,'share3')]]")); + assertTrue(shareRow3ToCheckName.getText(),true); + + + //Delete 1st 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 2nd Share + WebElement shareRow2 = driver.findElement( + By.xpath("//*[@id='shares-table']/tbody/tr[td[contains(.,'share2')]]")); + WebElement deleteShare2 = shareRow2.findElement( + By.xpath("td/button[contains(@data-name,'share2') and contains(@data-action,'delete')]")); + deleteShare2.click(); + + + //Delete 3rd Share + WebElement shareRow3 = driver.findElement( + By.xpath("//*[@id='shares-table']/tbody/tr[td[contains(.,'share3')]]")); + WebElement deleteShare3 = shareRow3.findElement( + By.xpath("td/button[contains(@data-name,'share3') and contains(@data-action,'delete')]")); + deleteShare3.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/SharesTestSuite.java b/java/src/main/java/com/rockstor/test/webdriver/SharesTestSuite.java new file mode 100644 index 0000000..c85919e --- /dev/null +++ b/java/src/main/java/com/rockstor/test/webdriver/SharesTestSuite.java @@ -0,0 +1,13 @@ +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({LinkToSharePage.class,DeleteShare.class,ListSharesWithSizes.class, + MultipleSharesinSamePool.class,}) + +public class SharesTestSuite { + +} + From a335e5980090ff2ba4faf0608bd3ee0ccc45d2a1 Mon Sep 17 00:00:00 2001 From: Priyanka Ganti Date: Tue, 18 Jun 2013 17:27:57 -0700 Subject: [PATCH 5/5] Add Delete pool, shares tests inside the test suite. --- .../webdriver/CheckShareUsedandFreeSpace.java | 10 +- .../test/webdriver/CreatePoolTestSuite.java | 2 +- .../test/webdriver/CreateShareTestSuite.java | 3 +- .../DeleteMultiplePoolsandShares.java | 107 ++++++++++++++++++ .../rockstor/test/webdriver/DeletePool.java | 91 +++++++++++++++ .../test/webdriver/DeleteShareandPool.java | 3 +- .../test/webdriver/RockStorSuite.java | 4 +- .../SharewithSameNameinDiffPools.java | 2 +- 8 files changed, 211 insertions(+), 11 deletions(-) create mode 100644 java/src/main/java/com/rockstor/test/webdriver/DeleteMultiplePoolsandShares.java create mode 100644 java/src/main/java/com/rockstor/test/webdriver/DeletePool.java diff --git a/java/src/main/java/com/rockstor/test/webdriver/CheckShareUsedandFreeSpace.java b/java/src/main/java/com/rockstor/test/webdriver/CheckShareUsedandFreeSpace.java index f77fd21..cb32e36 100644 --- a/java/src/main/java/com/rockstor/test/webdriver/CheckShareUsedandFreeSpace.java +++ b/java/src/main/java/com/rockstor/test/webdriver/CheckShareUsedandFreeSpace.java @@ -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(); diff --git a/java/src/main/java/com/rockstor/test/webdriver/CreatePoolTestSuite.java b/java/src/main/java/com/rockstor/test/webdriver/CreatePoolTestSuite.java index 5ad1818..7de5323 100644 --- a/java/src/main/java/com/rockstor/test/webdriver/CreatePoolTestSuite.java +++ b/java/src/main/java/com/rockstor/test/webdriver/CreatePoolTestSuite.java @@ -9,7 +9,7 @@ CreatePoolRaid1with1Disk.class,CreatePoolRaid1with1Disk.class,CreatePoolRaid10with1Disk.class, CreatePoolRaid10with0Disks.class,CreatePoolRaid10with3Disks.class, CreatePoolRaid0with5Disks.class,CreatePoolRaid1with5Disks.class,CreatePoolRaid10with10Disks.class, - NoDisplayofDisksAlreadyinUse.class,TwoPoolsWithSameName.class}) + NoDisplayofDisksAlreadyinUse.class,TwoPoolsWithSameName.class,DeletePool.class}) public class CreatePoolTestSuite { diff --git a/java/src/main/java/com/rockstor/test/webdriver/CreateShareTestSuite.java b/java/src/main/java/com/rockstor/test/webdriver/CreateShareTestSuite.java index 98bb886..06b3ec8 100644 --- a/java/src/main/java/com/rockstor/test/webdriver/CreateShareTestSuite.java +++ b/java/src/main/java/com/rockstor/test/webdriver/CreateShareTestSuite.java @@ -6,7 +6,8 @@ @RunWith(Suite.class) @SuiteClasses({ShareSelectPool.class,CreateShareinKb.class,CreateShareinMb.class, CreateShareinGb.class, CreateShareinTb.class, SharewithSameNameinSamePool.class, - SharewithSameNameinDiffPools.class}) + DeleteShareandPool.class,SharewithSameNameinDiffPools.class, + DeleteMultiplePoolsandShares.class}) public class CreateShareTestSuite { diff --git a/java/src/main/java/com/rockstor/test/webdriver/DeleteMultiplePoolsandShares.java b/java/src/main/java/com/rockstor/test/webdriver/DeleteMultiplePoolsandShares.java new file mode 100644 index 0000000..f9adfe2 --- /dev/null +++ b/java/src/main/java/com/rockstor/test/webdriver/DeleteMultiplePoolsandShares.java @@ -0,0 +1,107 @@ +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 DeleteMultiplePoolsandShares { + + 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 testdelete2Pools() 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(); + + //delete 2nd pool + WebElement poolRow2 = driver.findElement(By.xpath("//*[@id='pools-table']/tbody/tr[td[contains(.,'pool2')]]")); + WebElement deletePool2 = poolRow2.findElement(By.xpath("td/button[contains(@data-name,'pool2') and contains(@data-action,'delete')]")); + deletePool2.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/DeletePool.java b/java/src/main/java/com/rockstor/test/webdriver/DeletePool.java new file mode 100644 index 0000000..8bb8a2f --- /dev/null +++ b/java/src/main/java/com/rockstor/test/webdriver/DeletePool.java @@ -0,0 +1,91 @@ +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 DeletePool { + + 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 testdeletePool() 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 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/DeleteShareandPool.java b/java/src/main/java/com/rockstor/test/webdriver/DeleteShareandPool.java index 2f528e5..0283bc5 100644 --- a/java/src/main/java/com/rockstor/test/webdriver/DeleteShareandPool.java +++ b/java/src/main/java/com/rockstor/test/webdriver/DeleteShareandPool.java @@ -23,7 +23,6 @@ import java.util.Properties; import java.util.concurrent.TimeUnit; import java.util.List; - import junit.framework.Assert; import com.rockstor.test.util.RSProps; @@ -41,7 +40,7 @@ public static void setUpBeforeClass() throws Exception { } @Test - public void testSharePoolnameValidate() throws Exception { + public void testDeleteShareandPool() throws Exception { try{ driver.get(RSProps.getProperty("RockstorVm")); 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 421989e..ef122d9 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,9 @@ import org.junit.runners.Suite.SuiteClasses; @RunWith(Suite.class) -@SuiteClasses({ShareDetailsSuite.class}) +@SuiteClasses({ShareDetailsSuite.class,CreatePoolTestSuite.class,CreateShareTestSuite.class + ,SharesTestSuite.class}) public class RockStorSuite { } + diff --git a/java/src/main/java/com/rockstor/test/webdriver/SharewithSameNameinDiffPools.java b/java/src/main/java/com/rockstor/test/webdriver/SharewithSameNameinDiffPools.java index dc9883a..2467b73 100644 --- a/java/src/main/java/com/rockstor/test/webdriver/SharewithSameNameinDiffPools.java +++ b/java/src/main/java/com/rockstor/test/webdriver/SharewithSameNameinDiffPools.java @@ -38,7 +38,7 @@ public static void setUpBeforeClass() throws Exception { } @Test - public void testShareSizeTb() throws Exception { + public void testShareNameinDiffPools() throws Exception { try{ driver.get(RSProps.getProperty("RockstorVm"));