diff options
author | Teemu Suo-Anttila <teemusa@vaadin.com> | 2014-05-14 16:31:28 +0300 |
---|---|---|
committer | Vaadin Code Review <review@vaadin.com> | 2014-05-15 10:01:08 +0000 |
commit | cfbe3e213efed691cddc5f96cfe900544931658a (patch) | |
tree | ce3b72fd92dc59717883486d02daacd97d768286 /uitest | |
parent | 40a80c51803a109083d3949039448beeefd7f9da (diff) | |
download | vaadin-framework-cfbe3e213efed691cddc5f96cfe900544931658a.tar.gz vaadin-framework-cfbe3e213efed691cddc5f96cfe900544931658a.zip |
Make Vaadin TB3/4 tests work and run on PhantomJS (#13291)
Change-Id: I0d1747d41b3b9e0a32d995a5cea9081292c8c2c6
Diffstat (limited to 'uitest')
19 files changed, 88 insertions, 89 deletions
diff --git a/uitest/src/com/vaadin/tests/VerifyBrowserVersionTest.java b/uitest/src/com/vaadin/tests/VerifyBrowserVersionTest.java index 501233dad0..53317bd581 100644 --- a/uitest/src/com/vaadin/tests/VerifyBrowserVersionTest.java +++ b/uitest/src/com/vaadin/tests/VerifyBrowserVersionTest.java @@ -47,6 +47,9 @@ public class VerifyBrowserVersionTest extends MultiBrowserTest { expectedUserAgent .put(Browser.CHROME.getDesiredCapabilities(), "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/33.0.1750.117 Safari/537.36"); + expectedUserAgent + .put(Browser.PHANTOMJS.getDesiredCapabilities(), + "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/534.34 (KHTML, like Gecko) PhantomJS/1.9.7 Safari/534.34"); } diff --git a/uitest/src/com/vaadin/tests/actions/ActionsOnInvisibleComponentsTest.java b/uitest/src/com/vaadin/tests/actions/ActionsOnInvisibleComponentsTest.java index 1d08ee5ede..8dfcf52b75 100644 --- a/uitest/src/com/vaadin/tests/actions/ActionsOnInvisibleComponentsTest.java +++ b/uitest/src/com/vaadin/tests/actions/ActionsOnInvisibleComponentsTest.java @@ -4,26 +4,22 @@ import java.util.List; import org.junit.Assert; import org.junit.Test; -import org.openqa.selenium.WebElement; +import org.openqa.selenium.interactions.Actions; import org.openqa.selenium.remote.DesiredCapabilities; import com.vaadin.tests.tb3.MultiBrowserTest; public class ActionsOnInvisibleComponentsTest extends MultiBrowserTest { - private static final String LAST_INIT_LOG = "3. 'C' triggers a click on a visible and enabled button"; // This method should be removed once #12785 is fixed @Override public List<DesiredCapabilities> getBrowsersToTest() { List<DesiredCapabilities> browsers = super.getBrowsersToTest(); - // sendKeys does nothing on these browsers + // Send Keys does not function correctly on these browsers. + browsers.remove(Browser.CHROME.getDesiredCapabilities()); browsers.remove(Browser.FIREFOX.getDesiredCapabilities()); browsers.remove(Browser.IE8.getDesiredCapabilities()); - browsers.remove(Browser.OPERA.getDesiredCapabilities()); - - // Causes 'cannot focus element' - browsers.remove(Browser.CHROME.getDesiredCapabilities()); return browsers; } @@ -40,7 +36,6 @@ public class ActionsOnInvisibleComponentsTest extends MultiBrowserTest { } private void invokeShortcut(CharSequence key) { - WebElement shortcutTarget = vaadinElementById("test-root"); - shortcutTarget.sendKeys(key); + new Actions(getDriver()).sendKeys(key).perform(); } } diff --git a/uitest/src/com/vaadin/tests/components/combobox/ComboBoxSetNullWhenNewItemsAllowedTest.java b/uitest/src/com/vaadin/tests/components/combobox/ComboBoxSetNullWhenNewItemsAllowedTest.java index cfd5f46af1..54d355ab0a 100644 --- a/uitest/src/com/vaadin/tests/components/combobox/ComboBoxSetNullWhenNewItemsAllowedTest.java +++ b/uitest/src/com/vaadin/tests/components/combobox/ComboBoxSetNullWhenNewItemsAllowedTest.java @@ -20,9 +20,11 @@ import static org.junit.Assert.assertEquals; import org.junit.Test; import org.openqa.selenium.Keys; import org.openqa.selenium.WebElement; +import org.openqa.selenium.interactions.Actions; import com.vaadin.testbench.By; import com.vaadin.testbench.commands.TestBenchElementCommands; +import com.vaadin.testbench.elements.ComboBoxElement; import com.vaadin.tests.tb3.MultiBrowserTest; /** @@ -35,21 +37,18 @@ public class ComboBoxSetNullWhenNewItemsAllowedTest extends MultiBrowserTest { throws InterruptedException { setDebug(true); openTestURL(); - Thread.sleep(1000); - WebElement element = findElement(); + WebElement element = $(ComboBoxElement.class).first().findElement( + By.vaadin("#textbox")); ((TestBenchElementCommands) element).click(8, 7); element.clear(); element.sendKeys("New value"); assertEquals("New value", element.getAttribute("value")); - element.sendKeys(Keys.RETURN); + if (BrowserUtil.isPhantomJS(getDesiredCapabilities())) { + new Actions(getDriver()).sendKeys(Keys.ENTER).perform(); + } else { + element.sendKeys(Keys.RETURN); + } assertEquals("", element.getAttribute("value")); } - - private WebElement findElement() { - return getDriver() - .findElement( - By.vaadin("runcomvaadintestscomponentscomboboxComboBoxSetNullWhenNewItemsAllowed::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VFilterSelect[0]#textbox")); - } - } diff --git a/uitest/src/com/vaadin/tests/components/datefield/DateFieldTestTest.java b/uitest/src/com/vaadin/tests/components/datefield/DateFieldTestTest.java index 108b7030e7..5f659d389b 100644 --- a/uitest/src/com/vaadin/tests/components/datefield/DateFieldTestTest.java +++ b/uitest/src/com/vaadin/tests/components/datefield/DateFieldTestTest.java @@ -19,10 +19,10 @@ import org.junit.Assert; import org.junit.Test; import org.openqa.selenium.By; import org.openqa.selenium.Dimension; -import org.openqa.selenium.NoSuchElementException; import org.openqa.selenium.WebElement; import org.openqa.selenium.interactions.Actions; +import com.vaadin.testbench.elements.NotificationElement; import com.vaadin.tests.tb3.MultiBrowserTest; public class DateFieldTestTest extends MultiBrowserTest { @@ -44,12 +44,8 @@ public class DateFieldTestTest extends MultiBrowserTest { } private void assertNoErrorNotification() { - try { - getDriver().findElement( - By.xpath("//div[contains(@class, 'v-Notification') ]")); - Assert.fail("Error notification shown!"); - } catch (NoSuchElementException e) { - // As expected + if (isElementPresent(NotificationElement.class)) { + Assert.fail("Notification was present"); } } diff --git a/uitest/src/com/vaadin/tests/components/table/CtrlShiftMultiselectTest.java b/uitest/src/com/vaadin/tests/components/table/CtrlShiftMultiselectTest.java index 1c84533a42..255a798594 100644 --- a/uitest/src/com/vaadin/tests/components/table/CtrlShiftMultiselectTest.java +++ b/uitest/src/com/vaadin/tests/components/table/CtrlShiftMultiselectTest.java @@ -32,7 +32,9 @@ public class CtrlShiftMultiselectTest extends MultiBrowserTest { @Override public List<DesiredCapabilities> getBrowsersToTest() { List<DesiredCapabilities> browsers = super.getBrowsersToTest(); + // Shift + click doesn't select all rows correctly on these browsers browsers.remove(Browser.FIREFOX.getDesiredCapabilities()); + browsers.remove(Browser.PHANTOMJS.getDesiredCapabilities()); return browsers; } diff --git a/uitest/src/com/vaadin/tests/components/table/EmptyTableTest.java b/uitest/src/com/vaadin/tests/components/table/EmptyTableTest.java index 30e783f824..2332815ed6 100644 --- a/uitest/src/com/vaadin/tests/components/table/EmptyTableTest.java +++ b/uitest/src/com/vaadin/tests/components/table/EmptyTableTest.java @@ -17,9 +17,8 @@ package com.vaadin.tests.components.table; import org.junit.Assert; import org.junit.Test; -import org.openqa.selenium.By; -import org.openqa.selenium.NoSuchElementException; +import com.vaadin.testbench.elements.NotificationElement; import com.vaadin.tests.tb3.MultiBrowserTest; public class EmptyTableTest extends MultiBrowserTest { @@ -33,12 +32,9 @@ public class EmptyTableTest extends MultiBrowserTest { } private void ensureNoErrors() { - try { - getDriver().findElement(By.className("v-Notification")); - } catch (NoSuchElementException e) { - return; + if (isElementPresent(NotificationElement.class)) { + Assert.fail("Error notification was shown!"); } - Assert.fail("Error notification was shown!"); } } diff --git a/uitest/src/com/vaadin/tests/components/table/SelectAllRowsTest.java b/uitest/src/com/vaadin/tests/components/table/SelectAllRowsTest.java index 524b8a484f..0fc09adf40 100644 --- a/uitest/src/com/vaadin/tests/components/table/SelectAllRowsTest.java +++ b/uitest/src/com/vaadin/tests/components/table/SelectAllRowsTest.java @@ -47,10 +47,11 @@ public class SelectAllRowsTest extends MultiBrowserTest { @Override public List<DesiredCapabilities> getBrowsersToTest() { - // Pressing Shift modifier key does not work with Firefox + // Pressing Shift modifier key does not work with Firefox and PhantomJS ArrayList<DesiredCapabilities> browsers = new ArrayList<DesiredCapabilities>( super.getBrowsersToTest()); browsers.remove(Browser.FIREFOX.getDesiredCapabilities()); + browsers.remove(Browser.PHANTOMJS.getDesiredCapabilities()); return browsers; } diff --git a/uitest/src/com/vaadin/tests/components/tabsheet/TabSheetFocusedTabTest.java b/uitest/src/com/vaadin/tests/components/tabsheet/TabSheetFocusedTabTest.java index 9085a76375..12ae03080b 100644 --- a/uitest/src/com/vaadin/tests/components/tabsheet/TabSheetFocusedTabTest.java +++ b/uitest/src/com/vaadin/tests/components/tabsheet/TabSheetFocusedTabTest.java @@ -18,10 +18,13 @@ package com.vaadin.tests.components.tabsheet; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; +import java.util.List; + import org.junit.Test; import org.openqa.selenium.Keys; import org.openqa.selenium.WebElement; import org.openqa.selenium.interactions.Actions; +import org.openqa.selenium.remote.DesiredCapabilities; import com.vaadin.testbench.By; import com.vaadin.tests.tb3.MultiBrowserTest; @@ -29,6 +32,15 @@ import com.vaadin.tests.tb3.MultiBrowserTest; public class TabSheetFocusedTabTest extends MultiBrowserTest { @Override + public List<DesiredCapabilities> getBrowsersToTest() { + List<DesiredCapabilities> browsers = super.getBrowsersToTest(); + // PhantomJS doesn't send Focus / Blur events when clicking or + // navigating with keyboard + browsers.remove(Browser.PHANTOMJS.getDesiredCapabilities()); + return browsers; + } + + @Override protected Class<?> getUIClass() { return TabsheetScrolling.class; } @@ -41,7 +53,7 @@ public class TabSheetFocusedTabTest extends MultiBrowserTest { assertTrue(isFocused(getTab(1))); - new Actions(getDriver()).sendKeys(Keys.RIGHT).perform(); + new Actions(getDriver()).sendKeys(Keys.ARROW_RIGHT).perform(); assertFalse(isFocused(getTab(1))); assertTrue(isFocused(getTab(3))); @@ -65,6 +77,7 @@ public class TabSheetFocusedTabTest extends MultiBrowserTest { } private boolean isFocused(WebElement tab) { + return tab.getAttribute("class").contains("v-tabsheet-tabitem-focus"); } diff --git a/uitest/src/com/vaadin/tests/components/tabsheet/TabsheetScrollingTest.java b/uitest/src/com/vaadin/tests/components/tabsheet/TabsheetScrollingTest.java index 4738c48d7e..1da42bb1ce 100644 --- a/uitest/src/com/vaadin/tests/components/tabsheet/TabsheetScrollingTest.java +++ b/uitest/src/com/vaadin/tests/components/tabsheet/TabsheetScrollingTest.java @@ -22,6 +22,7 @@ import org.openqa.selenium.WebElement; import org.openqa.selenium.interactions.Actions; import com.vaadin.testbench.By; +import com.vaadin.testbench.elements.ButtonElement; import com.vaadin.tests.tb3.MultiBrowserTest; public class TabsheetScrollingTest extends MultiBrowserTest { @@ -38,19 +39,11 @@ public class TabsheetScrollingTest extends MultiBrowserTest { } private WebElement getTab(int index) { - return getDriver().findElement( - By.vaadin("/VVerticalLayout[0]/Slot[1]" - + "/VVerticalLayout[0]/Slot[0]/VTabsheet[0]" - + "/domChild[0]/domChild[0]/domChild[0]" - + "/domChild[0]/domChild[" + index + "]")); - + return getDriver().findElement(By.vaadin("//TabSheet#tab[1]")); } private String getHideButtonText() { - WebElement buttonCaption = getDriver().findElement( - By.vaadin("/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]" - + "/Slot[0]/VTabsheet[0]/VTabsheetPanel[0]" - + "/VButton[0]/domChild[0]/domChild[0]")); + ButtonElement buttonCaption = $(ButtonElement.class).first(); return buttonCaption.getText(); } diff --git a/uitest/src/com/vaadin/tests/components/ui/TextAreaEventPropagation.java b/uitest/src/com/vaadin/tests/components/ui/TextAreaEventPropagation.java index 31eeac02da..4235f5a989 100644 --- a/uitest/src/com/vaadin/tests/components/ui/TextAreaEventPropagation.java +++ b/uitest/src/com/vaadin/tests/components/ui/TextAreaEventPropagation.java @@ -48,10 +48,10 @@ public class TextAreaEventPropagation extends AbstractTestUIWithLog { FormLayout form = new FormLayout(); TextArea textArea = new TextArea("Text input"); TextField textField = new TextField("Text field input"); - enterButtonPressed = new Label("Enter Label"); - enterButtonPressed.setCaption(NO_BUTTON_PRESSED); - escapeButtonPressed = new Label("Escape Label"); - escapeButtonPressed.setCaption(NO_BUTTON_PRESSED); + enterButtonPressed = new Label(NO_BUTTON_PRESSED); + enterButtonPressed.setCaption("Enter Label"); + escapeButtonPressed = new Label(NO_BUTTON_PRESSED); + escapeButtonPressed.setCaption("Escape Label"); Button enterButton = new Button("Enter"); enterButton.setClickShortcut(KeyCode.ENTER); @@ -60,7 +60,7 @@ public class TextAreaEventPropagation extends AbstractTestUIWithLog { @Override public void buttonClick(ClickEvent event) { - enterButtonPressed.setCaption(BUTTON_PRESSED); + enterButtonPressed.setValue(BUTTON_PRESSED); } }); @@ -71,7 +71,7 @@ public class TextAreaEventPropagation extends AbstractTestUIWithLog { @Override public void buttonClick(ClickEvent event) { - escapeButtonPressed.setCaption(BUTTON_PRESSED); + escapeButtonPressed.setValue(BUTTON_PRESSED); } }); diff --git a/uitest/src/com/vaadin/tests/components/ui/TextAreaEventPropagationTest.java b/uitest/src/com/vaadin/tests/components/ui/TextAreaEventPropagationTest.java index 11e0c52d27..b1c38df460 100644 --- a/uitest/src/com/vaadin/tests/components/ui/TextAreaEventPropagationTest.java +++ b/uitest/src/com/vaadin/tests/components/ui/TextAreaEventPropagationTest.java @@ -18,11 +18,13 @@ package com.vaadin.tests.components.ui; import static org.junit.Assert.assertEquals; 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.LabelElement; +import com.vaadin.testbench.elements.TextAreaElement; +import com.vaadin.testbench.elements.TextFieldElement; import com.vaadin.tests.tb3.MultiBrowserTest; /** @@ -35,7 +37,7 @@ public class TextAreaEventPropagationTest extends MultiBrowserTest { @Test public void testTextAreaEnterEventPropagation() throws InterruptedException { openTestURL(); - WebElement textArea = vaadinElement("//TextArea[0]"); + WebElement textArea = $(TextAreaElement.class).first(); Actions builder = new Actions(driver); builder.click(textArea); builder.sendKeys(textArea, "first line asdf"); @@ -43,11 +45,11 @@ public class TextAreaEventPropagationTest extends MultiBrowserTest { builder.sendKeys(textArea, "second line jkl;"); builder.perform(); - WebElement enterLabel = driver.findElement(By.id("gwt-uid-8")); - String text = enterLabel.getText(); + String text = $(LabelElement.class).caption("Enter Label").first() + .getText(); assertEquals(TextAreaEventPropagation.NO_BUTTON_PRESSED, text); - WebElement textField = vaadinElement("//TextField[0]"); + WebElement textField = $(TextFieldElement.class).first(); Actions builder2 = new Actions(driver); builder2.click(textField); @@ -56,7 +58,7 @@ public class TextAreaEventPropagationTest extends MultiBrowserTest { builder2.perform(); - text = enterLabel.getText(); + text = $(LabelElement.class).caption("Enter Label").first().getText(); assertEquals(TextAreaEventPropagation.BUTTON_PRESSED, text); @@ -66,7 +68,7 @@ public class TextAreaEventPropagationTest extends MultiBrowserTest { public void testTextAreaEscapeEventPropagation() throws InterruptedException { openTestURL(); - WebElement textArea = vaadinElement("//TextArea[0]"); + WebElement textArea = $(TextAreaElement.class).first(); Actions builder = new Actions(driver); builder.click(textArea); builder.sendKeys(textArea, "first line asdf"); @@ -75,11 +77,10 @@ public class TextAreaEventPropagationTest extends MultiBrowserTest { builder.sendKeys(Keys.ESCAPE); builder.perform(); - WebElement enterLabel = driver.findElement(By.id("gwt-uid-8")); - String text = enterLabel.getText(); + String text = $(LabelElement.class).caption("Enter Label").first() + .getText(); assertEquals(TextAreaEventPropagation.NO_BUTTON_PRESSED, text); - WebElement escapeLabel = driver.findElement(By.id("gwt-uid-10")); - text = escapeLabel.getText(); + text = $(LabelElement.class).caption("Escape Label").first().getText(); assertEquals(TextAreaEventPropagation.BUTTON_PRESSED, text); } @@ -88,7 +89,7 @@ public class TextAreaEventPropagationTest extends MultiBrowserTest { public void testTextFieldEscapeEventPropagation() throws InterruptedException { openTestURL(); - WebElement textArea = vaadinElement("//TextArea[0]"); + WebElement textArea = $(TextAreaElement.class).first(); Actions builder = new Actions(driver); builder.click(textArea); builder.sendKeys(textArea, "first line asdf"); @@ -96,12 +97,11 @@ public class TextAreaEventPropagationTest extends MultiBrowserTest { builder.sendKeys(textArea, "second line jkl;"); builder.perform(); - WebElement enterLabel = driver.findElement(By.id("gwt-uid-8")); - String text = enterLabel.getText(); + String text = $(LabelElement.class).caption("Enter Label").first() + .getText(); assertEquals(TextAreaEventPropagation.NO_BUTTON_PRESSED, text); - WebElement escapeLabel = driver.findElement(By.id("gwt-uid-10")); - WebElement textField = vaadinElement("//TextField[0]"); + WebElement textField = $(TextFieldElement.class).first(); Actions builder2 = new Actions(driver); builder2.click(textField); @@ -111,13 +111,10 @@ public class TextAreaEventPropagationTest extends MultiBrowserTest { builder2.perform(); - text = enterLabel.getText(); + text = $(LabelElement.class).caption("Enter Label").first().getText(); assertEquals(TextAreaEventPropagation.BUTTON_PRESSED, text); - - text = escapeLabel.getText(); - + text = $(LabelElement.class).caption("Escape Label").first().getText(); assertEquals(TextAreaEventPropagation.BUTTON_PRESSED, text); } - } diff --git a/uitest/src/com/vaadin/tests/fonticon/FontIcons.java b/uitest/src/com/vaadin/tests/fonticon/FontIcons.java index bce4a79986..e9d2b91e95 100644 --- a/uitest/src/com/vaadin/tests/fonticon/FontIcons.java +++ b/uitest/src/com/vaadin/tests/fonticon/FontIcons.java @@ -57,11 +57,6 @@ import com.vaadin.ui.TwinColSelect; import com.vaadin.ui.Upload; import com.vaadin.ui.VerticalLayout; -/** - * - * @since - * @author Vaadin Ltd - */ public class FontIcons extends AbstractTestUI { @Override @@ -105,7 +100,7 @@ public class FontIcons extends AbstractTestUI { Notification n = new Notification("Hey there!"); n.setIcon(icon); n.setPosition(Position.BOTTOM_CENTER); - n.setDelayMsec(-1); + n.setDelayMsec(300000); n.show(Page.getCurrent()); // grid of compoents diff --git a/uitest/src/com/vaadin/tests/fonticon/FontIconsTest.java b/uitest/src/com/vaadin/tests/fonticon/FontIconsTest.java index bc08071cef..61a38bf552 100644 --- a/uitest/src/com/vaadin/tests/fonticon/FontIconsTest.java +++ b/uitest/src/com/vaadin/tests/fonticon/FontIconsTest.java @@ -21,11 +21,6 @@ import org.junit.Test; import com.vaadin.tests.tb3.MultiBrowserTest; -/** - * - * @since - * @author Vaadin Ltd - */ public class FontIconsTest extends MultiBrowserTest { @Test diff --git a/uitest/src/com/vaadin/tests/push/PushConfigurationStreamingTest.java b/uitest/src/com/vaadin/tests/push/PushConfigurationStreamingTest.java index 0443307b2f..8dc960c9ac 100644 --- a/uitest/src/com/vaadin/tests/push/PushConfigurationStreamingTest.java +++ b/uitest/src/com/vaadin/tests/push/PushConfigurationStreamingTest.java @@ -38,6 +38,8 @@ public class PushConfigurationStreamingTest extends PushConfigurationTest { @Test public void testStreaming() throws InterruptedException { + openDebugLogTab(); + new Select(getTransportSelect()).selectByVisibleText("STREAMING"); new Select(getPushModeSelect()).selectByVisibleText("AUTOMATIC"); diff --git a/uitest/src/com/vaadin/tests/push/PushConfigurationWebSocketTest.java b/uitest/src/com/vaadin/tests/push/PushConfigurationWebSocketTest.java index 2a36059ccb..c9a813fac0 100644 --- a/uitest/src/com/vaadin/tests/push/PushConfigurationWebSocketTest.java +++ b/uitest/src/com/vaadin/tests/push/PushConfigurationWebSocketTest.java @@ -33,6 +33,7 @@ public class PushConfigurationWebSocketTest extends PushConfigurationTest { List<DesiredCapabilities> browsers = super.getBrowsersToTest(); browsers.remove(Browser.IE8.getDesiredCapabilities()); browsers.remove(Browser.IE9.getDesiredCapabilities()); + browsers.remove(Browser.PHANTOMJS.getDesiredCapabilities()); return browsers; } diff --git a/uitest/src/com/vaadin/tests/push/PushErrorHandlingTest.java b/uitest/src/com/vaadin/tests/push/PushErrorHandlingTest.java index c31b167586..1f6e181c89 100644 --- a/uitest/src/com/vaadin/tests/push/PushErrorHandlingTest.java +++ b/uitest/src/com/vaadin/tests/push/PushErrorHandlingTest.java @@ -20,6 +20,7 @@ import org.junit.Test; import org.openqa.selenium.By; import org.openqa.selenium.WebElement; +import com.vaadin.testbench.elements.LabelElement; import com.vaadin.tests.annotations.TestCategory; import com.vaadin.tests.tb3.MultiBrowserTest; @@ -31,11 +32,15 @@ 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", - vaadinElement( - "/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[2]/VLabel[0]") - .getText()); + $(LabelElement.class).get(idx).getText()); WebElement table = vaadinElementById("testtable"); WebElement row = table.findElement(By diff --git a/uitest/src/com/vaadin/tests/tb3/AbstractTB3Test.java b/uitest/src/com/vaadin/tests/tb3/AbstractTB3Test.java index 0a0e498981..7be55ff298 100644 --- a/uitest/src/com/vaadin/tests/tb3/AbstractTB3Test.java +++ b/uitest/src/com/vaadin/tests/tb3/AbstractTB3Test.java @@ -956,10 +956,14 @@ public abstract class AbstractTB3Test extends TestBenchTestCase { } public void hitButton(String id) { - WebDriverBackedSelenium selenium = new WebDriverBackedSelenium(driver, - driver.getCurrentUrl()); + if (BrowserUtil.isPhantomJS(getDesiredCapabilities())) { + driver.findElement(By.id(id)).click(); + } else { + WebDriverBackedSelenium selenium = new WebDriverBackedSelenium( + driver, driver.getCurrentUrl()); - selenium.keyPress("id=" + id, "\\13"); + selenium.keyPress("id=" + id, "\\13"); + } } protected void openDebugLogTab() { diff --git a/uitest/src/com/vaadin/tests/tb3/MultiBrowserTest.java b/uitest/src/com/vaadin/tests/tb3/MultiBrowserTest.java index 13c34d475a..74073af217 100644 --- a/uitest/src/com/vaadin/tests/tb3/MultiBrowserTest.java +++ b/uitest/src/com/vaadin/tests/tb3/MultiBrowserTest.java @@ -66,6 +66,7 @@ public abstract class MultiBrowserTest extends PrivateTB3Configuration { // Uncomment once we have the capability to run on Safari 6 // allBrowsers.add(SAFARI); allBrowsers.add(Browser.CHROME.getDesiredCapabilities()); + allBrowsers.add(Browser.PHANTOMJS.getDesiredCapabilities()); // Re-enable this when it is possible to run on a modern Opera version // allBrowsers.add(Browser.OPERA.getDesiredCapabilities()); } diff --git a/uitest/src/com/vaadin/tests/tb3/WebsocketTest.java b/uitest/src/com/vaadin/tests/tb3/WebsocketTest.java index d466c39131..778c8b9113 100644 --- a/uitest/src/com/vaadin/tests/tb3/WebsocketTest.java +++ b/uitest/src/com/vaadin/tests/tb3/WebsocketTest.java @@ -41,6 +41,7 @@ public abstract class WebsocketTest extends PrivateTB3Configuration { websocketBrowsers.addAll(MultiBrowserTest.getAllBrowsers()); websocketBrowsers.remove(Browser.IE8.getDesiredCapabilities()); websocketBrowsers.remove(Browser.IE9.getDesiredCapabilities()); + websocketBrowsers.remove(Browser.PHANTOMJS.getDesiredCapabilities()); } /** |