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");
}
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;
}
}
private void invokeShortcut(CharSequence key) {
- WebElement shortcutTarget = vaadinElementById("test-root");
- shortcutTarget.sendKeys(key);
+ new Actions(getDriver()).sendKeys(key).perform();
}
}
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;
/**
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"));
- }
-
}
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 {
}
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");
}
}
@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;
}
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 {
}
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!");
}
}
@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;
}
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;
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;
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)));
}
private boolean isFocused(WebElement tab) {
+
return tab.getAttribute("class").contains("v-tabsheet-tabitem-focus");
}
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 {
}
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();
}
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);
@Override
public void buttonClick(ClickEvent event) {
- enterButtonPressed.setCaption(BUTTON_PRESSED);
+ enterButtonPressed.setValue(BUTTON_PRESSED);
}
});
@Override
public void buttonClick(ClickEvent event) {
- escapeButtonPressed.setCaption(BUTTON_PRESSED);
+ escapeButtonPressed.setValue(BUTTON_PRESSED);
}
});
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;
/**
@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");
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);
builder2.perform();
- text = enterLabel.getText();
+ text = $(LabelElement.class).caption("Enter Label").first().getText();
assertEquals(TextAreaEventPropagation.BUTTON_PRESSED, text);
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");
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);
}
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");
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);
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);
}
-
}
import com.vaadin.ui.Upload;
import com.vaadin.ui.VerticalLayout;
-/**
- *
- * @since
- * @author Vaadin Ltd
- */
public class FontIcons extends AbstractTestUI {
@Override
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
import com.vaadin.tests.tb3.MultiBrowserTest;
-/**
- *
- * @since
- * @author Vaadin Ltd
- */
public class FontIconsTest extends MultiBrowserTest {
@Test
@Test
public void testStreaming() throws InterruptedException {
+ openDebugLogTab();
+
new Select(getTransportSelect()).selectByVisibleText("STREAMING");
new Select(getPushModeSelect()).selectByVisibleText("AUTOMATIC");
List<DesiredCapabilities> browsers = super.getBrowsersToTest();
browsers.remove(Browser.IE8.getDesiredCapabilities());
browsers.remove(Browser.IE9.getDesiredCapabilities());
+ browsers.remove(Browser.PHANTOMJS.getDesiredCapabilities());
return browsers;
}
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;
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
}
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() {
// 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());
}
websocketBrowsers.addAll(MultiBrowserTest.getAllBrowsers());
websocketBrowsers.remove(Browser.IE8.getDesiredCapabilities());
websocketBrowsers.remove(Browser.IE9.getDesiredCapabilities());
+ websocketBrowsers.remove(Browser.PHANTOMJS.getDesiredCapabilities());
}
/**