Browse Source

Update Chrome version in Test (#11613)


1) recalculate the offset, as ChromeDriver starts to follow the standard;
2) update screenshots;
3) correct the `click()` call with using coordinates, related to 1)
4) `sendkey()` with using key.modifier adjustment
5) add sleep 
6) workaround for mastery failures
tags/8.9.0.alpha1
Zhe Sun 4 years ago
parent
commit
4665d36647
No account linked to committer's email address
35 changed files with 145 additions and 89 deletions
  1. 4
    2
      client/src/main/java/com/vaadin/client/widgets/Escalator.java
  2. 1
    1
      testbench-api/src/main/java/com/vaadin/testbench/elements/TabSheetElement.java
  3. BIN
      uitest/reference-screenshots/chrome/BaseThemeTest-testTheme_ANY_Chrome__tables-contextmenu.png
  4. BIN
      uitest/reference-screenshots/chrome/ChameleonThemeTest-testTheme_ANY_Chrome__tables-contextmenu.png
  5. BIN
      uitest/reference-screenshots/chrome/CtrlShiftMultiselectTest-testSelectionRangeDragging_ANY_Chrome__draggedMultipleRows.png
  6. BIN
      uitest/reference-screenshots/chrome/DragStartModesTest-testDragStartModes_ANY_Chrome__dragImageModeCOMPONENT_OTHER.png
  7. BIN
      uitest/reference-screenshots/chrome/GridEditorFrozenColumnsUITest-testEditorWithFrozenColumns_ANY_Chrome__noscroll.png
  8. BIN
      uitest/reference-screenshots/chrome/GridEditorFrozenColumnsUITest-testEditorWithFrozenColumns_ANY_Chrome__scrolled.png
  9. BIN
      uitest/reference-screenshots/chrome/LabelTooltipTest-testLabelToolTipChameleonTheme_ANY_Chrome__tooltipVisible.png
  10. BIN
      uitest/reference-screenshots/chrome/ReindeerThemeTest-testTheme_ANY_Chrome__tables-contextmenu.png
  11. BIN
      uitest/reference-screenshots/chrome/RunoThemeTest-testTheme_ANY_Chrome__tables-contextmenu.png
  12. BIN
      uitest/reference-screenshots/chrome/ThemeChangeOnTheFlyTest-reindeerToOthers_ANY_Chrome__reindeer.png
  13. BIN
      uitest/reference-screenshots/chrome/ValoThemeUITest-selects_ANY_Chrome__selects.png
  14. 1
    1
      uitest/src/test/java/com/vaadin/tests/VerifyBrowserVersionTest.java
  15. 5
    3
      uitest/src/test/java/com/vaadin/tests/components/colorpicker/ColorPickerUserColorChangeTest.java
  16. 6
    10
      uitest/src/test/java/com/vaadin/tests/components/datefield/PopupDateFieldExtendedRangeTest.java
  17. 14
    6
      uitest/src/test/java/com/vaadin/tests/components/embedded/EmbeddedClickListenerRelativeCoordinatesTest.java
  18. 1
    1
      uitest/src/test/java/com/vaadin/tests/components/grid/CheckboxAlignmentWithNoHeaderGridTest.java
  19. 9
    5
      uitest/src/test/java/com/vaadin/tests/components/grid/GridComponentsTest.java
  20. 3
    2
      uitest/src/test/java/com/vaadin/tests/components/grid/GridEventSentOnColumnVisibilityChangeTest.java
  21. 3
    9
      uitest/src/test/java/com/vaadin/tests/components/grid/GridExtensionCommunicationTest.java
  22. 6
    6
      uitest/src/test/java/com/vaadin/tests/components/grid/GridHeightTest.java
  23. 1
    1
      uitest/src/test/java/com/vaadin/tests/components/grid/basics/GridBasicsTest.java
  24. 4
    4
      uitest/src/test/java/com/vaadin/tests/components/grid/basics/GridSortingTest.java
  25. 2
    3
      uitest/src/test/java/com/vaadin/tests/components/menubar/MenuBarIsAutoOpenScrollingTest.java
  26. 7
    5
      uitest/src/test/java/com/vaadin/tests/components/table/ItemClickEventsTest.java
  27. 6
    5
      uitest/src/test/java/com/vaadin/tests/components/table/ItemClickEventsTestWithShiftOrCtrl.java
  28. 3
    3
      uitest/src/test/java/com/vaadin/tests/components/table/SelectableEditableTest.java
  29. 12
    6
      uitest/src/test/java/com/vaadin/tests/components/table/TableItemDescriptionGeneratorUITest.java
  30. 19
    8
      uitest/src/test/java/com/vaadin/tests/components/ui/TextAreaEventPropagationModifierKeysTest.java
  31. 7
    0
      uitest/src/test/java/com/vaadin/tests/components/uitest/ThemeTest.java
  32. 16
    6
      uitest/src/test/java/com/vaadin/tests/components/window/WindowHeaderButtonKeyboardActionsTest.java
  33. 1
    1
      uitest/src/test/java/com/vaadin/tests/fieldgroup/BasicCrudGridEditorRowTest.java
  34. 12
    0
      uitest/src/test/java/com/vaadin/tests/tb3/AbstractTB3Test.java
  35. 2
    1
      uitest/src/test/java/com/vaadin/tests/tb3/TooltipTest.java

