Author: lfryc(a)redhat.com
Date: 2011-01-13 09:40:51 -0500 (Thu, 13 Jan 2011)
New Revision: 20987
Modified:
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/AbstractComponentAttributes.java
Log:
AbstractComponentAttributes able to switch between guarding of XHR and HTTP
Modified:
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/AbstractComponentAttributes.java
===================================================================
---
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/AbstractComponentAttributes.java 2011-01-13
14:40:00 UTC (rev 20986)
+++
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/AbstractComponentAttributes.java 2011-01-13
14:40:51 UTC (rev 20987)
@@ -21,6 +21,10 @@
*******************************************************************************/
package org.richfaces.tests.metamer.ftest;
+import static org.jboss.test.selenium.guard.request.RequestTypeGuardFactory.guard;
+import static
org.jboss.test.selenium.locator.reference.ReferencedLocator.referenceInferred;
+import static org.richfaces.tests.metamer.ftest.AbstractMetamerTest.pjq;
+
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang.WordUtils;
import org.jboss.test.selenium.dom.Event;
@@ -29,15 +33,12 @@
import org.jboss.test.selenium.locator.Attribute;
import org.jboss.test.selenium.locator.AttributeLocator;
import org.jboss.test.selenium.locator.ElementLocator;
+import org.jboss.test.selenium.locator.ExtendedLocator;
import org.jboss.test.selenium.locator.JQueryLocator;
-import org.jboss.test.selenium.locator.ExtendedLocator;
import org.jboss.test.selenium.locator.reference.LocatorReference;
import org.jboss.test.selenium.locator.reference.ReferencedLocator;
+import org.jboss.test.selenium.request.RequestType;
-import static org.jboss.test.selenium.guard.request.RequestTypeGuardFactory.guardHttp;
-import static org.richfaces.tests.metamer.ftest.AbstractMetamerTest.pjq;
-import static
org.jboss.test.selenium.locator.reference.ReferencedLocator.referenceInferred;
-
/**
* @author <a href="mailto:lfryc@redhat.com">Lukas Fryc</a>
* @version $Revision$
@@ -49,6 +50,8 @@
pjq(""));
ReferencedLocator<JQueryLocator> propertyLocator = referenceInferred(root,
"input[id*={0}Input]{1}");
+ RequestType requestType = RequestType.HTTP;
+
public AbstractComponentAttributes() {
}
@@ -94,20 +97,30 @@
locator = propertyLocator.format(propertyName, "[value="
+ ("".equals(valueAsString) ? "null" : valueAsString)
+ "]");
- if (selenium.isChecked(locator)) {
- guardHttp(selenium).fireEvent(locator, Event.CHANGE);
- } else {
- guardHttp(selenium).click(locator);
+ if (!selenium.isChecked(locator)) {
+ applyRadio(locator);
}
}
}
+ public void setRequestType(RequestType requestType) {
+ this.requestType = requestType;
+ }
+
+ public RequestType getRequestType() {
+ return requestType;
+ }
+
protected void applyText(ElementLocator<?> locator, String value) {
- guardHttp(selenium).type(locator, value);
+ guard(selenium, requestType, false).type(locator, value);
}
protected void applyCheckbox(ElementLocator<?> locator, boolean checked) {
selenium.check(locator, checked);
- guardHttp(selenium).fireEvent(locator, Event.CHANGE);
+ guard(selenium, requestType, false).fireEvent(locator, Event.CHANGE);
}
+
+ protected void applyRadio(ElementLocator<?> locator) {
+ guard(selenium, requestType, false).click(locator);
+ }
}