diff options
author | Henri Sara <henri.sara@gmail.com> | 2017-02-03 13:15:13 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-02-03 13:15:13 +0200 |
commit | 167e733f1f998976569b448a1b6f52854d5e8d1e (patch) | |
tree | ec95228bcf7a5fba9f16479e3aae2c3cea4b4660 | |
parent | 641351ed72a4469f9bd092b178b9e45468e7ab6b (diff) | |
download | vaadin-framework-167e733f1f998976569b448a1b6f52854d5e8d1e.tar.gz vaadin-framework-167e733f1f998976569b448a1b6f52854d5e8d1e.zip |
Fix some broken tests and ComboBoxElement (#8430)
3 files changed, 34 insertions, 15 deletions
diff --git a/testbench-api/src/main/java/com/vaadin/testbench/elements/ComboBoxElement.java b/testbench-api/src/main/java/com/vaadin/testbench/elements/ComboBoxElement.java index dd538cecc1..dc6a59d360 100644 --- a/testbench-api/src/main/java/com/vaadin/testbench/elements/ComboBoxElement.java +++ b/testbench-api/src/main/java/com/vaadin/testbench/elements/ComboBoxElement.java @@ -21,7 +21,7 @@ import java.util.List; import org.openqa.selenium.JavascriptExecutor; import org.openqa.selenium.Keys; -import org.openqa.selenium.NoSuchElementException; +import org.openqa.selenium.WebDriverException; import org.openqa.selenium.WebElement; import com.vaadin.testbench.By; @@ -183,7 +183,9 @@ public class ComboBoxElement extends AbstractSelectElement { try { getSuggestionPopup().findElement(byNextPage).click(); return true; - } catch (NoSuchElementException e) { + } catch (WebDriverException e) { + // PhantomJS driver can throw WDE instead of the more specific + // NoSuchElementException return false; } } @@ -197,7 +199,9 @@ public class ComboBoxElement extends AbstractSelectElement { try { getSuggestionPopup().findElement(byPrevPage).click(); return true; - } catch (NoSuchElementException e) { + } catch (WebDriverException e) { + // PhantomJS driver can throw WDE instead of the more specific + // NoSuchElementException return false; } } diff --git a/uitest/src/test/java/com/vaadin/tests/components/listselect/ListSelectTest.java b/uitest/src/test/java/com/vaadin/tests/components/listselect/ListSelectTest.java index d934fa448f..9262b9ba49 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/listselect/ListSelectTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/listselect/ListSelectTest.java @@ -16,6 +16,7 @@ import org.openqa.selenium.By; import org.openqa.selenium.WebElement; import org.openqa.selenium.support.ui.Select; +import com.vaadin.testbench.elements.AbstractComponentElement.ReadOnlyException; import com.vaadin.testbench.elements.ListSelectElement; import com.vaadin.tests.tb3.SingleBrowserTestPhantomJS2; @@ -108,14 +109,35 @@ public class ListSelectTest extends SingleBrowserTestPhantomJS2 { selectItem("Item 4"); Assert.assertEquals(lastLogRow, getLogRow(0)); assertNothingSelected(); + } + + @Test(expected = ReadOnlyException.class) + public void readOnly_selectByText() { + selectMenuPath("Component", "Listeners", "Selection listener"); + selectMenuPath("Component", "State", "Readonly"); + + List<WebElement> select = getListSelect() + .findElements(By.tagName("select")); + Assert.assertEquals(1, select.size()); + Assert.assertNotNull(select.get(0).getAttribute("disabled")); addItemsToSelection("Item 2"); - Assert.assertEquals(lastLogRow, getLogRow(0)); - assertNothingSelected(); + } + + @Test(expected = ReadOnlyException.class) + public void readOnly_deselectByText() { + selectMenuPath("Component", "Listeners", "Selection listener"); + + selectItem("Item 4"); + + selectMenuPath("Component", "State", "Readonly"); + + List<WebElement> select = getListSelect() + .findElements(By.tagName("select")); + Assert.assertEquals(1, select.size()); + Assert.assertNotNull(select.get(0).getAttribute("disabled")); removeItemsFromSelection("Item 4"); - Assert.assertEquals(lastLogRow, getLogRow(0)); - assertNothingSelected(); } @Test diff --git a/uitest/src/test/java/com/vaadin/tests/push/PushErrorHandlingTest.java b/uitest/src/test/java/com/vaadin/tests/push/PushErrorHandlingTest.java index 03416b4b88..320627ca74 100644 --- a/uitest/src/test/java/com/vaadin/tests/push/PushErrorHandlingTest.java +++ b/uitest/src/test/java/com/vaadin/tests/push/PushErrorHandlingTest.java @@ -21,7 +21,6 @@ import org.openqa.selenium.By; import org.openqa.selenium.WebElement; import com.vaadin.testbench.elements.LabelElement; -import com.vaadin.testbench.parallel.BrowserUtil; import com.vaadin.testbench.parallel.TestCategory; import com.vaadin.tests.tb3.MultiBrowserTest; @@ -33,15 +32,9 @@ public class PushErrorHandlingTest extends MultiBrowserTest { setPush(true); openTestURL(); vaadinElementById("npeButton").click(); - int idx = 1; - if (BrowserUtil.isPhantomJS(getDesiredCapabilities())) { - // PhantomJS sends an extra event when page gets loaded. - // This results as an extra error label. - ++idx; - } Assert.assertEquals( "An error! Unable to invoke method click in com.vaadin.shared.ui.button.ButtonServerRpc", - $(LabelElement.class).get(idx).getText()); + $(LabelElement.class).get(1).getText()); WebElement table = vaadinElementById("testtable"); WebElement row = table |