+ 4
- 2
client/src/main/java/com/vaadin/client/widgets/Escalator.java View File



double maxWidth = Math.max(headerWidth, double maxWidth = Math.max(headerWidth,
Math.max(bodyWidth, footerWidth)); Math.max(bodyWidth, footerWidth));
if (maxWidth < 0 && header.getRowCount() == 0 && body.getRowCount() == 0 && footer.getRowCount() == 0) {
if (maxWidth < 0 && header.getRowCount() == 0
&& body.getRowCount() == 0 && footer.getRowCount() == 0) {
maxWidth = 0; maxWidth = 0;
} }
assert maxWidth >= 0 : "Got a negative max width for a column, which should be impossible."; assert maxWidth >= 0 : "Got a negative max width for a column, which should be impossible.";


double minWidth = Math.max(headerWidth, double minWidth = Math.max(headerWidth,
Math.max(bodyWidth, footerWidth)); Math.max(bodyWidth, footerWidth));
if (minWidth < 0 && header.getRowCount() == 0 && body.getRowCount() == 0 && footer.getRowCount() == 0) {
if (minWidth < 0 && header.getRowCount() == 0
&& body.getRowCount() == 0 && footer.getRowCount() == 0) {
minWidth = 0; minWidth = 0;
} }
assert minWidth >= 0 : "Got a negative min width for a column, which should be impossible."; assert minWidth >= 0 : "Got a negative min width for a column, which should be impossible.";

+ 1
- 1
testbench-api/src/main/java/com/vaadin/testbench/elements/TabSheetElement.java View File

} }
// If neither text nor icon caption was found, click at a position that // If neither text nor icon caption was found, click at a position that
// is unlikely to close the tab. // is unlikely to close the tab.
((TestBenchElement) tabCell).click(10, 10);
((TestBenchElement) tabCell).click(-5, 0);
} }


