/portal-web/test/com/liferay/portalweb/portlet/helloworld/portlet/removeportlethw/TearDownPageTest.java
Java | 343 lines | 257 code | 70 blank | 16 comment | 35 complexity | 803106fb7a282d9ad9ed0d809b0cde93 MD5 | raw file
- /**
- * Copyright (c) 2000-2011 Liferay, Inc. All rights reserved.
- *
- * This library is free software; you can redistribute it and/or modify it under
- * the terms of the GNU Lesser General Public License as published by the Free
- * Software Foundation; either version 2.1 of the License, or (at your option)
- * any later version.
- *
- * This library is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
- * details.
- */
- package com.liferay.portalweb.portlet.helloworld.portlet.removeportlethw;
- import com.liferay.portalweb.portal.BaseTestCase;
- import com.liferay.portalweb.portal.util.RuntimeVariables;
- /**
- * @author Brian Wing Shun Chan
- */
- public class TearDownPageTest extends BaseTestCase {
- public void testTearDownPage() throws Exception {
- int label = 1;
- while (label >= 1) {
- switch (label) {
- case 1:
- selenium.open("/web/guest/home/");
- selenium.clickAt("//div[@id='dockbar']",
- RuntimeVariables.replace("Dockbar"));
- for (int second = 0;; second++) {
- if (second >= 60) {
- fail("timeout");
- }
- try {
- if (selenium.isElementPresent("//div[4]/div/ul/li[1]/a")) {
- break;
- }
- }
- catch (Exception e) {
- }
- Thread.sleep(1000);
- }
- selenium.saveScreenShotAndSource();
- selenium.clickAt("//div[4]/div/ul/li[1]/a",
- RuntimeVariables.replace("Manage Pages"));
- for (int second = 0;; second++) {
- if (second >= 60) {
- fail("timeout");
- }
- try {
- if (RuntimeVariables.replace("Public Pages")
- .equals(selenium.getText(
- "//div/div[3]/a"))) {
- break;
- }
- }
- catch (Exception e) {
- }
- Thread.sleep(1000);
- }
- selenium.saveScreenShotAndSource();
- boolean welcomePresent = selenium.isElementPresent(
- "//li/ul/li[1]/div/div[3]/a");
- if (welcomePresent) {
- label = 2;
- continue;
- }
- selenium.clickAt("//div[@id='_88_layoutsTreeOutput']/ul/li/div/div[1]",
- RuntimeVariables.replace("Drop Down Arrow"));
- case 2:
- for (int second = 0;; second++) {
- if (second >= 60) {
- fail("timeout");
- }
- try {
- if (RuntimeVariables.replace("Welcome")
- .equals(selenium.getText(
- "//li/ul/li[1]/div/div[3]/a"))) {
- break;
- }
- }
- catch (Exception e) {
- }
- Thread.sleep(1000);
- }
- selenium.saveScreenShotAndSource();
- boolean page1Present = selenium.isElementPresent(
- "//li[2]/div/div[3]/a");
- if (!page1Present) {
- label = 3;
- continue;
- }
- selenium.clickAt("//li[2]/div/div[3]/a",
- RuntimeVariables.replace("Page Name"));
- for (int second = 0;; second++) {
- if (second >= 60) {
- fail("timeout");
- }
- try {
- if (!RuntimeVariables.replace("/home")
- .equals(selenium.getValue(
- "//input[@id='_88_friendlyURL']"))) {
- break;
- }
- }
- catch (Exception e) {
- }
- Thread.sleep(1000);
- }
- selenium.saveScreenShotAndSource();
- for (int second = 0;; second++) {
- if (second >= 60) {
- fail("timeout");
- }
- try {
- if (selenium.isVisible("//button[3]")) {
- break;
- }
- }
- catch (Exception e) {
- }
- Thread.sleep(1000);
- }
- selenium.saveScreenShotAndSource();
- assertEquals(RuntimeVariables.replace("Delete"),
- selenium.getText("//button[3]"));
- selenium.click(RuntimeVariables.replace("//button[3]"));
- selenium.waitForPageToLoad("30000");
- assertTrue(selenium.getConfirmation()
- .matches("^Are you sure you want to delete the selected page[\\s\\S]$"));
- selenium.saveScreenShotAndSource();
- case 3:
- selenium.clickAt("//div[@id='_88_layoutsTreeOutput']/ul/li/div/div[1]",
- RuntimeVariables.replace("Drop Down Arrow"));
- boolean page2Present = selenium.isElementPresent(
- "//li[2]/div/div[3]/a");
- if (!page2Present) {
- label = 4;
- continue;
- }
- selenium.clickAt("//li[2]/div/div[3]/a",
- RuntimeVariables.replace("Page Name"));
- for (int second = 0;; second++) {
- if (second >= 60) {
- fail("timeout");
- }
- try {
- if (RuntimeVariables.replace("Delete")
- .equals(selenium.getText(
- "//button[3]"))) {
- break;
- }
- }
- catch (Exception e) {
- }
- Thread.sleep(1000);
- }
- selenium.saveScreenShotAndSource();
- assertEquals(RuntimeVariables.replace("Delete"),
- selenium.getText("//button[3]"));
- selenium.click(RuntimeVariables.replace("//button[3]"));
- selenium.waitForPageToLoad("30000");
- assertTrue(selenium.getConfirmation()
- .matches("^Are you sure you want to delete the selected page[\\s\\S]$"));
- selenium.saveScreenShotAndSource();
- case 4:
- selenium.clickAt("//div[@id='_88_layoutsTreeOutput']/ul/li/div/div[1]",
- RuntimeVariables.replace("Drop Down Arrow"));
- boolean page3Present = selenium.isElementPresent(
- "//li[2]/div/div[3]/a");
- if (!page3Present) {
- label = 5;
- continue;
- }
- selenium.clickAt("//li[2]/div/div[3]/a",
- RuntimeVariables.replace("Page Name"));
- for (int second = 0;; second++) {
- if (second >= 60) {
- fail("timeout");
- }
- try {
- if (RuntimeVariables.replace("Delete")
- .equals(selenium.getText(
- "//button[3]"))) {
- break;
- }
- }
- catch (Exception e) {
- }
- Thread.sleep(1000);
- }
- selenium.saveScreenShotAndSource();
- assertEquals(RuntimeVariables.replace("Delete"),
- selenium.getText("//button[3]"));
- selenium.click(RuntimeVariables.replace("//button[3]"));
- selenium.waitForPageToLoad("30000");
- assertTrue(selenium.getConfirmation()
- .matches("^Are you sure you want to delete the selected page[\\s\\S]$"));
- selenium.saveScreenShotAndSource();
- case 5:
- selenium.clickAt("//div[@id='_88_layoutsTreeOutput']/ul/li/div/div[1]",
- RuntimeVariables.replace("Drop Down Arrow"));
- boolean page4Present = selenium.isElementPresent(
- "//li[2]/div/div[3]/a");
- if (!page4Present) {
- label = 6;
- continue;
- }
- selenium.clickAt("//li[2]/div/div[3]/a",
- RuntimeVariables.replace("Page Name"));
- for (int second = 0;; second++) {
- if (second >= 60) {
- fail("timeout");
- }
- try {
- if (RuntimeVariables.replace("Delete")
- .equals(selenium.getText(
- "//button[3]"))) {
- break;
- }
- }
- catch (Exception e) {
- }
- Thread.sleep(1000);
- }
- selenium.saveScreenShotAndSource();
- assertEquals(RuntimeVariables.replace("Delete"),
- selenium.getText("//button[3]"));
- selenium.click(RuntimeVariables.replace("//button[3]"));
- selenium.waitForPageToLoad("30000");
- assertTrue(selenium.getConfirmation()
- .matches("^Are you sure you want to delete the selected page[\\s\\S]$"));
- selenium.saveScreenShotAndSource();
- case 6:
- selenium.clickAt("//div[@id='_88_layoutsTreeOutput']/ul/li/div/div[1]",
- RuntimeVariables.replace("Drop Down Arrow"));
- boolean page5Present = selenium.isElementPresent(
- "//li[2]/div/div[3]/a");
- if (!page5Present) {
- label = 7;
- continue;
- }
- selenium.clickAt("//li[2]/div/div[3]/a",
- RuntimeVariables.replace("Page Name"));
- for (int second = 0;; second++) {
- if (second >= 60) {
- fail("timeout");
- }
- try {
- if (RuntimeVariables.replace("Delete")
- .equals(selenium.getText(
- "//button[3]"))) {
- break;
- }
- }
- catch (Exception e) {
- }
- Thread.sleep(1000);
- }
- selenium.saveScreenShotAndSource();
- assertEquals(RuntimeVariables.replace("Delete"),
- selenium.getText("//button[3]"));
- selenium.click(RuntimeVariables.replace("//button[3]"));
- selenium.waitForPageToLoad("30000");
- assertTrue(selenium.getConfirmation()
- .matches("^Are you sure you want to delete the selected page[\\s\\S]$"));
- selenium.saveScreenShotAndSource();
- case 7:
- case 100:
- label = -1;
- }
- }
- }
- }