Procházet zdrojové kódy

Fix some broken tests and ComboBoxElement (#8430)

tags/8.0.0.rc1
Henri Sara před 7 roky
rodič
revize
167e733f1f

+ 7
- 3
testbench-api/src/main/java/com/vaadin/testbench/elements/ComboBoxElement.java Zobrazit soubor



import org.openqa.selenium.JavascriptExecutor; import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.Keys; import org.openqa.selenium.Keys;
import org.openqa.selenium.NoSuchElementException;
import org.openqa.selenium.WebDriverException;
import org.openqa.selenium.WebElement; import org.openqa.selenium.WebElement;


import com.vaadin.testbench.By; import com.vaadin.testbench.By;
try { try {
getSuggestionPopup().findElement(byNextPage).click(); getSuggestionPopup().findElement(byNextPage).click();
return true; return true;
} catch (NoSuchElementException e) {
} catch (WebDriverException e) {
// PhantomJS driver can throw WDE instead of the more specific
// NoSuchElementException
return false; return false;
} }
} }
try { try {
getSuggestionPopup().findElement(byPrevPage).click(); getSuggestionPopup().findElement(byPrevPage).click();
return true; return true;
} catch (NoSuchElementException e) {
} catch (WebDriverException e) {
// PhantomJS driver can throw WDE instead of the more specific
// NoSuchElementException
return false; return false;
} }
} }

+ 26
- 4
uitest/src/test/java/com/vaadin/tests/components/listselect/ListSelectTest.java Zobrazit soubor

import org.openqa.selenium.WebElement; import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.ui.Select; import org.openqa.selenium.support.ui.Select;


import com.vaadin.testbench.elements.AbstractComponentElement.ReadOnlyException;
import com.vaadin.testbench.elements.ListSelectElement; import com.vaadin.testbench.elements.ListSelectElement;
import com.vaadin.tests.tb3.SingleBrowserTestPhantomJS2; import com.vaadin.tests.tb3.SingleBrowserTestPhantomJS2;


selectItem("Item 4"); selectItem("Item 4");
Assert.assertEquals(lastLogRow, getLogRow(0)); Assert.assertEquals(lastLogRow, getLogRow(0));
assertNothingSelected(); 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"); 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"); removeItemsFromSelection("Item 4");
Assert.assertEquals(lastLogRow, getLogRow(0));
assertNothingSelected();
} }


@Test @Test

+ 1
- 8
uitest/src/test/java/com/vaadin/tests/push/PushErrorHandlingTest.java Zobrazit soubor

import org.openqa.selenium.WebElement; import org.openqa.selenium.WebElement;


import com.vaadin.testbench.elements.LabelElement; import com.vaadin.testbench.elements.LabelElement;
import com.vaadin.testbench.parallel.BrowserUtil;
import com.vaadin.testbench.parallel.TestCategory; import com.vaadin.testbench.parallel.TestCategory;
import com.vaadin.tests.tb3.MultiBrowserTest; import com.vaadin.tests.tb3.MultiBrowserTest;


setPush(true); setPush(true);
openTestURL(); openTestURL();
vaadinElementById("npeButton").click(); 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( Assert.assertEquals(
"An error! Unable to invoke method click in com.vaadin.shared.ui.button.ButtonServerRpc", "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 table = vaadinElementById("testtable");
WebElement row = table WebElement row = table

Načítá se…
Zrušit
Uložit