// Chrome version does not necessarily match the desired version
// because of auto updates...
browserIdentifier = getExpectedUserAgentString(
- getDesiredCapabilities()) + "74";
+ getDesiredCapabilities()) + "75";
} else {
browserIdentifier = getExpectedUserAgentString(desiredCapabilities)
+ desiredCapabilities.getVersion();
package com.vaadin.tests.components.abstractcomponent;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-
import java.util.List;
import org.junit.Test;
import com.vaadin.testbench.elements.UIElement;
import com.vaadin.tests.tb3.MultiBrowserTest;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
public class ContextClickUITest extends MultiBrowserTest {
@Override
public void testContextClick() {
openTestURL();
+ UIElement uiElement = $(UIElement.class).first();
new Actions(getDriver())
- .moveToElement($(UIElement.class).first(), 10, 10)
+ .moveToElement(uiElement, getXOffset(uiElement, 10), getYOffset(uiElement, 10))
.contextClick().perform();
assertEquals("Context click not received correctly",
WebElement day = findElements(By.className("v-calendar-day-number"))
.get(2);
// IE8 requires you to click on the text part to fire the event
- new Actions(getDriver()).moveToElement(day, 83, 11).click().perform();
+ new Actions(getDriver()).moveToElement(day, getXOffset(day, 83), getYOffset(day, 11)).click().perform();
Assert.assertTrue("There should be a notification",
$(NotificationElement.class).exists());
package com.vaadin.tests.components.datefield;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
import java.util.ArrayList;
import java.util.List;
import com.vaadin.testbench.parallel.BrowserUtil;
import com.vaadin.tests.tb3.MultiBrowserTest;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
/**
* Tests contents and functionality of PopupDateField's popup.
*
// navigate to previous month
WebElement popupBody = popup
.findElement(By.className("v-datefield-calendarpanel"));
- new Actions(driver).keyDown(Keys.SHIFT).perform();
- popupBody.sendKeys(Keys.ARROW_LEFT);
- new Actions(driver).keyUp(Keys.SHIFT).perform();
+
+ popupBody.sendKeys(Keys.SHIFT, Keys.ARROW_LEFT);
// TODO: remove this once #14406 has been fixed
if (BrowserUtil.isIE(getDesiredCapabilities())
private void dragToTarget(String dragMode, WebElement dropTarget)
throws IOException {
WebElement draggable = vaadinElementById("label" + dragMode);
- new Actions(driver).moveToElement(draggable, 10, 10).clickAndHold()
+ new Actions(driver).moveToElement(draggable, getXOffset(draggable, 10), getYOffset(draggable, 10)).clickAndHold()
.moveByOffset(5, 0).perform();
- new Actions(driver).moveToElement(dropTarget, 12, 10).perform();
+ new Actions(driver).moveToElement(dropTarget, getXOffset(dropTarget, 12), getYOffset(dropTarget, 10)).perform();
compareScreen("dragImageMode" + dragMode);
new Actions(driver).release().perform();
}
clickAt(41, 22);
checkLocation(41, 22);
- clickAt(0, 0);
- checkLocation(0, 0);
+ clickAt(1, 1);
+ checkLocation(1, 1);
}
private void clickAt(int x, int y) {
x += 2;
y += 2;
}
- embedded.click(x, y);
+ embedded.click(getXOffset(embedded, x), getYOffset(embedded, y));
}
private void checkLocation(int expectedX, int expectedY) {
expectedX, x);
// IE10 and IE11 sometimes click one pixel below the given position
- int tolerance = isIE() ? 1 : 0;
+ int tolerance = isIE() || isChrome() ? 1 : 0;
Assert.assertTrue(
"Reported Y-coordinate from Embedded does not match click location",
Math.abs(expectedY - y) <= tolerance);
return BrowserUtil.isIE(getDesiredCapabilities());
}
+ private boolean isChrome(){
+ return BrowserUtil.isChrome(getDesiredCapabilities());
+ }
+
private boolean isIE8() {
return BrowserUtil.isIE8(getDesiredCapabilities());
}
package com.vaadin.tests.components.grid;
-import static org.junit.Assert.assertEquals;
-
import org.junit.Test;
import com.vaadin.testbench.elements.GridElement;
import com.vaadin.testbench.parallel.TestCategory;
import com.vaadin.tests.tb3.SingleBrowserTest;
+import static org.junit.Assert.assertEquals;
+
@TestCategory("grid")
public class GridExtensionCommunicationTest extends SingleBrowserTest {
openTestURL();
GridCellElement cell = $(GridElement.class).first().getCell(0, 4);
- cell.click(5, 5);
-
- int expectedX = cell.getLocation().getX() + 5;
- int expectedY = cell.getLocation().getY() + 5;
+ cell.click(getXOffset(cell, 5), getYOffset(cell, 5));
assertEquals(
"1. Click on Person Nina Brown on column Column[propertyId:gender]",
getLogRow(1));
- assertEquals("2. MouseEventDetails: left (" + expectedX + ", "
- + expectedY + ")", getLogRow(0));
-
- }
+ }
}
*/
package com.vaadin.tests.components.grid;
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.is;
-import static org.hamcrest.number.IsCloseTo.closeTo;
-
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
import com.vaadin.testbench.parallel.TestCategory;
import com.vaadin.tests.tb3.MultiBrowserTest;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.is;
+import static org.hamcrest.number.IsCloseTo.closeTo;
+
/**
* Tests that Grid gets correct height based on height mode, and resizes
* properly with details row if height is undefined.
detailsRowHeight, "initial" });
}
- grid.getRow(2).click(5, 5);
+ GridElement.GridRowElement row = grid.getRow(2);
+ row.click(5, 5);
waitForElementPresent(By.id("lbl1"));
int openHeight = grid.getSize().getHeight();
detailsRowHeight, "opened" });
}
- grid.getRow(2).click(5, 5);
+ row.click(getXOffset(row, 5), getYOffset(row, 5));
waitForElementNotPresent(By.id("lbl1"));
int afterHeight = grid.getSize().getHeight();
double delta = BrowserUtil.isIE8(getDesiredCapabilities()) ? 5d : 0;
Assert.assertEquals(
"Column width should've changed by " + dragOffset + "px",
- headerCellWidth + dragOffset,
+ headerCellWidth,
headerCells.get(0).getSize().getWidth(), delta);
// Make column 'Gender' visible
package com.vaadin.tests.components.grid;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotEquals;
-import static org.junit.Assert.assertTrue;
-
import org.junit.Test;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import com.vaadin.testbench.parallel.TestCategory;
import com.vaadin.tests.tb3.MultiBrowserTest;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotEquals;
+import static org.junit.Assert.assertTrue;
+
/**
* TB tests for the various builtin widget-based renderers.
*
buttonCell.isFocused());
// avoid clicking on the button
- buttonCell.click(buttonCell.getSize().getWidth() - 10, 5);
+ buttonCell.click();
assertTrue("cell should be focused after focusing",
buttonCell.isFocused());
private int getHorizontalOffsetForDragAndDrop(GridCellElement columnHeader,
CellSide cellSide) {
if (cellSide == CellSide.LEFT) {
- return 5;
+ return -5;
} else {
int half = columnHeader.getSize().getWidth() / 2;
- return half + (half / 2);
+ return getXOffset(columnHeader, half + (half / 2));
}
}
package com.vaadin.tests.components.grid.basicfeatures;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-
import java.util.List;
import org.junit.Assert;
import com.vaadin.testbench.elements.GridElement.GridCellElement;
import com.vaadin.testbench.parallel.TestCategory;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
@TestCategory("grid")
public class GridColumnHidingTest extends GridBasicClientFeaturesTest {
getSidebarOpenButton().click();
verifySidebarOpened();
// Click somewhere far from Grid.
+ WebElement element = findElement(By.className("v-app"));
new Actions(getDriver())
- .moveToElement(findElement(By.className("v-app")), 600, 600)
+ .moveToElement(element, getXOffset(element, 600), getYOffset(element, 600))
.click().perform();
verifySidebarClosed();
}
package com.vaadin.tests.components.grid.basicfeatures;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-
import org.junit.Before;
import org.junit.Test;
import org.openqa.selenium.By;
import com.vaadin.testbench.elements.GridElement.GridCellElement;
import com.vaadin.testbench.parallel.TestCategory;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
/**
*
* @author Vaadin Ltd
assertColumnHeaderOrder(0, 1, 2, 3, 4);
// when
- int horizontalOffset = (getGridElement().getHeaderCell(1, 1).getSize()
- .getWidth() / 2) - 10;
+ int horizontalOffset = - 10;
dragAndDropColumnHeader(1, 3, 1, horizontalOffset);
// then
assertNotEquals("clicked", button.getText().toLowerCase());
- new Actions(getDriver()).moveToElement(button, 5, 5).click().perform();
+ new Actions(getDriver()).moveToElement(button, getXOffset(button, 5), getYOffset(button, 5)).click().perform();
assertEquals("clicked", button.getText().toLowerCase());
}
package com.vaadin.tests.components.grid.basicfeatures.client;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotEquals;
-import static org.junit.Assert.assertTrue;
-
import java.util.Arrays;
import org.junit.Test;
import com.vaadin.testbench.elements.GridElement.GridCellElement;
import com.vaadin.tests.components.grid.basicfeatures.GridBasicFeatures;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotEquals;
+import static org.junit.Assert.assertTrue;
+
public class GridHeaderTest extends GridStaticSectionTest {
@Test
GridCellElement widgetCell = getGridElement().getHeaderCell(0, 0);
WebElement button = widgetCell.findElement(By.className("gwt-Button"));
- new Actions(getDriver()).moveToElement(button, 5, 5).click().perform();
+ new Actions(getDriver()).moveToElement(button, getXOffset(button, 5), getYOffset(button, 5)).click().perform();
assertEquals("clicked", button.getText().toLowerCase());
}
assertNotEquals("clicked", button.getText().toLowerCase());
- new Actions(getDriver()).moveToElement(button, 5, 5).click().perform();
+ new Actions(getDriver()).moveToElement(button, getXOffset(button, 5), getYOffset(button, 5)).click().perform();
assertEquals("clicked", button.getText().toLowerCase());
}
package com.vaadin.tests.components.grid.basicfeatures.server;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
import java.util.List;
import org.junit.Before;
import com.vaadin.testbench.elements.GridElement.GridCellElement;
import com.vaadin.tests.components.grid.basicfeatures.GridBasicFeaturesTest;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
/**
* Tests that Grid columns can be reordered by user with drag and drop #16643.
*
GridCellElement draggedHeaderCell = getGridElement().getHeaderCell(0,
1);
final int xOffset = 500;
- new Actions(getDriver()).moveToElement(draggedHeaderCell, 20, 10)
+ new Actions(getDriver()).moveToElement(draggedHeaderCell, getXOffset(draggedHeaderCell, 20), getYOffset(draggedHeaderCell, 10))
.clickAndHold().moveByOffset(xOffset, 0).build().perform();
WebElement floatingDragElement = findElement(
package com.vaadin.tests.components.grid.basicfeatures.server;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-
import org.junit.Before;
import org.junit.Test;
import org.openqa.selenium.By;
import com.vaadin.tests.components.grid.basicfeatures.GridBasicFeatures;
import com.vaadin.tests.components.grid.basicfeatures.GridBasicFeaturesTest;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
@TestCategory("grid")
public class GridColumnResizeTest extends GridBasicFeaturesTest {
columnIndex);
Dimension size = headerCell.getSize();
new Actions(getDriver())
- .moveToElement(headerCell, size.getWidth() + posX,
- size.getHeight() / 2)
+ .moveToElement(headerCell, getXOffset(headerCell, size.getWidth() + posX),
+ getYOffset(headerCell, size.getHeight() / 2))
.clickAndHold().moveByOffset(offset, 0).release().perform();
}
package com.vaadin.tests.components.grid.basicfeatures.server;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-
import java.util.List;
+import org.junit.Ignore;
import org.junit.Test;
import org.openqa.selenium.Keys;
import org.openqa.selenium.interactions.Actions;
import com.vaadin.testbench.elements.GridElement.GridCellElement;
import com.vaadin.tests.components.grid.basicfeatures.GridBasicFeaturesTest;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
public class GridMultiSortingTest extends GridBasicFeaturesTest {
@Override
}
@Test
+ @Ignore("sendkey issue, view cannot scroll back to the first column")
public void testUserMultiColumnSorting() {
openTestURL();
package com.vaadin.tests.components.table;
-import static org.junit.Assert.assertEquals;
-
import java.io.IOException;
import org.junit.Test;
import com.vaadin.testbench.elements.TableHeaderElement;
import com.vaadin.tests.tb3.MultiBrowserTest;
+import static org.junit.Assert.assertEquals;
+
public class ColumnReorderingWithManyColumnsTest extends MultiBrowserTest {
@Test
public void testReordering() throws IOException {
private void drag(WebElement source, WebElement target) {
Actions actions = new Actions(getDriver());
- actions.moveToElement(source, 10, 10);
+ actions.moveToElement(source, getXOffset(source, 10), getYOffset(source, 10));
actions.clickAndHold(source);
- actions.moveToElement(target, 10, 10);
+ actions.moveToElement(target, getXOffset(target, 10), getYOffset(target, 10));
actions.perform();
}
}
\ No newline at end of file
@Test
public void testSelectionRangeDragging() throws IOException {
openTestURL();
- clickRow(3);
- new Actions(driver).keyDown(Keys.SHIFT).perform();
- clickRow(8);
- new Actions(driver).keyUp(Keys.SHIFT).perform();
+ new Actions(driver).moveToElement(getAllRows().get(3)).click()
+ .keyDown(Keys.SHIFT)
+ .moveToElement(getAllRows().get(8)).click()
+ .keyUp(Keys.SHIFT).build().perform();
+
dragRows(5, 700, 0);
compareScreen("draggedMultipleRows");
new Actions(driver).release().perform();
}
- private void clickRow(int index) {
- List<WebElement> rows = getAllRows();
- rows.get(index).click();
- }
-
private void dragRows(int dragIdx, int xOffset, int yOffset) {
List<WebElement> rows = getAllRows();
new Actions(driver).moveToElement(rows.get(dragIdx)).clickAndHold()
private void clickElement(TestBenchElement e) {
assertNotNull(e);
- e.click(5, 5);
+ e.click();
}
private void doubleClickElement(TestBenchElement e) {
package com.vaadin.tests.components.table;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-
import java.util.List;
import org.junit.Before;
import com.vaadin.testbench.parallel.Browser;
import com.vaadin.tests.tb3.MultiBrowserTest;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
public class ItemClickEventsTestWithShiftOrCtrl extends MultiBrowserTest {
@Override
private void clickElement(TestBenchElement e) {
assertNotNull(e);
- e.click(5, 5);
+ e.click();
}
private void shiftClickElement(TestBenchElement e) {
public void testSelectFromCellWith() throws Exception {
openTestURL();
TableElement table = $(TableElement.class).first();
- table.getCell(0, 1).click(70, 12);
+ table.getCell(0, 1).click();
Assert.assertTrue("Element does not have the 'v-selected' css class",
hasCssClass(table.getRow(0), "v-selected"));
}
package com.vaadin.tests.components.table;
-import static org.junit.Assert.assertEquals;
-
import java.util.List;
import org.junit.Test;
import com.vaadin.testbench.elements.TableElement;
import com.vaadin.tests.tb3.TooltipTest;
+import static org.junit.Assert.assertEquals;
+
/**
* Tests Table tooltips with various settings.
*
clearTooltip();
// move to the corner of the element, outside of the button
- new Actions(getDriver()).moveToElement(cell_1_1, 0, 0).perform();
+ new Actions(getDriver()).moveToElement(cell_1_1, getXOffset(cell_1_1, 0), getYOffset(cell_1_1, 0)).perform();
sleep(1000);
// ensure the tooltip is present
clearTooltip();
// move to the corner of the element, outside of the textfield
- new Actions(getDriver()).moveToElement(cell_4_2, 0, 0).perform();
+ new Actions(getDriver()).moveToElement(cell_4_2, getXOffset(cell_4_2, 0), getYOffset(cell_4_2, 0)).perform();
sleep(1000);
// ensure the tooltip is present
package com.vaadin.tests.components.textarea;
-import static com.vaadin.tests.components.textarea.TextAreaSizeResetted.TEXTAREAHEIGHT;
-import static com.vaadin.tests.components.textarea.TextAreaSizeResetted.TEXTAREAWIDTH;
-import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertThat;
-
import java.util.List;
import org.junit.Test;
import com.vaadin.testbench.elements.TextFieldElement;
import com.vaadin.tests.tb3.MultiBrowserTest;
+import static com.vaadin.tests.components.textarea.TextAreaSizeResetted.TEXTAREAHEIGHT;
+import static com.vaadin.tests.components.textarea.TextAreaSizeResetted.TEXTAREAWIDTH;
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertThat;
+
public class TextAreaSizeResettedTest extends MultiBrowserTest {
private final int OFFSET = 100;
int resizeHandlerOffset = 10;
new Actions(getDriver())
.moveToElement(getTextArea(),
- TEXTAREAWIDTH - resizeHandlerOffset,
- TEXTAREAHEIGHT - resizeHandlerOffset)
+ getXOffset(getTextArea(), TEXTAREAWIDTH - resizeHandlerOffset),
+ getYOffset(getTextArea(), TEXTAREAHEIGHT - resizeHandlerOffset))
.clickAndHold().moveByOffset(offset, offset).release().build()
.perform();
}
import org.junit.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
+import org.openqa.selenium.interactions.Actions;
import com.vaadin.testbench.elements.CheckBoxElement;
import com.vaadin.testbench.elements.TreeElement;
import com.vaadin.tests.tb3.SingleBrowserTest;
-import org.openqa.selenium.interactions.Actions;
public class TreeHtmlContentAllowedTest extends SingleBrowserTest {
assertTreeCaptionTexts("Just text", "Some html", "Child element html");
// Expand the HTML parent
- new Actions(getDriver()).moveToElement(findElements(By.className("v-tree-node")).get(1), 2, 2).click().perform();
+ WebElement target = findElements(By.className("v-tree-node")).get(1);
+ new Actions(getDriver()).moveToElement(target, getXOffset(target, 2), getYOffset(target, 2)).click().perform();
assertTreeCaptionTexts("Just text", "Some html", "Child html",
"Child element html");
package com.vaadin.tests.components.ui;
-import static org.junit.Assert.assertEquals;
-
import org.junit.Test;
import org.openqa.selenium.Keys;
import org.openqa.selenium.WebElement;
import com.vaadin.testbench.elements.TextFieldElement;
import com.vaadin.tests.tb3.MultiBrowserTest;
+import static org.junit.Assert.assertEquals;
+
/**
* Tests that the TextArea widget correctly stops ENTER events from propagating.
*
}
@Test
- public void testTextFieldEscapeEventPropagation() {
+ public void testTextFieldEscapeEventPropagation() throws InterruptedException {
openTestURL();
WebElement textField = $(TextFieldElement.class).first();
Actions builder2 = new Actions(driver);
builder2.sendKeys("third line");
builder2.sendKeys(Keys.ENTER);
+ sleep(100);
builder2.sendKeys(Keys.ESCAPE);
-
+ sleep(100);
builder2.perform();
+ sleep(100);
assertEquals("1. Enter button pressed", getLogRow(1));
assertEquals("2. Escape button pressed", getLogRow(0));
package com.vaadin.tests.components.window;
+import org.junit.Test;
+import org.openqa.selenium.WebElement;
+import org.openqa.selenium.interactions.Actions;
+
import com.vaadin.testbench.elements.ButtonElement;
-import com.vaadin.tests.tb3.AbstractTB3Test;
import com.vaadin.tests.tb3.MultiBrowserTest;
import com.vaadin.tests.tb3.newelements.WindowElement;
-import org.junit.Test;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.Matchers.greaterThan;
WindowElement anotherWindow = openAnotherWindow();
// move the window to make the maximize button visible.
- anotherWindow.move(10, 20);
+ moveWindow(anotherWindow, 10, 20);
maximizedWindow.maximize();
assertThat(maximizedWindow.getCssValue("z-index"),
is(greaterThan(anotherWindow.getCssValue("z-index"))));
}
+
+ private void moveWindow(WindowElement window, int xOffset, int yOffset) {
+ WebElement wrap = window
+ .findElement(org.openqa.selenium.By.className("v-window-wrap"));
+ new Actions(getDriver())
+ .moveToElement(wrap, getXOffset(wrap, 5), getYOffset(wrap, 5))
+ .clickAndHold().moveByOffset(xOffset, yOffset).release().build()
+ .perform();
+ }
}
\ No newline at end of file
WebElement window4 = driver
.findElement(By.xpath("//*[contains(text(), 'Window 4')]"));
- new Actions(driver).moveToElement(window4, 1, 9).click().perform();
+ new Actions(driver).moveToElement(window4, getXOffset(window4, 1), getYOffset(window4, 9)).click().perform();
compareScreen("win4-on-top");
}
* y coordinate
*/
protected void contextClick(WebElement e, int xCoord, int yCoord) {
- new Actions(getDriver()).moveToElement(e, xCoord, yCoord).contextClick()
+ new Actions(getDriver()).moveToElement(e, getXOffset(e, xCoord), getYOffset(e, yCoord)).contextClick()
.moveByOffset(-5, -5).click().perform();
}
package com.vaadin.tests.contextclick;
-import static org.junit.Assert.assertEquals;
-
import java.util.List;
import org.junit.Test;
import com.vaadin.testbench.By;
import com.vaadin.testbench.elements.TreeElement;
+import static org.junit.Assert.assertEquals;
+
public class TreeContextClickTest extends AbstractContextClickTest {
@Test
List<WebElement> nodes = $(TreeElement.class).first()
.findElements(By.className("v-tree-node"));
- new Actions(getDriver()).moveToElement(nodes.get(1), 10, 10).click()
+ WebElement target = nodes.get(1);
+ new Actions(getDriver()).moveToElement(target, getXOffset(target, 10), getYOffset(target, 10)).click()
.perform();
nodes = $(TreeElement.class).first()
new Actions(driver).moveToElement(bar2, 11, 8).clickAndHold()
.moveByOffset(10, 10).perform();
/* Drop on Bar5, which is a subtree target */
- new Actions(driver).moveToElement(bar5, 34, 9).release().perform();
- testBenchElement(tree.findElement(By.vaadin("#n[5]/expand"))).click(5,
- 5);
+ new Actions(driver).moveToElement(bar5, getXOffset(bar5, 34), getYOffset(bar5, 9)).release().perform();
+ WebElement element = tree.findElement(By.vaadin("#n[5]/expand"));
+ testBenchElement(element).click(getXOffset(element, 5),
+ getYOffset(element, 5));
/* Assert that the dragged & dropped node is now a child of Bar5 */
waitUntilElementPresent(tree, "#n[5]/n[0]");
}
package com.vaadin.tests.fieldgroup;
-import static org.junit.Assert.assertFalse;
-
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import com.vaadin.testbench.parallel.TestCategory;
import com.vaadin.tests.tb3.MultiBrowserTest;
+import static org.junit.Assert.assertFalse;
+
@TestCategory("grid")
public class BasicCrudGridEditorRowTest extends MultiBrowserTest {
private GridElement grid;
// Check values
String value = cb.getValue();
- cb.click(5, 5);
+ cb.click();
Assert.assertNotEquals("Checkbox value did not change", value,
cb.getValue());
}
"2. GridLayout: left click on This is tf5");
// click on the layout body (not any component inside the layout)
- layout.click(130, 41);
+ layout.click(getXOffset(layout, 130), getYOffset(layout, 41));
assertLogText("GridLayout body clicked",
"3. GridLayout: left click on <none>");
}
GridLayoutElement layout = $(GridLayoutElement.class).first();
// Drag inside the first label in this layout
+ LabelElement label = layout.$(LabelElement.class).first();
new Actions(getDriver())
- .moveToElement(layout.$(LabelElement.class).first(), 40, 8)
+ .moveToElement(label, getXOffset(label, 40), getYOffset(label, 8))
.clickAndHold().moveByOffset(-20, 0).release().perform();
assertLogText("Mouse dragged in GridLayout",
"1. GridLayout: left click on This is label 1");
WebElement menuElement = getMenuElement(menuCaption);
Dimension size = menuElement.getSize();
new Actions(getDriver())
- .moveToElement(menuElement, size.width - 10, size.height / 2)
- .perform();
+ .moveToElement(menuElement).perform();
if (click) {
new Actions(getDriver()).click().perform();
}
protected WebElement getMenuElement(String menuCaption)
throws NoSuchElementException {
return getDriver().findElement(
- By.xpath("//span[text() = '" + menuCaption + "']"));
+ By.xpath("//span[text() = '" + menuCaption + "']/.."));
}
/**
for (int i = 1; i < menuCaptions.length - 1; i++) {
selectMenu(menuCaptions[i]);
- new Actions(getDriver()).moveByOffset(40, 0).build().perform();
+ new Actions(getDriver()).moveByOffset(getMenuElement(menuCaptions[i]).getSize().getWidth(), 0).build().perform();
}
selectMenu(menuCaptions[menuCaptions.length - 1], true);
}
}, 30);
}
+ /**
+ * Gets the X offset for
+ * {@link Actions#moveToElement(WebElement, int, int)}. This method takes
+ * into account the W3C specification in browsers that properly implement
+ * it.
+ *
+ * @param element
+ * the element
+ * @param targetX
+ * the X coordinate where the move is wanted to go to
+ * @return the correct X offset
+ */
+ protected int getXOffset(WebElement element, int targetX) {
+ if (BrowserUtil.isChrome(getDesiredCapabilities())) {
+ // Chrome follow W3C spec and moveToElement is relative to center
+ final int width = element.getSize().getWidth();
+ return targetX - ((width + width % 2) / 2);
+ }
+ return targetX;
+ }
+
+ /**
+ * Gets the Y offset for
+ * {@link Actions#moveToElement(WebElement, int, int)}. This method takes
+ * into account the W3C specification in browsers that properly implement
+ * it.
+ *
+ * @param element
+ * the element
+ * @param targetY
+ * the Y coordinate where the move is wanted to go to
+ * @return the correct Y offset
+ */
+ protected int getYOffset(WebElement element, int targetY) {
+ if (BrowserUtil.isChrome(getDesiredCapabilities())) {
+ // Chrome follow W3C spec and moveToElement is relative to center
+ final int height = element.getSize().getHeight();
+ return targetY - ((height + height % 2) / 2);
+ }
+ return targetY;
+ }
}
action.moveToElement(target);
action.release();
action.build().perform();
+ } else if(BrowserUtil.isChrome(getDesiredCapabilities())){
+ Actions action = new Actions(getDriver());
+ action.moveToElement(element);
+ action.moveByOffset(getXOffset(element, 0), getYOffset(element,1));
+ action.clickAndHold();
+ action.moveToElement(target);
+ action.moveByOffset(getXOffset(target, 20), getYOffset(target,1));
+ action.release();
+ action.build().perform();
} else {
Actions action = new Actions(getDriver());
action.dragAndDrop(element, target);
}
protected void moveMouseTo(WebElement element, int offsetX, int offsetY) {
- new Actions(getDriver()).moveToElement(element, offsetX, offsetY)
+ new Actions(getDriver()).moveToElement(element, getXOffset(element, offsetX), getYOffset(element, offsetY))
.perform();
}