Author: sebawagner
Date: Fri Oct 11 23:47:10 2013
New Revision: 1531463

URL: http://svn.apache.org/r1531463
Log:
OPENMEETINGS-816 UI test to sign up, to be continued
Added cglib to .classpath as you need it to run JUnit from inside Eclipse

Added:
    
openmeetings/trunk/singlewebapp/src/test/java/org/apache/openmeetings/test/selenium/AbstractLoadTestDefaults.java
      - copied, changed from r1529278, 
openmeetings/trunk/singlewebapp/src/test/java/org/apache/openmeetings/test/selenium/TestSeleniumSmokeTest.java
    
openmeetings/trunk/singlewebapp/src/test/java/org/apache/openmeetings/test/selenium/TestSignUp.java
Removed:
    
openmeetings/trunk/singlewebapp/src/test/java/org/apache/openmeetings/test/selenium/TestSeleniumSmokeTest.java
Modified:
    openmeetings/trunk/singlewebapp/.classpath
    
openmeetings/trunk/singlewebapp/src/test/java/org/apache/openmeetings/test/selenium/SeleniumUtils.java

Modified: openmeetings/trunk/singlewebapp/.classpath
URL: 
http://svn.apache.org/viewvc/openmeetings/trunk/singlewebapp/.classpath?rev=1531463&r1=1531462&r2=1531463&view=diff
==============================================================================
--- openmeetings/trunk/singlewebapp/.classpath (original)
+++ openmeetings/trunk/singlewebapp/.classpath Fri Oct 11 23:47:10 2013
@@ -1,23 +1,4 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<!--
-  Licensed to the Apache Software Foundation (ASF) under one
-  or more contributor license agreements.  See the NOTICE file
-  distributed with this work for additional information
-  regarding copyright ownership.  The ASF licenses this file
-  to you under the Apache License, Version 2.0 (the
-  "License"); you may not use this file except in compliance
-  with the License.  You may obtain a copy of the License at
-  
-      http://www.apache.org/licenses/LICENSE-2.0
-          
-  Unless required by applicable law or agreed to in writing,
-  software distributed under the License is distributed on an
-  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-  KIND, either express or implied.  See the License for the
-  specific language governing permissions and limitations
-  under the License.
-  
--->
 <classpath>
        <classpathentry kind="src" path="src/axis/java"/>
        <classpathentry kind="src" path="src/db/java"/>
@@ -64,5 +45,6 @@
        <classpathentry kind="lib" 
path="build/red5/server/dist/lib/ehcache-core-2.5.0.jar"/>
        <classpathentry kind="lib" 
path="build/red5/server/dist/plugins/tomcat-embed-core-7.0.41.jar"/>
        <classpathentry kind="lib" 
path="build/red5/server/dist/lib/bcprov-jdk15on-1.47.jar"/>
+       <classpathentry kind="lib" 
path="build/red5/server/dist/lib/cglib-nodep-2.2.2.jar"/>
        <classpathentry kind="output" path="build/classes/eclipse"/>
 </classpath>

Copied: 
openmeetings/trunk/singlewebapp/src/test/java/org/apache/openmeetings/test/selenium/AbstractLoadTestDefaults.java
 (from r1529278, 
openmeetings/trunk/singlewebapp/src/test/java/org/apache/openmeetings/test/selenium/TestSeleniumSmokeTest.java)
URL: 
http://svn.apache.org/viewvc/openmeetings/trunk/singlewebapp/src/test/java/org/apache/openmeetings/test/selenium/AbstractLoadTestDefaults.java?p2=openmeetings/trunk/singlewebapp/src/test/java/org/apache/openmeetings/test/selenium/AbstractLoadTestDefaults.java&p1=openmeetings/trunk/singlewebapp/src/test/java/org/apache/openmeetings/test/selenium/TestSeleniumSmokeTest.java&r1=1529278&r2=1531463&rev=1531463&view=diff
==============================================================================
--- 
openmeetings/trunk/singlewebapp/src/test/java/org/apache/openmeetings/test/selenium/TestSeleniumSmokeTest.java
 (original)
+++ 
openmeetings/trunk/singlewebapp/src/test/java/org/apache/openmeetings/test/selenium/AbstractLoadTestDefaults.java
 Fri Oct 11 23:47:10 2013
@@ -20,43 +20,107 @@ package org.apache.openmeetings.test.sel
 
 import java.util.List;
 
+import org.apache.openmeetings.db.dao.label.FieldLanguagesValuesDao;
 import org.junit.After;
 import org.junit.Before;
