[seam-commits] Seam SVN: r9506 - in trunk: src/test/ftest/examples/icefaces/src/org/jboss/seam/example/icefaces/test/selenium and 4 other directories.
seam-commits at lists.jboss.org
seam-commits at lists.jboss.org
Wed Nov 5 05:53:57 EST 2008
Author: jharting
Date: 2008-11-05 05:53:57 -0500 (Wed, 05 Nov 2008)
New Revision: 9506
Added:
trunk/src/test/ftest/examples/nestedbooking/src/org/jboss/seam/example/nestedbooking/test/selenium/NestedSimpleBookingTest.java
Modified:
trunk/examples/nestedbooking/view/confirm.xhtml
trunk/examples/nestedbooking/view/main.xhtml
trunk/examples/nestedbooking/view/rooms.xhtml
trunk/src/test/ftest/examples/icefaces/src/org/jboss/seam/example/icefaces/test/selenium/icefaces.properties
trunk/src/test/ftest/examples/nestedbooking/testng.xml
trunk/src/test/ftest/examples/wicket/src/org/jboss/seam/example/wicket/test/selenium/WicketSimpleBookingTest.java
trunk/src/test/ftest/src/main/org/jboss/seam/example/common/test/booking/selenium/ChangePasswordTest.java
trunk/src/test/ftest/src/main/org/jboss/seam/example/common/test/booking/selenium/RegistrationTest.java
trunk/src/test/ftest/src/main/org/jboss/seam/example/common/test/booking/selenium/SeleniumBookingTest.java
trunk/src/test/ftest/src/main/org/jboss/seam/example/common/test/booking/selenium/SimpleBookingTest.java
Log:
minor fixes and enhancements in selenium tests
Modified: trunk/examples/nestedbooking/view/confirm.xhtml
===================================================================
--- trunk/examples/nestedbooking/view/confirm.xhtml 2008-11-05 10:01:54 UTC (rev 9505)
+++ trunk/examples/nestedbooking/view/confirm.xhtml 2008-11-05 10:53:57 UTC (rev 9506)
@@ -64,7 +64,7 @@
<ui:define name="label">Credit Card #:</ui:define>
#{booking.creditCard}
</s:decorate>
- <s:decorate template="output.xhtml">
+ <s:decorate id="buttonDecorate" template="output.xhtml">
<ui:define name="label"> </ui:define>
<h:commandButton id="confirm" value="Confirm" action="#{hotelBooking.confirm}"/> 
<s:button id="revise" value="Revise" view="/payment.xhtml"/> 
Modified: trunk/examples/nestedbooking/view/main.xhtml
===================================================================
--- trunk/examples/nestedbooking/view/main.xhtml 2008-11-05 10:01:54 UTC (rev 9505)
+++ trunk/examples/nestedbooking/view/main.xhtml 2008-11-05 10:53:57 UTC (rev 9506)
@@ -13,7 +13,7 @@
<h:form id="main">
<span class="errors">
- <h:messages globalOnly="true"/>
+ <h:messages id="messages" globalOnly="true"/>
</span>
<h1>Search Hotels</h1>
@@ -43,7 +43,7 @@
<a:outputPanel id="searchResults">
<div class="section">
- <h:outputText id="NoBookingsFoundMessage" value="No Hotels Found" rendered="#{hotels != null and hotels.rowCount==0}"/>
+ <h:outputText id="NoHotelsFoundMessage" value="No Hotels Found" rendered="#{hotels != null and hotels.rowCount==0}"/>
<h:dataTable id="hotels" value="#{hotels}" var="hot" rendered="#{hotels.rowCount>0}">
<h:column id="column1">
<f:facet id="NameFacet" name="header">Name</f:facet>
Modified: trunk/examples/nestedbooking/view/rooms.xhtml
===================================================================
--- trunk/examples/nestedbooking/view/rooms.xhtml 2008-11-05 10:01:54 UTC (rev 9505)
+++ trunk/examples/nestedbooking/view/rooms.xhtml 2008-11-05 10:53:57 UTC (rev 9506)
@@ -23,7 +23,7 @@
<br/><br/>
- <h:dataTable value="#{availableRooms}" var="room" rendered="#{availableRooms.rowCount > 0}">
+ <h:dataTable id="rooms" value="#{availableRooms}" var="room" rendered="#{availableRooms.rowCount > 0}">
<h:column>
<f:facet name="header">Name</f:facet>
#{room.name}
Modified: trunk/src/test/ftest/examples/icefaces/src/org/jboss/seam/example/icefaces/test/selenium/icefaces.properties
===================================================================
--- trunk/src/test/ftest/examples/icefaces/src/org/jboss/seam/example/icefaces/test/selenium/icefaces.properties 2008-11-05 10:01:54 UTC (rev 9505)
+++ trunk/src/test/ftest/examples/icefaces/src/org/jboss/seam/example/icefaces/test/selenium/icefaces.properties 2008-11-05 10:53:57 UTC (rev 9506)
@@ -27,8 +27,8 @@
LOGIN_SUBMIT id=login:login
LOGOUT id=logout
PASSWORD_UPDATED_MESSAGE Password updated
-PASSWORD_REENTER_MESSAGE verify
-PASSWORD_VALUE_REQUIRED_MESSAGE //*[@id\='setpassword\:Message']
+PASSWORD_REENTER_MESSAGE Re-enter new password
+PASSWORD_VALUE_REQUIRED_MESSAGE //*[contains(@id, 'Decorate:message')]
PASSWORD_LENGTH_MESSAGE length must be between
PASSWORD_PASSWORD id=setpassword:PasswordDecorate:password
PASSWORD_VERIFY id=setpassword:VerifyDecorate:verify
@@ -43,10 +43,10 @@
BOOKING_CANCEL id=hotel:cancel
HOTEL_BED_FIELD id=booking:bedsDecorate:beds
HOTEL_BED_FIELD_SELECT_CRITERIA value=
-HOTEL_CHECKIN_DATE_FIELD id=booking:checkinDateDecorate:checkinDate_calendarInputtext
-HOTEL_CHECKIN_DATE_MESSAGE id=booking:Message
-HOTEL_CHECKOUT_DATE_FIELD id=booking:checkoutDateDecorate:checkoutDate_calendarInputtext
-HOTEL_CHECKOUT_DATE_MESSAGE id=booking:Message
+HOTEL_CHECKIN_DATE_FIELD id=booking:checkinDateDecorate:checkinDate
+HOTEL_CHECKIN_DATE_MESSAGE id=booking:checkinDateDecorate:message
+HOTEL_CHECKOUT_DATE_FIELD id=booking:checkoutDateDecorate:checkoutDate
+HOTEL_CHECKOUT_DATE_MESSAGE id=booking:checkoutDateDecorate:message
HOTEL_SMOKING_1 id=booking:smokingDecorate:smoking:_1
HOTEL_SMOKING_2 id=booking:smokingDecorate:smoking:_2
HOTEL_CREDIT_CARD id=booking:creditCardDecorate:creditCard
@@ -65,7 +65,8 @@
REGISTRATION_VERIFY id=registration:verifyDecorate:verify
REGISTRATION_VERIFY_MESSAGE id=registration:verifyDecorate:message
REGISTRATION_SUBMIT id=registration:register
-REGISTRATION_REENTER_MESSAGE verify
+REGISTRATION_CANCEL id=registration:cancel
+REGISTRATION_REENTER_MESSAGE Re-enter your password
REGISTRATION_LENGTH_MESSAGE length must be between
REGISTRATION_SUCCESSFUL_MESSAGE Successfully registered as {0}
REGISTRATION_USER_EXISTS_MESSAGE Username {0} already exists
@@ -76,9 +77,13 @@
BOOKING_CANCELLED_MESSAGE Booking cancelled for confirmation number {0}
BOOKING_CONFIRMATION_MESSAGE Thank you, {0}, your confimation number for {1} is \\d+
BOOKING_INVALID_DATE_MESSAGE1 Check out date must be later than check in date
-BOOKING_INVALID_DATE_MESSAGE2 Check in date must be a future date
+BOOKING_INVALID_DATE_MESSAGE2 Check In Date
WORKSPACE_BOOKING_TEXT Book hotel: {0}
WORKSPACE_VIEW_TEXT View hotel: {0}
WORKSPACE_TABLE_LINK_BY_ID id=ConversationListForm:ConversationListDataTable:{0}:EntryDescriptionLink
WORKSPACE_TABLE_ROW_COUNT = //table[@id\='ConversationListForm\:ConversationListDataTable']/tbody/tr
-SPINNER id\=searchCriteria\:Spinner\:connection-working
\ No newline at end of file
+SPINNER id\=searchCriteria\:Spinner\:connection-working
+FOOTER id=footer
+
+USE_ICEFACES_FORMS TRUE
+
Added: trunk/src/test/ftest/examples/nestedbooking/src/org/jboss/seam/example/nestedbooking/test/selenium/NestedSimpleBookingTest.java
===================================================================
--- trunk/src/test/ftest/examples/nestedbooking/src/org/jboss/seam/example/nestedbooking/test/selenium/NestedSimpleBookingTest.java (rev 0)
+++ trunk/src/test/ftest/examples/nestedbooking/src/org/jboss/seam/example/nestedbooking/test/selenium/NestedSimpleBookingTest.java 2008-11-05 10:53:57 UTC (rev 9506)
@@ -0,0 +1,84 @@
+/*
+ * 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.nestedbooking.test.selenium;
+
+import java.text.MessageFormat;
+
+import org.jboss.seam.example.common.test.booking.selenium.SimpleBookingTest;
+
+/**
+ * This class alters behaviour of SimpleBookingTest to match nestedbooking example
+ *
+ * @author jharting
+ */
+public class NestedSimpleBookingTest extends SimpleBookingTest {
+
+ @Override
+ protected int bookHotel(String hotelName) {
+ return bookHotel(hotelName, 0, CREDIT_CARD, CREDIT_CARD_NAME);
+ }
+
+ protected int bookHotel(String hotelName, int room, String creditCard, String creditCardName) {
+ if (!isLoggedIn()) {
+ return -1;
+ }
+
+ if (!browser.isElementPresent(getProperty("SEARCH_SUBMIT"))) {
+ browser.open(getProperty("MAIN_PAGE"));
+ browser.waitForPageToLoad(TIMEOUT);
+ }
+
+ enterSearchQuery(hotelName);
+ browser.click(getProperty("SEARCH_RESULT_TABLE_FIRST_ROW_LINK"));
+ browser.waitForPageToLoad(TIMEOUT);
+ // hotel page
+ browser.click(getProperty("BOOKING_BOOK"));
+ browser.waitForPageToLoad(TIMEOUT);
+ // book page
+ browser.click(getProperty("BOOKING_SELECT_ROOM"));
+ browser.waitForPageToLoad(TIMEOUT);
+ // room select page
+ browser.click(MessageFormat.format(getProperty("ROOM_LINK"), room));
+ browser.waitForPageToLoad(TIMEOUT);
+ // payment page
+ browser.type(getProperty("PAYMENT_CREDIT_CARD"), creditCard);
+ browser.type(getProperty("PAYMENT_CREDIT_CARD_NAME"), creditCardName);
+ browser.click(getProperty("PAYMENT_PROCEED"));
+ browser.waitForPageToLoad(TIMEOUT);
+ // confirm page
+ browser.click(getProperty("CONFIRM_CONFIRM"));
+ browser.waitForPageToLoad(TIMEOUT);
+ // main page
+ String message = browser.getText(getProperty("HOTEL_MESSAGE"));
+ if (message.matches(MessageFormat.format(
+ getProperty("BOOKING_CONFIRMATION_MESSAGE"), EXPECTED_NAME, hotelName))) {
+ String[] messageParts = message.split(" ");
+ int confirmationNumber = Integer.parseInt(messageParts[messageParts.length - 1]);
+ return confirmationNumber;
+ } else {
+ return -1;
+ }
+ }
+
+ @Override
+ protected void populateBookingFields() {}
+}
Modified: trunk/src/test/ftest/examples/nestedbooking/testng.xml
===================================================================
--- trunk/src/test/ftest/examples/nestedbooking/testng.xml 2008-11-05 10:01:54 UTC (rev 9505)
+++ trunk/src/test/ftest/examples/nestedbooking/testng.xml 2008-11-05 10:53:57 UTC (rev 9506)
@@ -29,6 +29,7 @@
<class
name="org.jboss.seam.example.common.test.booking.selenium.ChangePasswordTest" />
<class name="org.jboss.seam.example.common.test.booking.selenium.BackButtonTest" />
+ <class name="org.jboss.seam.example.nestedbooking.test.selenium.NestedSimpleBookingTest"></class>
</classes>
</test>
</suite>
\ No newline at end of file
Modified: trunk/src/test/ftest/examples/wicket/src/org/jboss/seam/example/wicket/test/selenium/WicketSimpleBookingTest.java
===================================================================
--- trunk/src/test/ftest/examples/wicket/src/org/jboss/seam/example/wicket/test/selenium/WicketSimpleBookingTest.java 2008-11-05 10:01:54 UTC (rev 9505)
+++ trunk/src/test/ftest/examples/wicket/src/org/jboss/seam/example/wicket/test/selenium/WicketSimpleBookingTest.java 2008-11-05 10:53:57 UTC (rev 9506)
@@ -35,13 +35,8 @@
protected void populateBookingFields(int bed, int smoking,
String creditCard, String creditCardName) {
super.populateBookingFields(bed, smoking, creditCard, creditCardName);
- populateBookingFields();
- }
-
- protected void populateBookingFields() {
- browser
- .select(getProperty("HOTEL_CREDIT_CARD_EXPIRY_MONTH"),
- "index=1");
+ browser.select(getProperty("HOTEL_CREDIT_CARD_EXPIRY_MONTH"),
+ "index=1");
browser.select(getProperty("HOTEL_CREDIT_CARD_EXPIRY_YEAR"), "index=1");
}
}
Modified: trunk/src/test/ftest/src/main/org/jboss/seam/example/common/test/booking/selenium/ChangePasswordTest.java
===================================================================
--- trunk/src/test/ftest/src/main/org/jboss/seam/example/common/test/booking/selenium/ChangePasswordTest.java 2008-11-05 10:01:54 UTC (rev 9505)
+++ trunk/src/test/ftest/src/main/org/jboss/seam/example/common/test/booking/selenium/ChangePasswordTest.java 2008-11-05 10:53:57 UTC (rev 9506)
@@ -18,7 +18,7 @@
* 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.common.test.booking.selenium;
import org.testng.annotations.BeforeMethod;
@@ -105,6 +105,6 @@
browser.type(getProperty("PASSWORD_PASSWORD"), newPassword);
browser.type(getProperty("PASSWORD_VERIFY"), verify);
browser.click(getProperty("PASSWORD_SUBMIT"));
- browser.waitForPageToLoad(TIMEOUT);
+ waitForForm();
}
}
Modified: trunk/src/test/ftest/src/main/org/jboss/seam/example/common/test/booking/selenium/RegistrationTest.java
===================================================================
--- trunk/src/test/ftest/src/main/org/jboss/seam/example/common/test/booking/selenium/RegistrationTest.java 2008-11-05 10:01:54 UTC (rev 9505)
+++ trunk/src/test/ftest/src/main/org/jboss/seam/example/common/test/booking/selenium/RegistrationTest.java 2008-11-05 10:53:57 UTC (rev 9506)
@@ -53,7 +53,6 @@
@BeforeMethod
public void setUp() {
startBrowser();
- assertTrue("Login failed.", login());
}
@Override
@@ -128,7 +127,7 @@
browser.type(getProperty("REGISTRATION_PASSWORD"), password);
browser.type(getProperty("REGISTRATION_VERIFY"), verify);
browser.click(getProperty("REGISTRATION_SUBMIT"));
- browser.waitForPageToLoad(TIMEOUT);
+ waitForForm();
}
}
Modified: trunk/src/test/ftest/src/main/org/jboss/seam/example/common/test/booking/selenium/SeleniumBookingTest.java
===================================================================
--- trunk/src/test/ftest/src/main/org/jboss/seam/example/common/test/booking/selenium/SeleniumBookingTest.java 2008-11-05 10:01:54 UTC (rev 9505)
+++ trunk/src/test/ftest/src/main/org/jboss/seam/example/common/test/booking/selenium/SeleniumBookingTest.java 2008-11-05 10:53:57 UTC (rev 9506)
@@ -107,12 +107,20 @@
if (click) {
browser.click(getProperty("SEARCH_SUBMIT"));
}
+ // wait for javascript to show spinner
+ try {
+ Thread.sleep(1000);
+ } catch (InterruptedException e) {
+ }
+ // wait for page to get updated
new Wait() {
+ @Override
public boolean until() {
return !browser.isVisible(getProperty("SPINNER"));
}
}.wait("Spinner hasn't come out.");
new Wait() {
+ @Override
public boolean until() {
return (browser.isElementPresent(getProperty("SEARCH_RESULT_TABLE")) || browser
.isElementPresent(getProperty("NO_HOTELS_FOUND")));
@@ -126,4 +134,18 @@
browser.click(getProperty("SEARCH_SUBMIT"));
browser.waitForPageToLoad(TIMEOUT);
}
+
+ public void waitForForm() {
+ if (getProperty("USE_ICEFACES_FORMS").equalsIgnoreCase("TRUE")) {
+ new Wait() {
+ @Override
+ public boolean until() {
+ return !browser.isElementPresent("xpath=//*[@style='cursor: wait;']")
+ && browser.isElementPresent(getProperty("FOOTER"));
+ }
+ }.wait("Page was not refreshed.");
+ } else {
+ browser.waitForPageToLoad(TIMEOUT);
+ }
+ }
}
Modified: trunk/src/test/ftest/src/main/org/jboss/seam/example/common/test/booking/selenium/SimpleBookingTest.java
===================================================================
--- trunk/src/test/ftest/src/main/org/jboss/seam/example/common/test/booking/selenium/SimpleBookingTest.java 2008-11-05 10:01:54 UTC (rev 9505)
+++ trunk/src/test/ftest/src/main/org/jboss/seam/example/common/test/booking/selenium/SimpleBookingTest.java 2008-11-05 10:53:57 UTC (rev 9506)
@@ -36,9 +36,9 @@
*/
public class SimpleBookingTest extends SeleniumBookingTest {
- private final String EXPECTED_NAME = "Demo User";
- private final String CREDIT_CARD = "0123456789012345";
- private final String CREDIT_CARD_NAME = "visa";
+ protected final String EXPECTED_NAME = "Demo User";
+ protected final String CREDIT_CARD = "0123456789012345";
+ protected final String CREDIT_CARD_NAME = "visa";
/**
* Tries searching for non existing hotel.
@@ -55,7 +55,7 @@
*/
@Test(enabled = true)
public void simpleBookingTest() {
- String hotelName = "Swissotel";
+ String hotelName = "W Hotel";
int confirmationNumber;
confirmationNumber = bookHotel(hotelName);
assertTrue("Booking with confirmation number " + confirmationNumber
@@ -68,7 +68,7 @@
*/
@Test(enabled = true)
public void invalidDatesTest() {
- String hotelName = "Swissotel";
+ String hotelName = "W Hotel";
enterSearchQuery(hotelName);
browser.click(getProperty("SEARCH_RESULT_TABLE_FIRST_ROW_LINK"));
browser.waitForPageToLoad(TIMEOUT);
@@ -76,16 +76,12 @@
browser.click(getProperty("BOOKING_BOOK"));
browser.waitForPageToLoad(TIMEOUT);
// booking page
- String checkIn = browser.getValue(getProperty("HOTEL_CHECKIN_DATE_FIELD"));
String checkOut = browser.getValue(getProperty("HOTEL_CHECKOUT_DATE_FIELD"));
populateBookingFields();
// switch check in and check out date
browser.type(getProperty("HOTEL_CHECKIN_DATE_FIELD"), checkOut);
- browser.type(getProperty("HOTEL_CHECKOUT_DATE_FIELD"), checkIn);
- browser.type(getProperty("HOTEL_CREDIT_CARD"), CREDIT_CARD);
- browser.type(getProperty("HOTEL_CREDIT_CARD_NAME"), CREDIT_CARD_NAME);
browser.click(getProperty("HOTEL_PROCEED"));
- browser.waitForPageToLoad(TIMEOUT);
+ waitForForm();
assertTrue("Date verification #1 failed.", browser
.isTextPresent(getProperty("BOOKING_INVALID_DATE_MESSAGE1")));
assertTrue("Check-out date error message expected.", browser
@@ -93,7 +89,7 @@
// set check in to past
browser.type(getProperty("HOTEL_CHECKIN_DATE_FIELD"), "01/01/1970");
browser.click(getProperty("HOTEL_PROCEED"));
- browser.waitForPageToLoad(TIMEOUT);
+ waitForForm();
assertTrue("Date verification #2 failed.", browser
.isTextPresent(getProperty("BOOKING_INVALID_DATE_MESSAGE2")));
assertTrue("Checkin-date error message expected.", browser
@@ -112,7 +108,6 @@
// make 3 bookings
for (int i = 0; i < 3; i++) {
int confirmationNumber = bookHotel(hotelNames[i]);
- assertNotSame("Booking process failed.", -1, confirmationNumber);
confirmationNumbers[i] = confirmationNumber;
}
// assert that there bookings are listed in hotel booking list
@@ -138,7 +133,7 @@
protected int bookHotel(String hotelName, int bed, int smoking,
String creditCard, String creditCardName) {
if (!isLoggedIn())
- return -1;
+ fail();
if (!browser.isElementPresent(getProperty("SEARCH_SUBMIT"))) {
browser.open(getProperty("MAIN_PAGE"));
browser.waitForPageToLoad(TIMEOUT);
@@ -160,15 +155,12 @@
browser.waitForPageToLoad(TIMEOUT);
// main page
String message = browser.getText(getProperty("HOTEL_MESSAGE"));
- if (message.matches(MessageFormat.format(
- getProperty("BOOKING_CONFIRMATION_MESSAGE"), EXPECTED_NAME, hotelName))) {
+ assertTrue("Booking failed. Confirmation message does not match.", message.matches(
+ MessageFormat.format(getProperty("BOOKING_CONFIRMATION_MESSAGE"), EXPECTED_NAME, hotelName)));
String[] messageParts = message.split(" ");
int confirmationNumber = Integer
.parseInt(messageParts[messageParts.length - 1]);
return confirmationNumber;
- } else {
- return -1;
- }
}
protected int bookHotel(String hotelName) {
@@ -189,5 +181,6 @@
}
protected void populateBookingFields() {
+ populateBookingFields(2, 0, CREDIT_CARD, CREDIT_CARD_NAME);
}
}
More information about the seam-commits
mailing list