List of usage examples for org.openqa.selenium WebElement findElements
@Override List<WebElement> findElements(By by);
From source file:com.vaadin.testbench.elements.TabSheetElement.java
License:Apache License
/** * Opens the given tab by clicking its caption text or icon. If the tab has * neither text caption nor icon, clicks at a fixed position. * * @param tabCell//w w w.ja v a 2 s . co m * The tab to be opened. */ private void openTab(WebElement tabCell) { // Open the tab by clicking its caption text if it exists. List<WebElement> tabCaptions = tabCell.findElements(byCaption); if (!tabCaptions.isEmpty()) { tabCaptions.get(0).click(); return; } // If no caption text was found, click the icon of the tab. List<WebElement> tabIcons = tabCell.findElements(By.className("v-icon")); if (!tabIcons.isEmpty()) { tabIcons.get(0).click(); return; } // If neither text nor icon caption was found, click at a position that // is unlikely to close the tab. ((TestBenchElement) tabCell).click(-5, 0); }
From source file:com.vaadin.testbench.elements.TabSheetElement.java
License:Apache License
/** * Returns the caption text of the given tab. If the tab has no caption, * returns null./*from w w w . j a v a 2 s .c o m*/ * * @param tabCell * A web element representing a tab, as given by * findElements(byTabCell).get(index). * @return The caption of tabCell or null if tabCell has no caption. */ private String getTabCaption(WebElement tabCell) { List<WebElement> captionElements = tabCell.findElements(byCaption); if (captionElements.isEmpty()) { return null; } else { return captionElements.get(0).getText(); } }
From source file:com.vaadin.testbench.elements.TwinColSelectElement.java
License:Apache License
/** * Return first selected item (item in the right part of component). * * @return the option text for the item// w w w .j a v a 2 s.co m */ public String getValue() { String value = ""; WebElement selectedElement = findElement(By.className("v-select-twincol-selections")); List<WebElement> optionElements = selectedElement.findElements(By.tagName("option")); if (!optionElements.isEmpty()) { value = optionElements.get(0).getText(); } return value; }
From source file:com.vaadin.tests.components.grid.basicfeatures.client.GridEditorClientTest.java
License:Apache License
@Test public void testWidgetBinding() throws Exception { selectMenuPath(EDIT_ROW_100);// ww w . ja v a 2s. com WebElement editor = getEditor(); List<WebElement> widgets = editor.findElements(By.className("gwt-TextBox")); assertEquals(GridBasicFeatures.EDITABLE_COLUMNS, widgets.size()); assertEquals("(100, 0)", widgets.get(0).getAttribute("value")); assertEquals("(100, 1)", widgets.get(1).getAttribute("value")); assertEquals("(100, 2)", widgets.get(2).getAttribute("value")); assertEquals("100", widgets.get(6).getAttribute("value")); assertEquals("<b>100</b>", widgets.get(8).getAttribute("value")); }
From source file:com.vaadin.tests.components.grid.basicfeatures.client.GridEditorClientTest.java
License:Apache License
@Test public void testWithSelectionColumn() throws Exception { selectMenuPath("Component", "State", "Selection mode", "multi"); selectMenuPath("Component", "State", "Frozen column count", "-1 columns"); selectMenuPath(EDIT_ROW_5);/*w ww .j av a 2s. c o m*/ WebElement editorCells = findElements(By.className("v-grid-editor-cells")).get(1); List<WebElement> selectorDivs = editorCells.findElements(By.cssSelector("div")); assertFalse("selector column cell should've had contents", selectorDivs.get(0).getAttribute("innerHTML").isEmpty()); assertFalse("normal column cell shoul've had contents", selectorDivs.get(1).getAttribute("innerHTML").isEmpty()); }
From source file:com.vaadin.tests.components.grid.basicfeatures.GridBasicFeaturesTest.java
License:Apache License
/** * Returns the toggle inside the sidebar for hiding the column at the given * index, or null if not found.//from ww w .j a va 2 s . c om */ protected WebElement getColumnHidingToggle(int columnIndex) { WebElement sidebar = getSidebarPopup(); List<WebElement> elements = sidebar.findElements(By.className("column-hiding-toggle")); for (WebElement e : elements) { if ((e.getText().toLowerCase()).startsWith("column " + columnIndex)) { return e; } } return null; }
From source file:com.vaadin.tests.components.grid.basicfeatures.GridColumnHidingTest.java
License:Apache License
private void verifyColumnHidingTogglesOrder(int... indices) { WebElement sidebar = getSidebarPopup(); List<WebElement> elements = sidebar.findElements(By.className("column-hiding-toggle")); for (int i = 0; i < indices.length; i++) { WebElement e = elements.get(i);//from ww w . ja v a2s .c o m assertTrue(("Header (0," + indices[i] + ")").equalsIgnoreCase(e.getText())); } }
From source file:com.vaadin.tests.components.grid.basicfeatures.GridColumnHidingTest.java
License:Apache License
/** * Returns the toggle inside the sidebar for hiding the column at the given * index, or null if not found.//from ww w.j a v a2s .co m */ @Override protected WebElement getColumnHidingToggle(int columnIndex) { WebElement sidebar = getSidebarPopup(); List<WebElement> elements = sidebar.findElements(By.className("column-hiding-toggle")); for (WebElement e : elements) { if (("Header (0," + columnIndex + ")").equalsIgnoreCase(e.getText())) { return e; } } return null; }
From source file:com.vaadin.tests.integration.JSPIntegrationTest.java
License:Apache License
private List<UIData> getUIs() { List<UIData> uis = new ArrayList<UIData>(); getDriver().get(jspUrl);/*from www. j av a2s. c o m*/ List<WebElement> rows = getDriver().findElements(By.xpath("//tr[@class='uirow']")); for (WebElement row : rows) { UIData data = new UIData(); List<WebElement> tds = row.findElements(By.xpath("./td")); data.serviceName = tds.get(0).getText(); data.uiId = Integer.parseInt(tds.get(2).getText()); uis.add(data); } return uis; }
From source file:com.vaadin.tests.testbenchapi.components.tabsheet.TabSheetElementTabWithoutCaptionIT.java
License:Apache License
private void checkSelectedTab(String caption) { // Check that the currently selected tab has the given caption. WebElement elem = $(TabSheetElement.class).first().getWrappedElement(); List<WebElement> openTabs = elem.findElements(By.className("v-tabsheet-tabitem-selected")); assertTrue("Exactly one tab should be open, but there are " + openTabs.size() + " open tabs.", openTabs.size() == 1);/*w w w . java 2 s. c om*/ WebElement tab = openTabs.get(0); List<WebElement> openTabCaptionElements = tab.findElement(By.className("v-caption")) .findElements(By.className("v-captiontext")); if (openTabCaptionElements.size() > 0) { String openTabCaption = openTabCaptionElements.get(0).getText(); assertEquals("Wrong tab is open.", caption, openTabCaption); } else { assertEquals("Wrong tab is open.", caption, null); } }