import com.vaadin.testbench.elements.TableElement;
import com.vaadin.tests.tb3.MultiBrowserTest;
import org.junit.Test;
-import org.openqa.selenium.By;
import org.openqa.selenium.Keys;
-import org.openqa.selenium.WebDriver;
import org.openqa.selenium.interactions.Actions;
import org.openqa.selenium.remote.DesiredCapabilities;
-import org.openqa.selenium.support.ui.ExpectedCondition;
import java.util.List;
-import java.util.NoSuchElementException;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
}
private void scrollToBottom() {
- testBenchElement(getTable().findElement(By.className("v-scrollable"))).scroll(ROWCOUNT * 30);
-
- waitUntilRowIsVisible(LASTSELECTEDROW);
- }
-
- private void waitUntilRowIsVisible(final int row) {
- waitUntil(new ExpectedCondition<Object>() {
- @Override
- public Object apply(WebDriver input) {
- try {
- return getTable().getCell(row, 0) != null;
- } catch (NoSuchElementException e) {
- return false;
- }
- }
- });
+ scrollTable(getTable(), ROWCOUNT, LASTSELECTEDROW);
}
}
\ No newline at end of file
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
-<head profile="http://selenium-ide.openqa.org/profiles/test-case">
-<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
-<link rel="selenium.base" href="" />
-<title>New Test</title>
-</head>
-<body>
-<table cellpadding="1" cellspacing="1" border="1">
-<thead>
-<tr><td rowspan="1" colspan="3">New Test</td></tr>
-</thead><tbody>
-<tr>
- <td>open</td>
- <td>/run/com.vaadin.tests.components.table.TableScrollsOnSelection?restartApplication</td>
- <td></td>
-</tr>
-<!--Scroll to the end of the page (show last items in Table)-->
-<tr>
- <td>scroll</td>
- <td>vaadin=runcomvaadintestscomponentstableTableScrollsOnSelection::</td>
- <td>2000</td>
-</tr>
-<tr>
- <td>pause</td>
- <td>300</td>
- <td></td>
-</tr>
-<!--Select the last item (79)-->
-<tr>
- <td>mouseClick</td>
- <td>vaadin=runcomvaadintestscomponentstableTableScrollsOnSelection::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VScrollTable[0]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[79]/domChild[0]/domChild[0]</td>
- <td>38,-892</td>
-</tr>
-<!--Ensure the page is not scrolled to the beginning-->
-<tr>
- <td>screenCapture</td>
- <td></td>
- <td>scrolled-down-and-selected-79</td>
-</tr>
-
-</tbody></table>
-</body>
-</html>
import com.vaadin.data.Item;
import com.vaadin.data.util.IndexedContainer;
-import com.vaadin.tests.components.TestBase;
+import com.vaadin.server.VaadinRequest;
+import com.vaadin.tests.components.AbstractTestUI;
import com.vaadin.ui.Table;
-public class TableScrollsOnSelection extends TestBase {
+public class TableScrollsOnSelection extends AbstractTestUI {
@Override
- protected void setup() {
- getMainWindow().getContent().setSizeUndefined();
+ protected void setup(VaadinRequest request) {
+ getContent().setSizeUndefined();
IndexedContainer cont = new IndexedContainer();
cont.addContainerProperty("number", String.class, null);
}
@Override
- protected String getDescription() {
+ protected String getTestDescription() {
return "The scroll position should not change when an item is selected in a Table that is higher than the view.";
}
--- /dev/null
+package com.vaadin.tests.components.table;
+
+import com.vaadin.testbench.elements.TableElement;
+import com.vaadin.tests.tb3.MultiBrowserTest;
+import org.junit.Test;
+
+import java.io.IOException;
+
+public class TableScrollsOnSelectionTest extends MultiBrowserTest {
+
+ @Test
+ public void tableIsNotScrolledOnSelect() throws IOException {
+ openTestURL();
+
+ TableElement table = $(TableElement.class).first();
+
+ scrollTable(table, 80, 79);
+
+ table.getCell(79, 0).click();
+
+ compareScreen("scrolled-down");
+ }
+}
\ No newline at end of file
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
+import java.util.NoSuchElementException;
+import com.vaadin.testbench.elements.TableElement;
import org.apache.commons.io.IOUtils;
import org.apache.http.HttpHost;
import org.apache.http.HttpResponse;
.click();
}
+ protected void waitUntilRowIsVisible(final TableElement table, final int row) {
+ waitUntil(new ExpectedCondition<Object>() {
+ @Override
+ public Object apply(WebDriver input) {
+ try {
+ return table.getCell(row, 0) != null;
+ } catch (NoSuchElementException e) {
+ return false;
+ }
+ }
+ });
+ }
+
+ protected void scrollTable(TableElement table, int rows, int rowToWait) {
+ testBenchElement(table.findElement(By.className("v-scrollable"))).scroll(rows * 30);
+
+ waitUntilRowIsVisible(table, rowToWait);
+ }
+
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE)
public @interface RunLocally {