[kune-commits] r1594 - in trunk: . src/main/webapp src/test/java/cc/kune/selenium src/test/java/cc/kune/selenium/login src/test/java/cc/kune/selenium/userspace

Vicente J. Ruiz Jurado vjrj_ at ourproject.org
Tue Nov 8 15:16:07 CET 2011


Author: vjrj_
Date: 2011-11-08 15:16:07 +0100 (Tue, 08 Nov 2011)
New Revision: 1594

Added:
   trunk/src/test/java/cc/kune/selenium/userspace/
   trunk/src/test/java/cc/kune/selenium/userspace/UserSpacePageObject.java
Modified:
   trunk/TODO
   trunk/src/main/webapp/ws.html
   trunk/src/test/java/cc/kune/selenium/CustomWebDriverEventListener.java
   trunk/src/test/java/cc/kune/selenium/KuneSeleniumDefaults.java
   trunk/src/test/java/cc/kune/selenium/PageObject.java
   trunk/src/test/java/cc/kune/selenium/SeleniumModule.java
   trunk/src/test/java/cc/kune/selenium/SeleniumUtils.java
   trunk/src/test/java/cc/kune/selenium/login/LoginPageObject.java
   trunk/src/test/java/cc/kune/selenium/login/LoginSeleniumTests.java
   trunk/src/test/java/cc/kune/selenium/login/RegisterSeleniumTests.java
Log:
NEW - # 127: Generate some screencast while doing automate testing 
http://kune.ourproject.org/issues/ticket/127

Modified: trunk/TODO
===================================================================
--- trunk/TODO	2011-11-08 04:15:12 UTC (rev 1593)
+++ trunk/TODO	2011-11-08 14:16:07 UTC (rev 1594)
@@ -19,6 +19,8 @@
 http://gxt-multiupload-demo.appspot.com/
 http://code.google.com/p/gxt-multi-upload/
 http://code.google.com/p/gwtupload/
+** TODO improve session timeouts
+http://stackoverflow.com/questions/1406287/jspservlethow-do-i-set-session-timeout-of-greater-than-30-minutes
 ** TODO workaround websocket issues
 *** compatibilities
 | jetty M2              | new wesocket | socketio  |

Modified: trunk/src/main/webapp/ws.html
===================================================================
--- trunk/src/main/webapp/ws.html	2011-11-08 04:15:12 UTC (rev 1593)
+++ trunk/src/main/webapp/ws.html	2011-11-08 14:16:07 UTC (rev 1594)
@@ -280,7 +280,7 @@
 </head>
 <body>
     <div id="kcursor"
-        style="visibility: hidden; position: absolute; z-Index: 100001'; height: 0; width: 0">
+        style="visibility: hidden; position: absolute; z-Index: 100001; height: 0; width: 0">
         <img src="/others/cursor-orange.png">
     </div>
     <script type="text/javascript">
@@ -295,8 +295,8 @@
       var diff_x;
       var diff_y;
       function kmove(x, y) {
-        newx = x - 18 + 15;
-        newy = y - 7 + 15;
+        newx = x - 18 + 20;
+        newy = y - 7 + 17;
         kmoveit();
       }
 

Modified: trunk/src/test/java/cc/kune/selenium/CustomWebDriverEventListener.java
===================================================================
--- trunk/src/test/java/cc/kune/selenium/CustomWebDriverEventListener.java	2011-11-08 04:15:12 UTC (rev 1593)
+++ trunk/src/test/java/cc/kune/selenium/CustomWebDriverEventListener.java	2011-11-08 14:16:07 UTC (rev 1594)
@@ -10,11 +10,13 @@
 
   @Override
   public void afterChangeValueOf(final WebElement element, final WebDriver driver) {
+    // SeleniumUtils.showCursor(driver);
     sleep(600);
   }
 
   @Override
   public void afterClickOn(final WebElement element, final WebDriver driver) {
+    // SeleniumUtils.showCursor(driver);
     slow();
   }
 
@@ -45,12 +47,14 @@
   public void beforeChangeValueOf(final WebElement element, final WebDriver driver) {
     SeleniumUtils.hightlight(element, driver);
     sleep(300);
+    // SeleniumUtils.hideCursor(driver);
   }
 
   @Override
   public void beforeClickOn(final WebElement element, final WebDriver driver) {
     SeleniumUtils.hightlight(element, driver);
     slow();
+    // SeleniumUtils.hideCursor(driver);
   }
 
   @Override