-import org.junit.Test;
+import org.junit.runner.RunWith;
 import org.openqa.selenium.Keys;
 import org.openqa.selenium.WebDriver;
 import org.openqa.selenium.WebElement;
 import org.openqa.selenium.firefox.FirefoxDriver;
+import org.openqa.selenium.firefox.FirefoxProfile;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.TestExecutionListeners;
+import 
org.springframework.test.context.junit4.AbstractJUnit4SpringContextTests;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+
+@RunWith(SpringJUnit4ClassRunner.class)
+@TestExecutionListeners({})
+@ContextConfiguration(locations={"classpath:openmeetings-applicationContext.xml"},
 inheritLocations = true)
+public abstract class AbstractLoadTestDefaults extends 
AbstractJUnit4SpringContextTests {
+       
+       @Autowired
+       private FieldLanguagesValuesDao fieldLanguagesValuesDao;
 
-public class TestSeleniumSmokeTest {
+       public WebDriver driver = null;
+       
+       private String BASE_URL = "http://localhost:5080/openmeetings";;
+       private String username = "swagner";
+       private String userpass = "qweqwe";
+       private String orgname = "seleniumtest";
+       private String email = "selen...@openmeetings.apache.org";
+       private String locale = "en-us";
 
-       public static String BASE_URL = "http://localhost:5080/openmeetings";;
-       public static String username = "swagner";
-       public static String userpass = "qweqwe";
-       private static final String orgname = "seleniumtest";
-       private static final String email = "selen...@openmeetings.apache.org";
 
-       public WebDriver driver = null;
+       public String getBASE_URL() {
+               return BASE_URL;
+       }
+
+       public String getUsername() {
+               return username;
+       }
+
+       public String getUserpass() {
+               return userpass;
+       }
+
+       public String getOrgname() {
+               return orgname;
+       }
+
+       public String getEmail() {
+               return email;
+       }
+       
+       public Long getLanguageId() {
+               return 1L;
+       }
+       
+       public String getLocale() {
+               return locale;
+       }
 
        // setting this to false can be handy if you run the test from inside
        // Eclipse, the browser will not shut down after the test so you can 
start
        // to diagnose the test issue
        public boolean doTearDownAfterTest = false;
+       
+       public String getString(long id) {
+               return fieldLanguagesValuesDao.getString(id, getLanguageId());
+       }
+
+       /**
+        * Make method overwrite possible to have custom behavior in tests
+        * 
+        * @return
+        */
+       public boolean getDoTearDownAfterTest() {
+               return doTearDownAfterTest;
+       }
 
        @Before
        public void setUp() {
-               driver = new FirefoxDriver();
+               FirefoxProfile profile = new FirefoxProfile();
+               profile.setPreference("intl.accept_languages", getLocale());
+               driver = new FirefoxDriver(profile);
        }
 
-       @Test
+       /**
+        * This test is a basic test to verify the default loader mechanism 
works
+        * it is not intend to be a part of any sub test
+        * 
+        * @throws Exception
+        */
+       //@Test
        public void smokeTest() throws Exception {
                try {
-                       driver.get(BASE_URL);
-                       
-                       testWebSite();
-                       
-                       SeleniumUtils.inputText(driver, "login", username);
-                       SeleniumUtils.inputText(driver, "pass", userpass);
+                       driver.get(getBASE_URL());
+
+                       testIsInstalledAndDoInstallation();
+
+                       SeleniumUtils.inputText(driver, "login", getUsername());
+                       SeleniumUtils.inputText(driver, "pass", getUserpass());
 
                        WebElement signInButton = 
SeleniumUtils.findElement(driver,
                                        "//button[span[contains(text(), 'Sign 
in')]]", true);
@@ -71,90 +135,101 @@ public class TestSeleniumSmokeTest {
                }
        }
 
-       private void testWebSite() throws Exception {
-               
-               WebElement wicketExtensionsWizardHeaderTitle = 
SeleniumUtils.findElement(driver,
-                               "wicketExtensionsWizardHeaderTitle", false);
+       /**
+        * Throws exception in case that test fails, so it is important to not 
catch 
+        * that exception but really let the test fail!
+        * 
+        * @throws Exception
+        */
+       protected void testIsInstalledAndDoInstallation() throws Exception {
+
+               WebElement wicketExtensionsWizardHeaderTitle = SeleniumUtils
+                               .findElement(driver, 
"wicketExtensionsWizardHeaderTitle", false);
                if (wicketExtensionsWizardHeaderTitle == null) {
                        return;
                }
-               if 
(wicketExtensionsWizardHeaderTitle.getText().contains("Installation")) {
+               if (wicketExtensionsWizardHeaderTitle.getText()
+                               .contains("Installation")) {
                        System.out.println("Do Installation");
                        doInstallation();
                }
-               
+
        }
-       
+
        private void doInstallation() throws Exception {
                Thread.sleep(3000L);
-               
-               List<WebElement> buttons_next = 
SeleniumUtils.findElements(driver, "buttons:next", true);
-               
+
+               List<WebElement> buttons_next = 
SeleniumUtils.findElements(driver,
+                               "buttons:next", true);
+
                buttons_next.get(1).sendKeys(Keys.RETURN);
-               
+
                Thread.sleep(1000L);
-               
-               SeleniumUtils.inputText(driver, "view:cfg.username", username);
-               SeleniumUtils.inputText(driver, "view:cfg.password", userpass);
-               SeleniumUtils.inputText(driver, "view:cfg.email", email);
-               SeleniumUtils.inputText(driver, "view:cfg.group", orgname);
-               
+
+               SeleniumUtils.inputText(driver, "view:cfg.username", 
getUsername());
+               SeleniumUtils.inputText(driver, "view:cfg.password", 
getUserpass());
+               SeleniumUtils.inputText(driver, "view:cfg.email", getEmail());
+               SeleniumUtils.inputText(driver, "view:cfg.group", getOrgname());
+
                buttons_next = SeleniumUtils.findElements(driver, 
"buttons:next", true);
-               
+
                buttons_next.get(1).sendKeys(Keys.RETURN);
-               
+
                Thread.sleep(1000L);
-               
+
                buttons_next = SeleniumUtils.findElements(driver, 
"buttons:next", true);
-               
+
                buttons_next.get(1).sendKeys(Keys.RETURN);
-               
+
                Thread.sleep(1000L);
-               
+
                buttons_next = SeleniumUtils.findElements(driver, 
"buttons:next", true);
-               
+
                buttons_next.get(1).sendKeys(Keys.RETURN);
-               
+
                Thread.sleep(1000L);
-               
+
                buttons_next = SeleniumUtils.findElements(driver, 
"buttons:next", true);
-               
+
                buttons_next.get(1).sendKeys(Keys.RETURN);
-               
+
                Thread.sleep(2000L);
-               
-               List<WebElement> elements = SeleniumUtils.findElements(driver, 
"buttons:finish", true);
-               
+
+               List<WebElement> elements = SeleniumUtils.findElements(driver,
+                               "buttons:finish", true);
+
                elements.get(1).sendKeys(Keys.RETURN);
-               
+
                long maxMilliSecondsWait = 120000;
-               
+
                while (maxMilliSecondsWait > 0) {
-                       
-                       //check if installation is complete by searching for 
the link on the success page
-                       WebElement enterApplicationLink = 
SeleniumUtils.findElement(driver, 
-                                                               
"//a[contains(@href,'install')]", false);
-                       
+
+                       // check if installation is complete by searching for 
the link on
+                       // the success page
+                       WebElement enterApplicationLink = 
SeleniumUtils.findElement(driver,
+                                       "//a[contains(@href,'install')]", 
false);
+
                        if (enterApplicationLink == null) {
-                               System.out.println("Installation running - wait 
3 more seconds and check again");
-                               
+                               System.out
+                                               .println("Installation running 
- wait 3 more seconds and check again");
+
                                Thread.sleep(3000L);
                                maxMilliSecondsWait -= 3000;
                        } else {
                                maxMilliSecondsWait = 0;
-                               
+
                                enterApplicationLink.click();
-                               
+
                                return;
                        }
                }
-               
+
                throw new Exception("Timeout during installation");
        }
 
        @After
        public void tearDown() throws Exception {
-               if (doTearDownAfterTest) {
+               if (getDoTearDownAfterTest()) {
                        driver.close();
                        driver.quit();
                }

Modified: 
openmeetings/trunk/singlewebapp/src/test/java/org/apache/openmeetings/test/selenium/SeleniumUtils.java
URL: 
http://svn.apache.org/viewvc/openmeetings/trunk/singlewebapp/src/test/java/org/apache/openmeetings/test/selenium/SeleniumUtils.java?rev=1531463&r1=1531462&r2=1531463&view=diff
==============================================================================
--- 
openmeetings/trunk/singlewebapp/src/test/java/org/apache/openmeetings/test/selenium/SeleniumUtils.java
 (original)
+++ 
openmeetings/trunk/singlewebapp/src/test/java/org/apache/openmeetings/test/selenium/SeleniumUtils.java
 Fri Oct 11 23:47:10 2013
@@ -42,6 +42,9 @@ public class SeleniumUtils {
                        String inputText) throws Exception {
                WebElement element = SeleniumUtils.findElement(driver, search, 
true);
 
+               //clear text before adding input
+               element.clear();
+               
                // Would make send to check if this element is really an input 
text
                element.sendKeys(inputText);
        }
@@ -120,9 +123,6 @@ public class SeleniumUtils {
        private static List<WebElement> _findElement(WebDriver driver, String 
search) {
                for (By by : _getSearchArray(search)) {
                        try {
-                               
-                               
-                               
                                List<WebElement> elements = 
driver.findElements(by);
                                if (elements != null && elements.size() > 0) {
                                        return elements;

Added: 
openmeetings/trunk/singlewebapp/src/test/java/org/apache/openmeetings/test/selenium/TestSignUp.java
URL: 
http://svn.apache.org/viewvc/openmeetings/trunk/singlewebapp/src/test/java/org/apache/openmeetings/test/selenium/TestSignUp.java?rev=1531463&view=auto
==============================================================================
--- 
openmeetings/trunk/singlewebapp/src/test/java/org/apache/openmeetings/test/selenium/TestSignUp.java
 (added)
+++ 
openmeetings/trunk/singlewebapp/src/test/java/org/apache/openmeetings/test/selenium/TestSignUp.java
 Fri Oct 11 23:47:10 2013
@@ -0,0 +1,95 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License") +  you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.openmeetings.test.selenium;
+
+import java.util.Date;
+
+import org.junit.Test;
+import org.openqa.selenium.WebElement;
+
+public class TestSignUp extends AbstractLoadTestDefaults {
+       
+       String pass = "pass";
+       
+       @Override
+       public boolean getDoTearDownAfterTest() {
+               return false;
+       }
+
+       @Test
+       public void testSignUp() throws Exception {
+               driver.get(getBASE_URL());
+               
+               String currentRandomCounter = "" + ((new 
Date().getTime())/1000);
+               String userName = "seba" + currentRandomCounter;
+               String email = "hans." + currentRandomCounter + 
"@openmeetings.apache.org";
+               
+               super.testIsInstalledAndDoInstallation();
+               
+               WebElement signUpButton = SeleniumUtils.findElement(driver,
+                               "//button[span[contains(text(), 'Not a 
member')]]", true);
+               signUpButton.click();
+               
+               // ##################################
+               // Test validation message for passwords to be identical
+               // ##################################
+               doSignUp("Hans","Muster", userName, "pw", "pw2", email);
+               
+               //Find Error label-id 232 "Please enter two identical passwords"
+               SeleniumUtils.findElement(driver, 
"//span[@class='feedbackPanelERROR'][contains(text(), '" + getString(232) + 
"')]", true);
+               
+               
+               // ##################################
+               // Sign up with user and sign in
+               // ##################################
+               doSignUp("Hans","Muster", userName, pass, pass, email);
+               
+               //Login with user
+               SeleniumUtils.inputText(driver, "login", userName);
+               SeleniumUtils.inputText(driver, "pass", pass);
+
+               //click labelid 112 "Sign In"
+               WebElement signInButton = SeleniumUtils.findElement(driver,
+                               "//button[span[contains(text(), '" + 
getString(112) + "')]]", true);
+               signInButton.click();
+
+               // check for some text in dashbaord, labelid 281, "Help and 
support"
+               SeleniumUtils.elementExists(driver,
+                               "//h3[contains(text(), '" + getString(281) + 
"')]", true);
+               
+               // ##################################
+               // Sign up with same user and check duplicate user message
+               // ##################################
+       }
+       
+       private void doSignUp(String firstName, String lastName, String login, 
String password,
+                                       String confirmPassword, String email) 
throws Exception {
+               
+               SeleniumUtils.inputText(driver, "firstName", firstName);
+               SeleniumUtils.inputText(driver, "lastName", lastName);
+               SeleniumUtils.inputText(driver, "//div[contains(@id, 
'register')]//input[@name='login']", login);
+               SeleniumUtils.inputText(driver, "password", password);
+               SeleniumUtils.inputText(driver, "confirmPassword", 
confirmPassword);
+               SeleniumUtils.inputText(driver, "email", email);
+               
+               WebElement submitButton = SeleniumUtils.findElement(driver,
+                               "//button[span[contains(text(), 'Register')]]", 
true);
+               submitButton.click();
+       }
+}


Reply via email to