From eb485af6caa780c4d05443adf50d344ef47d29e3 Mon Sep 17 00:00:00 2001 From: prabushi Date: Wed, 25 May 2016 14:48:44 +0530 Subject: [PATCH 1/6] added carbon archive theme deployer test --- .../test/common/CustomThemeDeployerTest.java | 96 ++++++++++++++++++ .../test/dashboard/AddCustomThemeTest.java | 16 +++ .../src/test/resources/files/Custom_Theme.car | Bin 0 -> 7196 bytes .../tests-ui/src/test/resources/testng.xml | 1 + 4 files changed, 113 insertions(+) create mode 100644 modules/integration/tests-ui-integration/tests-ui/src/test/java/org/wso2/ds/ui/integration/test/common/CustomThemeDeployerTest.java create mode 100644 modules/integration/tests-ui-integration/tests-ui/src/test/java/org/wso2/ds/ui/integration/test/dashboard/AddCustomThemeTest.java create mode 100644 modules/integration/tests-ui-integration/tests-ui/src/test/resources/files/Custom_Theme.car diff --git a/modules/integration/tests-ui-integration/tests-ui/src/test/java/org/wso2/ds/ui/integration/test/common/CustomThemeDeployerTest.java b/modules/integration/tests-ui-integration/tests-ui/src/test/java/org/wso2/ds/ui/integration/test/common/CustomThemeDeployerTest.java new file mode 100644 index 00000000..10402492 --- /dev/null +++ b/modules/integration/tests-ui-integration/tests-ui/src/test/java/org/wso2/ds/ui/integration/test/common/CustomThemeDeployerTest.java @@ -0,0 +1,96 @@ +package org.wso2.ds.ui.integration.test.common; + +import org.openqa.selenium.By; +import org.testng.annotations.AfterClass; +import org.testng.annotations.Test; +import org.wso2.carbon.automation.engine.frameworkutils.FrameworkPathUtil; +import org.wso2.ds.ui.integration.util.DSUIIntegrationTest; + +import javax.xml.xpath.XPathExpressionException; +import java.io.File; +import java.net.MalformedURLException; + +import static org.testng.Assert.assertFalse; +import static org.testng.Assert.assertTrue; + +/** + * Test cases related to deploying a custom theme files using a carbon archive file + */ +public class CustomThemeDeployerTest extends DSUIIntegrationTest { + private static final String USER_NAME = "admin"; + private static final String PASSWORD = "admin"; + private static final String CUSTOM_THEME_NAME = "custom-theme-sample"; + + /** + * Initializes class + */ + public CustomThemeDeployerTest() { + super(); + } + + /** + * This test case checks for the availability of custom theme files before deploying, after deploying and after + * un deploying the .car file + * + * @throws MalformedURLException + * @throws XPathExpressionException + * @throws InterruptedException + */ + @Test(groups = "wso2.ds.common", description = "Deploying and un-deploying a custom theme in the admin console") + public void addDeleteCustomTheme() throws MalformedURLException, XPathExpressionException, InterruptedException { + + //log in to admin console + loginToAdminConsole(USER_NAME, PASSWORD); + + //get the path to custom theme carbon archive file + String systemResourceLocation = FrameworkPathUtil.getSystemResourceLocation(); + String carFilePath = systemResourceLocation + "files/Custom_Theme.car"; + + //get the path to store location of custom themes + String carbonHome = FrameworkPathUtil.getCarbonHome(); + String themeStoredLocation = carbonHome + File.separator + "repository" + File.separator + "deployment" + + File.separator + "server" + File.separator + "jaggeryapps" + File.separator + "portal" + + File.separator + "store" + File.separator + "carbon.super" + File.separator + "fs" + + File.separator + "theme" + File.separator + CUSTOM_THEME_NAME; + + //check for custom theme availability before deploying the .car file + File folder = new File(themeStoredLocation); + assertFalse(folder.exists(), + "Before deploying the theme, the " + CUSTOM_THEME_NAME + " folder should not " + "exist in " + + themeStoredLocation); + + //check for custom theme availability after deploying the .car file + getDriver().findElement(By.xpath("(//a[contains(text(),'Add')])[7]")).click(); + getDriver().findElement(By.id("filename")).sendKeys(carFilePath); + getDriver().findElement(By.name("upload")).click(); + getDriver().findElement(By.cssSelector("button[type=\"button\"]")).click(); + Thread.sleep(15000); + folder = new File(themeStoredLocation); + assertTrue(folder.exists(), "After deploying the theme, the " + CUSTOM_THEME_NAME + " folder should exist in " + + themeStoredLocation); + + //check for custom theme availability after un deploying the .car file + getDriver().findElement(By.xpath("(//a[contains(text(),'List')])[6]")).click(); + getDriver().findElement(By.linkText("Delete")).click(); + getDriver().findElement(By.cssSelector("button[type=\"button\"]")).click(); + Thread.sleep(15000); + folder = new File(themeStoredLocation); + assertFalse(folder.exists(), + "After un-deploying the theme, the " + CUSTOM_THEME_NAME + " folder should not " + "exist in " + + themeStoredLocation); + } + + /** + * Clean up after running tests + * + * @throws MalformedURLException + * @throws XPathExpressionException + */ + @AfterClass(alwaysRun = true) public void tearDown() throws MalformedURLException, XPathExpressionException { + try { + logoutFromAdminConsole(); + } finally { + getDriver().quit(); + } + } +} diff --git a/modules/integration/tests-ui-integration/tests-ui/src/test/java/org/wso2/ds/ui/integration/test/dashboard/AddCustomThemeTest.java b/modules/integration/tests-ui-integration/tests-ui/src/test/java/org/wso2/ds/ui/integration/test/dashboard/AddCustomThemeTest.java new file mode 100644 index 00000000..69f1e097 --- /dev/null +++ b/modules/integration/tests-ui-integration/tests-ui/src/test/java/org/wso2/ds/ui/integration/test/dashboard/AddCustomThemeTest.java @@ -0,0 +1,16 @@ +package org.wso2.ds.ui.integration.test.dashboard; + +/** + * Created by prabushi on 5/25/16. + */ +public class AddCustomThemeTest { + private static final String USER_NAME = "admin"; + private static final String PASSWORD = "admin"; + private static final String CUSTOM_THEME_NAME = "custom-theme-sample"; + /** + * Initializes class + */ + public AddCustomThemeTest() { + super(); + } +} diff --git a/modules/integration/tests-ui-integration/tests-ui/src/test/resources/files/Custom_Theme.car b/modules/integration/tests-ui-integration/tests-ui/src/test/resources/files/Custom_Theme.car new file mode 100644 index 0000000000000000000000000000000000000000..a836bb0ddc179d4f25f7d089a71feae89c9daa76 GIT binary patch literal 7196 zcmb_h2RIe#|35az3>890M##+W%E%@enHgC})-leo30c{DX3vyOHbq9+WK(8G#^oFl zivGuSZ~4jZKF__szw><0a}Lk*e#ZNr_xtrZ>MA(6)Bpe>ApnG5tC&9Ypx_w*03g5u z07wD!08=R3+S1e<4&!l!*lBAK0dR74Wps}U;Ytj^!d=Dz0RDJ_L^hGN@{#yI*r$&E zqB%~pFW}<}U>AVKN--~~DTORgE$C4D`io?!eb{^Z(OS@>iz2@AyxrI(lOgEUxF%gk z>&QK_lpELhSr9VmW@-E>{e4_?`mel$-z3{ksW8tGh+qvbziH!#_gz?S(xIoK&Fs_3 zi!#0^oy=^IxtQkWmg4FryRd!vd4(alUl#`n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ANMmi*cA@8hgmz= z!+30tqYO?A`ca)?z{?5b1RbXyARAL>Q60La;ZdDp`4chb6r%M1fM{)RZim3=JWiMl zF|bE<2J~^lqz*1EmLbvzD5Dzr-BJxfrZ7qTG{OevMI2YT?5EJFGKUV2&XM z^UOf?NZ+x4zecJjG2{L*=5fG^!96ov{pstk@#;xm0hlim&QSE{zMb(G-Xq-O-yhGC z7zSqqtv?PUW@mpLVNWt(B>OiEeq5M8NSraup4{?ZJHko(wW$6ni9h-SM*Eq);peXZ z+8s`6Z}~T{Kct`T6&N;W^of%u{Cex3Gy#FRJI>hgzc~vhdjJOg%=`bR7r%CZljz9* z0sTZjz|c6e7ySG{{MrppZi(6Xe{aGM8fWwd46if#g1QPG{?Tnrf_YToVLH==qj&!Y Dk`iFg literal 0 HcmV?d00001 diff --git a/modules/integration/tests-ui-integration/tests-ui/src/test/resources/testng.xml b/modules/integration/tests-ui-integration/tests-ui/src/test/resources/testng.xml index 74a5704a..a4e9bad2 100755 --- a/modules/integration/tests-ui-integration/tests-ui/src/test/resources/testng.xml +++ b/modules/integration/tests-ui-integration/tests-ui/src/test/resources/testng.xml @@ -38,6 +38,7 @@ + From 0b55576c8e0ed7206e4bfad0cdbc5dbf8ee67e63 Mon Sep 17 00:00:00 2001 From: prabushi Date: Wed, 25 May 2016 16:46:24 +0530 Subject: [PATCH 2/6] added theme deploying --- .../test/dashboard/AddCustomThemeTest.java | 16 -- .../AddCustomThemeToDashboardTest.java | 218 ++++++++++++++++++ 2 files changed, 218 insertions(+), 16 deletions(-) delete mode 100644 modules/integration/tests-ui-integration/tests-ui/src/test/java/org/wso2/ds/ui/integration/test/dashboard/AddCustomThemeTest.java create mode 100644 modules/integration/tests-ui-integration/tests-ui/src/test/java/org/wso2/ds/ui/integration/test/dashboard/AddCustomThemeToDashboardTest.java diff --git a/modules/integration/tests-ui-integration/tests-ui/src/test/java/org/wso2/ds/ui/integration/test/dashboard/AddCustomThemeTest.java b/modules/integration/tests-ui-integration/tests-ui/src/test/java/org/wso2/ds/ui/integration/test/dashboard/AddCustomThemeTest.java deleted file mode 100644 index 69f1e097..00000000 --- a/modules/integration/tests-ui-integration/tests-ui/src/test/java/org/wso2/ds/ui/integration/test/dashboard/AddCustomThemeTest.java +++ /dev/null @@ -1,16 +0,0 @@ -package org.wso2.ds.ui.integration.test.dashboard; - -/** - * Created by prabushi on 5/25/16. - */ -public class AddCustomThemeTest { - private static final String USER_NAME = "admin"; - private static final String PASSWORD = "admin"; - private static final String CUSTOM_THEME_NAME = "custom-theme-sample"; - /** - * Initializes class - */ - public AddCustomThemeTest() { - super(); - } -} diff --git a/modules/integration/tests-ui-integration/tests-ui/src/test/java/org/wso2/ds/ui/integration/test/dashboard/AddCustomThemeToDashboardTest.java b/modules/integration/tests-ui-integration/tests-ui/src/test/java/org/wso2/ds/ui/integration/test/dashboard/AddCustomThemeToDashboardTest.java new file mode 100644 index 00000000..16f76757 --- /dev/null +++ b/modules/integration/tests-ui-integration/tests-ui/src/test/java/org/wso2/ds/ui/integration/test/dashboard/AddCustomThemeToDashboardTest.java @@ -0,0 +1,218 @@ +package org.wso2.ds.ui.integration.test.dashboard; + +import org.openqa.selenium.By; +import org.testng.annotations.AfterClass; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Factory; +import org.testng.annotations.Test; +import org.wso2.carbon.automation.engine.context.TestUserMode; +import org.wso2.carbon.automation.engine.frameworkutils.FrameworkPathUtil; +import org.wso2.ds.ui.integration.util.DSUIIntegrationTest; + +import javax.xml.xpath.XPathExpressionException; +import java.io.File; +import java.net.MalformedURLException; + +/** + * Created by prabushi on 5/25/16. + */ +public class AddCustomThemeToDashboardTest extends DSUIIntegrationTest { + private static final String USER_NAME = "admin"; + private static final String PASSWORD = "admin"; + private static final String CUSTOM_THEME_NAME = "custom-theme-sample"; + //get the path to custom theme carbon archive file + String systemResourceLocation = FrameworkPathUtil.getSystemResourceLocation(); + String carFilePath = systemResourceLocation + "files/Custom_Theme.car"; + + //get the path to store location of custom themes + String carbonHome = FrameworkPathUtil.getCarbonHome(); + String themeStoredLocation = carbonHome + File.separator + "repository" + File.separator + "deployment" + + File.separator + "server" + File.separator + "jaggeryapps" + File.separator + "portal" + + File.separator + "store" + File.separator + "carbon.super" + File.separator + "fs" + + File.separator + "theme" + File.separator + CUSTOM_THEME_NAME; + + @Factory(dataProvider = "userMode") + public AddCustomThemeToDashboardTest(TestUserMode userMode) { + super(userMode); + } + + /** + * Setup the testing environment. + * + * @throws MalformedURLException + * @throws XPathExpressionException + * @throws InterruptedException + */ + @BeforeClass(alwaysRun = true) public void setUp() + throws MalformedURLException, XPathExpressionException, InterruptedException { + //log in to admin console + loginToAdminConsole(USER_NAME, PASSWORD); + + //deploy the custom theme file + getDriver().findElement(By.xpath("(//a[contains(text(),'Add')])[7]")).click(); + getDriver().findElement(By.id("filename")).sendKeys(carFilePath); + getDriver().findElement(By.name("upload")).click(); + getDriver().findElement(By.cssSelector("button[type=\"button\"]")).click(); + Thread.sleep(15000); + //logout from admin console + logoutFromAdminConsole(); + } + + @Test(groups = "wso2.ds.dashboard", description = "Adding a custom theme when creating a dashboard") + public void addCustomThemeToDashboard() throws XPathExpressionException, MalformedURLException { + //log in to portal + login(getCurrentUsername(), getCurrentPassword()); + + } + +// driver.findElement(By.name("username")).clear(); +// driver.findElement(By.name("username")).sendKeys("admin"); +// driver.findElement(By.name("password")).clear(); +// driver.findElement(By.name("password")).sendKeys("admin"); +// driver.findElement(By.xpath("//button[@type='submit']")).click(); + driver.findElement(By.xpath("//div[@id='navbar']/ul/li/a/span/i[2]")).click(); + driver.findElement(By.id("ues-dashboard-title")).clear(); + driver.findElement(By.id("ues-dashboard-title")).sendKeys("sample-dashboard"); + driver.findElement(By.id("ues-dashboard-description")).clear(); + driver.findElement(By.id("ues-dashboard-description")).sendKeys("This is a sample dashboard"); + new Select(driver.findElement(By.id("ues-theme-list"))).selectByVisibleText("custom-theme-sample"); + driver.findElement(By.id("ues-dashboard-create")).click(); + // ERROR: Caught exception [ERROR: Unsupported command [selectWindow | name=opensearch | ]] + driver.findElement(By.xpath("//div[@id='ues-page-layouts']/div[2]/img")).click(); + // ERROR: Caught exception [ERROR: Unsupported command [selectWindow | name=opensearch | ]] + driver.findElement(By.id("pagesButtonlanding")).click(); + // ERROR: Caught exception [ERROR: Unsupported command [selectWindow | name=opensearch | ]] + driver.findElement(By.id("pagesButtonlanding")).click(); + // ERROR: Caught exception [ERROR: Unsupported command [selectWindow | name=opensearch | ]] + driver.findElement(By.id("pagesButtonlanding")).click(); + // ERROR: Caught exception [ERROR: Unsupported command [selectWindow | name=opensearch | ]] + driver.findElement(By.id("pagesButtonlanding")).click(); + // ERROR: Caught exception [ERROR: Unsupported command [selectWindow | name=opensearch | ]] + driver.findElement(By.id("pagesButtonlanding")).click(); + // ERROR: Caught exception [ERROR: Unsupported command [selectWindow | name=opensearch | ]] + driver.findElement(By.id("pagesButtonlanding")).click(); + // ERROR: Caught exception [ERROR: Unsupported command [selectWindow | name=opensearch | ]] + driver.findElement(By.id("pagesButtonlanding")).click(); + // ERROR: Caught exception [ERROR: Unsupported command [selectWindow | name=opensearch | ]] + driver.findElement(By.id("pagesButtonlanding")).click(); + // ERROR: Caught exception [ERROR: Unsupported command [selectWindow | name=opensearch | ]] + driver.findElement(By.id("pagesButtonlanding")).click(); + // ERROR: Caught exception [ERROR: Unsupported command [selectWindow | name=opensearch | ]] + driver.findElement(By.id("pagesButtonlanding")).click(); + // ERROR: Caught exception [ERROR: Unsupported command [selectWindow | name=opensearch | ]] + driver.findElement(By.id("pagesButtonlanding")).click(); + // ERROR: Caught exception [ERROR: Unsupported command [selectWindow | name=opensearch | ]] + driver.findElement(By.id("pagesButtonlanding")).click(); + // ERROR: Caught exception [ERROR: Unsupported command [selectWindow | name=opensearch | ]] + driver.findElement(By.id("pagesButtonlanding")).click(); + // ERROR: Caught exception [ERROR: Unsupported command [selectWindow | name=opensearch | ]] + driver.findElement(By.id("pagesButtonlanding")).click(); + // ERROR: Caught exception [ERROR: Unsupported command [selectWindow | name=opensearch | ]] + driver.findElement(By.id("pagesButtonlanding")).click(); + // ERROR: Caught exception [ERROR: Unsupported command [selectWindow | name=opensearch | ]] + driver.findElement(By.id("pagesButtonlanding")).click(); + // ERROR: Caught exception [ERROR: Unsupported command [selectWindow | name=opensearch | ]] + driver.findElement(By.id("pagesButtonlanding")).click(); + // ERROR: Caught exception [ERROR: Unsupported command [selectWindow | name=opensearch | ]] + driver.findElement(By.id("pagesButtonlanding")).click(); + // ERROR: Caught exception [ERROR: Unsupported command [selectWindow | name=opensearch | ]] + driver.findElement(By.id("pagesButtonlanding")).click(); + // ERROR: Caught exception [ERROR: Unsupported command [selectWindow | name=opensearch | ]] + driver.findElement(By.xpath("//a[@id='btn-sidebar-gadgets']/i")).click(); + // ERROR: Caught exception [ERROR: Unsupported command [selectWindow | name=opensearch | ]] + driver.findElement(By.id("pagesButtonlanding")).click(); + // ERROR: Caught exception [ERROR: Unsupported command [selectWindow | name=opensearch | ]] + driver.findElement(By.id("pagesButtonlanding")).click(); + // ERROR: Caught exception [ERROR: Unsupported command [selectWindow | name=opensearch | ]] + driver.findElement(By.xpath("//a[@id='btn-pages-sidebar']/i")).click(); + // ERROR: Caught exception [ERROR: Unsupported command [selectWindow | name=opensearch | ]] + driver.findElement(By.xpath("//div[@id='ues-page-layouts']/div[2]/img")).click(); + // ERROR: Caught exception [ERROR: Unsupported command [selectWindow | name=opensearch | ]] + driver.findElement(By.id("pagesButtonpage0")).click(); + // ERROR: Caught exception [ERROR: Unsupported command [selectWindow | name=opensearch | ]] + driver.findElement(By.id("pagesButtonpage0")).click(); + // ERROR: Caught exception [ERROR: Unsupported command [selectWindow | name=opensearch | ]] + driver.findElement(By.id("pagesButtonpage0")).click(); + // ERROR: Caught exception [ERROR: Unsupported command [selectWindow | name=opensearch | ]] + driver.findElement(By.xpath("//a[@id='btn-sidebar-gadgets']/i")).click(); + // ERROR: Caught exception [ERROR: Unsupported command [selectWindow | name=opensearch | ]] + driver.findElement(By.linkText("View")).click(); + // ERROR: Caught exception [ERROR: Unsupported command [selectWindow | name=opensearch | ]] + // ERROR: Caught exception [ERROR: Unsupported command [waitForPopUp | _blank | 30000]] + // ERROR: Caught exception [ERROR: Unsupported command [selectWindow | name=opensearch | ]] + driver.findElement(By.id("dashboard-settings")).click(); + // ERROR: Caught exception [ERROR: Unsupported command [selectWindow | name=opensearch | ]] + driver.findElement(By.cssSelector("input[type=\"checkbox\"]")).click(); + driver.findElement(By.cssSelector("span.helper")).click(); + + + driver.get(baseUrl + "/portal/login-controller?destination=%2Fportal%2F"); + driver.findElement(By.name("username")).clear(); + driver.findElement(By.name("username")).sendKeys("admin"); + driver.findElement(By.name("password")).clear(); + driver.findElement(By.name("password")).sendKeys("admin"); + driver.findElement(By.xpath("//button[@type='submit']")).click(); + driver.findElement(By.xpath("//div[@id='navbar']/ul/li/a/span/i[2]")).click(); + driver.findElement(By.id("ues-dashboard-title")).clear(); + driver.findElement(By.id("ues-dashboard-title")).sendKeys("sample-dashboard"); + driver.findElement(By.id("ues-dashboard-description")).clear(); + driver.findElement(By.id("ues-dashboard-description")).sendKeys("This is a sample dashboard"); + new Select(driver.findElement(By.id("ues-theme-list"))).selectByVisibleText("custom-theme-sample"); + driver.findElement(By.id("ues-dashboard-create")).click(); + driver.findElement(By.xpath("//div[@id='ues-page-layouts']/div[2]/img")).click(); + driver.findElement(By.id("pagesButtonlanding")).click(); + driver.findElement(By.id("pagesButtonlanding")).click(); + driver.findElement(By.id("pagesButtonlanding")).click(); + driver.findElement(By.id("pagesButtonlanding")).click(); + driver.findElement(By.xpath("//a[@id='btn-sidebar-gadgets']/i")).click(); + driver.findElement(By.id("pagesButtonlanding")).click(); + driver.findElement(By.id("pagesButtonlanding")).click(); + driver.findElement(By.id("btn-pages-sidebar")).click(); + driver.findElement(By.xpath("(//button[@type='button'])[2]")).click(); + driver.findElement(By.xpath("(//button[@type='button'])[2]")).click(); + driver.findElement(By.xpath("//div[@id='ues-page-layouts']/div[2]/img")).click(); + driver.findElement(By.id("pagesButtonpage0")).click(); + driver.findElement(By.id("pagesButtonpage0")).click(); + driver.findElement(By.id("pagesButtonpage0")).click(); + driver.findElement(By.xpath("//a[@id='btn-sidebar-gadgets']/i")).click(); + driver.findElement(By.linkText("View")).click(); + // ERROR: Caught exception [ERROR: Unsupported command [waitForPopUp | _blank | 30000]] + driver.findElement(By.linkText("Home")).click(); + driver.findElement(By.linkText("Page 0")).click(); + driver.findElement(By.id("dashboard-settings")).click(); + driver.findElement(By.xpath("(//button[@type='button'])[2]")).click(); + driver.findElement(By.linkText("Default Theme")).click(); + driver.findElement(By.id("ues-dashboard-saveBtn")).click(); + driver.findElement(By.linkText("Dashboards")).click(); + driver.findElement(By.id("ues-view")).click(); + // ERROR: Caught exception [ERROR: Unsupported command [waitForPopUp | _blank | 30000]] + // ERROR: Caught exception [ERROR: Unsupported command [selectWindow | null | ]] + // ERROR: Caught exception [Error: locator strategy either id or name must be specified explicitly.] + // ERROR: Caught exception [ERROR: Unsupported command [selectWindow | name=toolbox-panel-iframe-inspector | ]] + // ERROR: Caught exception [Error: locator strategy either id or name must be specified explicitly.] + + + + /** + * Clean up after running tests + * + * @throws MalformedURLException + * @throws XPathExpressionException + */ + @AfterClass(alwaysRun = true) public void tearDown() + throws MalformedURLException, XPathExpressionException, InterruptedException { + //log in to admin console + loginToAdminConsole(USER_NAME, PASSWORD); + + //undeploy custom theme file + getDriver().findElement(By.xpath("(//a[contains(text(),'List')])[6]")).click(); + getDriver().findElement(By.linkText("Delete")).click(); + getDriver().findElement(By.cssSelector("button[type=\"button\"]")).click(); + Thread.sleep(15000); + try { + logoutFromAdminConsole(); + } finally { + getDriver().quit(); + } + } +} From 9de47818e9520ca1e7b354406c13b0926fa42a94 Mon Sep 17 00:00:00 2001 From: prabushi Date: Thu, 26 May 2016 11:01:59 +0530 Subject: [PATCH 3/6] added test for applying custom theme --- .../AddCustomThemeToDashboardTest.java | 204 ++++++------------ .../tests-ui/src/test/resources/testng.xml | 1 + 2 files changed, 68 insertions(+), 137 deletions(-) diff --git a/modules/integration/tests-ui-integration/tests-ui/src/test/java/org/wso2/ds/ui/integration/test/dashboard/AddCustomThemeToDashboardTest.java b/modules/integration/tests-ui-integration/tests-ui/src/test/java/org/wso2/ds/ui/integration/test/dashboard/AddCustomThemeToDashboardTest.java index 16f76757..fbf31638 100644 --- a/modules/integration/tests-ui-integration/tests-ui/src/test/java/org/wso2/ds/ui/integration/test/dashboard/AddCustomThemeToDashboardTest.java +++ b/modules/integration/tests-ui-integration/tests-ui/src/test/java/org/wso2/ds/ui/integration/test/dashboard/AddCustomThemeToDashboardTest.java @@ -1,10 +1,11 @@ package org.wso2.ds.ui.integration.test.dashboard; import org.openqa.selenium.By; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Factory; -import org.testng.annotations.Test; +import org.openqa.selenium.WebElement; +import org.openqa.selenium.support.ui.Select; +import org.testng.annotations.*; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import org.wso2.carbon.automation.engine.context.TestUserMode; import org.wso2.carbon.automation.engine.frameworkutils.FrameworkPathUtil; import org.wso2.ds.ui.integration.util.DSUIIntegrationTest; @@ -13,12 +14,17 @@ import java.io.File; import java.net.MalformedURLException; +import static org.testng.Assert.assertEquals; + /** * Created by prabushi on 5/25/16. */ public class AddCustomThemeToDashboardTest extends DSUIIntegrationTest { + private static final Log log = LogFactory.getLog(AddCustomThemeToDashboardTest.class); private static final String USER_NAME = "admin"; private static final String PASSWORD = "admin"; + private static final String dashboardTitle = "sample-dashboard"; + private static final String description = "This is a sample dashboard"; private static final String CUSTOM_THEME_NAME = "custom-theme-sample"; //get the path to custom theme carbon archive file String systemResourceLocation = FrameworkPathUtil.getSystemResourceLocation(); @@ -31,11 +37,19 @@ public class AddCustomThemeToDashboardTest extends DSUIIntegrationTest { File.separator + "store" + File.separator + "carbon.super" + File.separator + "fs" + File.separator + "theme" + File.separator + CUSTOM_THEME_NAME; - @Factory(dataProvider = "userMode") - public AddCustomThemeToDashboardTest(TestUserMode userMode) { + @Factory(dataProvider = "userMode") public AddCustomThemeToDashboardTest(TestUserMode userMode) { super(userMode); } + /** + * Provides user modes. + * + * @return user modes + */ + @DataProvider(name = "userMode") public static Object[][] userModeProvider() { + return new Object[][] { { TestUserMode.SUPER_TENANT_ADMIN } }; + } + /** * Setup the testing environment. * @@ -58,140 +72,55 @@ public AddCustomThemeToDashboardTest(TestUserMode userMode) { logoutFromAdminConsole(); } - @Test(groups = "wso2.ds.dashboard", description = "Adding a custom theme when creating a dashboard") - public void addCustomThemeToDashboard() throws XPathExpressionException, MalformedURLException { + @Test(groups = "wso2.ds.dashboard", description = "Adding a custom theme when creating a dashboard") public void addCustomThemeToDashboard() + throws XPathExpressionException, MalformedURLException, InterruptedException { //log in to portal login(getCurrentUsername(), getCurrentPassword()); - } - -// driver.findElement(By.name("username")).clear(); -// driver.findElement(By.name("username")).sendKeys("admin"); -// driver.findElement(By.name("password")).clear(); -// driver.findElement(By.name("password")).sendKeys("admin"); -// driver.findElement(By.xpath("//button[@type='submit']")).click(); - driver.findElement(By.xpath("//div[@id='navbar']/ul/li/a/span/i[2]")).click(); - driver.findElement(By.id("ues-dashboard-title")).clear(); - driver.findElement(By.id("ues-dashboard-title")).sendKeys("sample-dashboard"); - driver.findElement(By.id("ues-dashboard-description")).clear(); - driver.findElement(By.id("ues-dashboard-description")).sendKeys("This is a sample dashboard"); - new Select(driver.findElement(By.id("ues-theme-list"))).selectByVisibleText("custom-theme-sample"); - driver.findElement(By.id("ues-dashboard-create")).click(); - // ERROR: Caught exception [ERROR: Unsupported command [selectWindow | name=opensearch | ]] - driver.findElement(By.xpath("//div[@id='ues-page-layouts']/div[2]/img")).click(); - // ERROR: Caught exception [ERROR: Unsupported command [selectWindow | name=opensearch | ]] - driver.findElement(By.id("pagesButtonlanding")).click(); - // ERROR: Caught exception [ERROR: Unsupported command [selectWindow | name=opensearch | ]] - driver.findElement(By.id("pagesButtonlanding")).click(); - // ERROR: Caught exception [ERROR: Unsupported command [selectWindow | name=opensearch | ]] - driver.findElement(By.id("pagesButtonlanding")).click(); - // ERROR: Caught exception [ERROR: Unsupported command [selectWindow | name=opensearch | ]] - driver.findElement(By.id("pagesButtonlanding")).click(); - // ERROR: Caught exception [ERROR: Unsupported command [selectWindow | name=opensearch | ]] - driver.findElement(By.id("pagesButtonlanding")).click(); - // ERROR: Caught exception [ERROR: Unsupported command [selectWindow | name=opensearch | ]] - driver.findElement(By.id("pagesButtonlanding")).click(); - // ERROR: Caught exception [ERROR: Unsupported command [selectWindow | name=opensearch | ]] - driver.findElement(By.id("pagesButtonlanding")).click(); - // ERROR: Caught exception [ERROR: Unsupported command [selectWindow | name=opensearch | ]] - driver.findElement(By.id("pagesButtonlanding")).click(); - // ERROR: Caught exception [ERROR: Unsupported command [selectWindow | name=opensearch | ]] - driver.findElement(By.id("pagesButtonlanding")).click(); - // ERROR: Caught exception [ERROR: Unsupported command [selectWindow | name=opensearch | ]] - driver.findElement(By.id("pagesButtonlanding")).click(); - // ERROR: Caught exception [ERROR: Unsupported command [selectWindow | name=opensearch | ]] - driver.findElement(By.id("pagesButtonlanding")).click(); - // ERROR: Caught exception [ERROR: Unsupported command [selectWindow | name=opensearch | ]] - driver.findElement(By.id("pagesButtonlanding")).click(); - // ERROR: Caught exception [ERROR: Unsupported command [selectWindow | name=opensearch | ]] - driver.findElement(By.id("pagesButtonlanding")).click(); - // ERROR: Caught exception [ERROR: Unsupported command [selectWindow | name=opensearch | ]] - driver.findElement(By.id("pagesButtonlanding")).click(); - // ERROR: Caught exception [ERROR: Unsupported command [selectWindow | name=opensearch | ]] - driver.findElement(By.id("pagesButtonlanding")).click(); - // ERROR: Caught exception [ERROR: Unsupported command [selectWindow | name=opensearch | ]] - driver.findElement(By.id("pagesButtonlanding")).click(); - // ERROR: Caught exception [ERROR: Unsupported command [selectWindow | name=opensearch | ]] - driver.findElement(By.id("pagesButtonlanding")).click(); - // ERROR: Caught exception [ERROR: Unsupported command [selectWindow | name=opensearch | ]] - driver.findElement(By.id("pagesButtonlanding")).click(); - // ERROR: Caught exception [ERROR: Unsupported command [selectWindow | name=opensearch | ]] - driver.findElement(By.id("pagesButtonlanding")).click(); - // ERROR: Caught exception [ERROR: Unsupported command [selectWindow | name=opensearch | ]] - driver.findElement(By.xpath("//a[@id='btn-sidebar-gadgets']/i")).click(); - // ERROR: Caught exception [ERROR: Unsupported command [selectWindow | name=opensearch | ]] - driver.findElement(By.id("pagesButtonlanding")).click(); - // ERROR: Caught exception [ERROR: Unsupported command [selectWindow | name=opensearch | ]] - driver.findElement(By.id("pagesButtonlanding")).click(); - // ERROR: Caught exception [ERROR: Unsupported command [selectWindow | name=opensearch | ]] - driver.findElement(By.xpath("//a[@id='btn-pages-sidebar']/i")).click(); - // ERROR: Caught exception [ERROR: Unsupported command [selectWindow | name=opensearch | ]] - driver.findElement(By.xpath("//div[@id='ues-page-layouts']/div[2]/img")).click(); - // ERROR: Caught exception [ERROR: Unsupported command [selectWindow | name=opensearch | ]] - driver.findElement(By.id("pagesButtonpage0")).click(); - // ERROR: Caught exception [ERROR: Unsupported command [selectWindow | name=opensearch | ]] - driver.findElement(By.id("pagesButtonpage0")).click(); - // ERROR: Caught exception [ERROR: Unsupported command [selectWindow | name=opensearch | ]] - driver.findElement(By.id("pagesButtonpage0")).click(); - // ERROR: Caught exception [ERROR: Unsupported command [selectWindow | name=opensearch | ]] - driver.findElement(By.xpath("//a[@id='btn-sidebar-gadgets']/i")).click(); - // ERROR: Caught exception [ERROR: Unsupported command [selectWindow | name=opensearch | ]] - driver.findElement(By.linkText("View")).click(); - // ERROR: Caught exception [ERROR: Unsupported command [selectWindow | name=opensearch | ]] - // ERROR: Caught exception [ERROR: Unsupported command [waitForPopUp | _blank | 30000]] - // ERROR: Caught exception [ERROR: Unsupported command [selectWindow | name=opensearch | ]] - driver.findElement(By.id("dashboard-settings")).click(); - // ERROR: Caught exception [ERROR: Unsupported command [selectWindow | name=opensearch | ]] - driver.findElement(By.cssSelector("input[type=\"checkbox\"]")).click(); - driver.findElement(By.cssSelector("span.helper")).click(); - - - driver.get(baseUrl + "/portal/login-controller?destination=%2Fportal%2F"); - driver.findElement(By.name("username")).clear(); - driver.findElement(By.name("username")).sendKeys("admin"); - driver.findElement(By.name("password")).clear(); - driver.findElement(By.name("password")).sendKeys("admin"); - driver.findElement(By.xpath("//button[@type='submit']")).click(); - driver.findElement(By.xpath("//div[@id='navbar']/ul/li/a/span/i[2]")).click(); - driver.findElement(By.id("ues-dashboard-title")).clear(); - driver.findElement(By.id("ues-dashboard-title")).sendKeys("sample-dashboard"); - driver.findElement(By.id("ues-dashboard-description")).clear(); - driver.findElement(By.id("ues-dashboard-description")).sendKeys("This is a sample dashboard"); - new Select(driver.findElement(By.id("ues-theme-list"))).selectByVisibleText("custom-theme-sample"); - driver.findElement(By.id("ues-dashboard-create")).click(); - driver.findElement(By.xpath("//div[@id='ues-page-layouts']/div[2]/img")).click(); - driver.findElement(By.id("pagesButtonlanding")).click(); - driver.findElement(By.id("pagesButtonlanding")).click(); - driver.findElement(By.id("pagesButtonlanding")).click(); - driver.findElement(By.id("pagesButtonlanding")).click(); - driver.findElement(By.xpath("//a[@id='btn-sidebar-gadgets']/i")).click(); - driver.findElement(By.id("pagesButtonlanding")).click(); - driver.findElement(By.id("pagesButtonlanding")).click(); - driver.findElement(By.id("btn-pages-sidebar")).click(); - driver.findElement(By.xpath("(//button[@type='button'])[2]")).click(); - driver.findElement(By.xpath("(//button[@type='button'])[2]")).click(); - driver.findElement(By.xpath("//div[@id='ues-page-layouts']/div[2]/img")).click(); - driver.findElement(By.id("pagesButtonpage0")).click(); - driver.findElement(By.id("pagesButtonpage0")).click(); - driver.findElement(By.id("pagesButtonpage0")).click(); - driver.findElement(By.xpath("//a[@id='btn-sidebar-gadgets']/i")).click(); - driver.findElement(By.linkText("View")).click(); - // ERROR: Caught exception [ERROR: Unsupported command [waitForPopUp | _blank | 30000]] - driver.findElement(By.linkText("Home")).click(); - driver.findElement(By.linkText("Page 0")).click(); - driver.findElement(By.id("dashboard-settings")).click(); - driver.findElement(By.xpath("(//button[@type='button'])[2]")).click(); - driver.findElement(By.linkText("Default Theme")).click(); - driver.findElement(By.id("ues-dashboard-saveBtn")).click(); - driver.findElement(By.linkText("Dashboards")).click(); - driver.findElement(By.id("ues-view")).click(); - // ERROR: Caught exception [ERROR: Unsupported command [waitForPopUp | _blank | 30000]] - // ERROR: Caught exception [ERROR: Unsupported command [selectWindow | null | ]] - // ERROR: Caught exception [Error: locator strategy either id or name must be specified explicitly.] - // ERROR: Caught exception [ERROR: Unsupported command [selectWindow | name=toolbox-panel-iframe-inspector | ]] - // ERROR: Caught exception [Error: locator strategy either id or name must be specified explicitly.] - + //create dashboard + redirectToLocation(DS_HOME_CONTEXT, DS_DASHBOARDS_CONTEXT); + getDriver().findElement(By.cssSelector("[href='create-dashboard']")).click(); + getDriver().findElement(By.id("ues-dashboard-title")).clear(); + getDriver().findElement(By.id("ues-dashboard-title")).sendKeys(dashboardTitle); + getDriver().findElement(By.id("ues-dashboard-description")).clear(); + getDriver().findElement(By.id("ues-dashboard-description")).sendKeys(description); + new Select(getDriver().findElement(By.id("ues-theme-list"))).selectByVisibleText("custom-theme-sample"); + getDriver().findElement(By.id("ues-dashboard-create")).click(); + selectLayout("default-grid"); + + //add a page to the dashboard + redirectToLocation(DS_HOME_CONTEXT, DS_DASHBOARDS_CONTEXT); + WebElement webElement = getDriver().findElement(By.id(dashboardTitle.toLowerCase())); + webElement.findElement(By.cssSelector(".ues-edit")).click(); + addPageToDashboard(); + + redirectToLocation(DS_HOME_CONTEXT, "dashboards/" + dashboardTitle + "/landing"); + String x = getDriver().findElement(By.cssSelector(".product-name")).getText(); + log.info("$$$$" + x); + assertEquals(getDriver().findElement(By.cssSelector(".product-name")).getText(), + "This is a custom theme title"); + + redirectToLocation(DS_HOME_CONTEXT, "dashboard-settings/" + dashboardTitle); + //edirectToLocation(DS_HOME_CONTEXT, DS_DASHBOARDS_CONTEXT); + //bElement = getDriver().findElement(By.id(dashboardTitle.toLowerCase())); + //getDriver().findElement(By.id("dashboard-settings")).click(); + //getDriver().findElement(By.xpath("(//button[@type='button'])[2]")).click(); + //change custom theme to default theme through dashboard settings + //getDriver().findElement(By.linkText("Default Theme")).click(); + //getDriver().findElement(By.id("ues-dashboard-theme")).sendKeys("Default Theme"); + getDriver().findElement(By.xpath("(//button[@type='button'])[2]")).click(); + getDriver().findElement(By.linkText("Default Theme")).click(); + getDriver().findElement(By.id("ues-dashboard-saveBtn")).click(); + Thread.sleep(10000); + //redirectToLocation(DS_HOME_CONTEXT, DS_DASHBOARDS_CONTEXT); + redirectToLocation(DS_HOME_CONTEXT, "dashboards/" + dashboardTitle + "/landing"); + // getDriver().findElement(By.linkText("Dashboards")).click(); + // getDriver().findElement(By.id("ues-view")).click(); + String y = getDriver().findElement(By.cssSelector(".product-name")).getText(); + log.info("$$$$" + y); + assertEquals(getDriver().findElement(By.cssSelector(".product-name")).getText(), dashboardTitle); + } /** * Clean up after running tests @@ -210,7 +139,8 @@ public void addCustomThemeToDashboard() throws XPathExpressionException, Malform getDriver().findElement(By.cssSelector("button[type=\"button\"]")).click(); Thread.sleep(15000); try { - logoutFromAdminConsole(); + logout(); + //logoutFromAdminConsole(); } finally { getDriver().quit(); } diff --git a/modules/integration/tests-ui-integration/tests-ui/src/test/resources/testng.xml b/modules/integration/tests-ui-integration/tests-ui/src/test/resources/testng.xml index 32348588..d2b20409 100755 --- a/modules/integration/tests-ui-integration/tests-ui/src/test/resources/testng.xml +++ b/modules/integration/tests-ui-integration/tests-ui/src/test/resources/testng.xml @@ -39,6 +39,7 @@ + From 08e5b2c5f5586e40e85bdf20c859d5dc608cae3d Mon Sep 17 00:00:00 2001 From: prabushi Date: Thu, 26 May 2016 11:43:49 +0530 Subject: [PATCH 4/6] added the test to check whether the custom themes get applied --- .../AddCustomThemeToDashboardTest.java | 84 +++++++++++-------- 1 file changed, 48 insertions(+), 36 deletions(-) diff --git a/modules/integration/tests-ui-integration/tests-ui/src/test/java/org/wso2/ds/ui/integration/test/dashboard/AddCustomThemeToDashboardTest.java b/modules/integration/tests-ui-integration/tests-ui/src/test/java/org/wso2/ds/ui/integration/test/dashboard/AddCustomThemeToDashboardTest.java index fbf31638..75db3fa9 100644 --- a/modules/integration/tests-ui-integration/tests-ui/src/test/java/org/wso2/ds/ui/integration/test/dashboard/AddCustomThemeToDashboardTest.java +++ b/modules/integration/tests-ui-integration/tests-ui/src/test/java/org/wso2/ds/ui/integration/test/dashboard/AddCustomThemeToDashboardTest.java @@ -4,8 +4,6 @@ import org.openqa.selenium.WebElement; import org.openqa.selenium.support.ui.Select; import org.testng.annotations.*; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; import org.wso2.carbon.automation.engine.context.TestUserMode; import org.wso2.carbon.automation.engine.frameworkutils.FrameworkPathUtil; import org.wso2.ds.ui.integration.util.DSUIIntegrationTest; @@ -17,15 +15,15 @@ import static org.testng.Assert.assertEquals; /** - * Created by prabushi on 5/25/16. + * This class check whether the custom theme get applied to the dashboard */ public class AddCustomThemeToDashboardTest extends DSUIIntegrationTest { - private static final Log log = LogFactory.getLog(AddCustomThemeToDashboardTest.class); private static final String USER_NAME = "admin"; private static final String PASSWORD = "admin"; - private static final String dashboardTitle = "sample-dashboard"; - private static final String description = "This is a sample dashboard"; + private static final String DASHBOARD_TITLE = "sample-dashboard"; + private static final String DESCRIPTION = "This is a sample dashboard"; private static final String CUSTOM_THEME_NAME = "custom-theme-sample"; + //get the path to custom theme carbon archive file String systemResourceLocation = FrameworkPathUtil.getSystemResourceLocation(); String carFilePath = systemResourceLocation + "files/Custom_Theme.car"; @@ -37,6 +35,11 @@ public class AddCustomThemeToDashboardTest extends DSUIIntegrationTest { File.separator + "store" + File.separator + "carbon.super" + File.separator + "fs" + File.separator + "theme" + File.separator + CUSTOM_THEME_NAME; + /** + * Initializes the class. + * + * @param userMode user mode + */ @Factory(dataProvider = "userMode") public AddCustomThemeToDashboardTest(TestUserMode userMode) { super(userMode); } @@ -68,10 +71,20 @@ public class AddCustomThemeToDashboardTest extends DSUIIntegrationTest { getDriver().findElement(By.name("upload")).click(); getDriver().findElement(By.cssSelector("button[type=\"button\"]")).click(); Thread.sleep(15000); + //logout from admin console logoutFromAdminConsole(); } + /** + * This test method sets the custom theme for the dashboard and check whether it get applied, + * then again change the theme to default theme form the dashboard settings and check whether + * the changes get applied. + * + * @throws XPathExpressionException + * @throws MalformedURLException + * @throws InterruptedException + */ @Test(groups = "wso2.ds.dashboard", description = "Adding a custom theme when creating a dashboard") public void addCustomThemeToDashboard() throws XPathExpressionException, MalformedURLException, InterruptedException { //log in to portal @@ -81,44 +94,37 @@ public class AddCustomThemeToDashboardTest extends DSUIIntegrationTest { redirectToLocation(DS_HOME_CONTEXT, DS_DASHBOARDS_CONTEXT); getDriver().findElement(By.cssSelector("[href='create-dashboard']")).click(); getDriver().findElement(By.id("ues-dashboard-title")).clear(); - getDriver().findElement(By.id("ues-dashboard-title")).sendKeys(dashboardTitle); - getDriver().findElement(By.id("ues-dashboard-description")).clear(); - getDriver().findElement(By.id("ues-dashboard-description")).sendKeys(description); + getDriver().findElement(By.id("ues-dashboard-title")).sendKeys(DASHBOARD_TITLE); + getDriver().findElement(By.id("ues-dashboard-DESCRIPTION")).clear(); + getDriver().findElement(By.id("ues-dashboard-DESCRIPTION")).sendKeys(DESCRIPTION); + + //select the custom theme for the dashboard new Select(getDriver().findElement(By.id("ues-theme-list"))).selectByVisibleText("custom-theme-sample"); getDriver().findElement(By.id("ues-dashboard-create")).click(); selectLayout("default-grid"); //add a page to the dashboard redirectToLocation(DS_HOME_CONTEXT, DS_DASHBOARDS_CONTEXT); - WebElement webElement = getDriver().findElement(By.id(dashboardTitle.toLowerCase())); + WebElement webElement = getDriver().findElement(By.id(DASHBOARD_TITLE.toLowerCase())); webElement.findElement(By.cssSelector(".ues-edit")).click(); addPageToDashboard(); - redirectToLocation(DS_HOME_CONTEXT, "dashboards/" + dashboardTitle + "/landing"); - String x = getDriver().findElement(By.cssSelector(".product-name")).getText(); - log.info("$$$$" + x); + redirectToLocation(DS_HOME_CONTEXT, "dashboards/" + DASHBOARD_TITLE + "/landing"); + + //check for the dashboard name in the custom theme assertEquals(getDriver().findElement(By.cssSelector(".product-name")).getText(), "This is a custom theme title"); - redirectToLocation(DS_HOME_CONTEXT, "dashboard-settings/" + dashboardTitle); - //edirectToLocation(DS_HOME_CONTEXT, DS_DASHBOARDS_CONTEXT); - //bElement = getDriver().findElement(By.id(dashboardTitle.toLowerCase())); - //getDriver().findElement(By.id("dashboard-settings")).click(); - //getDriver().findElement(By.xpath("(//button[@type='button'])[2]")).click(); - //change custom theme to default theme through dashboard settings - //getDriver().findElement(By.linkText("Default Theme")).click(); - //getDriver().findElement(By.id("ues-dashboard-theme")).sendKeys("Default Theme"); + //reset the theme to the default theme from the dashboard settings + redirectToLocation(DS_HOME_CONTEXT, "dashboard-settings/" + DASHBOARD_TITLE); getDriver().findElement(By.xpath("(//button[@type='button'])[2]")).click(); getDriver().findElement(By.linkText("Default Theme")).click(); getDriver().findElement(By.id("ues-dashboard-saveBtn")).click(); Thread.sleep(10000); - //redirectToLocation(DS_HOME_CONTEXT, DS_DASHBOARDS_CONTEXT); - redirectToLocation(DS_HOME_CONTEXT, "dashboards/" + dashboardTitle + "/landing"); - // getDriver().findElement(By.linkText("Dashboards")).click(); - // getDriver().findElement(By.id("ues-view")).click(); - String y = getDriver().findElement(By.cssSelector(".product-name")).getText(); - log.info("$$$$" + y); - assertEquals(getDriver().findElement(By.cssSelector(".product-name")).getText(), dashboardTitle); + redirectToLocation(DS_HOME_CONTEXT, "dashboards/" + DASHBOARD_TITLE + "/landing"); + + //check for the name in the default theme + assertEquals(getDriver().findElement(By.cssSelector(".product-name")).getText(), DASHBOARD_TITLE); } @@ -130,19 +136,25 @@ public class AddCustomThemeToDashboardTest extends DSUIIntegrationTest { */ @AfterClass(alwaysRun = true) public void tearDown() throws MalformedURLException, XPathExpressionException, InterruptedException { - //log in to admin console - loginToAdminConsole(USER_NAME, PASSWORD); - //undeploy custom theme file - getDriver().findElement(By.xpath("(//a[contains(text(),'List')])[6]")).click(); - getDriver().findElement(By.linkText("Delete")).click(); - getDriver().findElement(By.cssSelector("button[type=\"button\"]")).click(); - Thread.sleep(15000); try { + //log ot form the portal logout(); - //logoutFromAdminConsole(); } finally { + //log in to admin console + loginToAdminConsole(USER_NAME, PASSWORD); + + //undeploy custom theme file + getDriver().findElement(By.xpath("(//a[contains(text(),'List')])[6]")).click(); + getDriver().findElement(By.linkText("Delete")).click(); + getDriver().findElement(By.cssSelector("button[type=\"button\"]")).click(); + Thread.sleep(15000); + + //logout from admin console + logoutFromAdminConsole(); + getDriver().quit(); } + } } From 934759c8f52f25f7f4cadf06de6219908be37714 Mon Sep 17 00:00:00 2001 From: prabushi Date: Thu, 26 May 2016 11:58:15 +0530 Subject: [PATCH 5/6] added code refactoring --- .../test/dashboard/AddCustomThemeToDashboardTest.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/modules/integration/tests-ui-integration/tests-ui/src/test/java/org/wso2/ds/ui/integration/test/dashboard/AddCustomThemeToDashboardTest.java b/modules/integration/tests-ui-integration/tests-ui/src/test/java/org/wso2/ds/ui/integration/test/dashboard/AddCustomThemeToDashboardTest.java index 75db3fa9..de806d4b 100644 --- a/modules/integration/tests-ui-integration/tests-ui/src/test/java/org/wso2/ds/ui/integration/test/dashboard/AddCustomThemeToDashboardTest.java +++ b/modules/integration/tests-ui-integration/tests-ui/src/test/java/org/wso2/ds/ui/integration/test/dashboard/AddCustomThemeToDashboardTest.java @@ -95,8 +95,8 @@ public class AddCustomThemeToDashboardTest extends DSUIIntegrationTest { getDriver().findElement(By.cssSelector("[href='create-dashboard']")).click(); getDriver().findElement(By.id("ues-dashboard-title")).clear(); getDriver().findElement(By.id("ues-dashboard-title")).sendKeys(DASHBOARD_TITLE); - getDriver().findElement(By.id("ues-dashboard-DESCRIPTION")).clear(); - getDriver().findElement(By.id("ues-dashboard-DESCRIPTION")).sendKeys(DESCRIPTION); + getDriver().findElement(By.id("ues-dashboard-description")).clear(); + getDriver().findElement(By.id("ues-dashboard-description")).sendKeys(DESCRIPTION); //select the custom theme for the dashboard new Select(getDriver().findElement(By.id("ues-theme-list"))).selectByVisibleText("custom-theme-sample"); @@ -120,7 +120,7 @@ public class AddCustomThemeToDashboardTest extends DSUIIntegrationTest { getDriver().findElement(By.xpath("(//button[@type='button'])[2]")).click(); getDriver().findElement(By.linkText("Default Theme")).click(); getDriver().findElement(By.id("ues-dashboard-saveBtn")).click(); - Thread.sleep(10000); + Thread.sleep(2000); redirectToLocation(DS_HOME_CONTEXT, "dashboards/" + DASHBOARD_TITLE + "/landing"); //check for the name in the default theme @@ -138,7 +138,7 @@ public class AddCustomThemeToDashboardTest extends DSUIIntegrationTest { throws MalformedURLException, XPathExpressionException, InterruptedException { try { - //log ot form the portal + //log out form the portal logout(); } finally { //log in to admin console From e071b58ed3c46625103fbbb6f265abe35e286578 Mon Sep 17 00:00:00 2001 From: prabushi Date: Thu, 26 May 2016 12:12:32 +0530 Subject: [PATCH 6/6] added code refactoring --- .../AddCustomThemeToDashboardTest.java | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/modules/integration/tests-ui-integration/tests-ui/src/test/java/org/wso2/ds/ui/integration/test/dashboard/AddCustomThemeToDashboardTest.java b/modules/integration/tests-ui-integration/tests-ui/src/test/java/org/wso2/ds/ui/integration/test/dashboard/AddCustomThemeToDashboardTest.java index de806d4b..319bf52e 100644 --- a/modules/integration/tests-ui-integration/tests-ui/src/test/java/org/wso2/ds/ui/integration/test/dashboard/AddCustomThemeToDashboardTest.java +++ b/modules/integration/tests-ui-integration/tests-ui/src/test/java/org/wso2/ds/ui/integration/test/dashboard/AddCustomThemeToDashboardTest.java @@ -40,7 +40,8 @@ public class AddCustomThemeToDashboardTest extends DSUIIntegrationTest { * * @param userMode user mode */ - @Factory(dataProvider = "userMode") public AddCustomThemeToDashboardTest(TestUserMode userMode) { + @Factory(dataProvider = "userMode") + public AddCustomThemeToDashboardTest(TestUserMode userMode) { super(userMode); } @@ -49,7 +50,8 @@ public class AddCustomThemeToDashboardTest extends DSUIIntegrationTest { * * @return user modes */ - @DataProvider(name = "userMode") public static Object[][] userModeProvider() { + @DataProvider(name = "userMode") + public static Object[][] userModeProvider() { return new Object[][] { { TestUserMode.SUPER_TENANT_ADMIN } }; } @@ -60,8 +62,8 @@ public class AddCustomThemeToDashboardTest extends DSUIIntegrationTest { * @throws XPathExpressionException * @throws InterruptedException */ - @BeforeClass(alwaysRun = true) public void setUp() - throws MalformedURLException, XPathExpressionException, InterruptedException { + @BeforeClass(alwaysRun = true) + public void setUp() throws MalformedURLException, XPathExpressionException, InterruptedException { //log in to admin console loginToAdminConsole(USER_NAME, PASSWORD); @@ -85,8 +87,9 @@ public class AddCustomThemeToDashboardTest extends DSUIIntegrationTest { * @throws MalformedURLException * @throws InterruptedException */ - @Test(groups = "wso2.ds.dashboard", description = "Adding a custom theme when creating a dashboard") public void addCustomThemeToDashboard() - throws XPathExpressionException, MalformedURLException, InterruptedException { + @Test(groups = "wso2.ds.dashboard", description = "Adding a custom theme when creating a dashboard") + public void addCustomThemeToDashboard() throws XPathExpressionException, MalformedURLException, + InterruptedException { //log in to portal login(getCurrentUsername(), getCurrentPassword()); @@ -134,8 +137,8 @@ public class AddCustomThemeToDashboardTest extends DSUIIntegrationTest { * @throws MalformedURLException * @throws XPathExpressionException */ - @AfterClass(alwaysRun = true) public void tearDown() - throws MalformedURLException, XPathExpressionException, InterruptedException { + @AfterClass(alwaysRun = true) + public void tearDown() throws MalformedURLException, XPathExpressionException, InterruptedException { try { //log out form the portal