Author: vrockai
Date: 2009-01-21 09:59:19 -0500 (Wed, 21 Jan 2009)
New Revision: 12584
Modified:
branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/JBossPortalSeleniumTestCase.java
branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/JBossSeleniumTestListener.java
branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/cms/CMSArchiveUploadTestCase.java
Log:
cms archive upload hack
Modified:
branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/JBossPortalSeleniumTestCase.java
===================================================================
---
branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/JBossPortalSeleniumTestCase.java 2009-01-21
11:49:15 UTC (rev 12583)
+++
branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/JBossPortalSeleniumTestCase.java 2009-01-21
14:59:19 UTC (rev 12584)
@@ -162,6 +162,20 @@
waitFor(1000);
}
}
+
+ protected void waitForElement(String locatorElem, String locatorLink, long timeToWait,
long n) {
+ for (int i = 0;; i++) {
+ if (i >= n) {
+ Assert.fail("Element " + locatorElem + " not found.");
+ }
+ try {
+ if (selenium.isElementPresent(locatorElem))
+ break;
+ } catch (Exception e) {
+ }
+ waitFor(1000);
+ }
+ }
public void waitForText(String text) {
for (int second = 0;; second++) {
Modified:
branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/JBossSeleniumTestListener.java
===================================================================
---
branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/JBossSeleniumTestListener.java 2009-01-21
11:49:15 UTC (rev 12583)
+++
branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/JBossSeleniumTestListener.java 2009-01-21
14:59:19 UTC (rev 12584)
@@ -31,7 +31,7 @@
}
String sh = System.getProperty("html-src");
- if ("true".equals(ss)) {
+ if ("true".equals(sh)) {
htmlSource = true;
}
}
Modified:
branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/cms/CMSArchiveUploadTestCase.java
===================================================================
---
branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/cms/CMSArchiveUploadTestCase.java 2009-01-21
11:49:15 UTC (rev 12583)
+++
branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/cms/CMSArchiveUploadTestCase.java 2009-01-21
14:59:19 UTC (rev 12584)
@@ -13,16 +13,17 @@
@Test(groups = { "cms_archive_upload" }, enabled = true)
public class CMSArchiveUploadTestCase extends JBossPortalSeleniumTestCase {
- private static final String ARCHIVE_WAITING = "60000";
+ private static final Integer ARCHIVE_WAITING = 10000;
+ private static final int n = 10;
/*
* uncomment following lines and set the right path to the workspace in the
* case you want to use this test case locally from eclipse
*/
- /*
- * {
- *
System.setProperty("workspace","/home/vrockai/workspace/p2.7tests/ui-tests/"
- * ); }
- */
+/*
+ {
+ System.setProperty("workspace",
"/home/vrockai/workspace/p2.7tests/ui-tests/");
+ }
+*/
private static final String SUB_CANCEL_ARCH_UPLOAD = "cancel";
private static final String LNK_ADMIN = "link=Admin";
private static final String LNK_CMS = "link=CMS";
@@ -36,6 +37,8 @@
public void loginBeforeTest() {
logoutIfPossible();
login("admin", "admin");
+ // timeout hack
+ selenium.setSpeed("10000");
}
@AfterMethod(groups = { "log" })
@@ -46,7 +49,6 @@
@Test(enabled = true, description = "Test archive consisting of two files
upload.")
public void testArchiveUpload() {
// canceling at the first stage
-
selenium.click(LNK_ADMIN);
selenium.waitForPageToLoad(PAGE_LOAD);
selenium.click(LNK_CMS);
@@ -85,18 +87,26 @@
Assert.assertEquals(selenium.getText(DIV_ARCHIVE_STATUS),
"Your archive has been accepted for processing. The resources will appear in
your Folder once the processing is finished");
- selenium.setSpeed(ARCHIVE_WAITING);
- selenium.click("link=Home");
- selenium.setSpeed("0");
- selenium.waitForPageToLoad(PAGE_LOAD);
+ for (int i = 0;; i++) {
+ selenium.click("link=Home");
+ selenium.waitForPageToLoad(PAGE_LOAD);
- Assert.assertTrue(selenium.isElementPresent("link=archive"), "uploaded
archive not found");
+ if (i >= n) {
+ Assert.assertTrue(selenium.isElementPresent("link=archive"), "uploaded
archive not found");
+ break;
+ }
+ if (selenium.isElementPresent("link=archive"))
+ break;
+
+ waitFor(ARCHIVE_WAITING);
+ }
+
selenium.click("link=archive");
selenium.waitForPageToLoad(PAGE_LOAD);
- Assert.assertEquals(selenium.isElementPresent("link=readme.txt"),
"content of uploaded file not found #1");
- Assert.assertEquals(selenium.isElementPresent("link=jbosslogo.png"),
"content of uploaded file not found #2");
+ Assert.assertTrue(selenium.isElementPresent("link=readme.txt"), "content
of uploaded file not found #1");
+ Assert.assertTrue(selenium.isElementPresent("link=jbosslogo.png"),
"content of uploaded file not found #2");
}
@Test(enabled = true, description = "Test archive consisting of > 100 files
upload.")
@@ -113,21 +123,31 @@
selenium.type(INP_ARCHIVE_FILE, WORKSPACE + "/test_files/many_files.zip");
selenium.click(SUB_SEND_ARCHIVE);
+ selenium.waitForPageToLoad(PAGE_LOAD);
- selenium.waitForPageToLoad(PAGE_LOAD);
Assert.assertEquals(selenium.getText(DIV_ARCHIVE_STATUS),
"Your archive has been accepted for processing. The resources will appear in
your Folder once the processing is finished");
- selenium.setSpeed(ARCHIVE_WAITING);
selenium.click("link=Home");
- selenium.setSpeed("0");
selenium.waitForPageToLoad(PAGE_LOAD);
- Assert.assertTrue(selenium.isElementPresent("link=many_files"),
"uploaded archive not found");
+ for (int i = 0;; i++) {
+ selenium.click("link=Home");
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ if (i >= n) {
+ Assert.assertTrue(selenium.isElementPresent("link=many_files"),
"uploaded archive not found");
+ break;
+ }
+
+ if (selenium.isElementPresent("link=many_files"))
+ break;
+
+ waitFor(ARCHIVE_WAITING);
+ }
+
selenium.click("link=many_files");
selenium.waitForPageToLoad(PAGE_LOAD);
-
Assert.assertTrue(selenium.isElementPresent("link=file31.txt"), "content
of uploaded archive not found");
}
@@ -150,11 +170,23 @@
Assert.assertEquals(selenium.getText(DIV_ARCHIVE_STATUS),
"Your archive has been accepted for processing. The resources will appear in
your Folder once the processing is finished");
- selenium.setSpeed(ARCHIVE_WAITING);
selenium.click("link=Home");
- selenium.setSpeed("0");
selenium.waitForPageToLoad(PAGE_LOAD);
- Assert.assertTrue(selenium.isElementPresent("link=bigfile"), "uploaded
archive not found");
+ for (int i = 0;; i++) {
+ selenium.click("link=Home");
+ selenium.waitForPageToLoad(PAGE_LOAD);
+
+ if (i >= n) {
+ Assert.assertTrue(selenium.isElementPresent("link=bigfile"), "uploaded
archive not found");
+ break;
+ }
+
+ if (selenium.isElementPresent("link=bigfile"))
+ break;
+
+ waitFor(ARCHIVE_WAITING);
+ }
+
}
}
Show replies by date