Modified: trunk/src/test/java/cc/kune/selenium/KuneSeleniumDefaults.java
===================================================================
--- trunk/src/test/java/cc/kune/selenium/KuneSeleniumDefaults.java	2011-11-08 04:15:12 UTC (rev 1593)
+++ trunk/src/test/java/cc/kune/selenium/KuneSeleniumDefaults.java	2011-11-08 14:16:07 UTC (rev 1594)
@@ -46,6 +46,7 @@
 import cc.kune.selenium.login.LoginPageObject;
 import cc.kune.selenium.login.RegisterPageObject;
 import cc.kune.selenium.tools.SeleniumConstants;
+import cc.kune.selenium.userspace.UserSpacePageObject;
 
 import com.google.inject.Guice;
 import com.google.inject.Injector;
@@ -55,7 +56,7 @@
   public static final Injector INJECTOR = Guice.createInjector(new SeleniumModule());
 
   private static final Log LOG = LogFactory.getLog(KuneSeleniumDefaults.class);
-  public static boolean mustCloseFinally = false;
+  public static boolean mustCloseFinally = true;
   private final String baseUrl;
   protected final ChatPageObject chat;
   protected final EntityHeaderPageObject entityHeader;
@@ -64,13 +65,13 @@
   private final ResourceBundle messages;
   protected RegisterPageObject register;
   protected final SpacesPageObject spaces;
+  protected UserSpacePageObject userSpace;
   private final WebDriver webdriver;
 
   public KuneSeleniumDefaults() {
     // baseUrl = "http://kune.beta.iepala.es/?locale=en#";
-    // baseUrl =
-    // "http://127.0.0.1:8888/?locale=es&log_level=INFO&gwt.codesvr=127.0.0.1:9997#";
-    baseUrl = "http://beta.eurosur.org/#";
+    baseUrl = "http://127.0.0.1:8888/?locale=es&log_level=INFO&gwt.codesvr=127.0.0.1:9997#";
+    // baseUrl = "http://beta.eurosur.org/#";
     injector = INJECTOR;
     webdriver = injector.getInstance(WebDriver.class);
     login = injector.getInstance(LoginPageObject.class);
@@ -78,6 +79,7 @@
     entityHeader = injector.getInstance(EntityHeaderPageObject.class);
     spaces = injector.getInstance(SpacesPageObject.class);
     chat = injector.getInstance(ChatPageObject.class);
+    userSpace = injector.getInstance(UserSpacePageObject.class);
     messages = injector.getInstance(ResourceBundle.class);
     final ElementLocatorFactory locator = injector.getInstance(ElementLocatorFactory.class);
     PageFactory.initElements(locator, login);
@@ -85,6 +87,7 @@
     PageFactory.initElements(locator, entityHeader);
     PageFactory.initElements(locator, spaces);
     PageFactory.initElements(locator, chat);
+    PageFactory.initElements(locator, userSpace);
   }
 
   @BeforeMethod

