Author: andrei_exadel
Date: 2008-04-14 08:13:24 -0400 (Mon, 14 Apr 2008)
New Revision: 7793
Added:
trunk/test-applications/seleniumTest/src/main/webapp/layout/
trunk/test-applications/seleniumTest/src/main/webapp/layout/template.xhtml
trunk/test-applications/seleniumTest/src/main/webapp/pages/ajaxCommands/
trunk/test-applications/seleniumTest/src/main/webapp/pages/ajaxCommands/ajaxButtonDescription.xhtml
trunk/test-applications/seleniumTest/src/main/webapp/pages/ajaxCommands/ajaxButtonTest.xhtml
trunk/test-applications/seleniumTest/src/test/java/org/ajax4jsf/
trunk/test-applications/seleniumTest/src/test/java/org/ajax4jsf/test/
trunk/test-applications/seleniumTest/src/test/java/org/ajax4jsf/test/base/
trunk/test-applications/seleniumTest/src/test/java/org/ajax4jsf/test/base/SeleniumTestBase.java
Removed:
trunk/test-applications/seleniumTest/src/main/webapp/pages/ajaxCommands.xhtml
trunk/test-applications/seleniumTest/src/test/java/org/richfaces/SeleniumTestBase.java
Modified:
trunk/test-applications/seleniumTest/pom.xml
trunk/test-applications/seleniumTest/src/main/java/org/ajax4jsf/A4JCommandTestBean.java
trunk/test-applications/seleniumTest/src/test/java/org/richfaces/AjaxCommandsTest.java
trunk/test-applications/seleniumTest/src/test/java/org/richfaces/SeleniumExampleTest.java
Log:
test for ajax command buttons
Modified: trunk/test-applications/seleniumTest/pom.xml
===================================================================
--- trunk/test-applications/seleniumTest/pom.xml 2008-04-14 10:20:16 UTC (rev 7792)
+++ trunk/test-applications/seleniumTest/pom.xml 2008-04-14 12:13:24 UTC (rev 7793)
@@ -182,5 +182,10 @@
</exclusion>
</exclusions>
</dependency>
+ <dependency>
+ <groupId>org.richfaces.ui</groupId>
+ <artifactId>richfaces-ui</artifactId>
+ <version>3.2.1-SNAPSHOT</version>
+ </dependency>
</dependencies>
</project>
\ No newline at end of file
Modified:
trunk/test-applications/seleniumTest/src/main/java/org/ajax4jsf/A4JCommandTestBean.java
===================================================================
---
trunk/test-applications/seleniumTest/src/main/java/org/ajax4jsf/A4JCommandTestBean.java 2008-04-14
10:20:16 UTC (rev 7792)
+++
trunk/test-applications/seleniumTest/src/main/java/org/ajax4jsf/A4JCommandTestBean.java 2008-04-14
12:13:24 UTC (rev 7793)
@@ -6,17 +6,17 @@
public class A4JCommandTestBean {
- private Integer text = 1;
+ private Integer value = 0;
private String param;
public void actionListener(ActionEvent event) {
- this.text++;
+ this.value++;
}
public String action () {
- this.text++;
+ this.value++;
return null;
}
@@ -25,18 +25,18 @@
}
/**
- * @return the text
+ * @return the value
*/
- public Integer getText() {
- return text;
+ public Integer getValue() {
+ return value;
}
/**
- * @param text the text to set
+ * @param value the value to set
*/
- public void setText(Integer text) {
- text++;
- this.text = text;
+ public void setValue(Integer value) {
+ value++;
+ this.value = value;
}
/**
Added: trunk/test-applications/seleniumTest/src/main/webapp/layout/template.xhtml
===================================================================
--- trunk/test-applications/seleniumTest/src/main/webapp/layout/template.xhtml
(rev 0)
+++ trunk/test-applications/seleniumTest/src/main/webapp/layout/template.xhtml 2008-04-14
12:13:24 UTC (rev 7793)
@@ -0,0 +1,103 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html
xmlns="http://www.w3.org/1999/xhtml"
+
xmlns:a4j="http://richfaces.org/a4j"
+
xmlns:h="http://java.sun.com/jsf/html"
+
xmlns:rich="http://richfaces.org/rich"
+
xmlns:f="http://java.sun.com/jsf/core"
+
xmlns:ui="http://java.sun.com/jsf/facelets">
+<head>
+ <script>
+ var errorMessage = null;
+ window.onerror = function (message, url, code) {
+ errorMessage = message;
+ };
+ function checkError () {
+ return errorMessage;
+ }
+
+ function submitForm () {
+ document.getElementById('_form').submit();
+ }
+
+ function reRenderAll () {
+ document.getElementById('_Selenium_Test_ReRender_Form:_reRender').onclick();
+ return;
+ }
+ </script>
+</head>
+<f:view>
+<body>
+<div style="padding: 10px; font-size: 24px;">Rich faces component testing
by Selenium</div><br/>
+<h:form id="_Selenium_Test_ReRender_Form">
+ <table border="0" cellpadding="5" cellspacing="0">
+ <tr>
+ <td colspan="2">
+ <a4j:commandLink reRender="_Selenium_Test_Form1, _Selenium_Test_Form2"
style="text-decoration: underline; color: blue" value="ReRenderAll"
id="_reRender"/>
+ </td>
+ </tr>
+ <!-- tr>
+ <td>
+ <b>Ajax Status:</b>
+ </td>
+ <td>
+ <a4j:status startText="Ajax in progress...">
+ <f:facet name="stop">
+ <h:outputText value="Completed" style="color:
green"></h:outputText>
+ </f:facet>
+ <f:facet name="start">
+ <h:outputText value="In progress..." style="color:
red"></h:outputText>
+ </f:facet>
+ </a4j:status>
+ </td>
+ </tr-->
+ </table>
+</h:form>
+<br/>
+<div id="_Selenium_Test_ControlPoint1" style="display:
none;">Control1</div>
+ <br/>
+<table border="0" cellpadding="0"
cellspacing="10"><tr><td style="vertical-align: top">
+ <rich:dataTable value="1" id="_Selenium_Test_Description">
+ <h:column>
+ <f:facet name="header">
+ <h:outputText value="Description area"></h:outputText>
+ </f:facet>
+ <ui:insert name="description"></ui:insert>
+ </h:column>
+ </rich:dataTable>
+</td></tr></table>
+
+ <br/><br/>
+<table border="0" cellpadding="0"
cellspacing="10"><tr><td style="vertical-align: top">
+<h:form id="_Selenium_Test_Form1">
+ <rich:dataTable value="1" id="_Selenium_Test_DataTable"
style="width: auto">
+ <h:column>
+ <f:facet name="header">
+ <h:outputText value="Testing area inside Data
Table"></h:outputText>
+ </f:facet>
+ <ui:insert name="component" />
+ </h:column>
+ </rich:dataTable>
+</h:form>
+</td>
+<td style="width: 20px">
+</td>
+<td style="vertical-align: top">
+<h:form id="_Selenium_Test_Form2">
+ <rich:panel id="_Selenium_Test_Panel">
+ <f:facet name="header">
+ <h:outputText value="Testing area inside Panel"></h:outputText>
+ </f:facet>
+ <ui:insert name="component" />
+ </rich:panel>
+</h:form>
+</td></tr></table>
+
+
+<script type="text/javascript">
+ window.done=false;A4J.AJAX.AddListener(new
A4J.AJAX.Listener(function(){window.done=true}));
+</script>
+
+<div id="_Selenium_Test_ControlPoint2" style="display:
none;">Control2</div>
+</body>
+</f:view>
+</html>
\ No newline at end of file
Added:
trunk/test-applications/seleniumTest/src/main/webapp/pages/ajaxCommands/ajaxButtonDescription.xhtml
===================================================================
---
trunk/test-applications/seleniumTest/src/main/webapp/pages/ajaxCommands/ajaxButtonDescription.xhtml
(rev 0)
+++
trunk/test-applications/seleniumTest/src/main/webapp/pages/ajaxCommands/ajaxButtonDescription.xhtml 2008-04-14
12:13:24 UTC (rev 7793)
@@ -0,0 +1,3 @@
+<html>
+askgfjas faskjfaskl klj
+</html>
\ No newline at end of file
Added:
trunk/test-applications/seleniumTest/src/main/webapp/pages/ajaxCommands/ajaxButtonTest.xhtml
===================================================================
---
trunk/test-applications/seleniumTest/src/main/webapp/pages/ajaxCommands/ajaxButtonTest.xhtml
(rev 0)
+++
trunk/test-applications/seleniumTest/src/main/webapp/pages/ajaxCommands/ajaxButtonTest.xhtml 2008-04-14
12:13:24 UTC (rev 7793)
@@ -0,0 +1,63 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html
xmlns="http://www.w3.org/1999/xhtml"
+
xmlns:a4j="http://richfaces.org/a4j"
+
xmlns:rich="http://richfaces.org/rich"
+
xmlns:h="http://java.sun.com/jsf/html"
+
xmlns:f="http://java.sun.com/jsf/core"
+
xmlns:ui="http://java.sun.com/jsf/facelets">
+
+<ui:composition template="../../layout/template.xhtml">
+ <ui:define name="component">
+ <a4j:commandButton
+ id="b1"
+ action="#{commandBean.action}"
+ actionListener="#{commandBean.actionListener}"
+ reRender="_value"
+ value="Button1">
+ </a4j:commandButton>
+
+ <a4j:commandButton
+ id="b2"
+ action="#{commandBean.action}"
+ actionListener="#{commandBean.actionListener}"
+ immediate="true"
+ reRender="_value"
+ value="Button2">
+ </a4j:commandButton>
+
+ <a4j:commandButton
+ id="b3"
+ action="#{commandBean.action}"
+ immediate="true"
+ reRender="_value"
+ value="Button3">
+ </a4j:commandButton>
+
+ <a4j:commandButton
+ id="b4"
+ action="#{commandBean.action}"
+ immediate="true"
+ ajaxSingle="true"
+ reRender="_value"
+ value="Button4">
+ </a4j:commandButton>
+
+ <a4j:commandButton
+ id="b5"
+ action="#{commandBean.action}"
+ actionListener="#{commandBean.actionListener}"
+ ajaxSingle="true"
+ reRender="_value"
+ value="Button5">
+ </a4j:commandButton>
+
+ <br/>
+ <h:inputText value="#{commandBean.value}"
id="_value"></h:inputText>
+ <br/>
+ <rich:calendar></rich:calendar>
+ </ui:define>
+ <ui:define name="description">
+ <ui:include src="ajaxButtonDescription.xhtml" />
+ </ui:define>
+</ui:composition>
+</html>
\ No newline at end of file
Deleted: trunk/test-applications/seleniumTest/src/main/webapp/pages/ajaxCommands.xhtml
===================================================================
---
trunk/test-applications/seleniumTest/src/main/webapp/pages/ajaxCommands.xhtml 2008-04-14
10:20:16 UTC (rev 7792)
+++
trunk/test-applications/seleniumTest/src/main/webapp/pages/ajaxCommands.xhtml 2008-04-14
12:13:24 UTC (rev 7793)
@@ -1,52 +0,0 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html
xmlns="http://www.w3.org/1999/xhtml"
-
xmlns:a4j="http://richfaces.org/a4j"
-
xmlns:h="http://java.sun.com/jsf/html"
-
xmlns:f="http://java.sun.com/jsf/core">
- <head><title>test</title></head>
- <body>
- <a4j:status startText="Ajax in progress..." stopText="Ajax
completed" id="status"></a4j:status>
- <h:form id="fff">
- <a4j:commandButton
- actionListener="#{commandBean.actionListener}"
- reRender="date,text"
- value="Button1"
- id="b1" />
- <a4j:commandLink
- actionListener="#{commandBean.actionListener}"
- ajaxSingle="true"
- reRender="date,text"
- value="Link1"
- id="l1"></a4j:commandLink> <br/>
- <h:inputText value="#{commandBean.text}" id="text"
style="width: 100px"/>
- <h:panelGrid id="panel">
- <a4j:commandButton
- requestDelay="1000"
- actionListener="#{commandBean.actionListener}"
- reRender="date,text,param"
- ajaxSingle="true"
- value="Button2"
- action="#{commandBean.action}"
- id="b2">
- <a4j:actionparam name="param" value="actionParameter1"
assignTo="#{commandBean.param}" />
- </a4j:commandButton>
- <a4j:commandLink
- requestDelay="1000"
- actionListener="#{commandBean.actionListener}"
- action="#{commandBean.action}"
- reRender="date,text,param"
- value="Link2"
- id="l2">
- <a4j:actionparam name="param" value="actionParameter2"
assignTo="#{commandBean.param}" />
- </a4j:commandLink> <br/>
- </h:panelGrid>
- <h:outputText value="#{commandBean.date}" id="date"/>
- </h:form>
- <h:form id="_form">
- <h:outputText value="#{commandBean.param}"
id="param"></h:outputText>
- </h:form>
- <script type="text/javascript">
- window.done=false;A4J.AJAX.AddListener(new
A4J.AJAX.Listener(function(){window.done=true}));
- </script>
- </body>
-</html>
\ No newline at end of file
Added:
trunk/test-applications/seleniumTest/src/test/java/org/ajax4jsf/test/base/SeleniumTestBase.java
===================================================================
---
trunk/test-applications/seleniumTest/src/test/java/org/ajax4jsf/test/base/SeleniumTestBase.java
(rev 0)
+++
trunk/test-applications/seleniumTest/src/test/java/org/ajax4jsf/test/base/SeleniumTestBase.java 2008-04-14
12:13:24 UTC (rev 7793)
@@ -0,0 +1,249 @@
+package org.ajax4jsf.test.base;
+
+import org.ajax4jsf.renderkit.RendererUtils;
+import org.testng.Assert;
+import org.testng.annotations.AfterTest;
+import org.testng.annotations.BeforeTest;
+import org.testng.annotations.Parameters;
+
+import com.thoughtworks.selenium.DefaultSelenium;
+
+/**
+ * The base java class for selenium tests implementation.
+ * @author Andrey Markavtsov
+ *
+ */
+public class SeleniumTestBase {
+
+ private static final String equalCh = "=";
+
+ private static final String idSearch = RendererUtils.HTML.id_ATTRIBUTE + equalCh;
+
+ /** Specifies the time to wait for page rendering */
+ private static final Integer pageRenderTime = 5000;
+
+ /** The default selenium instance */
+ protected DefaultSelenium selenium;
+
+ /** Host */
+ public String host;
+
+ /** Port */
+ public String port;
+
+ /** Protocol */
+ public String protocol;
+
+ /** Defines the name of current j2ee application name*/
+ public static final String APPLICATION_NAME = "seleniumTest";
+
+ public static final String COMPONENT_PREFIX_INSIDE_TABLE =
"_Selenium_Test_Form1:_Selenium_Test_DataTable:0:";
+
+ public static final String COMPONENT_PREFIX_INSIDE_PANEL =
"_Selenium_Test_Form2:";
+
+ public SeleniumTestBase() {
+ /* Default constructor */
+ }
+
+ public SeleniumTestBase(String protocol, String host, String port) {
+ this.host = host;
+ this.port = port;
+ this.protocol = protocol;
+ }
+
+ /**
+ * @param url
+ * @param browser
+ * @return
+ */
+ public DefaultSelenium createSeleniumClient(String url, String browser) {
+ return new DefaultSelenium(host, 4444, browser, url);
+ }
+
+ /**
+ * This method are invoking before selenium tests started
+ */
+ @BeforeTest
+ @Parameters( { "browser" })
+ public void startSelenium(String browser) {
+ selenium = createSeleniumClient(protocol + "://" + host + ":" +
port + "/", browser);
+ selenium.start();
+ }
+
+ /**
+ * Renders page
+ */
+ protected void renderPage (String homePage) {
+ selenium.open(protocol + "://" + host + ":" + port + "/"
+ APPLICATION_NAME + homePage);
+ selenium.waitForPageToLoad(String.valueOf(pageRenderTime));
+
+ checkPageRendering(); // At the first we check if page has been rendered
+ checkJSError(); // At the second we check if JS errors occurred
+
+ reRenderForm(); // ReRender component
+
+ checkPageRendering(); // Check all again
+ checkJSError();
+
+ }
+
+ /**
+ * Return component id inside Data table
+ * @param id
+ * @return
+ */
+ public String getComponentIdInsideTable(String id) {
+ return COMPONENT_PREFIX_INSIDE_TABLE + id;
+ }
+
+
+ /**
+ * Return component id inside Panel
+ * @param id
+ * @return
+ */
+ public String getComponentIdInsidePanel(String id) {
+ return COMPONENT_PREFIX_INSIDE_PANEL + id;
+ }
+
+
+ /**
+ * ReRenders the component
+ */
+ public void reRenderForm () {
+ selenium.getEval("selenium.browserbot.getCurrentWindow().reRenderAll();");
+ //clickById("_Selenium_Test_ReRender_Form:_reRender");
+ waitForAjaxCompletion(3000);
+ }
+
+ /**
+ * This method are invoking after selenium tests completed
+ */
+ @AfterTest
+ public void stopSelenium() {
+ selenium.stop();
+ selenium = null;
+ }
+
+ /**
+ * Checks if JS error occurred.
+ * Fails test if yes.
+ * This method should be invoked after each event or any thing which can be a cause of
JS error.
+ */
+ public void checkJSError () {
+ String error =
selenium.getEval("selenium.browserbot.getCurrentWindow().checkError();");
+ if (error != null && !("null".equals(error)) &&
!("".equals(error))) {
+ Assert.fail("Failure by the following Javascript error: " + error);
+ }
+ }
+
+ /**
+ * Checks if page containing component test has been rendered completely
+ */
+ public void checkPageRendering() {
+ String t1 = getTextById("_Selenium_Test_ControlPoint1");
+ String t2 = getTextById("_Selenium_Test_ControlPoint2");
+ if (t1 == null || t2 == null || !"Control1".equals(t1) ||
!"Control2".equals(t2)) {
+ Assert.fail("The page has been not rendered properlly");
+ }
+ }
+
+ /**
+ * Waits while AJAX request will be completed
+ * @param miliseconds - time to wait
+ */
+ public void waitForAjaxCompletion (int miliseconds) {
+ selenium.waitForCondition(
+ "selenium.browserbot.getCurrentWindow().done==true",
String.valueOf(miliseconds));
+ }
+
+
+ /**
+ * Asserts DOM node value equals to value defined
+ * @param id - DOM element id
+ * @param value - value defined
+ */
+ public void AssertValueEquals(String id, String value) {
+ String _v = getValueById(id);
+ Assert.assertEquals(_v, value);
+ }
+
+ /**
+ * Asserts DOM node value does not equal to value defined
+ * @param id - DOM element id
+ * @param value - value defined
+ */
+ public void AssertValueNotEquals(String id, String value) {
+ String _v = getValueById(id);
+ Assert.assertNotSame(_v, value);
+ }
+
+
+ /**
+ * Asserts DOM node text equals to text defined
+ * @param id - DOM element id
+ * @param value - text defined
+ */
+ public void AssertTextEquals(String id, String value) {
+ String _v = getTextById(id);
+ Assert.assertEquals(_v, value);
+ }
+
+ /**
+ * Asserts DOM node text does not equal to text defined
+ * @param id - DOM element id
+ * @param value - text defined
+ */
+ public void AssertTextNotEquals(String id, String value) {
+ String _v = getTextById(id);
+ Assert.assertNotSame(_v, value);
+ }
+
+ /**
+ * Returns element's text
+ * @param id - DOM element id
+ * @return
+ */
+ public String getTextById(String id) {
+ return selenium.getText(idSearch + id);
+ }
+
+ /**
+ * Returns element's value
+ * @param id - DOM element id
+ * @return
+ */
+ public String getValueById(String id) {
+ return selenium.getValue(idSearch + id);
+ }
+
+ /**
+ * Clicks on element
+ * @param id - DOM element id
+ * @return
+ */
+ public void clickById(String id) {
+ selenium.click(idSearch + id);
+ checkJSError();
+ }
+
+
+ /**
+ * Return true if element is visible
+ * @param id - DOM element id
+ * @return
+ */
+ public boolean isVisibleById(String id) {
+ return selenium.isVisible(idSearch + id);
+ }
+
+ /**
+ * Creates delay
+ * @param miliSeconds
+ * @throws InterruptedException
+ */
+ public void delay (int miliSeconds) throws InterruptedException {
+ Thread.sleep(miliSeconds);
+ }
+
+}
Modified:
trunk/test-applications/seleniumTest/src/test/java/org/richfaces/AjaxCommandsTest.java
===================================================================
---
trunk/test-applications/seleniumTest/src/test/java/org/richfaces/AjaxCommandsTest.java 2008-04-14
10:20:16 UTC (rev 7792)
+++
trunk/test-applications/seleniumTest/src/test/java/org/richfaces/AjaxCommandsTest.java 2008-04-14
12:13:24 UTC (rev 7793)
@@ -1,11 +1,9 @@
package org.richfaces;
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertFalse;
-import static org.testng.Assert.assertTrue;
-
+import org.ajax4jsf.test.base.SeleniumTestBase;
import org.testng.annotations.Test;
+
public class AjaxCommandsTest extends SeleniumTestBase {
public AjaxCommandsTest() {
@@ -14,76 +12,60 @@
@Test
public void testAjaxCommandsComponents() throws Exception {
- selenium.open("http://localhost:8080/seleniumTest/faces/pages/ajaxCommands.xhtml");
- selenium.waitForPageToLoad("5000");
-
- assertEquals("1", getValueById("fff:text"));
- assertTrue(isVisibleById("_viewRoot:status.stop"));
-
- String date = getTextById("fff:date");
-
- // the click on command button [ ajaxSingle = false ]
- clickById("fff:b1");
- selenium.waitForCondition(
- "selenium.browserbot.getCurrentWindow().done==true", "1000");
- assertEquals("3", getValueById("fff:text"));
- assertFalse(getTextById("fff:date").equals(date));
-
- // the click on command button [ ajaxSingle = false ]
- clickById("fff:b1");
- selenium.waitForCondition(
- "selenium.browserbot.getCurrentWindow().done==true", "1000");
- assertEquals("5", getValueById("fff:text"));
- assertFalse(getTextById("fff:date").equals(date));
-
- // the click on command link [ ajaxSingle = true ]
- clickById("fff:l1");
- selenium.waitForCondition(
- "selenium.browserbot.getCurrentWindow().done==true", "1000");
- assertEquals("2", getValueById("fff:text"));
- assertFalse(getTextById("fff:date").equals(date));
-
- // the click on command link [ ajaxSingle = true ]
- clickById("fff:l1");
- selenium.waitForCondition(
- "selenium.browserbot.getCurrentWindow().done==true", "1000");
- assertEquals("2", getValueById("fff:text"));
- assertFalse(getTextById("fff:date").equals(date));
-
- // the click on command button [ ajaxSingle = true ]
- clickById("fff:b2");
- assertTrue("".equals(getTextById("_form:param")));
- assertEquals("2", getValueById("fff:text"));
- delay(2000);
- assertEquals("3", getValueById("fff:text"));
- assertFalse(getTextById("fff:date").equals(date));
-
- // the click on command button [ ajaxSingle = true ]
- clickById("fff:b2");
- assertEquals("3", getValueById("fff:text"));
- delay(2000);
- assertEquals("3", getValueById("fff:text"));
- assertFalse(getTextById("fff:date").equals(date));
-
- // the click on command link [ ajaxSingle = false ]
- clickById("fff:l2");
- assertTrue("actionParameter1"
- .equals(getTextById("_form:param")));
- assertEquals("3", getValueById("fff:text"));
- delay(2000);
- assertEquals("6", getValueById("fff:text"));
- assertFalse(getTextById("fff:date").equals(date));
- assertTrue("actionParameter2"
- .equals(getTextById("_form:param")));
-
- // the click on command link [ ajaxSingle = false ]
- clickById("fff:l2");
- assertEquals("6", getValueById("fff:text"));
- delay(2000);
- assertEquals("9", getValueById("fff:text"));
- assertFalse(getTextById("fff:date").equals(date));
- assertTrue("actionParameter2"
- .equals(getTextById("_form:param")));
+ renderPage("/faces/pages/ajaxCommands/ajaxButtonTest.xhtml");
+
+ _testAjaxCommandsComponents(COMPONENT_PREFIX_INSIDE_TABLE);
+ _testAjaxCommandsComponents(COMPONENT_PREFIX_INSIDE_PANEL);
}
+
+ private void _testAjaxCommandsComponents (String parentId) {
+ // test inside DataTable
+ String buttonId = parentId + "b1";
+ String inputId = parentId + "_value";
+
+ clickById(buttonId);
+ waitForAjaxCompletion(3000);
+ AssertValueEquals(inputId, "3");
+
+ clickById(buttonId);
+ waitForAjaxCompletion(1000);
+ AssertValueEquals(inputId, "6");
+
+ buttonId = parentId + "b2";
+
+ clickById(buttonId);
+ waitForAjaxCompletion(1000);
+ AssertValueEquals(inputId, "6");
+
+ buttonId = parentId + "b3";
+
+ clickById(buttonId);
+ waitForAjaxCompletion(1000);
+ AssertValueEquals(inputId, "6");
+
+ buttonId = parentId + "b4";
+
+ clickById(buttonId);
+ waitForAjaxCompletion(1000);
+ AssertValueEquals(inputId, "1");
+
+ buttonId = parentId + "b5";
+
+ clickById(buttonId);
+ waitForAjaxCompletion(1000);
+ AssertValueEquals(inputId, "2");
+
+ buttonId = parentId + "b1";
+
+ clickById(buttonId);
+ waitForAjaxCompletion(1000);
+ AssertValueEquals(inputId, "5");
+
+ buttonId = parentId + "b3";
+
+ clickById(buttonId);
+ waitForAjaxCompletion(1000);
+ AssertValueEquals(inputId, "5");
+ }
}
Modified:
trunk/test-applications/seleniumTest/src/test/java/org/richfaces/SeleniumExampleTest.java
===================================================================
---
trunk/test-applications/seleniumTest/src/test/java/org/richfaces/SeleniumExampleTest.java 2008-04-14
10:20:16 UTC (rev 7792)
+++
trunk/test-applications/seleniumTest/src/test/java/org/richfaces/SeleniumExampleTest.java 2008-04-14
12:13:24 UTC (rev 7793)
@@ -7,9 +7,8 @@
* @author asmirnov
*
*/
-import static org.testng.Assert.*;
+import static org.testng.Assert.assertEquals;
-import org.testng.Assert;
import org.testng.annotations.AfterTest;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Parameters;
@@ -33,7 +32,7 @@
selenium.start();
}
- @Test(enabled=false)
+ @Test(enabled=true)
public void testSomethingSimple() throws Exception {
selenium.open("http://localhost:8080/seleniumTest/faces/test.xhtml");
selenium.waitForPageToLoad("5000");
Deleted:
trunk/test-applications/seleniumTest/src/test/java/org/richfaces/SeleniumTestBase.java
===================================================================
---
trunk/test-applications/seleniumTest/src/test/java/org/richfaces/SeleniumTestBase.java 2008-04-14
10:20:16 UTC (rev 7792)
+++
trunk/test-applications/seleniumTest/src/test/java/org/richfaces/SeleniumTestBase.java 2008-04-14
12:13:24 UTC (rev 7793)
@@ -1,110 +0,0 @@
-package org.richfaces;
-
-import org.ajax4jsf.renderkit.RendererUtils;
-import org.testng.annotations.AfterTest;
-import org.testng.annotations.BeforeTest;
-import org.testng.annotations.Parameters;
-
-import com.thoughtworks.selenium.DefaultSelenium;
-
-public class SeleniumTestBase {
-
- private static final String equalCh = "=";
-
- private static final String idSearch = RendererUtils.HTML.id_ATTRIBUTE + equalCh;
-
- protected DefaultSelenium selenium;
-
- private String host;
-
- private String port;
-
- private String protocol;
-
- public SeleniumTestBase() {
- // Default constructor
- }
-
- public SeleniumTestBase(String protocol, String host, String port) {
- this.host = host;
- this.port = port;
- this.protocol = protocol;
- }
-
- /**
- * @param url
- * @param browser
- * @return
- */
- public DefaultSelenium createSeleniumClient(String url, String browser) {
- return new DefaultSelenium(host, 4444, browser, url);
- }
-
- /**
- * This method are invoking before selenium tests started
- */
- @BeforeTest
- @Parameters( { "browser" })
- public void startSelenium(String browser) {
- System.out.println("___________>>>>>>>>>>>>."
+ protocol + "://" + host + ":" + port);
- selenium = createSeleniumClient(protocol + "://" + host + ":" +
port, browser);
- selenium.start();
- }
-
- /**
- * This method are invoking after selenium tests completed
- */
- @AfterTest
- public void stopSelenium() {
- selenium.stop();
- selenium = null;
- }
-
-
- /**
- * Returns element's text
- * @param id - DOM element id
- * @return
- */
- public String getTextById(String id) {
- return selenium.getText(idSearch + id);
- }
-
- /**
- * Returns element's value
- * @param id - DOM element id
- * @return
- */
- public String getValueById(String id) {
- return selenium.getValue(idSearch + id);
- }
-
- /**
- * Clicks on element
- * @param id - DOM element id
- * @return
- */
- public void clickById(String id) {
- selenium.click(idSearch + id);
- }
-
-
- /**
- * Return true if element is visible
- * @param id - DOM element id
- * @return
- */
- public boolean isVisibleById(String id) {
- return selenium.isVisible(idSearch + id);
- }
-
- /**
- * Creates delay
- * @param miliSeconds
- * @throws InterruptedException
- */
- public void delay (int miliSeconds) throws InterruptedException {
- Thread.sleep(miliSeconds);
- }
-
-}