PageRenderTime 213ms CodeModel.GetById 27ms RepoModel.GetById 1ms app.codeStats 0ms

/portal-web/test/com/liferay/portalweb/portlet/helloworld/portlet/addportlethwduplicate/TearDownPageTest.java

https://github.com/oterral/liferay-portal
Java | 343 lines | 257 code | 70 blank | 16 comment | 35 complexity | c6dd31b5ff43ca927128fdc1a67e3607 MD5 | raw file
  1. /**
  2. * Copyright (c) 2000-2011 Liferay, Inc. All rights reserved.
  3. *
  4. * This library is free software; you can redistribute it and/or modify it under
  5. * the terms of the GNU Lesser General Public License as published by the Free
  6. * Software Foundation; either version 2.1 of the License, or (at your option)
  7. * any later version.
  8. *
  9. * This library is distributed in the hope that it will be useful, but WITHOUT
  10. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  11. * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
  12. * details.
  13. */
  14. package com.liferay.portalweb.portlet.helloworld.portlet.addportlethwduplicate;
  15. import com.liferay.portalweb.portal.BaseTestCase;
  16. import com.liferay.portalweb.portal.util.RuntimeVariables;
  17. /**
  18. * @author Brian Wing Shun Chan
  19. */
  20. public class TearDownPageTest extends BaseTestCase {
  21. public void testTearDownPage() throws Exception {
  22. int label = 1;
  23. while (label >= 1) {
  24. switch (label) {
  25. case 1:
  26. selenium.open("/web/guest/home/");
  27. selenium.clickAt("//div[@id='dockbar']",
  28. RuntimeVariables.replace("Dockbar"));
  29. for (int second = 0;; second++) {
  30. if (second >= 60) {
  31. fail("timeout");
  32. }
  33. try {
  34. if (selenium.isElementPresent("//div[4]/div/ul/li[1]/a")) {
  35. break;
  36. }
  37. }
  38. catch (Exception e) {
  39. }
  40. Thread.sleep(1000);
  41. }
  42. selenium.saveScreenShotAndSource();
  43. selenium.clickAt("//div[4]/div/ul/li[1]/a",
  44. RuntimeVariables.replace("Manage Pages"));
  45. for (int second = 0;; second++) {
  46. if (second >= 60) {
  47. fail("timeout");
  48. }
  49. try {
  50. if (RuntimeVariables.replace("Public Pages")
  51. .equals(selenium.getText(
  52. "//div/div[3]/a"))) {
  53. break;
  54. }
  55. }
  56. catch (Exception e) {
  57. }
  58. Thread.sleep(1000);
  59. }
  60. selenium.saveScreenShotAndSource();
  61. boolean welcomePresent = selenium.isElementPresent(
  62. "//li/ul/li[1]/div/div[3]/a");
  63. if (welcomePresent) {
  64. label = 2;
  65. continue;
  66. }
  67. selenium.clickAt("//div[@id='_88_layoutsTreeOutput']/ul/li/div/div[1]",
  68. RuntimeVariables.replace("Drop Down Arrow"));
  69. case 2:
  70. for (int second = 0;; second++) {
  71. if (second >= 60) {
  72. fail("timeout");
  73. }
  74. try {
  75. if (RuntimeVariables.replace("Welcome")
  76. .equals(selenium.getText(
  77. "//li/ul/li[1]/div/div[3]/a"))) {
  78. break;
  79. }
  80. }
  81. catch (Exception e) {
  82. }
  83. Thread.sleep(1000);
  84. }
  85. selenium.saveScreenShotAndSource();
  86. boolean page1Present = selenium.isElementPresent(
  87. "//li[2]/div/div[3]/a");
  88. if (!page1Present) {
  89. label = 3;
  90. continue;
  91. }
  92. selenium.clickAt("//li[2]/div/div[3]/a",
  93. RuntimeVariables.replace("Page Name"));
  94. for (int second = 0;; second++) {
  95. if (second >= 60) {
  96. fail("timeout");
  97. }
  98. try {
  99. if (!RuntimeVariables.replace("/home")
  100. .equals(selenium.getValue(
  101. "//input[@id='_88_friendlyURL']"))) {
  102. break;
  103. }
  104. }
  105. catch (Exception e) {
  106. }
  107. Thread.sleep(1000);
  108. }
  109. selenium.saveScreenShotAndSource();
  110. for (int second = 0;; second++) {
  111. if (second >= 60) {
  112. fail("timeout");
  113. }
  114. try {
  115. if (selenium.isVisible("//button[3]")) {
  116. break;
  117. }
  118. }
  119. catch (Exception e) {
  120. }
  121. Thread.sleep(1000);
  122. }
  123. selenium.saveScreenShotAndSource();
  124. assertEquals(RuntimeVariables.replace("Delete"),
  125. selenium.getText("//button[3]"));
  126. selenium.click(RuntimeVariables.replace("//button[3]"));
  127. selenium.waitForPageToLoad("30000");
  128. assertTrue(selenium.getConfirmation()
  129. .matches("^Are you sure you want to delete the selected page[\\s\\S]$"));
  130. selenium.saveScreenShotAndSource();
  131. case 3:
  132. selenium.clickAt("//div[@id='_88_layoutsTreeOutput']/ul/li/div/div[1]",
  133. RuntimeVariables.replace("Drop Down Arrow"));
  134. boolean page2Present = selenium.isElementPresent(
  135. "//li[2]/div/div[3]/a");
  136. if (!page2Present) {
  137. label = 4;
  138. continue;
  139. }
  140. selenium.clickAt("//li[2]/div/div[3]/a",
  141. RuntimeVariables.replace("Page Name"));
  142. for (int second = 0;; second++) {
  143. if (second >= 60) {
  144. fail("timeout");
  145. }
  146. try {
  147. if (RuntimeVariables.replace("Delete")
  148. .equals(selenium.getText(
  149. "//button[3]"))) {
  150. break;
  151. }
  152. }
  153. catch (Exception e) {
  154. }
  155. Thread.sleep(1000);
  156. }
  157. selenium.saveScreenShotAndSource();
  158. assertEquals(RuntimeVariables.replace("Delete"),
  159. selenium.getText("//button[3]"));
  160. selenium.click(RuntimeVariables.replace("//button[3]"));
  161. selenium.waitForPageToLoad("30000");
  162. assertTrue(selenium.getConfirmation()
  163. .matches("^Are you sure you want to delete the selected page[\\s\\S]$"));
  164. selenium.saveScreenShotAndSource();
  165. case 4:
  166. selenium.clickAt("//div[@id='_88_layoutsTreeOutput']/ul/li/div/div[1]",
  167. RuntimeVariables.replace("Drop Down Arrow"));
  168. boolean page3Present = selenium.isElementPresent(
  169. "//li[2]/div/div[3]/a");
  170. if (!page3Present) {
  171. label = 5;
  172. continue;
  173. }
  174. selenium.clickAt("//li[2]/div/div[3]/a",
  175. RuntimeVariables.replace("Page Name"));
  176. for (int second = 0;; second++) {
  177. if (second >= 60) {
  178. fail("timeout");
  179. }
  180. try {
  181. if (RuntimeVariables.replace("Delete")
  182. .equals(selenium.getText(
  183. "//button[3]"))) {
  184. break;
  185. }
  186. }
  187. catch (Exception e) {
  188. }
  189. Thread.sleep(1000);
  190. }
  191. selenium.saveScreenShotAndSource();
  192. assertEquals(RuntimeVariables.replace("Delete"),
  193. selenium.getText("//button[3]"));
  194. selenium.click(RuntimeVariables.replace("//button[3]"));
  195. selenium.waitForPageToLoad("30000");
  196. assertTrue(selenium.getConfirmation()
  197. .matches("^Are you sure you want to delete the selected page[\\s\\S]$"));
  198. selenium.saveScreenShotAndSource();
  199. case 5:
  200. selenium.clickAt("//div[@id='_88_layoutsTreeOutput']/ul/li/div/div[1]",
  201. RuntimeVariables.replace("Drop Down Arrow"));
  202. boolean page4Present = selenium.isElementPresent(
  203. "//li[2]/div/div[3]/a");
  204. if (!page4Present) {
  205. label = 6;
  206. continue;
  207. }
  208. selenium.clickAt("//li[2]/div/div[3]/a",
  209. RuntimeVariables.replace("Page Name"));
  210. for (int second = 0;; second++) {
  211. if (second >= 60) {
  212. fail("timeout");
  213. }
  214. try {
  215. if (RuntimeVariables.replace("Delete")
  216. .equals(selenium.getText(
  217. "//button[3]"))) {
  218. break;
  219. }
  220. }
  221. catch (Exception e) {
  222. }
  223. Thread.sleep(1000);
  224. }
  225. selenium.saveScreenShotAndSource();
  226. assertEquals(RuntimeVariables.replace("Delete"),
  227. selenium.getText("//button[3]"));
  228. selenium.click(RuntimeVariables.replace("//button[3]"));
  229. selenium.waitForPageToLoad("30000");
  230. assertTrue(selenium.getConfirmation()
  231. .matches("^Are you sure you want to delete the selected page[\\s\\S]$"));
  232. selenium.saveScreenShotAndSource();
  233. case 6:
  234. selenium.clickAt("//div[@id='_88_layoutsTreeOutput']/ul/li/div/div[1]",
  235. RuntimeVariables.replace("Drop Down Arrow"));
  236. boolean page5Present = selenium.isElementPresent(
  237. "//li[2]/div/div[3]/a");
  238. if (!page5Present) {
  239. label = 7;
  240. continue;
  241. }
  242. selenium.clickAt("//li[2]/div/div[3]/a",
  243. RuntimeVariables.replace("Page Name"));
  244. for (int second = 0;; second++) {
  245. if (second >= 60) {
  246. fail("timeout");
  247. }
  248. try {
  249. if (RuntimeVariables.replace("Delete")
  250. .equals(selenium.getText(
  251. "//button[3]"))) {
  252. break;
  253. }
  254. }
  255. catch (Exception e) {
  256. }
  257. Thread.sleep(1000);
  258. }
  259. selenium.saveScreenShotAndSource();
  260. assertEquals(RuntimeVariables.replace("Delete"),
  261. selenium.getText("//button[3]"));
  262. selenium.click(RuntimeVariables.replace("//button[3]"));
  263. selenium.waitForPageToLoad("30000");
  264. assertTrue(selenium.getConfirmation()
  265. .matches("^Are you sure you want to delete the selected page[\\s\\S]$"));
  266. selenium.saveScreenShotAndSource();
  267. case 7:
  268. case 100:
  269. label = -1;
  270. }
  271. }
  272. }
  273. }