summaryrefslogtreecommitdiffstats
path: root/uitest/src/test
diff options
context:
space:
mode:
authorcaalador <mikael.grankvist@gmail.com>2017-02-07 09:16:07 +0200
committerGitHub <noreply@github.com>2017-02-07 09:16:07 +0200
commita642d536bb74ee3ecfc9b082c32a1e728c6a5a75 (patch)
tree59db09f10d26e91e9f2ac90aa2bcd68bf9c1daaa /uitest/src/test
parent75998972bae46255ff12a761720f35e4463e75c6 (diff)
downloadvaadin-framework-a642d536bb74ee3ecfc9b082c32a1e728c6a5a75.tar.gz
vaadin-framework-a642d536bb74ee3ecfc9b082c32a1e728c6a5a75.zip
Fix problem with re-opening the popup (#8446) (#8454)
Fixed problem that disables opening of popup after closing it by clicking the datefield-button.
Diffstat (limited to 'uitest/src/test')
-rw-r--r--uitest/src/test/java/com/vaadin/tests/components/datefield/PopupDateFieldTest.java82
1 files changed, 82 insertions, 0 deletions
diff --git a/uitest/src/test/java/com/vaadin/tests/components/datefield/PopupDateFieldTest.java b/uitest/src/test/java/com/vaadin/tests/components/datefield/PopupDateFieldTest.java
new file mode 100644
index 0000000000..cc50da6f98
--- /dev/null
+++ b/uitest/src/test/java/com/vaadin/tests/components/datefield/PopupDateFieldTest.java
@@ -0,0 +1,82 @@
+/*
+ * Copyright 2000-2014 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.datefield;
+
+import org.junit.Test;
+import org.openqa.selenium.WebDriver;
+import org.openqa.selenium.WebElement;
+import org.openqa.selenium.support.ui.ExpectedCondition;
+import org.openqa.selenium.support.ui.ExpectedConditions;
+
+import com.vaadin.testbench.By;
+import com.vaadin.testbench.elements.PopupDateFieldElement;
+import com.vaadin.tests.tb3.MultiBrowserTest;
+
+public class PopupDateFieldTest extends MultiBrowserTest {
+
+ @Test
+ public void testOpenCloseOpen_popupShouldBeOpen() throws Exception {
+ openTestURL();
+
+ WebElement toggleButton = $(PopupDateFieldElement.class).first()
+ .findElement(By.className("v-datefield-button"));
+
+ toggleButton.click();
+
+ assertThatPopupIsVisible();
+
+ toggleButton.click();
+
+ assertThatPopupIsInvisible();
+
+ // We should be able to immediately open the popup from the popup after
+ // clicking the button to close it. (#8446)
+ toggleButton.click();
+
+ assertThatPopupIsVisible();
+ }
+
+ private void assertThatPopupIsVisible() {
+ waitUntil(ExpectedConditions.visibilityOfElementLocated(
+ org.openqa.selenium.By.className("v-datefield-popup")));
+ }
+
+ private void assertThatPopupIsInvisible() {
+ // ExpectedConditions.invisibilityOfElementLocated doesn't work
+ // with PhantomJS when running with a hub:
+ // https://code.google.com/p/selenium/issues/detail?id=5000
+ // so we need to make our own.
+
+ waitUntil(new ExpectedCondition<Boolean>() {
+ @Override
+ public Boolean apply(WebDriver input) {
+ try {
+ return !(findElement(By.className("v-datefield-popup"))
+ .isDisplayed());
+ } catch (Exception e) {
+ return true;
+ }
+ }
+
+ @Override
+ public String toString() {
+ // Timed out after 10 seconds waiting for ...
+ return "popup to not be visible";
+ }
+ });
+ }
+
+}