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; | ||||
} | } | ||||
} | } |
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 |
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 |