<!-- Dependency unpack directory -->
<dependency.unpack.directory>${project.build.directory}/dependency-unpack</dependency.unpack.directory>
- <jetty.version>9.3.7.v20160115</jetty.version>
+ <!-- Cannot use 9.3 or 9.4 because they sometimes reset the connection too early in case of errors -->
+ <jetty.version>9.2.9.v20150224</jetty.version>
<phantomjs.version>2.1.1</phantomjs.version>
</properties>
<properties>
<skip.uitest.deployment>true</skip.uitest.deployment>
<skip.uitest.failsafe>true</skip.uitest.failsafe>
+
+ <!-- Parallel test count -->
+ <parallel.tests>12</parallel.tests>
+ <reference.screenshot.dir>${project.parent.basedir}/tests/screenshots/reference</reference.screenshot.dir>
</properties>
<url>https://vaadin.com/</url>
<id>vaadin-addons</id>
<url>http://maven.vaadin.com/vaadin-addons</url>
</repository>
+ <repository>
+ <id>vaadin-snapshots</id>
+ <url>http://oss.sonatype.org/content/repositories/vaadin-snapshots</url>
+ <releases>
+ <enabled>false</enabled>
+ </releases>
+ <snapshots>
+ <enabled>true</enabled>
+ </snapshots>
+ </repository>
</repositories>
<dependencies>
<dependency>
<groupId>com.vaadin</groupId>
<artifactId>vaadin-testbench</artifactId>
- <version>4.0.3</version>
+ <version>4.3-SNAPSHOT</version>
<scope>test</scope>
</dependency>
<!-- This should be removed once tests have been updated to use lang3 -->
<include>**/AllTB3Tests.java</include>
</includes>
<systemPropertyVariables>
- <com.vaadin.testbench.screenshot.directory>${project.parent.basedir}/tests/screenshots</com.vaadin.testbench.screenshot.directory>
- <com.vaadin.testbench.max.retries>${com.vaadin.testbench.max.retries}</com.vaadin.testbench.max.retries>
- <useLocalWebDriver>${useLocalWebDriver}</useLocalWebDriver>
+ <com.vaadin.testbench.Parameters.screenshotReferenceDirectory>${reference.screenshot.dir}</com.vaadin.testbench.Parameters.screenshotReferenceDirectory>
+ <com.vaadin.testbench.Parameters.screenshotErrorDirectory>${project.build.directory}/error-screenshots</com.vaadin.testbench.Parameters.screenshotErrorDirectory>
+ <com.vaadin.testbench.Parameters.maxAttempts>${com.vaadin.testbench.Parameters.maxAttempts}</com.vaadin.testbench.Parameters.maxAttempts>
+ <com.vaadin.testbench.Parameters.testsInParallel>${parallel.tests}</com.vaadin.testbench.Parameters.testsInParallel>
+ <com.vaadin.testbench.hub.url>${com.vaadin.testbench.hub.url}</com.vaadin.testbench.hub.url>
<browsers.include>${browsers.include}</browsers.include>
<categories.include>${categoriess.include}</categories.include>
<browsers.exclude>${browsers.exclude}</browsers.exclude>
<categories.exclude>${categories.exclude}</categories.exclude>
+ <browser.factory>${browser.factory}</browser.factory>
</systemPropertyVariables>
</configuration>
<executions>
</build>
</profile>
- <profile>
- <id>validation</id>
- <activation>
- <activeByDefault>false</activeByDefault>
- </activation>
- <build>
- <pluginManagement>
- <plugins>
- <plugin>
- <artifactId>maven-failsafe-plugin</artifactId>
- <configuration>
- <systemPropertyVariables>
- <useLocalWebDriver>true</useLocalWebDriver>
- <browsers.include>phantomjs1</browsers.include>
- <categories.exclude>push,needs-ssh</categories.exclude>
- </systemPropertyVariables>
- </configuration>
- <executions>
- <execution>
- <goals>
- <goal>integration-test</goal>
- <goal>verify</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </pluginManagement>
- </build>
- </profile>
</profiles>
</project>
getPage().getStyles().add("body { width: 50% !important}");
}
-
}
-/*
- * Copyright 2000-2018 Vaadin Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
package com.vaadin.tests.components.ui;
import com.vaadin.annotations.ViewportGeneratorClass;
@ViewportGeneratorClass(MyViewportGenerator.class)
public class DynamicViewport extends AbstractTestUI {
+
+ public static final String VIEWPORT_DISABLE_PARAMETER = "noViewport";
+
public static class MyViewportGenerator implements ViewportGenerator {
@Override
public String getViewport(VaadinRequest request) {
- String userAgent = request.getHeader("User-Agent");
- System.out.println(userAgent);
- if (userAgent == null || userAgent.contains("Chrome")) {
+ if (request.getParameterMap()
+ .containsKey(VIEWPORT_DISABLE_PARAMETER)) {
return null;
}
- return userAgent;
+ return request.getHeader("User-Agent");
}
}
@Override
protected void setup(VaadinRequest request) {
- addComponent(new Label("I should have a dynamic viewport tag"));
+ String negation = request.getParameterMap()
+ .containsKey(VIEWPORT_DISABLE_PARAMETER) ? "not " : "";
+ addComponent(new Label(
+ "I should " + negation + "have a dynamic viewport tag"));
}
-}
+}
\ No newline at end of file
package com.vaadin.tests.components.ui;
-import com.vaadin.annotations.Theme;
import com.vaadin.event.ShortcutAction;
import com.vaadin.server.VaadinRequest;
import com.vaadin.ui.Button;
import com.vaadin.ui.UI;
import com.vaadin.ui.VerticalLayout;
import com.vaadin.ui.Window;
-import com.vaadin.ui.themes.ValoTheme;
-@Theme(ValoTheme.THEME_NAME)
public class WindowAndUIShortcuts extends UI {
@Override
final VerticalLayout mainLayout = new VerticalLayout();
- mainLayout.addComponent(
- new Button("Show page", new Button.ClickListener() {
- @Override
- public void buttonClick(Button.ClickEvent clickEvent) {
- final VerticalLayout pageLayout = new VerticalLayout();
- pageLayout.setSpacing(true);
+ mainLayout.addComponent(new Button("Show page", new Button.ClickListener() {
+ @Override
+ public void buttonClick(Button.ClickEvent event) {
+ final VerticalLayout pageLayout = new VerticalLayout();
+ pageLayout.setSpacing(true);
- pageLayout.addComponent(new Label("Page"));
- pageLayout.addComponent(new Button("Open dialog window",
- new Button.ClickListener() {
- @Override
- public void buttonClick(
- Button.ClickEvent clickEvent) {
- Window dialog = new Window();
- dialog.setModal(true);
- dialog.setCaption("Press ESC shortcut");
- dialog.setWidth("300px");
- dialog.setHeight("100px");
+ pageLayout.addComponent(new Label("Page"));
+ pageLayout.addComponent(
+ new Button("Open dialog window", new Button.ClickListener() {
+ @Override
+ public void buttonClick(Button.ClickEvent event) {
+ Window dialog = new Window();
+ dialog.setModal(true);
+ dialog.setCaption("Press ESC shortcut");
+ dialog.setWidth("300px");
+ dialog.setHeight("100px");
- dialog.setContent(new TextField(
- "TextField in window"));
- addWindow(dialog);
- }
- }));
- Button closeButton = new Button("Close page",
- new Button.ClickListener() {
- @Override
- public void buttonClick(
- Button.ClickEvent clickEvent) {
- mainLayout.removeComponent(pageLayout);
+ dialog.setContent(new
- Notification.show(
- "OMG! Page is also closed!");
- }
- });
- closeButton.setClickShortcut(
- ShortcutAction.KeyCode.ESCAPE);
- pageLayout.addComponent(closeButton);
+ Button("Button in window"));
- mainLayout.addComponent(pageLayout);
- mainLayout.setExpandRatio(pageLayout, 1);
- }
- }));
+ addWindow(dialog);
+ }
+ }));
+ Button closeButton = new Button("Close page", new Button.ClickListener() {
+ @Override
+ public void buttonClick(Button.ClickEvent event) {
+ mainLayout.removeComponent(pageLayout);
+
+ Notification.show("OMG! Page is also closed!");
+ }
+ });
+ closeButton.setClickShortcut(ShortcutAction.KeyCode.ESCAPE);
+ pageLayout.addComponent(closeButton);
+
+ mainLayout.addComponent(pageLayout);
+ mainLayout.setExpandRatio(pageLayout, 1);
+ }
+ }));
layout.addComponent(mainLayout);
layout.setExpandRatio(mainLayout, 1);
setContent(layout);
}
-}
+}
\ No newline at end of file
public class DateForm extends AbstractTestUIWithLog {
+ static final Date DATE = new Date(443457289789L);
@PropertyId("date1")
private DateField dateField;
@PropertyId("date2")
addComponent(discardButton);
addComponent(showBean);
- DateObject d = new DateObject(new Date(443457289789L),
- new Date(443457289789L), new Date(443457289789L),
- new Date(443457289789L));
+ DateObject d = new DateObject(DATE,
+ new Date(443543689789L), DATE,
+ DATE);
fieldGroup.setItemDataSource(new BeanItem<DateObject>(d));
}
state.list = Arrays.asList(ContentMode.HTML, ContentMode.RAW);
rpc.sendDate(new Date(1));
- rpc.sendDate(new Date(2013 - 1900, 5 - 1, 31, 11, 12, 13));
- rpc.sendDateArray(new Date[] { new Date(2013 - 1900, 1, 1),
- new Date(2012 - 1900, 1, 1) });
+ rpc.sendDate(new Date(Date.UTC(2013 - 1900, 4, 1, 11, 12, 13)));
+ rpc.sendDateArray(new Date[] { new Date(Date.UTC(2013 - 1900, 0, 31, 0, 0, 0)),
+ new Date(Date.UTC(2012 - 1900, 0, 31, 0, 0, 0)) });
state.jsonNull = Json.createNull();
state.jsonString = Json.create("a string");
state.dateArray = new Date[] { new Date(1), new Date(2) };
state.date1 = new Date(1);
- state.date2 = new Date(2013 - 1900, 5 - 1, 31, 11, 12, 13);
+ state.date2 = new Date(Date.UTC(2013 - 1900, 4, 1, 11, 12, 13));
testExtension.registerRpc(new SerializerTestRpc() {
@Override
// This method should be removed once #12785 is fixed
@Override
public List<DesiredCapabilities> getBrowsersToTest() {
- return getBrowserCapabilities(Browser.IE9, Browser.IE10, Browser.IE11,
- Browser.PHANTOMJS);
+ return getBrowserCapabilities(Browser.IE9, Browser.IE10, Browser.IE11);
}
@Test
package com.vaadin.tests.application;
+import com.vaadin.tests.tb3.SingleBrowserTest;
import org.junit.Assert;
import org.junit.Test;
import com.vaadin.testbench.elements.ButtonElement;
-import com.vaadin.tests.tb3.SingleBrowserTestPhantomJS2;
-public class TimingInfoReportedTest extends SingleBrowserTestPhantomJS2 {
+public class TimingInfoReportedTest extends SingleBrowserTest {
@Test
public void ensureTimingsAvailable() {
import com.vaadin.testbench.elements.ButtonElement;
import com.vaadin.testbench.elements.LabelElement;
import com.vaadin.tests.tb3.MultiBrowserTest;
+import org.openqa.selenium.JavascriptExecutor;
public class WebBrowserTimeZoneTest extends MultiBrowserTest {
@Test
- public void testBrowserTimeZoneInfo() throws Exception {
+ public void testBrowserTimeZoneInfo() {
openTestURL();
$(ButtonElement.class).first().click();
- assertLabelText("Browser raw offset", "7200000");
- assertLabelText("Browser to Europe/Helsinki offset difference", "0");
- assertLabelText("Browser could be in Helsinki", "Yes");
+
+ // Ask TimeZone from browser
+ String tzOffset = ((JavascriptExecutor) getDriver())
+ .executeScript("return new Date().getTimezoneOffset()")
+ .toString();
+
+ // Translate the same way as Vaadin should
+ int offsetMillis = -Integer.parseInt(tzOffset) * 60 * 1000;
+
+ // Check that server got the same value.
+ assertLabelText("Browser offset", offsetMillis);
}
- private void assertLabelText(String caption, String expected) {
+ private void assertLabelText(String caption, int expected) {
String actual = $(LabelElement.class).caption(caption).first()
.getText();
Assert.assertEquals(
String.format("Unexpected text in label '%s',", caption),
- expected, actual);
+ "" + expected, actual);
}
}
import org.junit.Assert;
import org.junit.Test;
import org.openqa.selenium.By;
+import org.openqa.selenium.Keys;
import org.openqa.selenium.WebElement;
import com.vaadin.testbench.elements.ButtonElement;
b.click();
Assert.assertEquals("1. Hello clicked", getLogRow(0));
- b.sendKeys("A");
+ b.sendKeys("a");
Assert.assertEquals("2. Hello clicked", getLogRow(0));
WebElement body = findElement(By.xpath("//body"));
- body.sendKeys("A");
+ body.sendKeys("a");
Assert.assertEquals("3. Hello clicked", getLogRow(0));
}
}
import java.util.List;
+import com.vaadin.tests.tb3.SingleBrowserTest;
import org.junit.Test;
import org.openqa.selenium.Keys;
import org.openqa.selenium.WebElement;
import com.vaadin.testbench.By;
-import com.vaadin.tests.tb3.SingleBrowserTestPhantomJS2;
import com.vaadin.tests.tb3.newelements.ComboBoxElement;
public class ComboBoxEmptyItemsKeyboardNavigationTest
- extends SingleBrowserTestPhantomJS2 {
+ extends SingleBrowserTest {
@Test
public void navigatingUpOnAnEmptyMenuDoesntThrowErrors() {
Point newComboLocation = cb.getLocation();
Point newPopupLocation = popup.getLocation();
- assertNotEquals("ComboBox didn't move on the page", 0,
- newComboLocation.y - comboLocation.y);
+ assertNotEquals("ComboBox didn't move on the page", comboLocation.y,
+ newComboLocation.y);
assertEquals("Popup didn't move with the combo box",
newComboLocation.y - comboLocation.y,
- newPopupLocation.y - popupLocation.y);
+ newPopupLocation.y - popupLocation.y, 1);
}
private void testNoScrollbars(String theme) {
@TestCategory("grid")
public class GridThemeChangeTest extends MultiBrowserTest {
- @Override
- public List<DesiredCapabilities> getBrowsersToTest() {
- // Seems like stylesheet onload is not fired on PhantomJS
- // https://github.com/ariya/phantomjs/issues/12332
- return super.getBrowsersExcludingPhantomJS();
- }
@Test
public void testThemeChange() {
@TestCategory("grid")
public class GridSortingIndicatorsTest extends MultiBrowserTest {
- @Override
- public List<DesiredCapabilities> getBrowsersToTest() {
- List<DesiredCapabilities> browsers = getBrowsersExcludingPhantomJS();
- browsers.add(PHANTOMJS2());
- return browsers;
- }
-
@Test
public void testSortingIndicators() throws IOException {
openTestURL();
public class GridClientContextMenuEventTest
extends GridBasicClientFeaturesTest {
- @Override
- public List<DesiredCapabilities> getBrowsersToTest() {
- // PhantomJS doesn't support context click..
- return getBrowsersExcludingPhantomJS();
- }
-
@Test
public void testContextMenuEventIsHandledCorrectly() {
setDebug(true);
compareScreen(theme + "-SidebarClosed2");
}
-
- @Override
- public List<DesiredCapabilities> getBrowsersToTest() {
- // phantom JS looks wrong from the beginning, so not tested
- return getBrowsersExcludingPhantomJS();
- }
}
@Test
public void ensureLoadingIndicatorShown() {
openTestURL();
+ waitForElementPresent(By.id("js"));
testBench().disableWaitForVaadin();
WebElement js = findElement(By.id("js"));
public class JavaScriptPreloadingTest extends MultiBrowserTest {
- @Override
- public List<DesiredCapabilities> getBrowsersToTest() {
- return getBrowsersExcludingPhantomJS();
- }
-
@Test
public void scriptsShouldPreloadAndExecuteInCorrectOrder()
throws InterruptedException {
/*
* Some cases tooltip doesn't disappear without some extra mouse events
*/
- new Actions(getDriver()).moveByOffset(100, -40).perform();
- new Actions(getDriver()).moveToElement($(LabelElement.class).get(1))
- .click().perform();
+ $(LabelElement.class).get(1).showTooltip();
$(LabelElement.class).get(4).showTooltip();
Assert.assertEquals(
import java.util.List;
+import com.vaadin.tests.tb3.SingleBrowserTest;
import org.junit.Assert;
import org.junit.Test;
import org.openqa.selenium.By;
import com.vaadin.testbench.elements.ButtonElement;
import com.vaadin.testbench.elements.ListSelectElement;
import com.vaadin.testbench.elements.OptionGroupElement;
-import com.vaadin.tests.tb3.SingleBrowserTestPhantomJS2;
public class ListSelectPushSelectionChangesTest
- extends SingleBrowserTestPhantomJS2 {
+ extends SingleBrowserTest {
@Test
public void testMultiSelectBehavior() {
openTestURL();
import org.junit.Test;
import org.openqa.selenium.Keys;
import org.openqa.selenium.WebElement;
+import org.openqa.selenium.interactions.Actions;
import org.openqa.selenium.interactions.HasInputDevices;
import org.openqa.selenium.interactions.Mouse;
import org.openqa.selenium.internal.Locatable;
public void testEnableParentLayoutControlByMouse() {
openTestURL();
- Mouse mouse = ((HasInputDevices) getDriver()).getMouse();
-
List<WebElement> menuItemList = driver
.findElements(By.className("v-menubar-menuitem"));
- mouse.click(((Locatable) menuItemList.get(0)).getCoordinates());
+ new Actions(getDriver()).moveToElement(menuItemList.get(1)).click()
+ .perform();
waitForElementPresent(By.className("v-menubar-popup"));
- mouse.mouseMove(((Locatable) menuItemList.get(1)).getCoordinates());
- mouse.mouseMove(((Locatable) menuItemList.get(2)).getCoordinates());
-
+ new Actions(getDriver()).moveToElement(menuItemList.get(1)).perform();
+ new Actions(getDriver()).moveToElement(menuItemList.get(2)).perform();
waitForElementPresent(By.className("v-menubar-popup"));
int count = driver.findElements(By.className("v-menubar-popup")).size();
- Assert.assertTrue("The count of open popups should be one", count == 1);
+ Assert.assertEquals("The count of open popups should be one", 1, count);
}
}
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.lessThan;
import static org.junit.Assert.assertThat;
-
-import java.util.List;
+import static org.junit.Assert.assertTrue;
import org.junit.Test;
import org.openqa.selenium.WebElement;
-import org.openqa.selenium.interactions.HasInputDevices;
-import org.openqa.selenium.interactions.Mouse;
-import org.openqa.selenium.interactions.internal.Coordinates;
-import org.openqa.selenium.internal.Locatable;
-import org.openqa.selenium.remote.DesiredCapabilities;
+import org.openqa.selenium.interactions.Actions;
import com.vaadin.testbench.elements.MenuBarElement;
import com.vaadin.tests.tb3.MultiBrowserTest;
*/
public class MenuBarTooltipsNearEdgeTest extends MultiBrowserTest {
- @Override
- public List<DesiredCapabilities> getBrowsersToTest() {
- // Tooltip test is unreliable on IE8
- return getBrowsersExcludingIE8();
- };
-
@Test
public void testTooltipLocation() {
openTestURL();
- Mouse mouse = ((HasInputDevices) getDriver()).getMouse();
- WebElement menu = $(MenuBarElement.class).first().getWrappedElement();
- Coordinates menuLocation = ((Locatable) menu).getCoordinates();
- mouse.click(menuLocation);
- mouse.mouseMove(menuLocation, 5, -40);
+
+ final MenuBarElement menuBar = $(MenuBarElement.class).first();
+ new Actions(getDriver()).moveToElement(menuBar).click()
+ .moveByOffset(0, -40).perform();
+
WebElement tooltip = getTooltipElement();
- assertThat(tooltip.getLocation().x, is(lessThan(
- menuLocation.onPage().x - tooltip.getSize().getWidth())));
+ assertTrue("Tooltip outside of the screen.",
+ tooltip.getLocation().getX() > 0
+ && tooltip.getLocation().getY() > 0);
+ assertThat("Tooltip too far to the right",
+ tooltip.getLocation().getX() + tooltip.getSize().getWidth(),
+ is(lessThan(menuBar.getLocation().getX()
+ + menuBar.getSize().getWidth() / 2)));
+ assertThat("Tooltip too low on the screen",
+ tooltip.getLocation().getY(),
+ is(lessThan(menuBar.getLocation().getY())));
}
-}
+}
\ No newline at end of file
import java.util.List;
import org.junit.Test;
+import org.openqa.selenium.interactions.Actions;
import org.openqa.selenium.interactions.HasInputDevices;
import org.openqa.selenium.interactions.Mouse;
import org.openqa.selenium.interactions.internal.Coordinates;
public void testToolTipDelay() throws InterruptedException {
openTestURL();
- Coordinates elementCoordinates = getCoordinates(
- $(MenuBarElement.class).first());
- sleep(1000);
-
- Mouse mouse = ((HasInputDevices) getDriver()).getMouse();
-
- mouse.click(elementCoordinates);
- mouse.mouseMove(elementCoordinates, 15, 40);
-
- sleep(1000);
+ final MenuBarElement menuBar = $(MenuBarElement.class).first();
+ // Open menu bar and move on top of the first menu item
+ new Actions(getDriver()).moveToElement(menuBar).click()
+ .moveByOffset(0, menuBar.getSize().getHeight()).perform();
+ // Make sure tooltip is outside of the screen
assertThat(getTooltipElement().getLocation().getX(),
is(lessThan(-1000)));
+ // Wait for tooltip to open up
sleep(3000);
+ // Make sure it's the correct tooltip
assertThat(getTooltipElement().getLocation().getX(),
- is(greaterThan(elementCoordinates.onPage().getX())));
+ is(greaterThan(menuBar.getLocation().getX())));
assertThat(getTooltipElement().getText(), is("TOOLTIP 1"));
}
}
package com.vaadin.tests.components.nativeselect;
+import com.vaadin.tests.tb3.SingleBrowserTest;
import org.junit.Assert;
import org.junit.Test;
import com.vaadin.testbench.elements.NativeSelectElement;
-import com.vaadin.tests.tb3.SingleBrowserTest;
-import com.vaadin.tests.tb3.SingleBrowserTestPhantomJS2;
-public class NativeSelectNullTest extends SingleBrowserTestPhantomJS2 {
+public class NativeSelectNullTest extends SingleBrowserTest {
@Test
public void selectNull() {
openTestURL();
String tooltipText;
openTestURL();
- showTooltip($(TextFieldElement.class).first());
+ $(TextFieldElement.class).first().showTooltip();
tooltipText = driver.findElement(By.className("v-tooltip")).getText();
assertEquals(tooltipText, "Vertical layout tooltip");
- showTooltip($(TextFieldElement.class).get(1));
+ $(TextFieldElement.class).get(1).showTooltip();
tooltipText = driver.findElement(By.className("v-tooltip")).getText();
assertEquals(tooltipText, "Horizontal layout tooltip");
}
-
- private void showTooltip(WebElement element) {
- Coordinates elementCoordinates = ((Locatable) element).getCoordinates();
- Mouse mouse = ((HasInputDevices) getDriver()).getMouse();
- mouse.mouseMove(elementCoordinates);
- }
}
import org.openqa.selenium.By;
import org.openqa.selenium.NoSuchElementException;
import org.openqa.selenium.WebElement;
-import org.openqa.selenium.interactions.HasInputDevices;
-import org.openqa.selenium.interactions.internal.Coordinates;
-import org.openqa.selenium.internal.Locatable;
+import org.openqa.selenium.interactions.Actions;
import com.vaadin.tests.tb3.MultiBrowserTest;
assertEquals("inner layout", caption.getText());
// Hover over the caption
- Coordinates coords = ((Locatable) caption).getCoordinates();
- ((HasInputDevices) getDriver()).getMouse().mouseMove(coords);
+ new Actions(getDriver()).moveToElement(caption).perform();
sleep(1000);
String selector = "Root/VNotification[0]";
assertTrue(e.getMessage().contains(selector));
}
}
-}
+}
\ No newline at end of file
import java.io.IOException;
+import com.vaadin.testbench.elements.TableElement;
import org.junit.Assert;
import org.junit.Test;
import org.openqa.selenium.JavascriptExecutor;
import com.vaadin.testbench.TestBenchElement;
import com.vaadin.testbench.elements.ButtonElement;
import com.vaadin.testbench.parallel.BrowserUtil;
-import com.vaadin.tests.components.table.CustomTableElement.ContextMenuElement;
import com.vaadin.tests.tb3.MultiBrowserTest;
public class ColumnCollapsingAndColumnExpansionTest extends MultiBrowserTest {
show2.click();
} else {
contextClick(table.getCell(0, 0));
- ContextMenuElement contextMenu = table.getContextMenu();
+ TableElement.ContextMenuElement contextMenu = table.getContextMenu();
WebElement i = contextMenu.getItem(0);
i.click();
}
import org.openqa.selenium.WebElement;
import com.vaadin.testbench.elements.TableElement;
-import com.vaadin.testbench.elementsbase.AbstractElement;
import com.vaadin.testbench.elementsbase.ServerClass;
@ServerClass("com.vaadin.ui.Table")
return wrapElement(cm, getCommandExecutor()).wrap(CollapseMenu.class);
}
- public static class CollapseMenu extends ContextMenuElement {
+ public static class CollapseMenu extends TableElement.ContextMenuElement {
}
public WebElement getCollapseMenuToggle() {
return findElement(By.className("v-table-column-selector"));
}
-
- public static class ContextMenuElement extends AbstractElement {
-
- public WebElement getItem(int index) {
- return findElement(
- By.xpath(".//table//tr[" + (index + 1) + "]//td/*"));
- }
-
- }
-
- public ContextMenuElement getContextMenu() {
- WebElement cm = getDriver().findElement(By.className("v-contextmenu"));
- return wrapElement(cm, getCommandExecutor())
- .wrap(ContextMenuElement.class);
- }
-
}
package com.vaadin.tests.components.tabsheet;
import static org.hamcrest.core.Is.is;
+import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertThat;
import java.io.IOException;
-import org.junit.Assert;
import org.junit.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
-import org.openqa.selenium.interactions.HasInputDevices;
-import org.openqa.selenium.interactions.Mouse;
-import org.openqa.selenium.interactions.internal.Coordinates;
-import org.openqa.selenium.internal.Locatable;
import com.vaadin.tests.tb3.MultiBrowserTest;
}
private void assertTabHasTooltipAndError(int index, String tooltip,
- String errorMessage) {
- showTooltip(index);
+ String errorMessage) {
+ testBenchElement(getTab(index)).showTooltip();
assertTooltip(tooltip);
assertErrorMessage(errorMessage);
}
private void assertTabHasNoTooltipNorError(int index) {
- showTooltip(index);
+ testBenchElement(getTab(index)).showTooltip();
WebElement tooltip = getCurrentTooltip();
assertThat(tooltip.getText(), is(""));
}
- private void showTooltip(int index) {
- Coordinates elementCoordinates = ((Locatable) getTab(index))
- .getCoordinates();
- Mouse mouse = ((HasInputDevices) getDriver()).getMouse();
- mouse.mouseMove(elementCoordinates);
- }
-
private WebElement getTab(int index) {
return vaadinElement(
"/VTabsheet[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild["
}
private void assertTooltip(String tooltip) {
- Assert.assertEquals(tooltip, getCurrentTooltip().getText());
+ assertEquals(tooltip, getCurrentTooltip().getText());
}
private void assertErrorMessage(String message) {
- Assert.assertEquals(message, getCurrentErrorMessage().getText());
+ assertEquals(message, getCurrentErrorMessage().getText());
}
-}
+}
\ No newline at end of file
public class TabSheetFocusedTabTest extends MultiBrowserTest {
- @Override
- public List<DesiredCapabilities> getBrowsersToTest() {
- // PhantomJS doesn't send Focus / Blur events when clicking or
- // navigating with keyboard
- return getBrowsersExcludingPhantomJS();
- }
-
@Override
protected Class<?> getUIClass() {
return TabsheetScrolling.class;
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
- findElements(By.className("v-tree-node")).get(1).click();
+ new Actions(getDriver()).moveToElement(findElements(By.className("v-tree-node")).get(1), 2, 2).click().perform();
assertTreeCaptionTexts("Just text", "Some html", "Child html",
"Child element html");
public List<DesiredCapabilities> getBrowsersToTest() {
// Ignoring Chrome 40 because of a regression. See #16636.
return getBrowserCapabilities(Browser.IE8, Browser.IE9, Browser.IE10,
- Browser.IE11, Browser.FIREFOX, Browser.PHANTOMJS);
+ Browser.IE11, Browser.FIREFOX);
}
@Test
+++ /dev/null
-package com.vaadin.tests.components.ui;
-
-import java.util.List;
-
-import org.junit.Assert;
-import org.junit.Test;
-import org.openqa.selenium.By;
-import org.openqa.selenium.WebElement;
-import org.openqa.selenium.remote.DesiredCapabilities;
-
-import com.vaadin.testbench.parallel.Browser;
-import com.vaadin.tests.tb3.MultiBrowserTest;
-
-public class DynamicViewportEmptyTest extends MultiBrowserTest {
-
- @Override
- protected Class<?> getUIClass() {
- return DynamicViewport.class;
- }
-
- @Override
- public List<DesiredCapabilities> getBrowsersToTest() {
- return getBrowserCapabilities(Browser.CHROME);
- }
-
- @Test
- public void testGeneratedEmptyViewport() {
- openTestURL();
-
- List<WebElement> viewportElements = findElements(
- By.cssSelector("meta[name=viewport]"));
-
- Assert.assertTrue("There should be no viewport tags",
- viewportElements.isEmpty());
- }
-
-}
package com.vaadin.tests.components.ui;
-import org.junit.Assert;
+import static org.junit.Assert.assertTrue;
+
+import java.util.List;
+import java.util.Locale;
+
import org.junit.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
WebElement viewportElement = findElement(
By.cssSelector("meta[name=viewport]"));
- Assert.assertTrue(
- viewportElement.getAttribute("content").contains("PhantomJS"));
+ String viewportContent = viewportElement.getAttribute("content")
+ .toLowerCase(Locale.ROOT);
+ String browserName = getDesiredCapabilities().getBrowserName()
+ .toLowerCase(Locale.ROOT);
+
+ assertTrue(viewportContent.contains(browserName));
+ }
+
+ @Test
+ public void testGeneratedEmptyViewport() {
+ openTestURL(DynamicViewport.VIEWPORT_DISABLE_PARAMETER);
+
+ List<WebElement> viewportElements = findElements(
+ By.cssSelector("meta[name=viewport]"));
+
+ assertTrue("There should be no viewport tags",
+ viewportElements.isEmpty());
}
-}
+}
\ No newline at end of file
public List<DesiredCapabilities> getBrowsersToTest() {
// IE8 and Firefox can't handle ctrl.
// IE9-11 has issues with shift and ctrl
- return getBrowserCapabilities(Browser.CHROME, Browser.PHANTOMJS);
+ return getBrowserCapabilities(Browser.CHROME);
}
@Override
import static org.hamcrest.MatcherAssert.assertThat;
import org.junit.Ignore;
-import org.junit.Rule;
import org.junit.Test;
import org.openqa.selenium.WebElement;
import com.vaadin.tests.tb3.MultiBrowserTest;
-import com.vaadin.tests.tb3.RetryOnFail;
public class TimeoutRedirectResetsOnActivityTest extends MultiBrowserTest {
- @Rule
- // Timing issues are really hard to resolve in a way that this test would be
- // 100% reliable on all browsers. Hence we shall allow one retry.
- public RetryOnFail retry = new RetryOnFail();
-
private int waitBeforeActivity = 4000;
private int communicationOverhead = 2000;
package com.vaadin.tests.components.ui;
-import org.junit.Assert;
+import static org.junit.Assert.assertTrue;
+
import org.junit.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.Keys;
import org.openqa.selenium.WebElement;
+import org.openqa.selenium.interactions.Actions;
import com.vaadin.testbench.elements.ButtonElement;
-import com.vaadin.testbench.elements.TextFieldElement;
import com.vaadin.testbench.elements.WindowElement;
import com.vaadin.tests.tb3.SingleBrowserTest;
$(ButtonElement.class).caption("Show page").first().click();
$(ButtonElement.class).caption("Open dialog window").first().click();
- WindowElement window = $(WindowElement.class).first();
- window.$(TextFieldElement.class).first().sendKeys(Keys.ESCAPE);
+ $(WindowElement.class).$(ButtonElement.class).first()
+ .sendKeys(Keys.ESCAPE);
// Window should have been closed
- Assert.assertTrue($(WindowElement.class).all().isEmpty());
+ assertTrue($(WindowElement.class).all().isEmpty());
// "Close page" should not have been clicked
- Assert.assertTrue(
- $(ButtonElement.class).caption("Close page").exists());
+ assertTrue($(ButtonElement.class).caption("Close page").exists());
}
@Test
WebElement curtain = findElement(
By.className("v-window-modalitycurtain"));
- curtain.sendKeys(Keys.ESCAPE);
+
+ // Click in the curtain next to the window and send escape
+ new Actions(getDriver()).moveToElement(curtain,
+ $(WindowElement.class).first().getSize().getWidth() * 2, 0)
+ .click().sendKeys(Keys.ESCAPE).perform();
+
// "Close page" should not have been clicked
- Assert.assertTrue(
- $(ButtonElement.class).caption("Close page").exists());
+ assertTrue($(ButtonElement.class).caption("Close page").exists());
}
-}
+}
\ No newline at end of file
package com.vaadin.tests.components.upload;
-import static org.junit.Assert.assertTrue;
-
-import java.io.BufferedWriter;
-import java.io.File;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.util.List;
-
+import com.vaadin.testbench.elements.LabelElement;
+import com.vaadin.tests.tb3.MultiBrowserTest;
+import com.vaadin.tests.util.LoremIpsum;
import org.junit.Test;
import org.openqa.selenium.By;
+import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.internal.WrapsElement;
-import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.LocalFileDetector;
import org.openqa.selenium.remote.RemoteWebElement;
-import com.vaadin.testbench.elements.ButtonElement;
-import com.vaadin.testbench.elements.LabelElement;
-import com.vaadin.testbench.elements.WindowElement;
-import com.vaadin.tests.tb3.MultiBrowserTest;
-import com.vaadin.tests.util.LoremIpsum;
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
-public class InterruptUploadTest extends MultiBrowserTest {
+import static org.junit.Assert.assertTrue;
- @Override
- public List<DesiredCapabilities> getBrowsersToTest() {
- // PhantomJS fails to upload files for unknown reasons
- return getBrowsersExcludingPhantomJS();
- }
+public class InterruptUploadTest extends MultiBrowserTest {
@Test
public void testInterruptUpload() throws Exception {
openTestURL();
File tempFile = createTempFile();
- fillPathToUploadInput(tempFile.getPath());
+ // Schedule upload cancel in a second
+ ((JavascriptExecutor)getDriver()).executeScript("setTimeout( function () {window.document.querySelector(\".v-window .v-button\").click()},2000)");
- waitForElementPresent(By.className("v-window"));
+ fillPathToUploadInput(tempFile.getPath());
- $(ButtonElement.class).caption("Cancel").first().click();
+ // Wait for 3 seconds until everything is done.
+ Thread.sleep(3000);
String expected = " (counting interrupted at ";
String actual = $(LabelElement.class).caption("Line breaks counted")
assertTrue("Line break count note does not match expected (was: "
+ actual + ")", actual.contains(expected));
- $(WindowElement.class).first()
- .findElement(By.className("v-window-closebox")).click();
- waitForElementNotPresent(By.className("v-window"));
-
- tempFile = createTempFile();
- fillPathToUploadInput(tempFile.getPath());
-
- waitForElementPresent(By.className("v-window"));
- $(ButtonElement.class).caption("Cancel").first().click();
}
/**
return sb.toString();
}
- private void fillPathToUploadInput(String tempFileName) throws Exception {
+ private void fillPathToUploadInput(String tempFileName) {
// create a valid path in upload input element. Instead of selecting a
// file by some file browsing dialog, we use the local path directly.
WebElement input = getInput();
return getDriver().findElement(By.className("gwt-FileUpload"));
}
- private void setLocalFileDetector(WebElement element) throws Exception {
+ private void setLocalFileDetector(WebElement element) {
if (getRunLocallyBrowser() != null) {
return;
}
}
}
-}
+}
\ No newline at end of file
public class TestFileUploadTest extends MultiBrowserTest {
- @Override
- public List<DesiredCapabilities> getBrowsersToTest() {
- // PhantomJS fails to upload files for unknown reasons
- return getBrowsersExcludingPhantomJS();
- }
-
@Test
public void testUploadAnyFile() throws Exception {
openTestURL();
*/
public class UploadInTabsheetTest extends MultiBrowserTest {
- @Override
- public List<DesiredCapabilities> getBrowsersToTest() {
- // PhantomJS fails to upload files for unknown reasons
- return getBrowsersExcludingPhantomJS();
- }
-
@Test
public void testThatChangingTabAfterUploadDoesntCauseErrors()
throws Exception {
import java.awt.AWTException;
import java.io.IOException;
-import java.util.List;
import org.junit.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.Point;
import org.openqa.selenium.WebElement;
-import org.openqa.selenium.interactions.HasInputDevices;
-import org.openqa.selenium.interactions.Mouse;
-import org.openqa.selenium.interactions.internal.Coordinates;
-import org.openqa.selenium.internal.Locatable;
-import org.openqa.selenium.remote.DesiredCapabilities;
+import org.openqa.selenium.interactions.Actions;
import com.vaadin.tests.tb3.MultiBrowserTest;
WebElement wnd1Footer = wnd
.findElement(By.className("v-window-footer"));
Point startLoc = wnd.getLocation();
- Coordinates footerCoordinates = ((Locatable) wnd1Footer)
- .getCoordinates();
- Mouse mouse = ((HasInputDevices) getDriver()).getMouse();
- mouse.mouseDown(footerCoordinates);
- mouse.mouseMove(footerCoordinates, 200, 200);
- mouse.mouseUp(footerCoordinates);
+
+ new Actions(getDriver()).moveToElement(wnd1Footer).clickAndHold()
+ .moveByOffset(200, 200).release().perform();
+
Point endLoc = wnd.getLocation();
// don't compare to specific coordinate, because in IE9 and IE11
// the window position is random.
- // So, checkt that the window was moved
+ // So, check that the window was moved
org.junit.Assert.assertNotEquals(startLoc, endLoc);
}
- // IE8 doesn't support shadow-box css rule
- // ignore this browser in testing
- @Override
- public List<DesiredCapabilities> getBrowsersToTest() {
- return getBrowsersExcludingIE8();
- }
}
\ No newline at end of file
package com.vaadin.tests.core;
-import java.util.Collections;
-import java.util.List;
-
import org.junit.Assert;
import org.junit.Test;
import org.openqa.selenium.WebElement;
-import org.openqa.selenium.remote.DesiredCapabilities;
import com.vaadin.testbench.By;
import com.vaadin.testbench.elements.LabelElement;
import com.vaadin.testbench.elements.MenuBarElement;
import com.vaadin.testbench.elements.TextFieldElement;
-import com.vaadin.testbench.parallel.Browser;
-import com.vaadin.tests.tb3.MultiBrowserTest;
import com.vaadin.tests.tb3.SingleBrowserTest;
-import com.vaadin.tests.tb3.SingleBrowserTestPhantomJS2;
public class SpecialCharactersEncodingUITest extends SingleBrowserTest {
return Double.parseDouble(width.replace("%", "")) / 100.0;
}
- /**
- * @since 7.5.6
- * @param indicator
- * @param string
- * @return
- */
- private String getStyleAttribute(WebElement element, String styleName) {
- String style = element.getAttribute("style");
- String[] styles = style.split(";");
- for (String s : styles) {
- if (s.startsWith(styleName + ":")) {
- return s.substring(styleName.length() + 1).trim();
- }
- }
-
- return null;
- }
-
}
compareScreen("large");
// Resize below 600px width breakpoint
- testBench().resizeViewPortTo(400, 768);
+ testBench().resizeViewPortTo(550, 768);
waitUntil(new ExpectedCondition<Boolean>() {
@Override
testBench().resizeViewPortTo(1024, 768);
}
- @Override
- public List<DesiredCapabilities> getBrowsersToTest() {
- // Seems like stylesheet onload is not fired on PhantomJS
- // https://github.com/ariya/phantomjs/issues/12332
- return getBrowsersExcludingPhantomJS();
- }
-
@Test
public void testWidthAndHeightRanges() throws Exception {
openTestURL();
import java.util.List;
+import com.vaadin.tests.tb3.SingleBrowserTest;
import org.junit.Assert;
import org.junit.Test;
import com.vaadin.testbench.elements.AbstractComponentElement;
import com.vaadin.testbench.elements.GridElement;
import com.vaadin.testbench.elements.TextFieldElement;
-import com.vaadin.tests.tb3.SingleBrowserTestPhantomJS2;
-public class BasicCrudGridTest extends SingleBrowserTestPhantomJS2 {
+public class BasicCrudGridTest extends SingleBrowserTest {
@Test
public void fieldsInitiallyEmpty() {
package com.vaadin.tests.fieldgroup;
-import org.junit.Assert;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import java.text.SimpleDateFormat;
+import java.util.Locale;
+
import org.junit.Test;
import org.openqa.selenium.WebElement;
import com.vaadin.testbench.By;
import com.vaadin.testbench.elements.DateFieldElement;
import com.vaadin.testbench.elements.InlineDateFieldElement;
-import com.vaadin.testbench.elements.PopupDateFieldElement;
import com.vaadin.testbench.elements.TextFieldElement;
import com.vaadin.tests.tb3.MultiBrowserTest;
public class DateFormTest extends MultiBrowserTest {
+ private final SimpleDateFormat FORMAT = new SimpleDateFormat(
+ "MMM dd, yyyy h:mm:ss a");
+
@Test
public void testCorrectDateFormat() throws Exception {
openTestURL();
- Assert.assertEquals("Unexpected DateField value,", "1/20/84",
+ assertEquals("Unexpected DateField value,", "1/20/84",
getDateFieldValue());
- Assert.assertEquals("Unexpected PopupDateField value,", "1/20/84",
+ assertEquals("Unexpected PopupDateField value,", "1/21/84",
getPopupDateFieldValue());
WebElement day20 = getInlineDateFieldCalendarPanel()
.findElement(By.vaadin("#day20"));
- Assert.assertTrue(
- "Unexpected InlineDateField state, 20th not selected.",
+ assertTrue("Unexpected InlineDateField state, 20th not selected.",
hasCssClass(day20,
"v-inline-datefield-calendarpanel-day-selected"));
- Assert.assertEquals("Unexpected TextField contents,",
- "Jan 20, 1984 4:34:49 PM",
+ // Depends on the TZ offset on the server
+ assertEquals("Unexpected TextField contents,",
+ FORMAT.format(DateForm.DATE),
$(TextFieldElement.class).first().getValue());
}
}
protected String getPopupDateFieldValue() {
- return $(PopupDateFieldElement.class).first().getValue();
+ return $(DateFieldElement.class).get(1).getValue();
}
protected WebElement getInlineDateFieldCalendarPanel() {
.findElement(By.className("v-inline-datefield-calendarpanel"));
}
-}
+}
\ No newline at end of file
import java.util.List;
import java.util.Map;
+import com.vaadin.testbench.parallel.ParallelRunner;
import org.junit.runners.Parameterized.Parameters;
import org.junit.runners.model.FrameworkMethod;
import org.junit.runners.model.InitializationError;
-import com.vaadin.tests.tb3.TB3Runner;
-
/**
* TestBench test runner which supports static @Parameters annotated methods
* providing parameters for the corresponding setter.
*
* @author Vaadin Ltd
*/
-public class ParameterizedTB3Runner extends TB3Runner {
+public class ParameterizedTB3Runner extends ParallelRunner {
public ParameterizedTB3Runner(Class<?> klass) throws InitializationError {
super(klass);
import org.junit.Test;
import com.vaadin.tests.tb3.SingleBrowserTest;
+import org.openqa.selenium.Dimension;
public class ConcurrentModificationUITest extends SingleBrowserTest {
@Test
public void noExceptionWhenEnlarging() {
- testBench().resizeViewPortTo(100, 100);
+ getDriver().manage().window().setSize(new Dimension(100, 100));
openTestURL("debug");
- testBench().resizeViewPortTo(200, 200);
+ getDriver().manage().window().setSize(new Dimension(200, 200));
assertNoErrorNotifications();
}
}
package com.vaadin.tests.layouts;
+import com.vaadin.tests.tb3.SingleBrowserTest;
import org.junit.Assert;
import org.junit.Test;
import com.vaadin.testbench.elements.FormLayoutElement;
import com.vaadin.testbench.elements.TextFieldElement;
-import com.vaadin.tests.tb3.SingleBrowserTestPhantomJS2;
public class RelativeSizeInUndefinedCssLayoutTest
- extends SingleBrowserTestPhantomJS2 {
+ extends SingleBrowserTest {
@Test
public void relativeSizeInUndefinedCssLayout() {
public class ReconnectLongPollingTest extends ReconnectTest {
- @Override
- public List<DesiredCapabilities> getBrowsersToTest() {
-
- // PhantomJS doesn't seem to detect disconnection on
- // Long-Polling/Streaming:
- // https://github.com/ariya/phantomjs/issues/11938
- return getBrowsersExcludingPhantomJS();
- }
-
@Override
protected Class<?> getUIClass() {
return BasicPushLongPolling.class;
public class ReconnectStreamingTest extends ReconnectTest {
- @Override
- public List<DesiredCapabilities> getBrowsersToTest() {
-
- // PhantomJS doesn't seem to detect disconnection on
- // Long-Polling/Streaming:
- // https://github.com/ariya/phantomjs/issues/11938
- return getBrowsersExcludingPhantomJS();
- }
-
@Override
protected Class<?> getUIClass() {
return BasicPushStreaming.class;
package com.vaadin.tests.serialization;
-import org.junit.Assert;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.Locale;
+import java.util.TimeZone;
+
import org.junit.Test;
import com.vaadin.tests.tb3.MultiBrowserTest;
+import org.openqa.selenium.JavascriptExecutor;
public class SerializerTestTest extends MultiBrowserTest {
+ private final SimpleDateFormat FORMAT = new SimpleDateFormat(
+ "EEE MMM dd HH:mm:ss 'GMT'Z yyyy", new Locale("en", "fi"));
+
@Test
public void testSerialization() {
+ // Set up formatting with browsers timezone
+ FORMAT.setTimeZone(getBrowserTimeZone());
+
openTestURL();
int logRow = 0;
- Assert.assertEquals(
- "sendJson: {\"b\":false,\"s\":\"JSON\"}, null, \"value\"",
+ assertEquals("sendJson: {\"b\":false,\"s\":\"JSON\"}, null, \"value\"",
getLogRow(logRow++));
- Assert.assertEquals(
- "sendDateArray: January 31, 2013 10:00:00 PM UTC January 31, 2012 10:00:00 PM UTC",
+ assertEquals(
+ "sendDateArray: January 31, 2013 12:00:00 AM UTC January 31, 2012 12:00:00 AM UTC",
getLogRow(logRow++));
- Assert.assertEquals("sendDate: May 31, 2013 8:12:13 AM UTC",
+ assertEquals("sendDate: May 1, 2013 11:12:13 AM UTC",
getLogRow(logRow++));
- Assert.assertEquals("sendDate: January 1, 1970 12:00:00 AM UTC",
+ assertEquals("sendDate: January 1, 1970 12:00:00 AM UTC",
getLogRow(logRow++));
- Assert.assertEquals(
+ assertEquals(
"sendEnum: PREFORMATTED, [HTML, RAW], [PREFORMATTED, XML]",
getLogRow(logRow++));
- Assert.assertEquals(
+ assertEquals(
"sendWrappedGenerics: {[SimpleTestBean(1)]={1=[SimpleTestBean(42)]}}",
getLogRow(logRow++));
- Assert.assertEquals(
+ assertEquals(
"sendMap: {a=SimpleTestBean(1)}, [com.vaadin.tests.widgetset.server.SerializerTestExtension=SimpleTestBean(4)], [2=com.vaadin.tests.widgetset.server.SerializerTestExtension], {SimpleTestBean(4)=SimpleTestBean(-4), SimpleTestBean(-5)=SimpleTestBean(5)}",
getLogRow(logRow++));
- Assert.assertEquals(
+ assertEquals(
"sendSet: [-12, -7, -4], class com.vaadin.tests.serialization.SerializerTest, [SimpleTestBean(2), SimpleTestBean(3)]",
getLogRow(logRow++));
- Assert.assertEquals(
+ assertEquals(
"sendArrayList: [[2], [2]], [[2, 1], [2, 3]], [[SimpleTestBean(7)]]",
getLogRow(logRow++));
- Assert.assertEquals(
+ assertEquals(
"sendList: [-234, 5, 8], class com.vaadin.tests.widgetset.server.SerializerTestExtension, class com.vaadin.tests.serialization.SerializerTest, [SimpleTestBean(-568), SimpleTestBean(234)]",
getLogRow(logRow++));
- Assert.assertEquals(
+ assertEquals(
"sendNestedArray: [[7, 5]], [[SimpleTestBean(2)], [SimpleTestBean(4)]]",
getLogRow(logRow++));
- Assert.assertEquals("sendNull: null, Not null", getLogRow(logRow++));
- Assert.assertEquals(
+ assertEquals("sendNull: null, Not null", getLogRow(logRow++));
+ assertEquals(
"sendBean: ComplexTestBean [innerBean1=SimpleTestBean(1), innerBean2=SimpleTestBean(3), innerBeanCollection=[SimpleTestBean(6), SimpleTestBean(0)], privimite=6], SimpleTestBean(0), [SimpleTestBean(7)]",
getLogRow(logRow++));
- Assert.assertEquals(
+ assertEquals(
"sendConnector: com.vaadin.tests.widgetset.server.SerializerTestExtension",
getLogRow(logRow++));
- Assert.assertEquals("sendString: Taegghiiiinnrsssstt‡, [null, ‡]",
+ assertEquals("sendString: Taegghiiiinnrsssstt‡, [null, ‡]",
getLogRow(logRow++));
- Assert.assertEquals(
+ assertEquals(
"sendDouble: 0.423310825130748, 5.859874482048838, [2.0, 1.7976931348623157E308, 4.9E-324]",
getLogRow(logRow++));
- Assert.assertEquals("sendFloat: 1.0000001, 3.14159, [-12.0, 0.0, 57.0]",
- getLogRow(logRow++));
- Assert.assertEquals("sendLong: -57841235865, 577431841358, [57, 0]",
+ assertEquals("sendFloat: 1.0000001, 3.14159, [-12.0, 0.0, 57.0]",
getLogRow(logRow++));
- Assert.assertEquals("sendInt: 2, 5, [2147483647, 0]",
+ assertEquals("sendLong: -57841235865, 577431841358, [57, 0]",
getLogRow(logRow++));
- Assert.assertEquals("sendChar: Å, ∫, [a, b, c, d]",
- getLogRow(logRow++));
- Assert.assertEquals("sendByte: 5, -12, [3, 1, 2]", getLogRow(logRow++));
- Assert.assertEquals(
+ assertEquals("sendInt: 2, 5, [2147483647, 0]", getLogRow(logRow++));
+ assertEquals("sendChar: Å, ∫, [a, b, c, d]", getLogRow(logRow++));
+ assertEquals("sendByte: 5, -12, [3, 1, 2]", getLogRow(logRow++));
+ assertEquals(
"sendBoolean: false, false, [false, false, true, false, true, true]",
getLogRow(logRow++));
- Assert.assertEquals("sendBeanSubclass: 43", getLogRow(logRow++));
- Assert.assertEquals(
- "state.dateArray: Thu Jan 01 02:00:00 GMT+200 1970 Thu Jan 01 02:00:00 GMT+200 1970",
- getLogRow(logRow++));
- Assert.assertEquals("state.date2: Fri May 31 11:12:13 GMT+300 2013",
- getLogRow(logRow++));
- Assert.assertEquals("state.date1: Thu Jan 01 02:00:00 GMT+200 1970",
- getLogRow(logRow++));
- Assert.assertEquals("state.jsonBoolean: false", getLogRow(logRow++));
- Assert.assertEquals("state.jsonString: a string", getLogRow(logRow++));
- Assert.assertEquals("state.jsonNull: NULL", getLogRow(logRow++));
- Assert.assertEquals("state.stringArray: [null, ‡]",
- getLogRow(logRow++));
- Assert.assertEquals("state.string: This is a tesing string ‡",
+ assertEquals("sendBeanSubclass: 43", getLogRow(logRow++));
+
+ // Dates from state
+ Date date1 = new Date(1);
+ Date date2 = new Date(Date.UTC(2013 - 1900, 4, 1, 11, 12, 13));
+ Date[] dateArray = new Date[] { new Date(1), new Date(2) };
+
+ StringBuilder expected = new StringBuilder();
+ for (int i = 0; i < dateArray.length; ++i) {
+ if (i > 0) {
+ expected.append(" ");
+ }
+ expected.append(formatDate(dateArray[i]));
+ }
+
+ assertEquals(
+ "state.dateArray: " + expected.toString(),
getLogRow(logRow++));
- Assert.assertEquals(
- "state.doubleArray: [1.7976931348623157e+308, 5e-324]",
+ assertEquals("state.date2: " + formatDate(date2), getLogRow(logRow++));
+ assertEquals("state.date1: " + formatDate(date1), getLogRow(logRow++));
+
+ assertEquals("state.jsonBoolean: false", getLogRow(logRow++));
+ assertEquals("state.jsonString: a string", getLogRow(logRow++));
+ assertEquals("state.jsonNull: NULL", getLogRow(logRow++));
+ assertEquals("state.stringArray: [null, ‡]", getLogRow(logRow++));
+ assertEquals("state.string: This is a tesing string ‡",
getLogRow(logRow++));
- Assert.assertEquals("state.doubleObjectValue: -2.718281828459045",
+ assertEquals("state.doubleArray: [1.7976931348623157e+308, 5e-324]",
getLogRow(logRow++));
- Assert.assertEquals("state.doubleValue: 3.141592653589793",
+ assertEquals("state.doubleObjectValue: -2.718281828459045",
getLogRow(logRow++));
- Assert.assertEquals("state.floatArray: [57, 0, -12]",
+ assertEquals("state.doubleValue: 3.141592653589793",
getLogRow(logRow++));
- Assert.assertTrue(getLogRow(logRow++)
+ assertEquals("state.floatArray: [57, 0, -12]", getLogRow(logRow++));
+ assertTrue(getLogRow(logRow++)
.startsWith("state.floatObjectValue: 1.0000001"));
- Assert.assertTrue(
- getLogRow(logRow++).startsWith("state.floatValue: 3.14159"));
- Assert.assertEquals("state.longArray: [-57841235865, 57]",
- getLogRow(logRow++));
- Assert.assertEquals("state.longObjectValue: 577431841360",
- getLogRow(logRow++));
- Assert.assertEquals("state.longValue: 577431841359",
- getLogRow(logRow++));
- Assert.assertEquals("state.intArray: [5, 7]", getLogRow(logRow++));
- Assert.assertEquals("state.intObjectValue: 42", getLogRow(logRow++));
- Assert.assertEquals("state.intValue: 2147483647", getLogRow(logRow++));
- Assert.assertEquals("state.charArray: aBcD", getLogRow(logRow++));
- Assert.assertEquals("state.charObjectValue: å", getLogRow(logRow++));
- Assert.assertEquals("state.charValue: ∫", getLogRow(logRow++));
- Assert.assertEquals("state.byteArray: [3, 1, 2]", getLogRow(logRow++));
- Assert.assertEquals("state.byteObjectValue: -12", getLogRow(logRow++));
- Assert.assertEquals("state.byteValue: 5", getLogRow(logRow++));
- Assert.assertEquals(
+ assertTrue(getLogRow(logRow++).startsWith("state.floatValue: 3.14159"));
+ assertEquals("state.longArray: [-57841235865, 57]",
+ getLogRow(logRow++));
+ assertEquals("state.longObjectValue: 577431841360",
+ getLogRow(logRow++));
+ assertEquals("state.longValue: 577431841359", getLogRow(logRow++));
+ assertEquals("state.intArray: [5, 7]", getLogRow(logRow++));
+ assertEquals("state.intObjectValue: 42", getLogRow(logRow++));
+ assertEquals("state.intValue: 2147483647", getLogRow(logRow++));
+ assertEquals("state.charArray: aBcD", getLogRow(logRow++));
+ assertEquals("state.charObjectValue: å", getLogRow(logRow++));
+ assertEquals("state.charValue: ∫", getLogRow(logRow++));
+ assertEquals("state.byteArray: [3, 1, 2]", getLogRow(logRow++));
+ assertEquals("state.byteObjectValue: -12", getLogRow(logRow++));
+ assertEquals("state.byteValue: 5", getLogRow(logRow++));
+ assertEquals(
"state.booleanArray: [true, true, false, true, false, false]",
getLogRow(logRow++));
+ }
+
+ private TimeZone getBrowserTimeZone() {
+ // Ask TimeZone from browser
+ String browserTimeZone = ((JavascriptExecutor) getDriver())
+ .executeScript(
+ "return Intl.DateTimeFormat().resolvedOptions().timeZone;")
+ .toString();
+ return TimeZone.getTimeZone(browserTimeZone);
+ }
+ private String formatDate(Date date) {
+ // JavaScript formatting drops leading 0 from offset
+ return FORMAT.format(date).replaceAll("(GMT[+-])0", "$1");
}
-}
+}
\ No newline at end of file
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;
-import com.thoughtworks.selenium.webdriven.WebDriverBackedSelenium;
import com.vaadin.server.LegacyApplication;
import com.vaadin.server.UIProvider;
import com.vaadin.testbench.TestBenchDriverProxy;
*
* @author Vaadin Ltd
*/
-@RunWith(TB3Runner.class)
public abstract class AbstractTB3Test extends ParallelTest {
@Rule
public TestName testName = new TestName();
- @Rule
- public RetryOnFail retry = new RetryOnFail();
-
/**
* Height of the screenshots we want to capture
*/
*/
private static final int BROWSER_TIMEOUT_IN_MS = 30 * 1000;
- protected static DesiredCapabilities PHANTOMJS2() {
- DesiredCapabilities phantomjs2 = new VaadinBrowserFactory()
- .create(Browser.PHANTOMJS, "2");
- // Hack for the test cluster
- phantomjs2.setCapability("phantomjs.binary.path",
- "/usr/bin/phantomjs2");
- return phantomjs2;
- }
-
private boolean debug = false;
private boolean push = false;
}
public void hitButton(String id) {
- if (BrowserUtil.isPhantomJS(getDesiredCapabilities())) {
- driver.findElement(By.id(id)).click();
- } else {
- WebDriverBackedSelenium selenium = new WebDriverBackedSelenium(
- driver, driver.getCurrentUrl());
-
- selenium.keyPress("id=" + id, "\\13");
- }
+ driver.findElement(By.id(id)).click();
}
protected void openDebugLogTab() {
import java.util.ArrayList;
import java.util.List;
+import com.vaadin.testbench.Parameters;
import org.eclipse.jgit.api.DiffCommand;
import org.eclipse.jgit.api.Git;
import org.eclipse.jgit.api.errors.GitAPIException;
}
private String getScreenshotDirectory() {
- return PrivateTB3Configuration
- .getProperty(PrivateTB3Configuration.SCREENSHOT_DIRECTORY);
+ return Parameters.getScreenshotReferenceDirectory();
}
private List<DiffEntry> getDiffsInHead(Repository repository)
Browser.FIREFOX, Browser.CHROME);
}
- protected List<DesiredCapabilities> getBrowsersExcludingPhantomJS() {
- return getBrowserCapabilities(Browser.IE8, Browser.IE9, Browser.IE10,
- Browser.IE11, Browser.CHROME, Browser.FIREFOX);
- }
-
protected List<DesiredCapabilities> getBrowsersExcludingIE() {
- return getBrowserCapabilities(Browser.FIREFOX, Browser.CHROME,
- Browser.PHANTOMJS);
+ return getBrowserCapabilities(Browser.FIREFOX, Browser.CHROME);
}
protected List<DesiredCapabilities> getBrowsersExcludingFirefox() {
// this is sometimes needed as the Firefox driver causes extra mouseOut
// events that make tooltips disappear etc.
return getBrowserCapabilities(Browser.IE8, Browser.IE9, Browser.IE10,
- Browser.IE11, Browser.CHROME, Browser.PHANTOMJS);
+ Browser.IE11, Browser.CHROME);
}
protected List<DesiredCapabilities> getBrowsersExcludingIE8() {
return getBrowserCapabilities(Browser.IE9, Browser.IE10, Browser.IE11,
- Browser.FIREFOX, Browser.CHROME, Browser.PHANTOMJS);
+ Browser.FIREFOX, Browser.CHROME);
}
protected List<DesiredCapabilities> getBrowsersSupportingShiftClick() {
// On Firefox, the driver causes additional mouseOut events causing the
// tooltip to disappear immediately. Tooltips may work in some
// particular cases, but not in general.
- return getBrowserCapabilities(Browser.CHROME, Browser.PHANTOMJS);
+ return getBrowserCapabilities(Browser.CHROME);
}
@Override
public List<DesiredCapabilities> getBrowsersToTest() {
// Uncomment Safari and Opera if those become tested browsers again.
return getBrowserCapabilities(Browser.IE8, Browser.IE9, Browser.IE10,
- Browser.IE11, Browser.FIREFOX, Browser.CHROME,
- Browser.PHANTOMJS /* , Browser.SAFARI, Browser.OPERA */);
+ Browser.IE11, Browser.FIREFOX, Browser.CHROME
+ /* , Browser.SAFARI, Browser.OPERA */);
}
protected List<DesiredCapabilities> getBrowserCapabilities(
params.add("theme=" + theme);
super.openTestURL(uiClass, params.toArray(new String[params.size()]));
}
-
- @Override
- public List<DesiredCapabilities> getBrowsersToTest() {
- List<DesiredCapabilities> browsersToTest = getBrowsersExcludingPhantomJS();
- browsersToTest.add(PHANTOMJS2());
- return browsersToTest;
- }
}
params.add("theme=" + theme);
super.openTestURL(uiClass, params.toArray(new String[params.size()]));
}
-
- @Override
- public List<DesiredCapabilities> getBrowsersToTest() {
- List<DesiredCapabilities> browsersToTest = getBrowsersExcludingPhantomJS();
- browsersToTest.add(PHANTOMJS2());
- return browsersToTest;
- }
}
import java.util.Enumeration;
import java.util.Properties;
+import com.vaadin.testbench.Parameters;
import org.junit.Assert;
import org.openqa.selenium.ie.InternetExplorerDriver;
import org.openqa.selenium.remote.DesiredCapabilities;
/**
*
*/
- public static final String SCREENSHOT_DIRECTORY = "com.vaadin.testbench.screenshot.directory";
private static final String HOSTNAME_PROPERTY = "com.vaadin.testbench.deployment.hostname";
private static final String RUN_LOCALLY_PROPERTY = "com.vaadin.testbench.runLocally";
private static final String ALLOW_RUN_LOCALLY_PROPERTY = "com.vaadin.testbench.allowRunLocally";
private static final File propertiesFile = new File("../work",
"eclipse-run-selected-test.properties");
private static final String FIREFOX_PATH = "firefox.path";
- private static final String PHANTOMJS_PATH = "phantomjs.binary.path";
+ private static final String BROWSER_FACTORY = "browser.factory";
+ private static final String BROWSERS_INCLUDE = "browsers.include";
+ private static final String BROWSERS_EXCLUDE = "browsers.exclude";
+ private static final String CATEGORIES_INCLUDE = "categories.include";
+ private static final String CATEGORIES_EXCLUDE = "categories.exclude";
static {
if (propertiesFile.exists()) {
try {
properties.load(new FileInputStream(propertiesFile));
- if (properties.containsKey(RUN_LOCALLY_PROPERTY)) {
- System.setProperty("useLocalWebDriver", "true");
- DesiredCapabilities localBrowser = getRunLocallyCapabilities();
- System.setProperty("browsers.include",
- localBrowser.getBrowserName()
- + localBrowser.getVersion());
- }
- if (properties.containsKey(FIREFOX_PATH)) {
- System.setProperty(FIREFOX_PATH,
- properties.getProperty(FIREFOX_PATH));
- }
- if (properties.containsKey(PHANTOMJS_PATH)) {
- System.setProperty(PHANTOMJS_PATH,
- properties.getProperty(PHANTOMJS_PATH));
- }
+ System.err.println("LOADED");
} catch (IOException e) {
throw new RuntimeException(e);
}
}
+
+ if (properties.containsKey(RUN_LOCALLY_PROPERTY)) {
+ System.setProperty("useLocalWebDriver", "true");
+ DesiredCapabilities localBrowser = getRunLocallyCapabilities();
+ System.setProperty("browsers.include",
+ localBrowser.getBrowserName()
+ + localBrowser.getVersion());
+ }
+
+ String[] vars = new String[] {FIREFOX_PATH, BROWSER_FACTORY, BROWSERS_INCLUDE, BROWSERS_EXCLUDE, CATEGORIES_INCLUDE, CATEGORIES_EXCLUDE};
+
+ for (String var : vars) {
+ if (properties.containsKey(var)) {
+ System.err.println("Var; " + var + ", Value: " + properties.getProperty(var));
+ System.setProperty(var, properties.getProperty(var));
+ }
+ }
+
+ final String base = Parameters.class.getName() + ".";
+ if (properties.containsKey(base + "screenshotReferenceDirectory")) {
+ Parameters.setScreenshotReferenceDirectory(properties
+ .getProperty(base + "screenshotReferenceDirectory"));
+ }
+ if (properties.containsKey(base + "screenshotErrorDirectory")) {
+ Parameters.setScreenshotErrorDirectory(properties
+ .getProperty(base + "screenshotErrorDirectory"));
+ }
}
@Override
return property;
}
- @Override
- protected String getScreenshotDirectory() {
- String screenshotDirectory = getProperty(SCREENSHOT_DIRECTORY);
- if (screenshotDirectory == null) {
- throw new RuntimeException("No screenshot directory defined. Use -D"
- + SCREENSHOT_DIRECTORY + "=<path>");
- }
- return screenshotDirectory;
- }
-
@Override
protected String getHubURL() {
String hubUrl = getProperty(HUB_URL);
+++ /dev/null
-package com.vaadin.tests.tb3;
-
-import org.junit.rules.TestRule;
-import org.junit.runner.Description;
-import org.junit.runners.model.Statement;
-
-public class RetryOnFail implements TestRule {
- @Override
- public Statement apply(Statement base, Description description) {
- return statement(base, description);
- }
-
- private Statement statement(final Statement base,
- final Description description) {
- return new Statement() {
- @Override
- public void evaluate() throws Throwable {
- Throwable caughtThrowable = null;
- int retryCount = getRetryCount();
-
- for (int i = 0; i <= retryCount; i++) {
- try {
- base.evaluate();
- return;
- } catch (Throwable t) {
- caughtThrowable = t;
- System.err
- .println(String.format("%s: run %s/%s failed.",
- description.getDisplayName(), i + 1,
- retryCount + 1));
- System.err.println(t.getMessage());
- }
- }
- throw caughtThrowable;
- }
-
- private int getRetryCount() {
- String retryCount = System
- .getProperty("com.vaadin.testbench.max.retries");
-
- if (retryCount != null && retryCount != "") {
- return Integer.parseInt(retryCount);
- }
-
- return 0;
- }
- };
- }
-}
package com.vaadin.tests.tb3;
-import java.io.File;
-import java.io.FileFilter;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-
+import com.vaadin.testbench.Parameters;
+import com.vaadin.testbench.ScreenshotOnFailureRule;
+import com.vaadin.testbench.parallel.BrowserUtil;
+import com.vaadin.testbench.screenshot.ImageFileUtil;
import org.apache.commons.io.FileUtils;
import org.junit.After;
import org.junit.Before;
import org.junit.rules.TestRule;
import org.junit.rules.TestWatcher;
import org.junit.runner.Description;
+import org.openqa.selenium.Platform;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.remote.DesiredCapabilities;
-import com.vaadin.testbench.Parameters;
-import com.vaadin.testbench.ScreenshotOnFailureRule;
-import com.vaadin.testbench.parallel.BrowserUtil;
-import com.vaadin.testbench.screenshot.ImageFileUtil;
+import java.io.File;
+import java.io.FileFilter;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
/**
* Base class which provides functionality for tests which use the automatic
@Before
public void setupScreenComparisonParameters() {
screenshotFailures = new ArrayList<String>();
-
- Parameters.setScreenshotErrorDirectory(getScreenshotErrorDirectory());
- Parameters.setScreenshotReferenceDirectory(
- getScreenshotReferenceDirectory());
}
/**
*
* In case of a failed comparison this method stores the grabbed screenshots
* in the error directory as defined by
- * {@link #getScreenshotErrorDirectory()}. It will also generate a html file
+ * {@link Parameters#getScreenshotErrorDirectory()}. It will also generate a html file
* in the same directory, comparing the screenshot with the first found
* reference.
*
*
* @param referenceFile
* The reference image file (in the directory defined by
- * {@link #getScreenshotReferenceDirectory()})
+ * {@link Parameters#getScreenshotReferenceDirectory()})
* @return the file name of the file generated in the directory defined by
- * {@link #getScreenshotErrorDirectory()} if comparison with the
+ * {@link Parameters#getScreenshotErrorDirectory()} if comparison with the
* given reference image fails.
*/
private File getErrorFileFromReference(File referenceFile) {
String absolutePath = referenceFile.getAbsolutePath();
- String screenshotReferenceDirectory = getScreenshotReferenceDirectory();
- String screenshotErrorDirectory = getScreenshotErrorDirectory();
+ String screenshotReferenceDirectory = Parameters
+ .getScreenshotReferenceDirectory();
+ String screenshotErrorDirectory = Parameters
+ .getScreenshotErrorDirectory();
// We throw an exception to safeguard against accidental reference
// deletion. See (#14446)
if (!absolutePath.contains(screenshotReferenceDirectory)) {
}
/**
- * @param testName
+ * @param identifier
+ * the screenshot name identifier
* @return the reference file name to use for the given browser, as
* described by {@literal capabilities}, and identifier
*/
return exactVersionFile;
}
- /**
- * @return the base directory of 'reference' and 'errors' screenshots
- */
- protected abstract String getScreenshotDirectory();
-
- /**
- * @return the base directory of 'reference' and 'errors' screenshots with a
- * trailing file separator
- */
- private String getScreenshotDirectoryWithTrailingSeparator() {
- String screenshotDirectory = getScreenshotDirectory();
- if (!screenshotDirectory.endsWith(File.separator)) {
- screenshotDirectory += File.separator;
- }
- return screenshotDirectory;
- }
-
- /**
- * @return the directory where reference images are stored (the 'reference'
- * folder inside the screenshot directory)
- */
- private String getScreenshotReferenceDirectory() {
- return getScreenshotDirectoryWithTrailingSeparator() + "reference";
- }
-
- /**
- * @return the directory where comparison error images should be created
- * (the 'errors' folder inside the screenshot directory)
- */
- private String getScreenshotErrorDirectory() {
- return getScreenshotDirectoryWithTrailingSeparator() + "errors";
- }
-
/**
* Checks if any screenshot comparisons failures occurred during the test
* and combines all comparison errors into one exception
/**
* @return the name of a "failure" image which is stored in the folder
- * defined by {@link #getScreenshotErrorDirectory()} when the test
+ * defined by {@link Parameters#getScreenshotErrorDirectory()} when the test
* fails
*/
private String getScreenshotFailureName() {
- return getScreenshotBaseName() + "_" + getUniqueIdentifier(null)
+ return getScreenshotBaseName() + "_" + getUniqueIdentifier(null, null)
+ "-failure.png";
}
/**
* Returns the name of the reference file based on the given parameters.
*
- * @param testName
- * @param capabilities
* @param identifier
+ * the identifier for the screenshot
* @return the full path of the reference
*/
private String getScreenshotReferenceName(String identifier) {
- return getScreenshotReferenceName(identifier, null);
+ String fileName = getScreenshotReferenceName(identifier, null);
+ File refFile = new File(fileName);
+ if (!refFile.exists() && getDesiredCapabilities().getVersion().isEmpty()) {
+ int version = 100;
+ while (version > 0) {
+ String tmpName = getScreenshotReferenceName(identifier,version--);
+ if (new File(tmpName).exists()) {
+ return tmpName;
+ }
+ }
+ }
+ return fileName;
}
/**
* version given in {@literal capabilities} is used unless it is overridden
* by the {@literal versionOverride} parameter.
*
- * @param testName
- * @param capabilities
* @param identifier
+ * the identifier for the screenshot
+ * @param versionOverride
+ * the version number to use in the screenshot name
* @return the full path of the reference
*/
private String getScreenshotReferenceName(String identifier,
Integer versionOverride) {
- return getScreenshotReferenceDirectory() + File.separator
+ String fileName = getScreenshotReferenceName(identifier,
+ versionOverride, null);
+ File refFile = new File(fileName);
+ if (!refFile.exists()
+ && getDesiredCapabilities().getPlatform() == Platform.ANY) {
+ for (Platform p : Platform.values()) {
+ String tmpName = getScreenshotReferenceName(identifier,
+ versionOverride, p);
+ if (new File(tmpName).exists()) {
+ return tmpName;
+ }
+ }
+ }
+ return fileName;
+ }
+
+ private String getScreenshotReferenceName(String identifier, Integer versionOverride, Platform platformOverride) {
+ return Parameters.getScreenshotReferenceDirectory() + File.separator
+ getScreenshotBaseName() + "_"
- + getUniqueIdentifier(versionOverride) + "_" + identifier
+ + getUniqueIdentifier(versionOverride, platformOverride) + "_" + identifier
+ ".png";
}
- private String getUniqueIdentifier(Integer versionOverride) {
+ private String getUniqueIdentifier(Integer versionOverride, Platform platformOverride) {
String testNameAndParameters = testName.getMethodName();
// runTest-wildfly9-nginx[Windows_Firefox_24][/buffering/demo][valo]
if (versionOverride != null) {
// Windows_Firefox_17_bufferingdemo_valo
- parameters = parameters.replaceFirst(
+ int indexOfBrowser = parameters.indexOf("_") + 1;
+ parameters = parameters.substring(0, indexOfBrowser) + parameters.substring(indexOfBrowser).replaceFirst(
"_" + getDesiredCapabilities().getVersion(),
"_" + versionOverride);
+
}
+
+ if (platformOverride != null) {
+ // LINUX_Firefox_17_bufferingdemo_valo
+ parameters = getPlatformName(platformOverride)
+ + parameters.substring(parameters.indexOf("_"));
+ }
+
return parameters;
}
+ private String getPlatformName(Platform platform) {
+ switch (platform) {
+ case WINDOWS:
+ // Reference file names have Windows instead of WINDOWS
+ return "Windows";
+ default:
+ return platform.name();
+ }
+ }
+
/**
* Returns the base name of the screenshot in the error directory. This is a
* name so that all files matching {@link #getScreenshotErrorBaseName()}*
*/
private String getScreenshotErrorBaseName() {
return getScreenshotReferenceName("dummy", null)
- .replace(getScreenshotReferenceDirectory(),
- getScreenshotErrorDirectory())
+ .replace(Parameters.getScreenshotReferenceDirectory(),
+ Parameters.getScreenshotErrorDirectory())
.replace("_dummy.png", "");
}
public void cleanErrorDirectory() {
// Remove any screenshots for this test from the error directory
// before running it. Leave unrelated files as-is
- File errorDirectory = new File(getScreenshotErrorDirectory());
+ File errorDirectory = new File(Parameters.getScreenshotErrorDirectory());
// Create errors directory if it does not exist
if (!errorDirectory.exists()) {
return Collections.singletonList(getRunLocallyCapabilities());
}
return Collections
- .singletonList(Browser.PHANTOMJS.getDesiredCapabilities());
+ .singletonList(Browser.CHROME.getDesiredCapabilities());
}
}
+++ /dev/null
-package com.vaadin.tests.tb3;
-
-import java.util.Collections;
-import java.util.List;
-
-import org.openqa.selenium.remote.DesiredCapabilities;
-
-public abstract class SingleBrowserTestPhantomJS2
- extends PrivateTB3Configuration {
- @Override
- public List<DesiredCapabilities> getBrowsersToTest() {
- return Collections.singletonList(PHANTOMJS2());
- }
-}
+++ /dev/null
-package com.vaadin.tests.tb3;
-
-import java.lang.reflect.Field;
-import java.lang.reflect.Modifier;
-
-import org.apache.http.client.HttpClient;
-import org.junit.runners.Parameterized;
-import org.junit.runners.model.InitializationError;
-import org.openqa.selenium.remote.internal.ApacheHttpClient;
-import org.openqa.selenium.remote.internal.HttpClientFactory;
-
-import com.vaadin.testbench.parallel.ParallelRunner;
-
-/**
- * This runner is loosely based on FactoryTestRunner by Ted Young
- * (http://tedyoung.me/2011/01/23/junit-runtime-tests-custom-runners/). The
- * generated test names give information about the parameters used (unlike
- * {@link Parameterized}).
- *
- * @since 7.1
- */
-public class TB3Runner extends ParallelRunner {
-
- /**
- * Socket timeout for HTTP connections to the grid hub. The connection is
- * closed after 30 minutes of inactivity to avoid builds hanging for up to
- * three hours per connection if the test client crashes/hangs.
- */
- private static final int SOCKET_TIMEOUT = 30 * 60 * 1000;
-
- static {
-
- // reduce socket timeout to avoid tests hanging for three hours
- try {
- Field field = ApacheHttpClient.Factory.class
- .getDeclaredField("defaultClientFactory");
- assert (Modifier.isStatic(field.getModifiers()));
- field.setAccessible(true);
- field.set(null, new HttpClientFactory() {
- @Override
- public HttpClient getGridHttpClient(int connection_timeout,
- int socket_timeout) {
-
- if (socket_timeout == 0
- || socket_timeout > SOCKET_TIMEOUT) {
- return super.getGridHttpClient(connection_timeout,
- SOCKET_TIMEOUT);
- }
-
- return super.getGridHttpClient(connection_timeout,
- socket_timeout);
- }
- });
- } catch (Exception e) {
- e.printStackTrace();
- throw new RuntimeException(
- "Changing socket timeout for TestBench failed", e);
- }
- }
-
- public TB3Runner(Class<?> klass) throws InitializationError {
- super(klass);
- }
-
-}
@Override
public DesiredCapabilities create(Browser browser) {
- String browserFactoryClass = System.getProperty("testbench.browser.factory");
+ String browserFactoryClass = System.getProperty("browser.factory");
if (browserFactoryClass != null
&& !browserFactoryClass.trim().isEmpty()) {
if (delegate == null) {
--- /dev/null
+package com.vaadin.tests.tb3;
+
+import org.openqa.selenium.Platform;
+import org.openqa.selenium.remote.DesiredCapabilities;
+
+import com.vaadin.testbench.parallel.Browser;
+import com.vaadin.testbench.parallel.DefaultBrowserFactory;
+
+public class XvfbHubBrowserFactory extends DefaultBrowserFactory {
+
+ public DesiredCapabilities create(Browser browser) {
+ switch (browser) {
+ case IE11:
+ return super.create(browser);
+ case PHANTOMJS:
+ return create(browser, "2", Platform.LINUX);
+ case CHROME:
+ return create(browser, "", Platform.ANY);
+ case FIREFOX:
+ default:
+ return create(Browser.FIREFOX, "", Platform.ANY);
+ }
+ }
+}
}
}
- private boolean isMaximized() {
- return isElementPresent(By.className(restoreBoxClass));
- }
-
private WebElement getRestoreButton() {
return findElement(By.className("v-window-restorebox"));
}
public List<DesiredCapabilities> getBrowsersToTest() {
// Seems like stylesheet onload is not fired on PhantomJS
// https://github.com/ariya/phantomjs/issues/12332
- List<DesiredCapabilities> l = getBrowsersExcludingPhantomJS();
+ List<DesiredCapabilities> l = super.getBrowsersToTest();
// For some reason, IE times out when trying to open the combobox,
// #18341
public class ThemeChangeOnTheFlyTest extends MultiBrowserTest {
- @Override
- public List<DesiredCapabilities> getBrowsersToTest() {
- // Seems like stylesheet onload is not fired on PhantomJS
- // https://github.com/ariya/phantomjs/issues/12332
- return getBrowsersExcludingPhantomJS();
- }
-
@Test
public void injectedStyleAndThemeChange() throws IOException {
openTestURL();
import java.util.List;
+import com.vaadin.testbench.elements.LabelElement;
import org.junit.Test;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.interactions.Actions;
public void testValoMenuResponsiveHover() throws Exception {
openTestURL(COLLAPSED_MENU_TEST_PARAM);
+ // Make sure mouse is not hovering the menu
+ new Actions(getDriver()).moveToElement($(LabelElement.class).first())
+ .moveByOffset(0, 300).perform();
+
compareScreen("collapsedMenu");
List<WebElement> toggles = findElements(
import java.util.List;
import org.junit.Test;
-import org.openqa.selenium.interactions.Mouse;
-import org.openqa.selenium.interactions.internal.Coordinates;
+import org.openqa.selenium.interactions.Actions;
import org.openqa.selenium.remote.DesiredCapabilities;
import com.vaadin.testbench.elements.ButtonElement;
@Test
public void tooltipsHaveQuickOpenDelay() throws InterruptedException {
openTestURL();
- Coordinates button0Coordinates = getButtonCoordinates("Button 0");
- Coordinates button1Coordinates = getButtonCoordinates("Button 1");
- Mouse mouse = getMouse();
- mouse.mouseMove(button0Coordinates, 10, 10);
+ new Actions(getDriver()).moveToElement(getButton("Button 0")).perform();
sleep(1000);
- assertThat(getTooltipElement().getLocation().x, is(greaterThan(0)));
+ assertThat(getTooltipElement().getLocation().getX(),
+ is(greaterThan(0)));
- mouse.mouseMove(button1Coordinates, 10, 10);
- assertThat(getTooltipElement().getLocation().x, is(lessThan(-1000)));
+ ButtonElement button1 = getButton("Button 1");
+ new Actions(getDriver()).moveToElement(button1).perform();
+ assertThat(getTooltipElement().getLocation().getX(),
+ is(lessThan(-1000)));
sleep(1000);
- assertThat(getTooltipElement().getLocation().x,
- is(greaterThan(button1Coordinates.onPage().x)));
- }
-
- private Coordinates getButtonCoordinates(String caption) {
- return getCoordinates(getButton(caption));
+ assertThat(getTooltipElement().getLocation().getX(),
+ is(greaterThan(button1.getLocation().getX())));
}
private ButtonElement getButton(String caption) {
return $(ButtonElement.class).caption(caption).first();
}
-}
+}
\ No newline at end of file
import java.util.List;
import org.junit.Test;
-import org.openqa.selenium.Dimension;
-import org.openqa.selenium.interactions.Mouse;
-import org.openqa.selenium.interactions.internal.Coordinates;
+import org.openqa.selenium.interactions.Actions;
import org.openqa.selenium.remote.DesiredCapabilities;
import com.vaadin.testbench.elements.ButtonElement;
@Test
public void tooltipShouldBeStationary() throws InterruptedException {
openTestURL();
+ ButtonElement button = getButtonElement();
- Mouse mouse = getMouse();
-
- moveMouseToButtonUpperLeftCorner(mouse);
+ // Top left corner
+ new Actions(getDriver()).moveToElement(button, 2, 2).perform();
sleep(3000); // wait for the tooltip to become visible
+
int originalTooltipLocationX = getTooltipLocationX();
+ assertThat("Tooltip not displayed", originalTooltipLocationX,
+ is(greaterThan(0)));
- moveMouseToButtonBottomRightCorner(mouse);
+ // Bottom right corner
+ new Actions(getDriver()).moveToElement(button,
+ button.getSize().width - 2, button.getSize().height - 2)
+ .perform();
int actualTooltipLocationX = getTooltipLocationX();
- assertThat(actualTooltipLocationX, is(greaterThan(0)));
- assertThat(actualTooltipLocationX, is(originalTooltipLocationX));
- }
-
- private Coordinates getButtonCoordinates() {
- return getCoordinates(getButtonElement());
+ assertThat("Tooltip should not move", actualTooltipLocationX,
+ is(originalTooltipLocationX));
}
private ButtonElement getButtonElement() {
return $(ButtonElement.class).first();
}
- private void moveMouseToButtonBottomRightCorner(Mouse mouse) {
- Coordinates buttonCoordinates = getButtonCoordinates();
- Dimension buttonDimensions = getButtonDimensions();
-
- mouse.mouseMove(buttonCoordinates, buttonDimensions.getWidth() - 1,
- buttonDimensions.getHeight() - 1);
- }
-
- private void moveMouseToButtonUpperLeftCorner(Mouse mouse) {
- Coordinates buttonCoordinates = getButtonCoordinates();
-
- mouse.mouseMove(buttonCoordinates, 0, 0);
- }
-
- private org.openqa.selenium.Dimension getButtonDimensions() {
- ButtonElement buttonElement = getButtonElement();
-
- return buttonElement.getWrappedElement().getSize();
- }
-
private int getTooltipLocationX() {
return getTooltipElement().getLocation().getX();
}