Author: andrei_exadel
Date: 2008-08-12 04:46:25 -0400 (Tue, 12 Aug 2008)
New Revision: 10044
Modified:
trunk/test-applications/seleniumTest/src/main/webapp/layout/layout.xhtml
trunk/test-applications/seleniumTest/src/main/webapp/pages/listShuttle/listShuttleTest.xhtml
trunk/test-applications/seleniumTest/src/test/java/org/richfaces/SeleniumTestBase.java
trunk/test-applications/seleniumTest/src/test/java/org/richfaces/testng/ListShuttleTest.java
Log:
Add fireMouseEvent
Modified: trunk/test-applications/seleniumTest/src/main/webapp/layout/layout.xhtml
===================================================================
--- trunk/test-applications/seleniumTest/src/main/webapp/layout/layout.xhtml 2008-08-12
08:33:55 UTC (rev 10043)
+++ trunk/test-applications/seleniumTest/src/main/webapp/layout/layout.xhtml 2008-08-12
08:46:25 UTC (rev 10044)
@@ -70,6 +70,22 @@
element.style.cssText = 'background-color: white';
element.innerHTML = 'No';
}
+
+ function fireMouseEvent(id, eventName, x, y) {
+ var e = $(id);
+ var evt;
+ if (document.createEvent) {
+ evt = document.createEvent("MouseEvents");
+ evt.initMouseEvent(eventName, true, true, window,0, x, y, x, y, false, false, false,
false, 0, null);
+ evt.srcElement = e;
+ e.dispatchEvent(evt);
+ return evt;
+ }else {
+ if (e[eventName]) {
+ return e[eventName]();
+ }
+ }
+ }
</script>
<style type="text/css">
<ui:insert name="style"/>
Modified:
trunk/test-applications/seleniumTest/src/main/webapp/pages/listShuttle/listShuttleTest.xhtml
===================================================================
---
trunk/test-applications/seleniumTest/src/main/webapp/pages/listShuttle/listShuttleTest.xhtml 2008-08-12
08:33:55 UTC (rev 10043)
+++
trunk/test-applications/seleniumTest/src/main/webapp/pages/listShuttle/listShuttleTest.xhtml 2008-08-12
08:46:25 UTC (rev 10044)
@@ -11,21 +11,6 @@
</ui:define>
<ui:define name="component">
- <script type="text/javascript">
- function _selectItem(id) {
- var e = $(id);
- if (document.createEvent) {
- evt = document.createEvent("MouseEvents");
- evt.initMouseEvent("click", true, true, window,0, 0, 0, 0, 0, false,
false, false, false, 0, null);
- evt.srcElement = e;
- e.dispatchEvent(evt);
- }else {
- if (e.click) {
- e.click();
- }
- }
- }
- </script>
<a4j:outputPanel>
<h:messages></h:messages>
</a4j:outputPanel>
Modified:
trunk/test-applications/seleniumTest/src/test/java/org/richfaces/SeleniumTestBase.java
===================================================================
---
trunk/test-applications/seleniumTest/src/test/java/org/richfaces/SeleniumTestBase.java 2008-08-12
08:33:55 UTC (rev 10043)
+++
trunk/test-applications/seleniumTest/src/test/java/org/richfaces/SeleniumTestBase.java 2008-08-12
08:46:25 UTC (rev 10044)
@@ -832,4 +832,17 @@
* @return
*/
public abstract String getTestUrl();
+
+ /**
+ * Simulates mouse event for element
+ * @param id - Element ID
+ * @param eventName - Mouse event Name
+ * @param x - X mouse position
+ * @param y - Y mouse position
+ * @return - Event
+ */
+ public String fireMouseEvent(String id, String eventName, int x, int y) {
+ return runScript("fireMouseEvent('" + id + "','" +
eventName + "', "
+ + x + "," + y + ");");
+ }
}
Modified:
trunk/test-applications/seleniumTest/src/test/java/org/richfaces/testng/ListShuttleTest.java
===================================================================
---
trunk/test-applications/seleniumTest/src/test/java/org/richfaces/testng/ListShuttleTest.java 2008-08-12
08:33:55 UTC (rev 10043)
+++
trunk/test-applications/seleniumTest/src/test/java/org/richfaces/testng/ListShuttleTest.java 2008-08-12
08:46:25 UTC (rev 10044)
@@ -225,7 +225,7 @@
private void _selectItem(String itemId) {
writeStatus("Select item id: " + itemId);
try {
- runScript("_selectItem('" + itemId + "')");
+ fireMouseEvent(itemId, "click", 0, 0);
} catch (Exception e) {
writeStatus("Selection item id: " + itemId + "
failed.");
Assert.fail("No item was found. Item id: " + itemId + e);