Author: konstantin.mishin
Date: 2009-05-07 08:32:47 -0400 (Thu, 07 May 2009)
New Revision: 14060
Added:
trunk/examples/photoalbum/tests/src/test/java/org/richfaces/photoalbum/testng/DnDUseCasesTest.java
trunk/examples/photoalbum/tests/src/test/java/org/richfaces/photoalbum/testng/EditUseCasesTest.java
trunk/examples/photoalbum/tests/src/test/resources/script/
trunk/examples/photoalbum/tests/src/test/resources/script/selenium/
trunk/examples/photoalbum/tests/src/test/resources/script/selenium/user-extensions.js
Modified:
trunk/examples/photoalbum/tests/src/test/java/org/richfaces/photoalbum/RealWorldHelper.java
trunk/examples/photoalbum/tests/src/test/java/org/richfaces/photoalbum/SeleniumTestBase.java
trunk/examples/photoalbum/tests/src/test/java/org/richfaces/photoalbum/testng/AddUseCasesTest.java
trunk/examples/photoalbum/tests/src/test/java/org/richfaces/photoalbum/testng/LoginTest.java
Log:
RF-6909
Modified:
trunk/examples/photoalbum/tests/src/test/java/org/richfaces/photoalbum/RealWorldHelper.java
===================================================================
---
trunk/examples/photoalbum/tests/src/test/java/org/richfaces/photoalbum/RealWorldHelper.java 2009-05-07
12:13:33 UTC (rev 14059)
+++
trunk/examples/photoalbum/tests/src/test/java/org/richfaces/photoalbum/RealWorldHelper.java 2009-05-07
12:32:47 UTC (rev 14060)
@@ -80,31 +80,56 @@
String HEADER_PATH =
"//*[@class='content_box']/descendant::*[@class='shelf-header-table']";
String HEADER_NAME_PATH_SUFFIX = "//h1//text()";
String HEADER_NAME_PATH = HEADER_PATH + HEADER_NAME_PATH_SUFFIX;
- String DELETE_PATH = "//*[@class='shelf-header-table-col2']/a[2]";
+ String DESCRIPTION_PATH = HEADER_PATH + "/following-sibling::p";
+ String CONTROLS_PATH = "//*[@class='shelf-header-table-col2']";
+ String EDIT_PATH = CONTROLS_PATH + "/a[1]";
+ String DELETE_PATH = CONTROLS_PATH + "/a[2]";
}
+ public static interface EditShelfArea {
+ String DESCRIPTION_ID = IndexPage.MAIN_FORM_ID + ":shelf_description";
+ String SAVE_PATH = "//*[@id='" + IndexPage.MAIN_FORM_ID +
"']//*[@class='photoalbumButton'][1]/input";
+ }
+
public static interface AlbumArea {
String HEADER_PATH = "//*[@class='album-header-table']";
String HEADER_NAME_PATH_SUFFIX = "//h1//text()";
String HEADER_NAME_PATH = HEADER_PATH + HEADER_NAME_PATH_SUFFIX;
+ String DESCRIPTION_PATH = HEADER_PATH + "/following-sibling::p";
String PREVIEW_PATH = "//*[@class='preview_box_album_120']";
String PREVIEW_LINK_PATH_SUFFIX = "//a";
String PREVIEW_NAME_PATH_SUFFIX = "/*[@class='album_name']";
- String DELETE_PATH = "//*[@class='album-header-table-col2']/a[2]";
+ String CONTROLS_PATH = "//*[@class='album-header-table-col2']";
+ String EDIT_PATH = CONTROLS_PATH + "/a[1]";
+ String DELETE_PATH = CONTROLS_PATH + "/a[2]";
//String IMAGES_CONTAINER =
"//span[@id='mainform:userAlbumImages']";
}
+ public static interface EditAlbumArea {
+ String DESCRIPTION_ID = IndexPage.MAIN_FORM_ID + ":album_description";
+ String SAVE_PATH = "//*[@id='" + IndexPage.MAIN_FORM_ID +
"']//*[@class='photoalbumButton'][1]/input";
+ }
+
public static interface ImageArea {
String HEADER_PATH = "//*[@class='image-header-table']";
String HEADER_NAME_PATH_SUFFIX = "//h1//text()";
String HEADER_NAME_PATH = HEADER_PATH + HEADER_NAME_PATH_SUFFIX;
+ String DESCRIPTION_PATH = HEADER_PATH + "/following-sibling::p";
String PREVIEW_PATH = "//*[@class='preview_box_photo_120']";
String PREVIEW_LINK_PATH_SUFFIX = "//a";
String PREVIEW_NAME_PATH_SUFFIX = "/*[@class='photo_name']";
- String DELETE_PATH =
"//*[@class='mainImage-table-col3']/div[2]/input";
+ String CONTROLS_PATH = "//*[@class='mainImage-table-col3']";
+ String EDIT_PATH = CONTROLS_PATH + "/div[1]/input";
+ String DELETE_PATH = CONTROLS_PATH + "/div[2]/input";
}
- public static interface UserProfileArea {
+ public static interface EditImageArea {
+ String PATH = "//*[@class='image-edit-div-table']";
+ String DESCRIPTION_PATH = PATH + "//textarea";
+ String SAVE_PATH = PATH +
"//*[@class='photoalbumButton'][1]/input";
+ }
+
+ public static interface RegistrationArea {
String NAME_ID = IndexPage.MAIN_FORM_ID + ":loginName";
String PASSWORD_ID = IndexPage.MAIN_FORM_ID + ":password";
String CONFIRM_PASSWORD_ID = IndexPage.MAIN_FORM_ID + ":confirmPassword";
@@ -115,6 +140,10 @@
String REGISTER_PATH =
"//*[@class='content_box']/descendant::*[@class='photoalbumButton'][1]//input";
}
+ public static interface UserProfileArea {
+ String NAME_PATH = "//*[@class='reg-table']/descendant::td[2]";
+ }
+
public static interface FilesUploadArea {
String FILE_UPLOAD_ID = IndexPage.MAIN_FORM_ID + ":fileUpload";
}
@@ -193,9 +222,9 @@
}
public static void testUserProfile(Selenium selenium, String name) {
- Assert.assertTrue(selenium.isVisible(HtmlConstants.UserProfileArea.NAME_ID));
+ Assert.assertTrue(selenium.isVisible(HtmlConstants.UserProfileArea.NAME_PATH));
if (name != null) {
- Assert.assertEquals(selenium.getValue(HtmlConstants.UserProfileArea.NAME_ID), name);
+ Assert.assertEquals(selenium.getText(HtmlConstants.UserProfileArea.NAME_PATH), name);
}
}
@@ -204,15 +233,23 @@
}
public static void testShelfArea(Selenium selenium) {
- testShelfArea(selenium, null);
+ testShelfArea(selenium, null, null);
}
public static void testShelfArea(Selenium selenium, String shelfName) {
+ testShelfArea(selenium, shelfName, null);
+ }
+
+ public static void testShelfArea(Selenium selenium, String shelfName, String
description) {
Assert.assertTrue(selenium.isVisible(HtmlConstants.ShelfArea.HEADER_PATH));
if (shelfName != null) {
String text =
selenium.getText(RealWorldHelper.HtmlConstants.ShelfArea.HEADER_NAME_PATH);
Assert.assertTrue(text.equals(shelfName), "Incorrect data was opened on shelf
area.");
}
+ if (description != null) {
+ String text =
selenium.getText(RealWorldHelper.HtmlConstants.ShelfArea.DESCRIPTION_PATH);
+ Assert.assertTrue(text.equals(description), "Incorrect data was opened on album
area.");
+ }
}
public static boolean isShelfPresentOnPage(Selenium selenium, String shelfName) {
@@ -273,15 +310,23 @@
}
public static void testAlbumArea(Selenium selenium) {
- testAlbumArea(selenium, null);
+ testAlbumArea(selenium, null, null);
}
public static void testAlbumArea(Selenium selenium, String albumName) {
+ testAlbumArea(selenium, albumName, null);
+ }
+
+ public static void testAlbumArea(Selenium selenium, String albumName, String
description) {
Assert.assertTrue(selenium.isVisible(HtmlConstants.AlbumArea.HEADER_PATH));
if (albumName != null) {
String text =
selenium.getText(RealWorldHelper.HtmlConstants.AlbumArea.HEADER_NAME_PATH);
Assert.assertTrue(text.equals(albumName), "Incorrect data was opened on album
area.");
}
+ if (description != null) {
+ String text =
selenium.getText(RealWorldHelper.HtmlConstants.AlbumArea.DESCRIPTION_PATH);
+ Assert.assertTrue(text.equals(description), "Incorrect data was opened on album
area.");
+ }
}
public static boolean isAlbumPresentOnPage(Selenium selenium, String albumName) {
@@ -341,15 +386,23 @@
}
public static void testImageArea(Selenium selenium) {
- testImageArea(selenium, null);
+ testImageArea(selenium, null, null);
}
public static void testImageArea(Selenium selenium, String imageName) {
+ testImageArea(selenium, imageName, null);
+ }
+
+ public static void testImageArea(Selenium selenium, String imageName, String
description) {
Assert.assertTrue(selenium.isVisible(HtmlConstants.ImageArea.HEADER_PATH));
if (imageName != null) {
String text =
selenium.getText(RealWorldHelper.HtmlConstants.ImageArea.HEADER_NAME_PATH);
Assert.assertTrue(text.equals(imageName), "Incorrect data was opened on image
area.");
}
+ if (description != null) {
+ String text =
selenium.getText(RealWorldHelper.HtmlConstants.ImageArea.DESCRIPTION_PATH);
+ Assert.assertTrue(text.equals(description), "Incorrect data was opened on album
area.");
+ }
}
public static boolean isImagePresentOnPage(Selenium selenium, String imageName) {
Modified:
trunk/examples/photoalbum/tests/src/test/java/org/richfaces/photoalbum/SeleniumTestBase.java
===================================================================
---
trunk/examples/photoalbum/tests/src/test/java/org/richfaces/photoalbum/SeleniumTestBase.java 2009-05-07
12:13:33 UTC (rev 14059)
+++
trunk/examples/photoalbum/tests/src/test/java/org/richfaces/photoalbum/SeleniumTestBase.java 2009-05-07
12:32:47 UTC (rev 14060)
@@ -2,8 +2,10 @@
+import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileFilter;
+import java.io.FileInputStream;
import org.ajax4jsf.javascript.JSFunction;
import org.ajax4jsf.javascript.ScriptUtils;
@@ -79,6 +81,7 @@
RemoteControlConfiguration config = new RemoteControlConfiguration();
config.setMultiWindow(false);
config.setPort(seleniumServerPort);
+ config.setUserExtensions(new
File(getClass().getClassLoader().getResource("script/selenium/user-extensions.js").toURI()));
seleniumServer = new SeleniumServer(false, config);
seleniumServer.start();
}
@@ -105,6 +108,7 @@
synchronized (MUTEX) {
this.filterPrefix = filterPrefix;
selenium = createSeleniumClient(protocol + "://" + host +
":" + port + "/", browser);
+ setFileExtensionContent();
selenium.start();
selenium.allowNativeXpath("false");
}
@@ -146,6 +150,27 @@
return browser;
}
+ private void setFileExtensionContent() {
+ try {
+ File file = new File(getClass().getClassLoader().getResource(
+ "script/selenium/user-extensions.js").toURI());
+ FileInputStream stream = new FileInputStream(file);
+ ByteArrayOutputStream b = new ByteArrayOutputStream();
+ byte[] buffer = new byte[4096];
+ int read;
+ while ((read = stream.read(buffer)) > 0) {
+ b.write(buffer, 0, read);
+ }
+
+ String js = b.toString();
+ if (js != null && js.length() > 0) {
+ selenium.setExtensionJs(js);
+ }
+ } catch (Exception e) {
+
+ }
+ }
+
/**
* This method are invoked after selenium tests completed
*/
Modified:
trunk/examples/photoalbum/tests/src/test/java/org/richfaces/photoalbum/testng/AddUseCasesTest.java
===================================================================
---
trunk/examples/photoalbum/tests/src/test/java/org/richfaces/photoalbum/testng/AddUseCasesTest.java 2009-05-07
12:13:33 UTC (rev 14059)
+++
trunk/examples/photoalbum/tests/src/test/java/org/richfaces/photoalbum/testng/AddUseCasesTest.java 2009-05-07
12:32:47 UTC (rev 14060)
@@ -18,7 +18,7 @@
@Test
public void testAddAlbum() {
- String albumName = "_album album";
+ String albumName = "_album";
renderPage();
RealWorldHelper.login(selenium);
selenium.click(HtmlConstants.ToolBarArea.VIEW_ALBUMS_PATH);
Added:
trunk/examples/photoalbum/tests/src/test/java/org/richfaces/photoalbum/testng/DnDUseCasesTest.java
===================================================================
---
trunk/examples/photoalbum/tests/src/test/java/org/richfaces/photoalbum/testng/DnDUseCasesTest.java
(rev 0)
+++
trunk/examples/photoalbum/tests/src/test/java/org/richfaces/photoalbum/testng/DnDUseCasesTest.java 2009-05-07
12:32:47 UTC (rev 14060)
@@ -0,0 +1,30 @@
+/**
+ *
+ */
+package org.richfaces.photoalbum.testng;
+
+import org.richfaces.photoalbum.RealWorldHelper;
+import org.richfaces.photoalbum.SeleniumTestBase;
+import org.testng.annotations.Test;
+
+/**
+ * @author Konstantin Mishin
+ *
+ */
+public class DnDUseCasesTest extends SeleniumTestBase {
+
+ //TODO @Test
+ public void testDnDAlbum() {
+ renderPage();
+
+ RealWorldHelper.login(selenium);
+ RealWorldHelper.openAlbumFromPreview(selenium);
+
+ String compId = "treeform:j_id148";
+
+ String natureAlbumXpath = "//*[@id='"+ compId +
":childs']/div[1]/table[1]/tbody/tr/td[3]";
+ String sportShelfXpath = "//*[@id='"+ compId +
":childs']/table[2]/tbody/tr/td[3]";
+ selenium.dragAndDropToObject(natureAlbumXpath, sportShelfXpath);
+ waitForAjaxCompletion();
+ }
+}
Added:
trunk/examples/photoalbum/tests/src/test/java/org/richfaces/photoalbum/testng/EditUseCasesTest.java
===================================================================
---
trunk/examples/photoalbum/tests/src/test/java/org/richfaces/photoalbum/testng/EditUseCasesTest.java
(rev 0)
+++
trunk/examples/photoalbum/tests/src/test/java/org/richfaces/photoalbum/testng/EditUseCasesTest.java 2009-05-07
12:32:47 UTC (rev 14060)
@@ -0,0 +1,61 @@
+/**
+ *
+ */
+package org.richfaces.photoalbum.testng;
+
+import org.richfaces.photoalbum.RealWorldHelper;
+import org.richfaces.photoalbum.SeleniumTestBase;
+import org.richfaces.photoalbum.RealWorldHelper.HtmlConstants;
+import org.testng.annotations.Test;
+
+/**
+ * @author Konstantin Mishin
+ *
+ */
+public class EditUseCasesTest extends SeleniumTestBase {
+
+ @Test
+ public void testEditShelf() {
+ renderPage();
+ RealWorldHelper.login(selenium);
+ String shelfName = selenium.getText(HtmlConstants.ShelfArea.HEADER_NAME_PATH);
+ String description = "New shelf description";
+ selenium.click(HtmlConstants.ShelfArea.EDIT_PATH);
+ waitForAjaxCompletion();
+ selenium.type(HtmlConstants.EditShelfArea.DESCRIPTION_ID, description);
+ selenium.click(HtmlConstants.EditShelfArea.SAVE_PATH);
+ waitForAjaxCompletion();
+ RealWorldHelper.testShelfArea(selenium, shelfName, description);
+ }
+
+ @Test
+ public void testEditAlbum() {
+ renderPage();
+ RealWorldHelper.login(selenium);
+ String albumName = selenium.getText(HtmlConstants.AlbumArea.PREVIEW_PATH +
HtmlConstants.AlbumArea.PREVIEW_NAME_PATH_SUFFIX);
+ String description = "New album description";
+ RealWorldHelper.openAlbumFromPreview(selenium);
+ selenium.click(HtmlConstants.AlbumArea.EDIT_PATH);
+ waitForAjaxCompletion();
+ selenium.type(HtmlConstants.EditAlbumArea.DESCRIPTION_ID, description);
+ selenium.click(HtmlConstants.EditAlbumArea.SAVE_PATH);
+ waitForAjaxCompletion();
+ RealWorldHelper.testAlbumArea(selenium, albumName, description);
+ }
+
+ @Test
+ public void testEditImage() {
+ renderPage();
+ RealWorldHelper.login(selenium);
+ RealWorldHelper.openAlbumFromPreview(selenium);
+ String imageName = selenium.getText(HtmlConstants.ImageArea.PREVIEW_PATH +
HtmlConstants.ImageArea.PREVIEW_NAME_PATH_SUFFIX);
+ String description = "New image description";
+ RealWorldHelper.openImageFromPreview(selenium);
+ selenium.click(HtmlConstants.ImageArea.EDIT_PATH);
+ waitForAjaxCompletion();
+ selenium.type(HtmlConstants.EditImageArea.DESCRIPTION_PATH, description);
+ selenium.click(HtmlConstants.EditImageArea.SAVE_PATH);
+ waitForAjaxCompletion();
+ RealWorldHelper.testImageArea(selenium, imageName, description);
+ }
+}
Modified:
trunk/examples/photoalbum/tests/src/test/java/org/richfaces/photoalbum/testng/LoginTest.java
===================================================================
---
trunk/examples/photoalbum/tests/src/test/java/org/richfaces/photoalbum/testng/LoginTest.java 2009-05-07
12:13:33 UTC (rev 14059)
+++
trunk/examples/photoalbum/tests/src/test/java/org/richfaces/photoalbum/testng/LoginTest.java 2009-05-07
12:32:47 UTC (rev 14060)
@@ -33,14 +33,14 @@
selenium.click(HtmlConstants.LogInOutArea.REGISTER_PATH);
waitForAjaxCompletion();
RealWorldHelper.testUserProfile(selenium);
- selenium.type(HtmlConstants.UserProfileArea.NAME_ID, name);
- selenium.type(HtmlConstants.UserProfileArea.PASSWORD_ID, password);
- selenium.type(HtmlConstants.UserProfileArea.CONFIRM_PASSWORD_ID, password);
- selenium.type(HtmlConstants.UserProfileArea.FIRST_NAME_ID, "first");
- selenium.type(HtmlConstants.UserProfileArea.SECOND_NAME_ID, "second");
- selenium.type(HtmlConstants.UserProfileArea.BIRTH_DATE_ID, "Jan 1, 1");
- selenium.type(HtmlConstants.UserProfileArea.EMAIL_ID, "user(a)exadel.com");
- selenium.click(HtmlConstants.UserProfileArea.REGISTER_PATH);
+ selenium.type(HtmlConstants.RegistrationArea.NAME_ID, name);
+ selenium.type(HtmlConstants.RegistrationArea.PASSWORD_ID, password);
+ selenium.type(HtmlConstants.RegistrationArea.CONFIRM_PASSWORD_ID, password);
+ selenium.type(HtmlConstants.RegistrationArea.FIRST_NAME_ID, "first");
+ selenium.type(HtmlConstants.RegistrationArea.SECOND_NAME_ID, "second");
+ selenium.type(HtmlConstants.RegistrationArea.BIRTH_DATE_ID, "Jan 1, 1");
+ selenium.type(HtmlConstants.RegistrationArea.EMAIL_ID, "user(a)exadel.com");
+ selenium.click(HtmlConstants.RegistrationArea.REGISTER_PATH);
waitForAjaxCompletion();
Assert.assertTrue(RealWorldHelper.isLogined(selenium, name));
}
Added:
trunk/examples/photoalbum/tests/src/test/resources/script/selenium/user-extensions.js
===================================================================
--- trunk/examples/photoalbum/tests/src/test/resources/script/selenium/user-extensions.js
(rev 0)
+++
trunk/examples/photoalbum/tests/src/test/resources/script/selenium/user-extensions.js 2009-05-07
12:32:47 UTC (rev 14060)
@@ -0,0 +1,145 @@
+
+IEBrowserBot.prototype._fireEventOnElement = function(eventType, element, clientX,
clientY) {
+ var win = this.getCurrentWindow();
+ triggerEvent(element, 'focus', false);
+
+ var wasChecked = element.checked;
+
+ // Set a flag that records if the page will unload - this isn't always accurate,
because
+ // <a href="javascript:alert('foo'):"> triggers the
onbeforeunload event, even thought the page won't unload
+ var pageUnloading = false;
+ var pageUnloadDetector = function() {
+ pageUnloading = true;
+ };
+ win.attachEvent("onbeforeunload", pageUnloadDetector);
+ this._modifyElementTarget(element);
+ if (element[eventType] && !this.controlKeyDown && !this.altKeyDown
&& !this.shiftKeyDown && !this.metaKeyDown) {
+ element[eventType]();
+ }
+ else {
+ this.browserbot.triggerMouseEvent(element, eventType, true, clientX, clientY);
+ }
+
+
+ // If the page is going to unload - still attempt to fire any subsequent events.
+ // However, we can't guarantee that the page won't unload half way through,
so we need to handle exceptions.
+ try {
+ win.detachEvent("onbeforeunload", pageUnloadDetector);
+
+ if (this._windowClosed(win)) {
+ return;
+ }
+
+ // Onchange event is not triggered automatically in IE.
+ if (isDefined(element.checked) && wasChecked != element.checked) {
+ triggerEvent(element, 'change', true);
+ }
+
+ }
+ catch (e) {
+ // If the page is unloading, we may get a "Permission denied" or
"Unspecified error".
+ // Just ignore it, because the document may have unloaded.
+ if (pageUnloading) {
+ LOG.logHook = function() {
+ };
+ LOG.warn("Caught exception when firing events on unloading page: "
+ e.message);
+ return;
+ }
+ throw e;
+ }
+};
+
+
+
+Selenium.prototype.doDragAndDropToObject = function(locatorOfObjectToBeDragged,
locatorOfDragDestinationObject) {
+/** Drags an element and drops it on another element
+ *
+ * @param locatorOfObjectToBeDragged an element to be dragged
+ * @param locatorOfDragDestinationObject an element whose location (i.e., whose
center-most pixel) will be the point where locatorOfObjectToBeDragged is dropped
+ */
+ var startX = this.getElementPositionLeft(locatorOfObjectToBeDragged);
+ var startY = this.getElementPositionTop(locatorOfObjectToBeDragged);
+
+ var destinationLeftX = this.getElementPositionLeft(locatorOfDragDestinationObject);
+ var destinationTopY = this.getElementPositionTop(locatorOfDragDestinationObject);
+ var destinationWidth = this.getElementWidth(locatorOfDragDestinationObject);
+ var destinationHeight = this.getElementHeight(locatorOfDragDestinationObject);
+
+ var endX = Math.round(destinationLeftX + (destinationWidth / 2));
+ var endY = Math.round(destinationTopY + (destinationHeight / 2));
+
+ var deltaX = endX - startX;
+ var deltaY = endY - startY;
+
+ var movementsString = "" + deltaX + "," + deltaY;
+
+ this.doDragAndDrop(locatorOfObjectToBeDragged, movementsString);
+ var objectToBeDragged = this.browserbot.findElement(locatorOfObjectToBeDragged);
+ var clientStartXY = getClientXY(objectToBeDragged)
+ var clientStartX = clientStartXY[0];
+ var clientStartY = clientStartXY[1];
+
+ var movements = movementsString.split(/,/);
+ var movementX = Number(movements[0]);
+ var movementY = Number(movements[1]);
+
+ var clientFinishX = ((clientStartX + movementX) < 0) ? 0 : (clientStartX +
movementX);
+ var clientFinishY = ((clientStartY + movementY) < 0) ? 0 : (clientStartY +
movementY);
+
+ // We should also fire event on DragDestinationObject.
+ var dragDestinationObject =
this.browserbot.findElement(locatorOfDragDestinationObject);
+ this.browserbot.triggerMouseEvent(dragDestinationObject, 'mouseover', true,
clientFinishX, clientFinishY);
+
+ this.browserbot.triggerMouseEvent(objectToBeDragged, 'mousemove', true,
clientFinishX, clientFinishY);
+ this.browserbot.triggerMouseEvent(objectToBeDragged, 'mouseup', true,
clientFinishX, clientFinishY);
+ this.browserbot.triggerMouseEvent(dragDestinationObject, 'mouseup', true,
clientFinishX, clientFinishY);
+
+};
+
+
+Selenium.prototype.doDragAndDrop = function(locator, movementsString) {
+ /** Drags an element a certain distance and then drops it
+ * @param locator an element locator
+ * @param movementsString offset in pixels from the current location to which the
element should be moved, e.g., "+70,-300"
+ */
+ var element = this.browserbot.findElement(locator);
+ var clientStartXY = getClientXY(element)
+ var clientStartX = clientStartXY[0];
+ var clientStartY = clientStartXY[1];
+
+ var movements = movementsString.split(/,/);
+ var movementX = Number(movements[0]);
+ var movementY = Number(movements[1]);
+
+ var clientFinishX = ((clientStartX + movementX) < 0) ? 0 : (clientStartX +
movementX);
+ var clientFinishY = ((clientStartY + movementY) < 0) ? 0 : (clientStartY +
movementY);
+
+ var mouseSpeed = this.mouseSpeed;
+ var move = function(current, dest) {
+ if (current == dest) return current;
+ if (Math.abs(current - dest) < mouseSpeed) return dest;
+ return (current < dest) ? current + mouseSpeed : current - mouseSpeed;
+ }
+
+ this.browserbot.triggerMouseEvent(element, 'mousedown', true, clientStartX,
clientStartY);
+ this.browserbot.triggerMouseEvent(element, 'mousemove', true, clientStartX,
clientStartY);
+ var clientX = clientStartX;
+ var clientY = clientStartY;
+
+ while ((clientX != clientFinishX) || (clientY != clientFinishY)) {
+ clientX = move(clientX, clientFinishX);
+ clientY = move(clientY, clientFinishY);
+ this.browserbot.triggerMouseEvent(element, 'mousemove', true, clientX,
clientY);
+ }
+
+};
+
+try {
+if (commandFactory && selenium) {
+ commandFactory.registerAll(selenium);
+}
+}catch(e){}
+
+
+
+