[seam-commits] Seam SVN: r12369 - branches/enterprise/JBPAPP_5_0/src/test/ftest/src/main/org/jboss/seam/example/common/test/selenium.

seam-commits at lists.jboss.org seam-commits at lists.jboss.org
Fri Apr 2 04:20:45 EDT 2010


Author: jharting
Date: 2010-04-02 04:20:44 -0400 (Fri, 02 Apr 2010)
New Revision: 12369

Modified:
   branches/enterprise/JBPAPP_5_0/src/test/ftest/src/main/org/jboss/seam/example/common/test/selenium/SeamSelenium.java
   branches/enterprise/JBPAPP_5_0/src/test/ftest/src/main/org/jboss/seam/example/common/test/selenium/SeamSeleniumTest.java
Log:
JBPAPP-4036 Workaround for Selenium tests on IE

Modified: branches/enterprise/JBPAPP_5_0/src/test/ftest/src/main/org/jboss/seam/example/common/test/selenium/SeamSelenium.java
===================================================================
--- branches/enterprise/JBPAPP_5_0/src/test/ftest/src/main/org/jboss/seam/example/common/test/selenium/SeamSelenium.java	2010-04-02 08:00:56 UTC (rev 12368)
+++ branches/enterprise/JBPAPP_5_0/src/test/ftest/src/main/org/jboss/seam/example/common/test/selenium/SeamSelenium.java	2010-04-02 08:20:44 UTC (rev 12369)
@@ -26,6 +26,7 @@
 import java.io.OutputStreamWriter;
 
 import com.thoughtworks.selenium.DefaultSelenium;
+import com.thoughtworks.selenium.SeleniumException;
 import com.thoughtworks.selenium.Wait;
 
 /**
@@ -41,6 +42,8 @@
    private boolean icefacesDetection = false;
    private long icefacesWaitTime = 1000;
    private long windowMaximizeWaitTime = 5000L;
+   private boolean suppressSeleniumTimeoutException = true;
+   
 
    private final String ICEFACES_CONNECTION_STATUS = "xpath=//div[@class='iceOutConStat connectionStatus']";
    private final String ICEFACES_IDLE_VISIBLE = "xpath=//div[@class='iceOutConStatInactv connectionStatusInactv'][@style='visibility: visible;']";
@@ -107,6 +110,26 @@
       {
          waitForIcefaces(icefacesWaitTime, Long.valueOf(timeout));
       }
+      else if (suppressSeleniumTimeoutException)
+      {
+         try
+         {
+            super.waitForPageToLoad(timeout);
+         }
+         catch (SeleniumException e)
+         {
+            if (isTimeoutException(e))
+            {
+               // NOOP
+               // THIS IS A WORKAROUND FOR IE BEHAVIOR
+               // SEE JBPAPP-4036
+            }
+            else
+            {
+               throw e;
+            }
+         }
+      } 
       else
       {
          super.waitForPageToLoad(timeout);
@@ -274,4 +297,48 @@
          }
       }.wait("Timeout while waiting for document body after icefaces click.", timeout);
    }
+
+   @Override
+   public void open(String url)
+   {
+      if (suppressSeleniumTimeoutException)
+      {
+         try
+         {
+            super.open(url);
+         }
+         catch (SeleniumException e)
+         {
+            if (isTimeoutException(e))
+            {
+               // NOOP
+               // THIS IS A WORKAROUND FOR IE BEHAVIOR
+               // SEE JBPAPP-4036
+            }
+            else
+            {
+               throw e;
+            }
+         }
+      }
+      else
+      {
+         super.open(url);
+      }
+   }
+
+   private boolean isTimeoutException(SeleniumException e)
+   {
+      return e.getMessage().contains("Timed out");
+   }
+   
+   public boolean isSuppressSeleniumTimeoutException()
+   {
+      return suppressSeleniumTimeoutException;
+   }
+
+   public void setSuppressSeleniumTimeoutException(boolean suppressSeleniumTimeoutException)
+   {
+      this.suppressSeleniumTimeoutException = suppressSeleniumTimeoutException;
+   }
 }

Modified: branches/enterprise/JBPAPP_5_0/src/test/ftest/src/main/org/jboss/seam/example/common/test/selenium/SeamSeleniumTest.java
===================================================================
--- branches/enterprise/JBPAPP_5_0/src/test/ftest/src/main/org/jboss/seam/example/common/test/selenium/SeamSeleniumTest.java	2010-04-02 08:00:56 UTC (rev 12368)
+++ branches/enterprise/JBPAPP_5_0/src/test/ftest/src/main/org/jboss/seam/example/common/test/selenium/SeamSeleniumTest.java	2010-04-02 08:20:44 UTC (rev 12369)
@@ -96,6 +96,11 @@
         newBrowser.allowNativeXpath("false");
         newBrowser.setSpeed(SPEED);
         newBrowser.setTimeout(TIMEOUT);
+        if (BROWSER.contains("iexplore"))
+        {
+           // Turn on the workaround for JBPAPP-4036
+           newBrowser.setSuppressSeleniumTimeoutException(true);
+        }
         return newBrowser;
     }
     



More information about the seam-commits mailing list