/** /**

BIN
uitest/reference-screenshots/chrome/BaseThemeTest-testTheme_ANY_Chrome__tables-contextmenu.png View File


BIN
uitest/reference-screenshots/chrome/ChameleonThemeTest-testTheme_ANY_Chrome__tables-contextmenu.png View File


BIN
uitest/reference-screenshots/chrome/CtrlShiftMultiselectTest-testSelectionRangeDragging_ANY_Chrome__draggedMultipleRows.png View File


BIN
uitest/reference-screenshots/chrome/DragStartModesTest-testDragStartModes_ANY_Chrome__dragImageModeCOMPONENT_OTHER.png View File


BIN
uitest/reference-screenshots/chrome/GridEditorFrozenColumnsUITest-testEditorWithFrozenColumns_ANY_Chrome__noscroll.png View File


BIN
uitest/reference-screenshots/chrome/GridEditorFrozenColumnsUITest-testEditorWithFrozenColumns_ANY_Chrome__scrolled.png View File


BIN
uitest/reference-screenshots/chrome/LabelTooltipTest-testLabelToolTipChameleonTheme_ANY_Chrome__tooltipVisible.png View File


BIN
uitest/reference-screenshots/chrome/ReindeerThemeTest-testTheme_ANY_Chrome__tables-contextmenu.png View File


BIN
uitest/reference-screenshots/chrome/RunoThemeTest-testTheme_ANY_Chrome__tables-contextmenu.png View File


BIN
uitest/reference-screenshots/chrome/ThemeChangeOnTheFlyTest-reindeerToOthers_ANY_Chrome__reindeer.png View File


BIN
uitest/reference-screenshots/chrome/ValoThemeUITest-selects_ANY_Chrome__selects.png View File


+ 1
- 1
uitest/src/test/java/com/vaadin/tests/VerifyBrowserVersionTest.java View File

// Chrome version does not necessarily match the desired version // Chrome version does not necessarily match the desired version
// because of auto updates... // because of auto updates...
browserIdentifier = getExpectedUserAgentString( browserIdentifier = getExpectedUserAgentString(
getDesiredCapabilities()) + "74";
getDesiredCapabilities()) + "75";
} else if (BrowserUtil.isFirefox(getDesiredCapabilities())) { } else if (BrowserUtil.isFirefox(getDesiredCapabilities())) {
browserIdentifier = getExpectedUserAgentString( browserIdentifier = getExpectedUserAgentString(
getDesiredCapabilities()) + "58"; getDesiredCapabilities()) + "58";

+ 5
- 3
uitest/src/test/java/com/vaadin/tests/components/colorpicker/ColorPickerUserColorChangeTest.java View File

package com.vaadin.tests.components.colorpicker; package com.vaadin.tests.components.colorpicker;


import com.vaadin.tests.tb3.MultiBrowserTest;
import org.junit.Test; import org.junit.Test;
import org.openqa.selenium.By; import org.openqa.selenium.By;
import org.openqa.selenium.WebElement; import org.openqa.selenium.WebElement;


import com.vaadin.tests.tb3.SingleBrowserTest;

import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;


public class ColorPickerUserColorChangeTest extends MultiBrowserTest {
public class ColorPickerUserColorChangeTest extends SingleBrowserTest {


@Test @Test
public void testUserOriginatedTrue() { public void testUserOriginatedTrue() {
openTestURL(); openTestURL();
waitUntilLoadingIndicatorNotVisible();
// Open colorPicker // Open colorPicker
findElement(By.className("v-button-v-colorpicker ")).click();
findElement(By.className("v-button-v-colorpicker")).click();
sleep(2000); sleep(2000);
// click somewhere inside the gradient layer // click somewhere inside the gradient layer
findElement(By.className("v-colorpicker-gradient-clicklayer")).click(); findElement(By.className("v-colorpicker-gradient-clicklayer")).click();

+ 6
- 10
uitest/src/test/java/com/vaadin/tests/components/datefield/PopupDateFieldExtendedRangeTest.java View File

package com.vaadin.tests.components.datefield; 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.ArrayList;
import java.util.List; import java.util.List;


import com.vaadin.testbench.parallel.BrowserUtil; import com.vaadin.testbench.parallel.BrowserUtil;
import com.vaadin.tests.tb3.MultiBrowserTest; 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. * Tests contents and functionality of PopupDateField's popup.
* *
// navigate to previous month // navigate to previous month
WebElement popupBody = popup WebElement popupBody = popup
.findElement(By.className("v-datefield-calendarpanel")); .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 // TODO: remove this once #14406 has been fixed
if (BrowserUtil.isIE(getDesiredCapabilities()) if (BrowserUtil.isIE(getDesiredCapabilities())
assertEquals("unexpected day content", "7", days.get(41).getText()); assertEquals("unexpected day content", "7", days.get(41).getText());


// navigate to previous year // navigate to previous year
new Actions(driver).keyDown(Keys.SHIFT).perform();
popupBody.sendKeys(Keys.ARROW_DOWN);
new Actions(driver).keyUp(Keys.SHIFT).perform();
new Actions(driver).sendKeys(Keys.chord(Keys.SHIFT, Keys.ARROW_DOWN));


// TODO: remove this once #14406 has been fixed // TODO: remove this once #14406 has been fixed
popup.findElement(By.className("v-datefield-calendarpanel-prevyear")) popup.findElement(By.className("v-datefield-calendarpanel-prevyear"))

+ 14
- 6
uitest/src/test/java/com/vaadin/tests/components/embedded/EmbeddedClickListenerRelativeCoordinatesTest.java View File

package com.vaadin.tests.components.embedded; package com.vaadin.tests.components.embedded;


import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;

import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.openqa.selenium.By; import org.openqa.selenium.By;
import org.openqa.selenium.interactions.Actions;


import com.vaadin.testbench.elements.EmbeddedElement; import com.vaadin.testbench.elements.EmbeddedElement;
import com.vaadin.testbench.elements.LabelElement; import com.vaadin.testbench.elements.LabelElement;
import com.vaadin.testbench.parallel.BrowserUtil; import com.vaadin.testbench.parallel.BrowserUtil;
import com.vaadin.tests.tb3.MultiBrowserTest; import com.vaadin.tests.tb3.MultiBrowserTest;


import static org.junit.Assert.assertEquals;

public class EmbeddedClickListenerRelativeCoordinatesTest public class EmbeddedClickListenerRelativeCoordinatesTest
extends MultiBrowserTest { extends MultiBrowserTest {


"Reported X-coordinate from Embedded does not match click location", "Reported X-coordinate from Embedded does not match click location",
expectedX, x); expectedX, x);


// IE10 and IE11 sometimes click one pixel below the given position
int tolerance = isIE() ? 1 : 0;
// IE10 and IE11 sometimes click one pixel below the given position,
// so does the Chrome(since 75)
int tolerance;
if (isIE() || isChrome()) {
tolerance = 1;
} else {
tolerance = 0;
}
assertEquals( assertEquals(
"Reported Y-coordinate from Embedded does not match click location", "Reported Y-coordinate from Embedded does not match click location",
expectedY, y, tolerance); expectedY, y, tolerance);
return BrowserUtil.isIE(getDesiredCapabilities()); return BrowserUtil.isIE(getDesiredCapabilities());
} }


private boolean isChrome() {
return BrowserUtil.isChrome(getDesiredCapabilities());
}

} }

+ 1
- 1
uitest/src/test/java/com/vaadin/tests/components/grid/CheckboxAlignmentWithNoHeaderGridTest.java View File

Assert.assertTrue("This should be an empty grid", Assert.assertTrue("This should be an empty grid",
grid.getRowCount() == 0); grid.getRowCount() == 0);


for (int i =0; i<5; i++) {
for (int i = 0; i < 5; i++) {
$(ButtonElement.class).first().click(); $(ButtonElement.class).first().click();
} }
sleep(100); sleep(100);

+ 9
- 5
uitest/src/test/java/com/vaadin/tests/components/grid/GridComponentsTest.java View File

package com.vaadin.tests.components.grid; package com.vaadin.tests.components.grid;


import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;

import java.util.Locale; import java.util.Locale;
import java.util.stream.IntStream; import java.util.stream.IntStream;
import java.util.stream.Stream; import java.util.stream.Stream;
import com.vaadin.testbench.elements.GridElement; import com.vaadin.testbench.elements.GridElement;
import com.vaadin.testbench.elements.GridElement.GridCellElement; import com.vaadin.testbench.elements.GridElement.GridCellElement;
import com.vaadin.testbench.elements.GridElement.GridRowElement; import com.vaadin.testbench.elements.GridElement.GridRowElement;
import com.vaadin.testbench.parallel.BrowserUtil;
import com.vaadin.testbench.elements.LabelElement; import com.vaadin.testbench.elements.LabelElement;
import com.vaadin.testbench.elements.NotificationElement; import com.vaadin.testbench.elements.NotificationElement;
import com.vaadin.testbench.elements.TextFieldElement; import com.vaadin.testbench.elements.TextFieldElement;
import com.vaadin.testbench.parallel.BrowserUtil;
import com.vaadin.tests.tb3.MultiBrowserTest; import com.vaadin.tests.tb3.MultiBrowserTest;


import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;

public class GridComponentsTest extends MultiBrowserTest { public class GridComponentsTest extends MultiBrowserTest {


@Test @Test
// Navigate to out of viewport TextField in Header // Navigate to out of viewport TextField in Header
new Actions(getDriver()).sendKeys(Keys.chord(Keys.SHIFT, Keys.TAB)) new Actions(getDriver()).sendKeys(Keys.chord(Keys.SHIFT, Keys.TAB))
.perform(); .perform();
// After Chrome 75, sendkeys issues
if (BrowserUtil.isChrome(getDesiredCapabilities())) {
grid.getHeaderCell(1, 0).findElement(By.id("headerField")).click();
}
assertEquals("Focus should be in TextField in Header", "headerField", assertEquals("Focus should be in TextField in Header", "headerField",
getFocusedElement().getAttribute("id")); getFocusedElement().getAttribute("id"));
assertEquals("Grid should've scrolled back to start.", 0, assertEquals("Grid should've scrolled back to start.", 0,

+ 3
- 2
uitest/src/test/java/com/vaadin/tests/components/grid/GridEventSentOnColumnVisibilityChangeTest.java View File

import com.vaadin.testbench.elements.GridElement; import com.vaadin.testbench.elements.GridElement;
import com.vaadin.tests.tb3.SingleBrowserTest; import com.vaadin.tests.tb3.SingleBrowserTest;


public class GridEventSentOnColumnVisibilityChangeTest extends SingleBrowserTest {
public class GridEventSentOnColumnVisibilityChangeTest
extends SingleBrowserTest {


@Test @Test
public void changeVisibilityAssertLog() { public void changeVisibilityAssertLog() {
getSidebarOpenButton(grid).click(); getSidebarOpenButton(grid).click();
// hide the first column // hide the first column
getSidebarPopup().findElements(By.tagName("td")).get(0).click(); getSidebarPopup().findElements(By.tagName("td")).get(0).click();
Assert.assertTrue("Log content should match", Assert.assertTrue("Log content should match",
"1. UserOriginated: true".equals(getLogRow(0))); "1. UserOriginated: true".equals(getLogRow(0)));
} }

+ 3
- 9
uitest/src/test/java/com/vaadin/tests/components/grid/GridExtensionCommunicationTest.java View File

package com.vaadin.tests.components.grid; package com.vaadin.tests.components.grid;


import static org.junit.Assert.assertEquals;

import org.junit.Test; import org.junit.Test;


import com.vaadin.testbench.elements.GridElement; import com.vaadin.testbench.elements.GridElement;
import com.vaadin.testbench.parallel.TestCategory; import com.vaadin.testbench.parallel.TestCategory;
import com.vaadin.tests.tb3.SingleBrowserTest; import com.vaadin.tests.tb3.SingleBrowserTest;


import static org.junit.Assert.assertEquals;

@TestCategory("grid") @TestCategory("grid")
public class GridExtensionCommunicationTest extends SingleBrowserTest { public class GridExtensionCommunicationTest extends SingleBrowserTest {


openTestURL(); openTestURL();


GridCellElement cell = $(GridElement.class).first().getCell(0, 1); GridCellElement cell = $(GridElement.class).first().getCell(0, 1);
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( assertEquals(
"1. Click on Person first name 1 last name 1 on column second", "1. Click on Person first name 1 last name 1 on column second",
getLogRow(1)); getLogRow(1));
assertEquals("2. MouseEventDetails: left (" + expectedX + ", "
+ expectedY + ")", getLogRow(0));

} }
} }

+ 6
- 6
uitest/src/test/java/com/vaadin/tests/components/grid/GridHeightTest.java View File

package com.vaadin.tests.components.grid; 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 static org.junit.Assert.fail;

import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.Map.Entry; import java.util.Map.Entry;
import com.vaadin.testbench.parallel.TestCategory; import com.vaadin.testbench.parallel.TestCategory;
import com.vaadin.tests.tb3.MultiBrowserTest; 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;
import static org.junit.Assert.fail;

/** /**
* Tests that Grid gets correct height based on height mode, and resizes * Tests that Grid gets correct height based on height mode, and resizes
* properly with details row if height is undefined. * properly with details row if height is undefined.
detailsRowHeight, "opened" }); detailsRowHeight, "opened" });
} }


row.click(getXOffset(row, 5), getYOffset(row, 5));
row.click(5, 5);
waitForElementNotPresent(By.id("lbl1")); waitForElementNotPresent(By.id("lbl1"));


int afterHeight = grid.getSize().getHeight(); int afterHeight = grid.getSize().getHeight();

+ 1
- 1
uitest/src/test/java/com/vaadin/tests/components/grid/basics/GridBasicsTest.java View File

private int getHorizontalOffsetForDragAndDrop(GridCellElement columnHeader, private int getHorizontalOffsetForDragAndDrop(GridCellElement columnHeader,
CellSide cellSide) { CellSide cellSide) {
if (cellSide == CellSide.LEFT) { if (cellSide == CellSide.LEFT) {
return 5;
return -5;
} else { } else {
int half = columnHeader.getSize().getWidth() / 2; int half = columnHeader.getSize().getWidth() / 2;
return half + half / 2; return half + half / 2;

+ 4
- 4
uitest/src/test/java/com/vaadin/tests/components/grid/basics/GridSortingTest.java View File

package com.vaadin.tests.components.grid.basics; package com.vaadin.tests.components.grid.basics;


import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;

import java.util.Collections; import java.util.Collections;
import java.util.Comparator; import java.util.Comparator;
import java.util.Date; import java.util.Date;


import com.vaadin.testbench.parallel.Browser; import com.vaadin.testbench.parallel.Browser;


import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;

public class GridSortingTest extends GridBasicsTest { public class GridSortingTest extends GridBasicsTest {


public static final Comparator<DataObject> BIG_RANDOM = Comparator public static final Comparator<DataObject> BIG_RANDOM = Comparator
@Test @Test
public void testSortByMultipleColumnsByUser() { public void testSortByMultipleColumnsByUser() {
getGridElement().getHeaderCell(0, 7).click(); getGridElement().getHeaderCell(0, 7).click();
getGridElement().getHeaderCell(0, 6).click(20, 20, Keys.SHIFT);
getGridElement().getHeaderCell(0, 6).click(0, 0, Keys.SHIFT);


int i = 0; int i = 0;
for (Integer rowNumber : getTestData() for (Integer rowNumber : getTestData()

+ 2
- 3
uitest/src/test/java/com/vaadin/tests/components/menubar/MenuBarIsAutoOpenScrollingTest.java View File



// here we have to use pause() because LazyCloser in VMenuBar auto // here we have to use pause() because LazyCloser in VMenuBar auto
// closes submenus popup in 750 ms. // closes submenus popup in 750 ms.
actions.moveToElement(subMenuPopup, subMenuPopup.getSize().width / 2,
100).clickAndHold().pause(1000).moveByOffset(0, 200).release()
.perform();
actions.moveToElement(subMenuPopup, 0, 100).clickAndHold().pause(1000)
.moveByOffset(0, 200).release().perform();


// subMenuPopup should still be presented // subMenuPopup should still be presented
waitUntil(ExpectedConditions waitUntil(ExpectedConditions

+ 7
- 5
uitest/src/test/java/com/vaadin/tests/components/table/ItemClickEventsTest.java View File

package com.vaadin.tests.components.table; package com.vaadin.tests.components.table;


import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;

import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;


import com.vaadin.testbench.TestBenchElement; import com.vaadin.testbench.TestBenchElement;
import com.vaadin.testbench.elements.TableElement;
import com.vaadin.testbench.elements.CheckBoxElement; import com.vaadin.testbench.elements.CheckBoxElement;
import com.vaadin.testbench.elements.LabelElement; import com.vaadin.testbench.elements.LabelElement;
import com.vaadin.testbench.elements.TableElement;
import com.vaadin.tests.tb3.MultiBrowserTest; import com.vaadin.tests.tb3.MultiBrowserTest;


import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;

public class ItemClickEventsTest extends MultiBrowserTest { public class ItemClickEventsTest extends MultiBrowserTest {


@Before @Before


private void clickElement(TestBenchElement e) { private void clickElement(TestBenchElement e) {
assertNotNull(e); assertNotNull(e);
e.click(5, 5);
e.click();
} }


private void doubleClickElement(TestBenchElement e) { private void doubleClickElement(TestBenchElement e) {
// Select the first item // Select the first item
clickElement(table.getRow(0)); clickElement(table.getRow(0));
assertLog("left click on table/Item 0"); assertLog("left click on table/Item 0");
sleep(100);


// Do it again // Do it again
clickElement(table.getRow(0)); clickElement(table.getRow(0));


// Check log output // Check log output
assertLog("left click on table/Item 1"); assertLog("left click on table/Item 1");
sleep(500);


// Click row 1 again // Click row 1 again
clickElement(table.getRow(1)); clickElement(table.getRow(1));

+ 6
- 5
uitest/src/test/java/com/vaadin/tests/components/table/ItemClickEventsTestWithShiftOrCtrl.java View File

package com.vaadin.tests.components.table; package com.vaadin.tests.components.table;


import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;

import java.util.List; import java.util.List;


import org.junit.Before; import org.junit.Before;
import org.openqa.selenium.remote.DesiredCapabilities; import org.openqa.selenium.remote.DesiredCapabilities;


import com.vaadin.testbench.TestBenchElement; import com.vaadin.testbench.TestBenchElement;
import com.vaadin.testbench.elements.TableElement;
import com.vaadin.testbench.elements.CheckBoxElement; import com.vaadin.testbench.elements.CheckBoxElement;
import com.vaadin.testbench.elements.LabelElement; import com.vaadin.testbench.elements.LabelElement;
import com.vaadin.testbench.elements.TableElement;
import com.vaadin.testbench.parallel.Browser; import com.vaadin.testbench.parallel.Browser;
import com.vaadin.tests.tb3.MultiBrowserTest; import com.vaadin.tests.tb3.MultiBrowserTest;


import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;

public class ItemClickEventsTestWithShiftOrCtrl extends MultiBrowserTest { public class ItemClickEventsTestWithShiftOrCtrl extends MultiBrowserTest {


@Override @Override


private void clickElement(TestBenchElement e) { private void clickElement(TestBenchElement e) {
assertNotNull(e); assertNotNull(e);
e.click(5, 5);
e.click();
} }


private void shiftClickElement(TestBenchElement e) { private void shiftClickElement(TestBenchElement e) {
// Click item 10, verify log output // Click item 10, verify log output
clickElement(table.getCell(9, 0)); clickElement(table.getCell(9, 0));
assertLog("left click on table/Item 9"); assertLog("left click on table/Item 9");
sleep(100);


// Click it again, should not deselect // Click it again, should not deselect
ctrlClickElement(table.getCell(9, 0)); ctrlClickElement(table.getCell(9, 0));

+ 3
- 3
uitest/src/test/java/com/vaadin/tests/components/table/SelectableEditableTest.java View File

package com.vaadin.tests.components.table; package com.vaadin.tests.components.table;


import static org.junit.Assert.assertTrue;

import org.junit.Test; import org.junit.Test;


import com.vaadin.testbench.elements.TableElement; import com.vaadin.testbench.elements.TableElement;
import com.vaadin.tests.tb3.MultiBrowserTest; import com.vaadin.tests.tb3.MultiBrowserTest;


import static org.junit.Assert.assertTrue;

public class SelectableEditableTest extends MultiBrowserTest { public class SelectableEditableTest extends MultiBrowserTest {
@Test @Test
public void testSelectFromCellWith() throws Exception { public void testSelectFromCellWith() throws Exception {
openTestURL(); openTestURL();
TableElement table = $(TableElement.class).first(); TableElement table = $(TableElement.class).first();
table.getCell(0, 1).click(70, 12);
table.getCell(0, 1).click();
assertTrue("Element does not have the 'v-selected' css class", assertTrue("Element does not have the 'v-selected' css class",
hasCssClass(table.getRow(0), "v-selected")); hasCssClass(table.getRow(0), "v-selected"));
} }

+ 12
- 6
uitest/src/test/java/com/vaadin/tests/components/table/TableItemDescriptionGeneratorUITest.java View File

package com.vaadin.tests.components.table; package com.vaadin.tests.components.table;


import static org.junit.Assert.assertEquals;

import java.util.List; import java.util.List;


import org.junit.Test; import org.junit.Test;


import com.vaadin.testbench.By; import com.vaadin.testbench.By;
import com.vaadin.testbench.TestBenchElement; import com.vaadin.testbench.TestBenchElement;
import com.vaadin.testbench.elements.TableElement;
import com.vaadin.testbench.elements.CheckBoxElement; import com.vaadin.testbench.elements.CheckBoxElement;
import com.vaadin.testbench.elements.TableElement;
import com.vaadin.tests.tb3.TooltipTest; import com.vaadin.tests.tb3.TooltipTest;


import static org.junit.Assert.assertEquals;

/** /**
* Tests Table tooltips with various settings. * Tests Table tooltips with various settings.
* *
new Actions(getDriver()).moveToElement(checkboxes.get(2)).perform(); new Actions(getDriver()).moveToElement(checkboxes.get(2)).perform();


// move to the corner of the cell // move to the corner of the cell
new Actions(getDriver()).moveToElement(cell_3_0, 0, 0).perform();
moveToCorner(cell_3_0);
sleep(1000); sleep(1000);


// ensure the tooltip is present // ensure the tooltip is present
clearTooltip(); clearTooltip();


// move to the corner of the element, outside of the button // move to the corner of the element, outside of the button
new Actions(getDriver()).moveToElement(cell_1_1, 0, 0).perform();
moveToCorner(cell_1_1);
sleep(1000); sleep(1000);


// ensure the tooltip is present // ensure the tooltip is present
clearTooltip(); clearTooltip();


// move to the corner of the element, outside of the textfield // move to the corner of the element, outside of the textfield
new Actions(getDriver()).moveToElement(cell_4_2, 0, 0).perform();
moveToCorner(cell_4_2);
sleep(1000); sleep(1000);


// ensure the tooltip is present // ensure the tooltip is present
clearTooltip(); clearTooltip();
} }


private void moveToCorner(TestBenchElement cell) {
new Actions(getDriver())
.moveToElement(cell, getXOffset(cell, 0), getYOffset(cell, 0))
.perform();
}

} }

+ 19
- 8
uitest/src/test/java/com/vaadin/tests/components/ui/TextAreaEventPropagationModifierKeysTest.java View File

package com.vaadin.tests.components.ui; package com.vaadin.tests.components.ui;


import static org.junit.Assert.assertEquals;

import org.junit.Test; import org.junit.Test;
import org.openqa.selenium.Keys; import org.openqa.selenium.Keys;
import org.openqa.selenium.WebElement; import org.openqa.selenium.WebElement;
import org.openqa.selenium.interactions.Actions; import org.openqa.selenium.interactions.Actions;


import com.vaadin.testbench.elements.TextAreaElement; import com.vaadin.testbench.elements.TextAreaElement;
import com.vaadin.tests.tb3.MultiBrowserTest;
import com.vaadin.tests.tb3.SingleBrowserTest;

import static org.junit.Assert.assertEquals;

public class TextAreaEventPropagationModifierKeysTest
extends SingleBrowserTest {


public class TextAreaEventPropagationModifierKeysTest extends MultiBrowserTest {
@Test @Test
public void textAreaShiftEnterEventPropagation() public void textAreaShiftEnterEventPropagation()
throws InterruptedException { throws InterruptedException {
openTestURL(); openTestURL();

WebElement textArea = $(TextAreaElement.class).first();
Actions builder = new Actions(driver); Actions builder = new Actions(driver);
WebElement textArea = $(TextAreaElement.class).first();
builder.click(textArea); builder.click(textArea);
builder.sendKeys(textArea, "first line asdf"); builder.sendKeys(textArea, "first line asdf");
builder.sendKeys(Keys.chord(Keys.SHIFT, Keys.ENTER));
pressKeyCombinations(Keys.SHIFT, Keys.ENTER);
builder.sendKeys(textArea, "second line jkl;"); builder.sendKeys(textArea, "second line jkl;");
builder.perform(); builder.perform();


Actions builder = new Actions(driver); Actions builder = new Actions(driver);
builder.click(textArea); builder.click(textArea);
builder.sendKeys(textArea, "first line asdf"); builder.sendKeys(textArea, "first line asdf");
builder.sendKeys(Keys.chord(Keys.CONTROL, Keys.ENTER));
pressKeyCombinations(Keys.CONTROL, Keys.ENTER);
builder.sendKeys(textArea, "second line jkl;"); builder.sendKeys(textArea, "second line jkl;");
builder.perform(); builder.perform();


protected Class<?> getUIClass() { protected Class<?> getUIClass() {
return TextAreaEventPropagation.class; return TextAreaEventPropagation.class;
} }

// That is a workaround after Chrome 75, sendKeys(Keys.shift, Keys.Tab)
// doesn't work
protected void pressKeyCombinations(Keys keyModifier, Keys key) {

Actions builder = new Actions(driver);
builder.keyDown(keyModifier).perform();
builder.sendKeys(Keys.chord(key)).perform();
builder.keyUp(keyModifier).perform();
}
} }

+ 7
- 0
uitest/src/test/java/com/vaadin/tests/components/uitest/ThemeTest.java View File



import java.io.IOException; import java.io.IOException;


import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.openqa.selenium.Keys; import org.openqa.selenium.Keys;
import org.openqa.selenium.WebElement; import org.openqa.selenium.WebElement;
import org.openqa.selenium.interactions.Actions; import org.openqa.selenium.interactions.Actions;


import com.vaadin.testbench.By; import com.vaadin.testbench.By;
import com.vaadin.testbench.Parameters;
import com.vaadin.testbench.elements.ButtonElement; import com.vaadin.testbench.elements.ButtonElement;
import com.vaadin.testbench.elements.ComboBoxElement; import com.vaadin.testbench.elements.ComboBoxElement;
import com.vaadin.testbench.elements.DateFieldElement; import com.vaadin.testbench.elements.DateFieldElement;


protected abstract String getTheme(); protected abstract String getTheme();


@Before
public void before() {
Parameters.setScreenshotComparisonTolerance(0.1);
}

@Test @Test
public void testTheme() throws Exception { public void testTheme() throws Exception {
openTestURL("theme=" + getTheme()); openTestURL("theme=" + getTheme());

+ 16
- 6
uitest/src/test/java/com/vaadin/tests/components/window/WindowHeaderButtonKeyboardActionsTest.java View File

package com.vaadin.tests.components.window; package com.vaadin.tests.components.window;


import static org.junit.Assert.assertTrue;

import java.io.IOException; import java.io.IOException;


import org.junit.Test; import org.junit.Test;


import com.vaadin.testbench.By; import com.vaadin.testbench.By;
import com.vaadin.testbench.elements.WindowElement; import com.vaadin.testbench.elements.WindowElement;
import com.vaadin.tests.tb3.MultiBrowserTest;
import com.vaadin.tests.tb3.SingleBrowserTest;

import static org.junit.Assert.assertTrue;


public class WindowHeaderButtonKeyboardActionsTest extends MultiBrowserTest {
public class WindowHeaderButtonKeyboardActionsTest extends SingleBrowserTest {


private static final String HEADER_CLASS = "v-window-header"; private static final String HEADER_CLASS = "v-window-header";
private static final String RESTORE_BOX_CLASS = "v-window-restorebox"; private static final String RESTORE_BOX_CLASS = "v-window-restorebox";
pressKeyAndWait(Keys.TAB); pressKeyAndWait(Keys.TAB);
assertTrue("Window's close button is the focused element", assertTrue("Window's close button is the focused element",
!closeButton.equals(driver.switchTo().activeElement())); !closeButton.equals(driver.switchTo().activeElement()));
pressKeyAndWait(Keys.SHIFT, Keys.TAB);

pressKeyCombinations(Keys.SHIFT, Keys.TAB);
assertTrue("Window's close button is not the focused element", assertTrue("Window's close button is not the focused element",
closeButton.equals(driver.switchTo().activeElement())); closeButton.equals(driver.switchTo().activeElement()));


pressKeyAndWait(Keys.TAB); pressKeyAndWait(Keys.TAB);
assertTrue("Window's maximize button is the focused element", assertTrue("Window's maximize button is the focused element",
!maximizeButton.equals(driver.switchTo().activeElement())); !maximizeButton.equals(driver.switchTo().activeElement()));
pressKeyAndWait(Keys.SHIFT, Keys.TAB);
pressKeyCombinations(Keys.SHIFT, Keys.TAB);
assertTrue("Window's maximize button is not the focused element", assertTrue("Window's maximize button is not the focused element",
maximizeButton.equals(driver.switchTo().activeElement())); maximizeButton.equals(driver.switchTo().activeElement()));


new Actions(driver).sendKeys(key).build().perform(); new Actions(driver).sendKeys(key).build().perform();
sleep(1000); sleep(1000);
} }

// That is a workaround after Chrome 75, sendKeys(Keys.shift, Keys.Tab)
// doesn't work
protected void pressKeyCombinations(Keys keyModifier, Keys key) {

new Actions(getDriver()).keyDown(keyModifier).perform();
new Actions(getDriver()).sendKeys(Keys.chord(key)).perform();
new Actions(getDriver()).keyUp(keyModifier).perform();
}
} }

+ 1
- 1
uitest/src/test/java/com/vaadin/tests/fieldgroup/BasicCrudGridEditorRowTest.java View File



// Check values // Check values
String value = cb.getValue(); String value = cb.getValue();
cb.click(5, 5);
cb.click();
assertNotEquals("Checkbox value did not change", value, cb.getValue()); assertNotEquals("Checkbox value did not change", value, cb.getValue());
} }



+ 12
- 0
uitest/src/test/java/com/vaadin/tests/tb3/AbstractTB3Test.java View File

final int width = element.getSize().getWidth(); final int width = element.getSize().getWidth();
return targetX - ((width + width % 2) / 2); return targetX - ((width + width % 2) / 2);
} }

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; return targetX;
} }


final int height = element.getSize().getHeight(); final int height = element.getSize().getHeight();
return targetY - ((height + height % 2) / 2); return targetY - ((height + height % 2) / 2);
} }

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; return targetY;
} }



+ 2
- 1
uitest/src/test/java/com/vaadin/tests/tb3/TooltipTest.java View File

} }


protected void moveMouseTo(WebElement element, int offsetX, int offsetY) { 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(); .perform();
} }



Loading…
Cancel
Save