Modified: trunk/src/test/java/cc/kune/selenium/PageObject.java
===================================================================
--- trunk/src/test/java/cc/kune/selenium/PageObject.java	2011-11-08 04:15:12 UTC (rev 1593)
+++ trunk/src/test/java/cc/kune/selenium/PageObject.java	2011-11-08 14:16:07 UTC (rev 1594)
@@ -198,7 +198,7 @@
 
   public void waitFor(final WebElement element) {
     final String id = element.getAttribute("id");
-    LOG.info("WAIT FOR: " + id);
+    // LOG.info("WAIT FOR: " + id);
     waitFor(id, new Runnable() {
       @Override
       public void run() {
@@ -208,19 +208,19 @@
   }
 
   protected void waitFor(final WebElement element, final String text) {
-    LOG.info("WAIT FOR: " + text);
+    // LOG.info("WAIT FOR: " + text);
     waitFor(text, new Runnable() {
       @Override
       public void run() {
         final String elText = element.getText();
-        LOG.info("Element text: " + elText);
+        // LOG.info("Element text: " + elText);
         Assert.assertTrue(elText.contains(text));
       }
     });
   }
 
   protected void waitForId(final String id) {
-    LOG.info("WAIT FOR: " + id);
+    // LOG.info("WAIT FOR: " + id);
     waitFor(id, new Runnable() {
       @Override
       public void run() {
@@ -230,12 +230,12 @@
   }
 
   protected void waitForValue(final WebElement element, final String text) {
-    LOG.info("WAIT FOR: " + text);
+    // LOG.info("WAIT FOR: " + text);
     waitFor(text, new Runnable() {
       @Override
       public void run() {
         final String elValue = element.getText();
-        LOG.info("Element value: " + elValue);
+        // LOG.info("Element value: " + elValue);
         Assert.assertTrue(elValue.contains(text));
       }
     });

Modified: trunk/src/test/java/cc/kune/selenium/SeleniumModule.java
===================================================================
--- trunk/src/test/java/cc/kune/selenium/SeleniumModule.java	2011-11-08 04:15:12 UTC (rev 1593)
+++ trunk/src/test/java/cc/kune/selenium/SeleniumModule.java	2011-11-08 14:16:07 UTC (rev 1594)
@@ -47,8 +47,8 @@
 
   @Override
   protected void configure() {
-    final RemoteWebDriver driver = createChromeDriver();
-    // final WebDriver driver = creatFirefoxDriver();
+    // final RemoteWebDriver driver = createChromeDriver();
+    final WebDriver driver = creatFirefoxDriver();
     final EventFiringWebDriver wrap = new EventFiringWebDriver(driver);
     wrap.register(new CustomWebDriverEventListener());
 

Modified: trunk/src/test/java/cc/kune/selenium/SeleniumUtils.java
===================================================================
--- trunk/src/test/java/cc/kune/selenium/SeleniumUtils.java	2011-11-08 04:15:12 UTC (rev 1593)
+++ trunk/src/test/java/cc/kune/selenium/SeleniumUtils.java	2011-11-08 14:16:07 UTC (rev 1594)
@@ -13,22 +13,28 @@
 
 public class SeleniumUtils {
 
+  private static boolean fastSpeed = true;
   private static final Log LOG = LogFactory.getLog(SeleniumUtils.class);
 
+  public static void fastSpeed(final boolean fastSpeed) {
+    SeleniumUtils.fastSpeed = fastSpeed;
+  }
+
   public static void hideCursor(final WebDriver webdriver) {
     jsExec(webdriver).executeScript("khideCursor();");
   }
 
   public static void hightlight(final WebElement element, final WebDriver webdriver) {
-    showCursor(webdriver, element);
+    SeleniumUtils.showCursor(webdriver, element);
     sleep(300);
-    final String script = "window.jQuery('#" + element.getAttribute("id") + "').addClass('k-outline');"
-        + "setTimeout('window.jQuery(\"#" + element.getAttribute("id")
-        + "\").removeClass(\"k-outline\")', 1200);";
-    // Antes 700
-    // LOG.info("High: " + script);
-    jsExec(webdriver).executeScript(script);
-
+    if (TextUtils.notEmpty(element.getAttribute("id"))) {
+      final String script = "window.jQuery('#" + element.getAttribute("id")
+          + "').addClass('k-outline');" + "setTimeout('window.jQuery(\"#" + element.getAttribute("id")
+          + "\").removeClass(\"k-outline\")', 1200);";
+      // Antes 700
+      // LOG.info("High: " + script);
+      jsExec(webdriver).executeScript(script);
+    }
   }
 
   public static void initCursor(final WebDriver webdriver) {
@@ -50,7 +56,7 @@
   }
 
   public static void showCursor(final WebDriver webdriver, final int x, final int y) {
-    LOG.info("Mover cursor to x: " + x + ", y: " + y);
+    // LOG.info("Mover cursor to x: " + x + ", y: " + y);
     jsExec(webdriver).executeScript("kmove(" + x + "," + y + ");");
   }
 
@@ -74,7 +80,7 @@
 
   public static void sleep(final int milliseconds) {
     try {
-      Thread.sleep(milliseconds);
+      Thread.sleep(fastSpeed ? milliseconds / 10 : milliseconds);
     } catch (final InterruptedException e) {
       Assert.fail("Exception in sleep method", e);
     }

Modified: trunk/src/test/java/cc/kune/selenium/login/LoginPageObject.java
===================================================================
--- trunk/src/test/java/cc/kune/selenium/login/LoginPageObject.java	2011-11-08 04:15:12 UTC (rev 1593)
+++ trunk/src/test/java/cc/kune/selenium/login/LoginPageObject.java	2011-11-08 14:16:07 UTC (rev 1594)
@@ -42,7 +42,6 @@
   private WebElement user;
 
   public LoginPageObject() {
-    // i18n = new I18nHelper(LoginMessages.class);
   }
 
   public void createOne() {

Modified: trunk/src/test/java/cc/kune/selenium/login/LoginSeleniumTests.java
===================================================================
--- trunk/src/test/java/cc/kune/selenium/login/LoginSeleniumTests.java	2011-11-08 04:15:12 UTC (rev 1593)
+++ trunk/src/test/java/cc/kune/selenium/login/LoginSeleniumTests.java	2011-11-08 14:16:07 UTC (rev 1594)
@@ -25,6 +25,17 @@
 
 public class LoginSeleniumTests extends KuneSeleniumTest {
 
+  @Test(dataProvider = "correctlogin")
+  public void basicSignIn(final String user, final String passwd) {
+    login.assertIsDisconnected();
+    showTitleSlide("User sign in", "to get full access to this site");
+    login.signIn(user, passwd);
+    login.assertIsConnectedAs(user);
+    // userSpace.getWavePanel().click();
+    login.logout();
+    login.assertIsDisconnected();
+  }
+
   @Test
   public void high() {
     login.high();
@@ -44,16 +55,6 @@
     login.assertIsDisconnected();
   }
 
-  @Test(dataProvider = "correctlogin")
-  public void basicSignIn(final String user, final String passwd) {
-    login.assertIsDisconnected();
-    showTitleSlide("User sign in", "to get full access to this site");
-    login.signIn(user, passwd);
-    login.assertIsConnectedAs(user);
-    login.logout();
-    login.assertIsDisconnected();
-  }
-
   @Test
   public void signInIncorrectPasswd() {
     login.assertIsDisconnected();

Modified: trunk/src/test/java/cc/kune/selenium/login/RegisterSeleniumTests.java
===================================================================
--- trunk/src/test/java/cc/kune/selenium/login/RegisterSeleniumTests.java	2011-11-08 04:15:12 UTC (rev 1593)
+++ trunk/src/test/java/cc/kune/selenium/login/RegisterSeleniumTests.java	2011-11-08 14:16:07 UTC (rev 1594)
@@ -23,6 +23,7 @@
 
 import cc.kune.core.client.state.SiteTokens;
 import cc.kune.selenium.KuneSeleniumTest;
+import cc.kune.selenium.SeleniumUtils;
 import cc.kune.selenium.tools.SeleniumConstants;
 
 import com.calclab.emite.core.client.xmpp.stanzas.XmppURI;
@@ -32,6 +33,7 @@
   @Test(dataProvider = "correctregister")
   public void basicRegister(final String shortName, final String longName, final String passwd,
       final String email) {
+    SeleniumUtils.fastSpeed(false);
     // 15 chars, the limit, so we don't use shortName
     final String prefix = getTempString();
     showTitleSlide(t("User registration"), t("to get full access to this site tools/contents"));
@@ -46,6 +48,13 @@
     showTitleSlide(t("User space (your Inbox)"), t("contents in which you participate"));
     showTooltip(spaces.userBtn());
     spaces.userBtn().click();
+    showMsg(t("You can see this like an advanced email system"));
+    userSpace.getFirstWave().click();
+    sleep(2000);
+    userSpace.getNewWave().click();
+    showMsg(t("You can compose personal messages"));
+    showMsg(t("But aslo create contents to publish later"));
+    sleep(3000);
 
     // chat
     showTitleSlide(t("Chat with your buddies"), t("compatible with gmail and similars"),

Added: trunk/src/test/java/cc/kune/selenium/userspace/UserSpacePageObject.java
===================================================================
--- trunk/src/test/java/cc/kune/selenium/userspace/UserSpacePageObject.java	                        (rev 0)
+++ trunk/src/test/java/cc/kune/selenium/userspace/UserSpacePageObject.java	2011-11-08 14:16:07 UTC (rev 1594)
@@ -0,0 +1,51 @@
+/*
+ *
+ * Copyright (C) 2007-2011 The kune development team (see CREDITS for details)
+ * This file is part of kune.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program 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 Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+package cc.kune.selenium.userspace;
+
+import org.openqa.selenium.By;
+import org.openqa.selenium.WebElement;
+import org.openqa.selenium.support.FindBy;
+
+import cc.kune.selenium.PageObject;
+
+public class UserSpacePageObject extends PageObject {
+
+  @FindBy(xpath = "//div[3]/div/div/span[2]")
+  private WebElement firstWave;
+  @FindBy(xpath = "//div[2]/div[2]/div[4]")
+  private WebElement newWave;
+  @FindBy(xpath = "")
+  private WebElement wavePanel;
+
+  public UserSpacePageObject() {
+  }
+
+  public WebElement getFirstWave() {
+    return findElement(By.xpath("//div[3]/div[4]/div"));
+  }
+
+  public WebElement getNewWave() {
+    return findElement(By.xpath("//div[2]/div[2]/div[4]"));
+  }
+
+  public WebElement getWavePanel() {
+    return wavePanel;
+  }
+}




More information about the kune-commits mailing list