This repository has been archived by the owner on Apr 4, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #25 from priyaganti/master
solves issue #19 (Pools test suite)
- Loading branch information
Showing
9 changed files
with
666 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
191 changes: 191 additions & 0 deletions
191
java/src/main/java/com/rockstor/test/webdriver/DeletePoolSharenotPresent.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,191 @@ | ||
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.Alert; | ||
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 DeletePoolSharenotPresent { | ||
|
||
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 testDeletPoolWhenSharenotPresent() 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 poolPage = driver.findElement(By.linkText("pool1")); | ||
poolPage.click(); | ||
|
||
//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(); | ||
|
||
//wait for shares page to load | ||
WebElement shareRow = driver.findElement( | ||
By.xpath("//*[@id='shares-table']/tbody/tr[td[contains(.,'1') or contains(.,'share1') or contains(.,'pool1')]]")); | ||
assertTrue(shareRow.getText(),true); | ||
|
||
|
||
WebElement poolsNav2 = driver.findElement(By.id("pools_nav")); | ||
poolsNav2.click(); | ||
|
||
//Delete Share | ||
WebElement sharesNav = driver.findElement(By.id("shares_nav")); | ||
sharesNav.click(); | ||
|
||
WebElement shareRowDelete = driver.findElement(By.xpath("//*[@id='shares-table']/tbody/tr[td[contains(.,'share1')]]")); | ||
WebElement deleteShare = shareRowDelete.findElement(By.xpath("td/button[contains(@data-name,'share1') and contains(@data-action,'delete')]")); | ||
deleteShare.click(); | ||
|
||
//Browser Popup asking confirmation to delete | ||
Alert alertDeleteShare = driver.switchTo().alert(); | ||
alertDeleteShare.accept(); | ||
|
||
// verify if all shares are deleted | ||
WebElement verifyTextPresent = driver.findElement( | ||
By.xpath("//div/h4[text()='No shares have been created']")); | ||
assertTrue(verifyTextPresent.getText(), true); | ||
|
||
|
||
//Delete Pool | ||
|
||
WebElement poolsNav3 = driver.findElement(By.id("pools_nav")); | ||
poolsNav3.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(); | ||
|
||
Alert alertDeletePool = driver.switchTo().alert(); | ||
alertDeletePool.accept(); | ||
|
||
WebElement textVerify = driver.findElement( | ||
By.xpath("//h4[text()='No pools have been created.']")); | ||
assertTrue(textVerify.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(); | ||
} | ||
|
||
|
||
} | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
168 changes: 168 additions & 0 deletions
168
java/src/main/java/com/rockstor/test/webdriver/DeletePoolSharesPresent.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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.Alert; | ||
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 DeletePoolSharesPresent { | ||
|
||
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 testDeletPoolWhenSharePresent() 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 poolPage = driver.findElement(By.linkText("pool1")); | ||
poolPage.click(); | ||
|
||
//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(); | ||
|
||
//wait for shares page to load | ||
WebElement shareRow = driver.findElement( | ||
By.xpath("//*[@id='shares-table']/tbody/tr[td[contains(.,'1') or contains(.,'share1') or contains(.,'pool1')]]")); | ||
assertTrue(shareRow.getText(),true); | ||
|
||
|
||
WebElement poolsNav2 = driver.findElement(By.id("pools_nav")); | ||
poolsNav2.click(); | ||
|
||
//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(); | ||
|
||
Alert alertDeletePool = driver.switchTo().alert(); | ||
alertDeletePool.accept(); | ||
|
||
WebElement textVerify = driver.findElement( | ||
By.xpath("//h4[text()='No pools have been created.']")); | ||
assertTrue(textVerify.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(); | ||
} | ||
|
||
|
||
} | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
Oops, something went wrong.