gl.addComponent(l);
}
for (int i = nr; i < nr * 2; i++) {
- gl.addComponent(new TextField("This is tf" + i, "this is tf " + i));
+ TextField tf = new TextField("This is tf" + i, "this is tf " + i);
+ tf.setWidth("130px");
+ gl.addComponent(tf);
}
}
.findElements(By.tagName("select"));
Select select = new Select(timeSelects.get(0));
+ // select two different times to ensure a value change happens
select.selectByValue("09");
- // selecting is flaky, try index selection too to ensure selection
- // actually happens
- select.selectByIndex(9);
+ select.selectByValue("08");
findElement(By.id("test-button")).click();
waitUntil(new ExpectedCondition<Boolean>() {
private void assertEditorWithinGrid() {
GridEditorElement editor = grid.getEditor();
- assertThat(editor.getLocation().y + editor.getSize().height,
- not(greaterThan(grid.getLocation().y + grid.getSize().height)));
+ // allow 1px leeway
+ assertThat(editor.getLocation().y + editor.getSize().height, not(
+ greaterThan(grid.getLocation().y + grid.getSize().height + 1)));
}
@Test
button.click();
waitUntilLoadingIndicatorNotVisible();
+ // allow small discrepancies
assertEquals("Button's position changed unexpectedly", initialX,
- button.getLocation().getX());
+ button.getLocation().getX(), 5);
assertEquals("ProgressBar's width changed unexpectedly", initialWidth,
- pb.getSize().getWidth());
+ pb.getSize().getWidth(), 5);
}
}
import java.io.IOException;
import java.util.List;
-import org.openqa.selenium.interactions.Actions;
+import org.openqa.selenium.JavascriptExecutor;
import com.vaadin.testbench.elements.CheckBoxElement;
import com.vaadin.tests.layouts.layouttester.BaseLayoutRegErrorTest;
assertEquals(3, checkBoxes.size());
CheckBoxElement lastCheckBox = checkBoxes.get(2);
- new Actions(driver).moveToElement(lastCheckBox).build().perform();
+ // moveToElement fails on Firefox since the component is out of viewport
+ ((JavascriptExecutor) driver).executeScript(
+ "arguments[0].scrollIntoView(true);", lastCheckBox);
compareScreen("RegError-Scrolled");
}
import java.io.IOException;
import java.util.List;
-import org.openqa.selenium.interactions.Actions;
+import org.openqa.selenium.JavascriptExecutor;
import com.vaadin.testbench.elements.HorizontalLayoutElement;
import com.vaadin.tests.layouts.layouttester.BaseIconTest;
HorizontalLayoutElement lastOfRow1 = layouts.get(3);
HorizontalLayoutElement lastOfRow2 = layouts.get(7);
- // scroll to both to ensure both contents are fully in view
- new Actions(driver).moveToElement(lastOfRow1).build().perform();
- new Actions(driver).moveToElement(lastOfRow2).build().perform();
+ // scroll to both to ensure both contents are fully in view,
+ // moveToElement fails on Firefox since the component is out of viewport
+ ((JavascriptExecutor) driver).executeScript(
+ "arguments[0].scrollIntoView(true);", lastOfRow1);
+ ((JavascriptExecutor) driver).executeScript(
+ "arguments[0].scrollIntoView(true);", lastOfRow2);
compareScreen("icon-scrolled");
}
import java.io.IOException;
import java.util.List;
-import org.openqa.selenium.interactions.Actions;
+import org.openqa.selenium.JavascriptExecutor;
import com.vaadin.testbench.elements.HorizontalLayoutElement;
import com.vaadin.tests.layouts.layouttester.BaseLayoutRegErrorTest;
HorizontalLayoutElement lastOfRow1 = layouts.get(4);
HorizontalLayoutElement lastOfRow2 = layouts.get(9);
- // scroll to both to ensure both contents are fully in view
- new Actions(driver).moveToElement(group3row1).build().perform();
- new Actions(driver).moveToElement(group3row2).build().perform();
+ // scroll to both to ensure both contents are fully in view,
+ // moveToElement fails on Firefox since the component is out of viewport
+ ((JavascriptExecutor) driver).executeScript(
+ "arguments[0].scrollIntoView(true);", group3row1);
+ ((JavascriptExecutor) driver).executeScript(
+ "arguments[0].scrollIntoView(true);", group3row2);
// scroll back to get the previous group at the left edge
- new Actions(driver).moveToElement(group2row1).build().perform();
- new Actions(driver).moveToElement(group2row2).build().perform();
+ ((JavascriptExecutor) driver).executeScript(
+ "arguments[0].scrollIntoView(true);", group2row1);
+ ((JavascriptExecutor) driver).executeScript(
+ "arguments[0].scrollIntoView(true);", group2row2);
compareScreen("RegError-Scrolled-Middle");
// scroll to last ones
- new Actions(driver).moveToElement(lastOfRow1).build().perform();
- new Actions(driver).moveToElement(lastOfRow2).build().perform();
+ ((JavascriptExecutor) driver).executeScript(
+ "arguments[0].scrollIntoView(true);", lastOfRow1);
+ ((JavascriptExecutor) driver).executeScript(
+ "arguments[0].scrollIntoView(true);", lastOfRow2);
compareScreen("RegError-Scrolled-End");
}
import java.io.IOException;
import java.util.List;
-import org.openqa.selenium.interactions.Actions;
+import org.openqa.selenium.JavascriptExecutor;
import com.vaadin.testbench.elements.TextFieldElement;
import com.vaadin.tests.layouts.layouttester.BaseAlignmentTest;
assertEquals(9, textFields.size());
TextFieldElement lastTextField = textFields.get(8);
- new Actions(driver).moveToElement(lastTextField).build().perform();
+ // moveToElement fails on Firefox since the component is out of viewport
+ ((JavascriptExecutor) driver).executeScript(
+ "arguments[0].scrollIntoView(true);", lastTextField);
compareScreen("alignment-scrolled");
}
import java.io.IOException;
import java.util.List;
-import org.openqa.selenium.interactions.Actions;
+import org.openqa.selenium.JavascriptExecutor;
import com.vaadin.testbench.elements.CheckBoxElement;
import com.vaadin.tests.layouts.layouttester.BaseLayoutRegErrorTest;
assertEquals(3, checkBoxes.size());
CheckBoxElement lastCheckBox = checkBoxes.get(2);
- new Actions(driver).moveToElement(lastCheckBox).build().perform();
+ // moveToElement fails on Firefox since the component is out of viewport
+ ((JavascriptExecutor) driver).executeScript(
+ "arguments[0].scrollIntoView(true);", lastCheckBox);
compareScreen("RegError-Scrolled");
}
package com.vaadin.tests.themes.valo;
import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.closeTo;
import static org.hamcrest.Matchers.equalTo;
import java.util.List;
WebElement wideMenu = menus.get(WIDE_ELEMENT_INDEX);
int wideWidth = wideMenu.getSize().width;
- assertThat(wideWidth, equalTo(WIDE_WIDTH));
+ assertThat((double) wideWidth, closeTo(WIDE_WIDTH, 1));
sleep(300);
compareScreen("defaultMenuWidths");
// Test initial renderering with contentVisible = False
TestBenchElement cell = getGrid().getCell(51, 1);
- String backgroundColor = cell.getCssValue("backgroundColor");
+ String backgroundColor = cell.getCssValue("background-color");
assertEquals("Background color was not red.", colorRed,
backgroundColor);
// Content becomes visible
cell = getGrid().getCell(51, 1);
- backgroundColor = cell.getCssValue("backgroundColor");
+ backgroundColor = cell.getCssValue("background-color");
assertNotEquals("Background color was red.", colorRed, backgroundColor);
// scroll down, new cells becomes contentVisible = False
// Cell should be red (setContentVisible set cell red)
cell = getGrid().getCell(55, 1);
- backgroundColor = cell.getCssValue("backgroundColor");
+ backgroundColor = cell.getCssValue("background-color");
assertEquals("Background color was not red.", colorRed,
backgroundColor);
sleep((int) (latency * SLEEP_MULTIPLIER));
// Cell should no longer be red
- backgroundColor = cell.getCssValue("backgroundColor");
+ backgroundColor = cell.getCssValue("background-color");
assertTrue("Background color was not reset: " + backgroundColor,
backgroundColor.equals(colorWhite)
|| backgroundColor.equals(colorDark));
if (dragHeaderCell.findElements(By.className("gwt-HTML")).isEmpty()) {
// no selectable header caption, drag freely
new Actions(getDriver()).clickAndHold(dragHeaderCell)
- .moveToElement(targetHeaderCell, horizontalOffset, 0)
+ .moveToElement(targetHeaderCell,
+ getXOffset(targetHeaderCell, horizontalOffset), 0)
.release().perform();
} else {
// avoid clicking on the caption or the text gets selected and the
.moveToElement(dragHeaderCaption,
dragHeaderCaption.getSize().getWidth() + 5, 5)
.clickAndHold()
- .moveToElement(targetHeaderCell, horizontalOffset, 0)
+ .moveToElement(targetHeaderCell,
+ getXOffset(targetHeaderCell, horizontalOffset), 0)
.release().perform();
}
}
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(
}
private void doubleClick(WebElement element) {
- new Actions(getDriver()).doubleClick(element).build().perform();
+ new Actions(getDriver()).moveToElement(element).doubleClick().build()
+ .perform();
sleep(100);
}