Author: jharting
Date: 2008-11-07 06:53:51 -0500 (Fri, 07 Nov 2008)
New Revision: 9525
Added:
trunk/src/test/ftest/examples/contactlist/
trunk/src/test/ftest/examples/contactlist/build.xml
trunk/src/test/ftest/examples/contactlist/src/
trunk/src/test/ftest/examples/contactlist/src/org/
trunk/src/test/ftest/examples/contactlist/src/org/jboss/
trunk/src/test/ftest/examples/contactlist/src/org/jboss/seam/
trunk/src/test/ftest/examples/contactlist/src/org/jboss/seam/example/
trunk/src/test/ftest/examples/contactlist/src/org/jboss/seam/example/contactlist/
trunk/src/test/ftest/examples/contactlist/src/org/jboss/seam/example/contactlist/test/
trunk/src/test/ftest/examples/contactlist/src/org/jboss/seam/example/contactlist/test/selenium/
trunk/src/test/ftest/examples/contactlist/src/org/jboss/seam/example/contactlist/test/selenium/CommentTest.java
trunk/src/test/ftest/examples/contactlist/src/org/jboss/seam/example/contactlist/test/selenium/ContactCRUDTest.java
trunk/src/test/ftest/examples/contactlist/src/org/jboss/seam/example/contactlist/test/selenium/ContactlistConstants.java
trunk/src/test/ftest/examples/contactlist/src/org/jboss/seam/example/contactlist/test/selenium/Person.java
trunk/src/test/ftest/examples/contactlist/src/org/jboss/seam/example/contactlist/test/selenium/SeleniumContactlistTest.java
trunk/src/test/ftest/examples/contactlist/testng.xml
Modified:
trunk/examples/contactlist/view/editContact.xhtml
trunk/examples/contactlist/view/search.xhtml
trunk/examples/contactlist/view/viewContact.xhtml
trunk/src/test/ftest/build.xml
Log:
selenium tests for contactlist example
Modified: trunk/examples/contactlist/view/editContact.xhtml
===================================================================
--- trunk/examples/contactlist/view/editContact.xhtml 2008-11-07 10:11:41 UTC (rev 9524)
+++ trunk/examples/contactlist/view/editContact.xhtml 2008-11-07 11:53:51 UTC (rev 9525)
@@ -13,21 +13,21 @@
<body>
<div class="menuButtons">
- <s:link view="/search.xhtml" value="Search Contacts"/>
- <s:link view="/editContact.xhtml" value="Create New
Contact">
+ <s:link id="search" view="/search.xhtml" value="Search
Contacts"/>
+ <s:link id="create" view="/editContact.xhtml"
value="Create New Contact">
<f:param name="contactId"/> <!-- suppress propagation of
contact id page parameter -->
</s:link>
- <s:link view="/viewContact.xhtml" value="View Contact"
rendered="#{contactHome.managed}"/>
- <s:link view="/editContact.xhtml" value="Edit Contact"
rendered="#{contactHome.managed}"/>
+ <s:link id="view" view="/viewContact.xhtml" value="View
Contact" rendered="#{contactHome.managed}"/>
+ <s:link id="edit" view="/editContact.xhtml" value="Edit
Contact" rendered="#{contactHome.managed}"/>
</div>
<div class="body">
<h1>Edit Contact</h1>
- <h:form>
+ <h:form id="editForm">
- <h:messages globalOnly="true" styleClass="message"/>
+ <h:messages id="messages" globalOnly="true"
styleClass="message"/>
<!-- editable fields -->
<s:validateAll>
@@ -44,55 +44,55 @@
<tr class="prop">
<td class="name">First Name:</td>
<td class="value">
- <s:decorate><h:inputText id="firstName"
value="#{contact.firstName}" required="true"/></s:decorate>
+ <s:decorate id="firstNameDecorate"><h:inputText
id="firstName" value="#{contact.firstName}"
required="true"/></s:decorate>
</td>
</tr>
<tr class="prop">
<td class="name">Last Name:</td>
<td class="value">
- <s:decorate><h:inputText id="lastName"
value="#{contact.lastName}" required="true"/></s:decorate>
+ <s:decorate id="lastNameDecorate"><h:inputText
id="lastName" value="#{contact.lastName}"
required="true"/></s:decorate>
</td>
</tr>
<tr class="prop">
<td class="name">Cell Phone:</td>
<td class="value">
- <s:decorate><h:inputText id="cellPhone"
value="#{contact.cellPhone}"/></s:decorate>
+ <s:decorate id="cellPhoneDecorate"><h:inputText
id="cellPhone" value="#{contact.cellPhone}"/></s:decorate>
</td>
</tr>
<tr class="prop">
<td class="name">Home Phone:</td>
<td class="value">
- <s:decorate><h:inputText id="homePhone"
value="#{contact.homePhone}"/></s:decorate>
+ <s:decorate id="homePhoneDecorate"><h:inputText
id="homePhone" value="#{contact.homePhone}"/></s:decorate>
</td>
</tr>
<tr class="prop">
<td class="name">Address:</td>
<td class="value">
- <s:decorate><h:inputText id="address"
value="#{contact.address}"/></s:decorate>
+ <s:decorate id="addressDecorate"><h:inputText
id="address" value="#{contact.address}"/></s:decorate>
</td>
</tr>
<tr class="prop">
<td class="name">City:</td>
<td class="value">
- <s:decorate><h:inputText id="city"
value="#{contact.city}"/></s:decorate>
+ <s:decorate id="cityDecorate"><h:inputText
id="city" value="#{contact.city}"/></s:decorate>
</td>
</tr>
<tr class="prop">
<td class="name">State:</td>
<td class="value">
- <s:decorate><h:inputText id="state"
value="#{contact.state}"/></s:decorate>
+ <s:decorate id="stateDecorate"><h:inputText
id="state" value="#{contact.state}"/></s:decorate>
</td>
</tr>
<tr class="prop">
<td class="name">Zip:</td>
<td class="value">
- <s:decorate><h:inputText id="zip"
value="#{contact.zip}"/></s:decorate>
+ <s:decorate id="zipDecorate"><h:inputText
id="zip" value="#{contact.zip}"/></s:decorate>
</td>
</tr>
<tr class="prop">
<td class="name">Country:</td>
<td class="value">
- <s:decorate><h:inputText id="country"
value="#{contact.country}"/></s:decorate>
+ <s:decorate id="countryDecorate"><h:inputText
id="country" value="#{contact.country}"/></s:decorate>
</td>
</tr>
</table>
@@ -103,12 +103,12 @@
<!-- actions -->
<div class="actionButtons">
- <h:commandLink action="#{contactHome.update}" value="Update
Contact" rendered="#{contactHome.managed}"/>
- <s:link action="#{contactHome.remove}" value="Delete
Contact" rendered="#{contactHome.managed}"/>
- <s:link view="/viewContact.xhtml" value="Cancel"
rendered="#{contactHome.managed}"/>
+ <h:commandLink id="updateContact"
action="#{contactHome.update}" value="Update Contact"
rendered="#{contactHome.managed}"/>
+ <s:link id="deleteContact"
action="#{contactHome.remove}" value="Delete Contact"
rendered="#{contactHome.managed}"/>
+ <s:link id="cancelManaged" view="/viewContact.xhtml"
value="Cancel" rendered="#{contactHome.managed}"/>
- <h:commandLink action="#{contactHome.persist}" value="Create
Contact" rendered="#{!contactHome.managed}"/>
- <s:link view="/search.xhtml" value="Cancel"
rendered="#{!contactHome.managed}"/>
+ <h:commandLink id="createContact"
action="#{contactHome.persist}" value="Create Contact"
rendered="#{!contactHome.managed}"/>
+ <s:link id="cancel" view="/search.xhtml"
value="Cancel" rendered="#{!contactHome.managed}"/>
</div>
Modified: trunk/examples/contactlist/view/search.xhtml
===================================================================
--- trunk/examples/contactlist/view/search.xhtml 2008-11-07 10:11:41 UTC (rev 9524)
+++ trunk/examples/contactlist/view/search.xhtml 2008-11-07 11:53:51 UTC (rev 9525)
@@ -12,13 +12,13 @@
<body>
<div class="menuButtons">
- <s:link view="/search.xhtml" value="Search Contacts">
+ <s:link id="search" view="/search.xhtml" value="Search
Contacts">
<f:param name="firstName" />
<f:param name="lastName" />
<f:param name="firstResult" />
</s:link>
- <s:link view="/editContact.xhtml" value="Create New
Contact">
+ <s:link id="create" view="/editContact.xhtml"
value="Create New Contact">
<f:param name="contactId"/> <!-- suppress propagation of
contact id page parameter -->
</s:link>
</div>
@@ -27,22 +27,22 @@
<h1>ContactList</h1>
- <h:messages styleClass="message"/>
+ <h:messages id="messages" styleClass="message"/>
<!-- search box -->
<div class="dialog">
- <h:form>
+ <h:form id="searchForm">
<span class="prop">
<span class="name">First Name:</span>
- <span class="value"><h:inputText
value="#{exampleContact.firstName}"/></span>
+ <span class="value"><h:inputText id="firstName"
value="#{exampleContact.firstName}"/></span>
</span>
<span class="prop">
<span class="name">Last Name :</span>
- <span class="value"><h:inputText
value="#{exampleContact.lastName}"/></span>
+ <span class="value"><h:inputText id="lastName"
value="#{exampleContact.lastName}"/></span>
</span>
- <h:commandButton value="Search"
action="newsearch"/>
+ <h:commandButton id="submit" value="Search"
action="newsearch"/>
</h:form>
</div>
@@ -58,20 +58,20 @@
<th>Zip</th>
<th>Country</th>
</tr>
- <ui:repeat value="#{contacts.resultList}" var="cont">
+ <ui:repeat id="searchResult"
value="#{contacts.resultList}" var="cont">
<tr>
<td>
- <s:link view="/viewContact.xhtml"
value="#{cont.firstName} #{cont.lastName}">
+ <s:link id="link" view="/viewContact.xhtml"
value="#{cont.firstName} #{cont.lastName}">
<f:param name="contactId" value="#{cont.id}"/>
</s:link>
</td>
- <td>#{cont.cellPhone}</td>
- <td>#{cont.homePhone}</td>
- <td>#{cont.address}</td>
- <td>#{cont.city}</td>
- <td>#{cont.state}</td>
- <td>#{cont.zip}</td>
- <td>#{cont.country}</td>
+ <td><h:outputText id="cellPhone"
value="#{cont.cellPhone}" /></td>
+ <td><h:outputText id="homePhone"
value="#{cont.homePhone}" /></td>
+ <td><h:outputText id="address"
value="#{cont.address}" /></td>
+ <td><h:outputText id="city" value="#{cont.city}"
/></td>
+ <td><h:outputText id="state"
value="#{cont.state}" /></td>
+ <td><h:outputText id="zip" value="#{cont.zip}"
/></td>
+ <td><h:outputText id="country"
value="#{cont.country}" /></td>
</tr>
</ui:repeat>
</table>
Modified: trunk/examples/contactlist/view/viewContact.xhtml
===================================================================
--- trunk/examples/contactlist/view/viewContact.xhtml 2008-11-07 10:11:41 UTC (rev 9524)
+++ trunk/examples/contactlist/view/viewContact.xhtml 2008-11-07 11:53:51 UTC (rev 9525)
@@ -13,19 +13,19 @@
<body>
<div class="menuButtons">
- <s:link view="/search.xhtml" value="Search Contacts"/>
- <s:link view="/editContact.xhtml" value="Create New
Contact">
+ <s:link id="search" view="/search.xhtml" value="Search
Contacts"/>
+ <s:link id="create" view="/editContact.xhtml"
value="Create New Contact">
<f:param name="contactId"/> <!-- suppress propagation of
contact id page parameter -->
</s:link>
- <s:link view="/viewContact.xhtml" value="View Contact"/>
- <s:link view="/editContact.xhtml" value="Edit Contact"/>
+ <s:link id="view" view="/viewContact.xhtml" value="View
Contact"/>
+ <s:link id="edit" view="/editContact.xhtml" value="Edit
Contact"/>
</div>
<div class="body">
<h1>View Contact</h1>
- <h:messages styleClass="message"/>
+ <h:messages id="messages" styleClass="message"/>
<!-- fields -->
<div class="dialog">
@@ -71,8 +71,8 @@
<!-- actions -->
<div class="actionButtons">
- <s:link view="/editContact.xhtml" value="Edit
Contact"/>
- <s:link action="#{contactHome.remove}" value="Delete
Contact" rendered="#{contactHome.managed}"/>
+ <s:link id="editContact" view="/editContact.xhtml"
value="Edit Contact"/>
+ <s:link id="deleteContact" action="#{contactHome.remove}"
value="Delete Contact" rendered="#{contactHome.managed}"/>
</div>
<!-- associations -->
@@ -95,7 +95,7 @@
</h:column>
</h:dataTable>
- <h:form>
+ <h:form id="commentForm">
<!-- editable fields -->
<div class="dialog">
@@ -115,7 +115,7 @@
<!-- actions -->
<div class="actionButtons">
- <h:commandLink action="#{commentHome.persist}" value="Create
Comment"/>
+ <h:commandLink id="submit"
action="#{commentHome.persist}" value="Create Comment"/>
</div>
</h:form>
Modified: trunk/src/test/ftest/build.xml
===================================================================
--- trunk/src/test/ftest/build.xml 2008-11-07 10:11:41 UTC (rev 9524)
+++ trunk/src/test/ftest/build.xml 2008-11-07 11:53:51 UTC (rev 9525)
@@ -49,6 +49,7 @@
<!-- Execute tests for all examples-->
<testexample name="booking" />
<testexample name="dvdstore" />
+ <testexample name="contactlist" />
<testexample name="groovybooking" />
<testexample name="hibernate" />
<testexample name="icefaces" />
@@ -75,6 +76,7 @@
<target name="cleanall">
<cleanexample name="booking" />
<cleanexample name="dvdstore" />
+ <cleanexample name="contactlist" />
<cleanexample name="groovybooking" />
<cleanexample name="hibernate" />
<cleanexample name="icefaces" />
@@ -87,6 +89,7 @@
<target name="undeployall">
<undeployexample name="booking" />
<undeployexample name="dvdstore" />
+ <undeployexample name="contactlist" />
<undeployexample name="groovybooking" />
<undeployexample name="hibernate" />
<undeployexample name="icefaces" />
Added: trunk/src/test/ftest/examples/contactlist/build.xml
===================================================================
--- trunk/src/test/ftest/examples/contactlist/build.xml (rev 0)
+++ trunk/src/test/ftest/examples/contactlist/build.xml 2008-11-07 11:53:51 UTC (rev
9525)
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+JBoss, Home of Professional Open Source
+Copyright 2008, Red Hat Middleware LLC, and individual contributors
+by the @authors tag. See the copyright.txt in the distribution for a
+full listing of individual contributors.
+
+This is free software; you can redistribute it and/or modify it
+under the terms of the GNU Lesser General Public License as
+published by the Free Software Foundation; either version 2.1 of
+the License, or (at your option) any later version.
+
+This software 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
+Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this software; if not, write to the Free
+Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+-->
+<project name="contactlist.ftest.build" basedir="."
default="build">
+ <property name="example.name" value="contactlist"/>
+ <property name="jboss.deploy.target" value="deploy"/>
+ <property name="jboss.deploy.waittime" value="10"/>
+ <property name="jboss.undeploy.target" value="undeploy"/>
+ <property name="example.ready.check.url"
value="seam-contactlist/search.seam"/>
+
+ <import file="../build.xml" />
+</project>
Added:
trunk/src/test/ftest/examples/contactlist/src/org/jboss/seam/example/contactlist/test/selenium/CommentTest.java
===================================================================
---
trunk/src/test/ftest/examples/contactlist/src/org/jboss/seam/example/contactlist/test/selenium/CommentTest.java
(rev 0)
+++
trunk/src/test/ftest/examples/contactlist/src/org/jboss/seam/example/contactlist/test/selenium/CommentTest.java 2008-11-07
11:53:51 UTC (rev 9525)
@@ -0,0 +1,62 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.seam.example.contactlist.test.selenium;
+
+import org.testng.annotations.Test;
+import static org.testng.AssertJUnit.*;
+
+import com.thoughtworks.selenium.Wait;
+
+public class CommentTest extends SeleniumContactlistTest {
+
+ @Test
+ public void testComment() {
+ String firstName = "Gavin";
+ String lastName = "King";
+ String message = "founder of the Hibernate open source object/relational mapping
project";
+ // find contact
+ browser.open(START_PAGE);
+ new Wait() {
+ @Override
+ public boolean until() {
+ return browser.isElementPresent(SEARCH_SUBMIT);
+ }
+ }.wait("Search submit link not found.");
+ search(firstName, lastName);
+ assertTrue("Contact not found. Application is in unexpected state.",
+ searchResultPresent(firstName, lastName));
+ browser.click(SEARCH_RESULT_FIRST_ROW_LINK);
+ browser.waitForPageToLoad(TIMEOUT);
+ // submit comment
+ browser.type(COMMENT_TEXTAREA, message);
+ browser.click(COMMENT_SUBMIT);
+ browser.waitForPageToLoad(TIMEOUT);
+ // assert comment is stored
+ browser.click(SEARCH_CONTACT_PAGE);
+ browser.waitForPageToLoad(TIMEOUT);
+ search(firstName, lastName);
+ browser.click(SEARCH_RESULT_FIRST_ROW_LINK);
+ browser.waitForPageToLoad(TIMEOUT);
+ assertTrue("Comment is not stored.", browser
+ .isTextPresent(message));
+ }
+}
Property changes on:
trunk/src/test/ftest/examples/contactlist/src/org/jboss/seam/example/contactlist/test/selenium/CommentTest.java
___________________________________________________________________
Name: svn:executable
+ *
Added:
trunk/src/test/ftest/examples/contactlist/src/org/jboss/seam/example/contactlist/test/selenium/ContactCRUDTest.java
===================================================================
---
trunk/src/test/ftest/examples/contactlist/src/org/jboss/seam/example/contactlist/test/selenium/ContactCRUDTest.java
(rev 0)
+++
trunk/src/test/ftest/examples/contactlist/src/org/jboss/seam/example/contactlist/test/selenium/ContactCRUDTest.java 2008-11-07
11:53:51 UTC (rev 9525)
@@ -0,0 +1,154 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.seam.example.contactlist.test.selenium;
+
+import org.testng.annotations.Test;
+import static org.testng.AssertJUnit.*;
+import com.thoughtworks.selenium.Wait;
+
+public class ContactCRUDTest extends SeleniumContactlistTest {
+
+ // used for creation test
+ private Person john = new Person("John", "Doe",
"0123456789", "0123456789",
+ "Street", "City", "State", "01234",
"US");
+ private Person jane = new Person("Jane", "Doe",
"0123456789", "0123456789",
+ "Street", "City", "State", "01234",
"US");
+ // used for edit test
+ private Person jozef = new Person("Jozef", "Hartinger",
"0123456789",
+ "0123456789", "Cervinkova 99", "Brno",
"Czech Republic", "01234",
+ "CZ");
+
+ @Test
+ public void testCreateContact() {
+ browser.open(START_PAGE);
+ new Wait() {
+ @Override
+ public boolean until() {
+ return browser.isElementPresent(CREATE_CONTACT_PAGE);
+ }
+ }.wait("Create contact link not found.");
+ browser.click(CREATE_CONTACT_PAGE);
+ browser.waitForPageToLoad(TIMEOUT);
+ fillCreateContactForm(john);
+ browser.click(CREATE_CONTACT_SUBMIT);
+ new Wait() {
+ @Override
+ public boolean until() {
+ return browser.isElementPresent(SEARCH_CONTACT_PAGE);
+ }
+ }.wait("Search link not found.");
+ browser.click(SEARCH_CONTACT_PAGE);
+ browser.waitForPageToLoad(TIMEOUT);
+ search(john);
+ assertTrue("Creating new contact failed.", searchResultPresent(john));
+ }
+
+ @Test
+ public void testCreationCanceling() {
+ browser.open(START_PAGE);
+ new Wait() {
+ @Override
+ public boolean until() {
+ return browser.isElementPresent(CREATE_CONTACT_PAGE);
+ }
+ }.wait("Create contact link not found.");
+ browser.click(CREATE_CONTACT_PAGE);
+ browser.waitForPageToLoad(TIMEOUT);
+ fillCreateContactForm(jane);
+ browser.click(CREATE_CONTACT_CANCEL);
+ new Wait() {
+ @Override
+ public boolean until() {
+ return browser.isElementPresent(SEARCH_CONTACT_PAGE);
+ }
+ }.wait("Search link not found.");
+ browser.click(SEARCH_CONTACT_PAGE);
+ browser.waitForPageToLoad(TIMEOUT);
+ browser.type(SEARCH_FIRST_NAME_FIELD, jane.getFirstName());
+ browser.type(SEARCH_LAST_NAME_FIELD, jane.getLastName());
+ browser.click(SEARCH_SUBMIT);
+ browser.waitForPageToLoad(TIMEOUT);
+ assertFalse("New contact created despite cancel.",
searchResultPresent(jane));
+ }
+
+ @Test
+ public void testEditContact() {
+ String firstName = "Shane";
+ String lastName = "Bryzak";
+ // find contact
+ browser.open(START_PAGE);
+ new Wait() {
+ @Override
+ public boolean until() {
+ return browser.isElementPresent(SEARCH_SUBMIT);
+ }
+ }.wait("Search submit link not found.");
+ search(firstName, lastName);
+ assertTrue("Contact not found. Application is in unexpected state.",
+ searchResultPresent(firstName, lastName));
+ browser.click(SEARCH_RESULT_FIRST_ROW_LINK);
+ browser.waitForPageToLoad(TIMEOUT);
+ browser.click(EDIT_CONTACT_LINK);
+ browser.waitForPageToLoad(TIMEOUT);
+ // update form fields
+ fillCreateContactForm(jozef);
+ browser.click(UPDATE_CONTACT_SUBMIT);
+ browser.waitForPageToLoad(TIMEOUT);
+ // make sure new values are present
+ browser.click(SEARCH_CONTACT_PAGE);
+ browser.waitForPageToLoad(TIMEOUT);
+ search(jozef);
+ assertTrue("Contact update failed. New values missing",
searchResultPresent(jozef));
+ // make sure old values are not present
+ browser.click(SEARCH_CONTACT_PAGE);
+ browser.waitForPageToLoad(TIMEOUT);
+ search(firstName, lastName);
+ assertFalse("Contact update failed. Old values still present",
searchResultPresent(firstName, lastName));
+ }
+
+ @Test
+ public void testRemoveContact() {
+ String firstName = "Norman";
+ String lastName = "Richards";
+ // find contact
+ browser.open(START_PAGE);
+ new Wait() {
+ @Override
+ public boolean until() {
+ return browser.isElementPresent(SEARCH_SUBMIT);
+ }
+ }.wait("Search submit link not found.");
+ search(firstName, lastName);
+ assertTrue("Contact not found. Application is in unexpected state.",
+ searchResultPresent(firstName, lastName));
+ browser.click(SEARCH_RESULT_FIRST_ROW_LINK);
+ browser.waitForPageToLoad(TIMEOUT);
+ // remove contact
+ browser.click(REMOVE_CONTACT_LINK);
+ browser.waitForPageToLoad(TIMEOUT);
+ // assert contact is removed
+ browser.click(SEARCH_CONTACT_PAGE);
+ browser.waitForPageToLoad(TIMEOUT);
+ search(firstName, lastName);
+ assertFalse("Contact present despite it should be removed.",
searchResultPresent(firstName, lastName));
+ }
+}
Property changes on:
trunk/src/test/ftest/examples/contactlist/src/org/jboss/seam/example/contactlist/test/selenium/ContactCRUDTest.java
___________________________________________________________________
Name: svn:executable
+ *
Added:
trunk/src/test/ftest/examples/contactlist/src/org/jboss/seam/example/contactlist/test/selenium/ContactlistConstants.java
===================================================================
---
trunk/src/test/ftest/examples/contactlist/src/org/jboss/seam/example/contactlist/test/selenium/ContactlistConstants.java
(rev 0)
+++
trunk/src/test/ftest/examples/contactlist/src/org/jboss/seam/example/contactlist/test/selenium/ContactlistConstants.java 2008-11-07
11:53:51 UTC (rev 9525)
@@ -0,0 +1,57 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.seam.example.contactlist.test.selenium;
+
+public interface ContactlistConstants {
+
+ public static String START_PAGE = "/seam-contactlist";
+ public static String SEARCH_CONTACT_PAGE = "id=search";
+ public static String SEARCH_FIRST_NAME_FIELD = "id=searchForm:firstName";
+ public static String SEARCH_LAST_NAME_FIELD = "id=searchForm:lastName";
+ public static String SEARCH_SUBMIT = "id=searchForm:submit";
+ public static String CREATE_CONTACT_PAGE = "id=create";
+ public static String CREATE_CONTACT_SUBMIT = "id=editForm:createContact";
+ public static String CREATE_CONTACT_CANCEL = "id=editForm:cancel";
+ public static String FIRST_NAME_FIELD =
"id=editForm:firstNameDecorate:firstName";
+ public static String LAST_NAME_FIELD =
"id=editForm:lastNameDecorate:lastName";
+ public static String CELL_PHONE_FIELD =
"id=editForm:cellPhoneDecorate:cellPhone";
+ public static String HOME_PHONE_FIELD =
"id=editForm:homePhoneDecorate:homePhone";
+ public static String ADDRESS_FIELD =
"id=editForm:addressDecorate:address";
+ public static String CITY_FIELD = "id=editForm:cityDecorate:city";
+ public static String STATE_FIELD = "id=editForm:stateDecorate:state";
+ public static String ZIP_FIELD = "id=editForm:zipDecorate:zip";
+ public static String COUNTRY_FIELD =
"id=editForm:countryDecorate:country";
+ public static String EDIT_CONTACT_LINK = "editContact";
+ public static String UPDATE_CONTACT_SUBMIT = "editForm:updateContact";
+ public static String EDIT_FORM_REMOVE_CONTACT_LINK =
"id=editForm:deleteContact";
+ public static String REMOVE_CONTACT_LINK = "id=deleteContact";
+ public static String SEARCH_RESULT_FIRST_ROW_LINK =
"id=searchResult:0:link";
+ public static String SEARCH_RESULT_FIRST_ROW_CELL_PHONE =
"id=searchResult:0:cellPhone";
+ public static String SEARCH_RESULT_FIRST_ROW_HOME_PHONE =
"id=searchResult:0:homePhone";
+ public static String SEARCH_RESULT_FIRST_ROW_ADDRESS =
"id=searchResult:0:address";
+ public static String SEARCH_RESULT_FIRST_ROW_CITY =
"id=searchResult:0:city";
+ public static String SEARCH_RESULT_FIRST_ROW_STATE =
"id=searchResult:0:state";
+ public static String SEARCH_RESULT_FIRST_ROW_ZIP =
"id=searchResult:0:zip";
+ public static String SEARCH_RESULT_FIRST_ROW_COUNTRY =
"id=searchResult:0:country";
+ public static String COMMENT_TEXTAREA = "commentForm:text";
+ public static String COMMENT_SUBMIT = "commentForm:submit";
+}
Property changes on:
trunk/src/test/ftest/examples/contactlist/src/org/jboss/seam/example/contactlist/test/selenium/ContactlistConstants.java
___________________________________________________________________
Name: svn:executable
+ *
Added:
trunk/src/test/ftest/examples/contactlist/src/org/jboss/seam/example/contactlist/test/selenium/Person.java
===================================================================
---
trunk/src/test/ftest/examples/contactlist/src/org/jboss/seam/example/contactlist/test/selenium/Person.java
(rev 0)
+++
trunk/src/test/ftest/examples/contactlist/src/org/jboss/seam/example/contactlist/test/selenium/Person.java 2008-11-07
11:53:51 UTC (rev 9525)
@@ -0,0 +1,121 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.seam.example.contactlist.test.selenium;
+
+public class Person {
+ private String firstName;
+ private String lastName;
+ private String cellPhone;
+ private String homePhone;
+ private String address;
+ private String city;
+ private String state;
+ private String zip;
+ private String country;
+
+ public Person(String firstName, String lastName, String cellPhone, String homePhone,
+ String address, String city, String state, String zip, String country) {
+ this.firstName = firstName;
+ this.lastName = lastName;
+ this.cellPhone = cellPhone;
+ this.homePhone = homePhone;
+ this.address = address;
+ this.city = city;
+ this.state = state;
+ this.zip = zip;
+ this.country = country;
+ }
+
+ public String getFirstName() {
+ return firstName;
+ }
+
+ public void setFirstName(String firstName) {
+ this.firstName = firstName;
+ }
+
+ public String getLastName() {
+ return lastName;
+ }
+
+ public void setLastName(String lastName) {
+ this.lastName = lastName;
+ }
+
+
+ public String getCellPhone() {
+ return cellPhone;
+ }
+
+ public void setCellPhone(String cellPhone) {
+ this.cellPhone = cellPhone;
+ }
+
+ public String getHomePhone() {
+ return homePhone;
+ }
+
+ public void setHomePhone(String homePhone) {
+ this.homePhone = homePhone;
+ }
+
+ public String getAddress() {
+ return address;
+ }
+
+ public void setAddress(String address) {
+ this.address = address;
+ }
+
+ public String getCity() {
+ return city;
+ }
+
+ public void setCity(String city) {
+ this.city = city;
+ }
+
+ public String getState() {
+ return state;
+ }
+
+ public void setState(String state) {
+ this.state = state;
+ }
+
+ public String getZip() {
+ return zip;
+ }
+
+ public void setZip(String zip) {
+ this.zip = zip;
+ }
+
+ public String getCountry() {
+ return country;
+ }
+
+ public void setCountry(String country) {
+ this.country = country;
+ }
+
+}
Property changes on:
trunk/src/test/ftest/examples/contactlist/src/org/jboss/seam/example/contactlist/test/selenium/Person.java
___________________________________________________________________
Name: svn:executable
+ *
Added:
trunk/src/test/ftest/examples/contactlist/src/org/jboss/seam/example/contactlist/test/selenium/SeleniumContactlistTest.java
===================================================================
---
trunk/src/test/ftest/examples/contactlist/src/org/jboss/seam/example/contactlist/test/selenium/SeleniumContactlistTest.java
(rev 0)
+++
trunk/src/test/ftest/examples/contactlist/src/org/jboss/seam/example/contactlist/test/selenium/SeleniumContactlistTest.java 2008-11-07
11:53:51 UTC (rev 9525)
@@ -0,0 +1,66 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.seam.example.contactlist.test.selenium;
+
+import org.jboss.seam.example.common.test.selenium.SeamSeleniumTest;
+
+public class SeleniumContactlistTest extends SeamSeleniumTest implements
ContactlistConstants {
+
+ public boolean searchResultPresent(String firstName, String lastName) {
+ return browser.isElementPresent(SEARCH_RESULT_FIRST_ROW_LINK) &&
+ browser.getText(SEARCH_RESULT_FIRST_ROW_LINK).equals(firstName + "
" + lastName);
+ }
+
+ public boolean searchResultPresent(Person person) {
+ return searchResultPresent(person.getFirstName(), person.getLastName())
&&
+
browser.getText(SEARCH_RESULT_FIRST_ROW_CELL_PHONE).equals(person.getCellPhone())
&&
+
browser.getText(SEARCH_RESULT_FIRST_ROW_HOME_PHONE).equals(person.getHomePhone())
&&
+ browser.getText(SEARCH_RESULT_FIRST_ROW_ADDRESS).equals(person.getAddress())
&&
+ browser.getText(SEARCH_RESULT_FIRST_ROW_CITY).equals(person.getCity())
&&
+ browser.getText(SEARCH_RESULT_FIRST_ROW_STATE).equals(person.getState())
&&
+ browser.getText(SEARCH_RESULT_FIRST_ROW_ZIP).equals(person.getZip())
&&
+
browser.getText(SEARCH_RESULT_FIRST_ROW_COUNTRY).equals(person.getCountry());
+ }
+
+ public void fillCreateContactForm(Person person) {
+ browser.type(FIRST_NAME_FIELD, person.getFirstName());
+ browser.type(LAST_NAME_FIELD, person.getLastName());
+ browser.type(CELL_PHONE_FIELD, person.getCellPhone());
+ browser.type(HOME_PHONE_FIELD, person.getHomePhone());
+ browser.type(ADDRESS_FIELD, person.getAddress());
+ browser.type(CITY_FIELD, person.getCity());
+ browser.type(STATE_FIELD, person.getState());
+ browser.type(ZIP_FIELD, person.getZip());
+ browser.type(COUNTRY_FIELD, person.getCountry());
+ }
+
+ public void search(String firstName, String lastName) {
+ browser.type(SEARCH_FIRST_NAME_FIELD, firstName);
+ browser.type(SEARCH_LAST_NAME_FIELD, lastName);
+ browser.click(SEARCH_SUBMIT);
+ browser.waitForPageToLoad(TIMEOUT);
+ }
+
+ public void search(Person person) {
+ search(person.getFirstName(), person.getLastName());
+ }
+}
Added: trunk/src/test/ftest/examples/contactlist/testng.xml
===================================================================
--- trunk/src/test/ftest/examples/contactlist/testng.xml (rev 0)
+++ trunk/src/test/ftest/examples/contactlist/testng.xml 2008-11-07 11:53:51 UTC (rev
9525)
@@ -0,0 +1,33 @@
+<!--
+JBoss, Home of Professional Open Source
+Copyright 2008, Red Hat Middleware LLC, and individual contributors
+by the @authors tag. See the copyright.txt in the distribution for a
+full listing of individual contributors.
+
+This is free software; you can redistribute it and/or modify it
+under the terms of the GNU Lesser General Public License as
+published by the Free Software Foundation; either version 2.1 of
+the License, or (at your option) any later version.
+
+This software 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
+Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this software; if not, write to the Free
+Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+-->
+<!DOCTYPE suite SYSTEM "http://beust.com/testng/testng-1.0.dtd" >
+<suite name="Contactlist example" verbose="2"
parallel="false">
+ <test name="Contactlist example">
+ <parameter name="PROPERTY_FILE" value="empty" />
+ <classes>
+ <class
+
name="org.jboss.seam.example.contactlist.test.selenium.ContactCRUDTest" />
+ <class
+ name="org.jboss.seam.example.contactlist.test.selenium.CommentTest"
/>
+ </classes>
+ </test>
+</suite>
\ No newline at end of file
Property changes on: trunk/src/test/ftest/examples/contactlist/testng.xml
___________________________________________________________________
Name: svn:executable
+ *