List of usage examples for org.openqa.selenium WebElement getText
String getText();
From source file:com.cognifide.qa.bb.aem.ui.AemDialog.java
License:Apache License
/** * Finds the dialog tab by its index and returns its name (label). * * @param index of the tab (starts from 0) * @return Tab's label.//from ww w .ja v a 2 s. c o m */ public String getLabelFromTab(int index) { WebElement dialog = webDriver.findElement(DIALOG_XPATH_COMPILED); List<WebElement> items = dialog.findElements(By.className("x-tab-item")); WebElement widget = items.get(index); WebElement label = widget.findElement(By.xpath(".//label")); return label.getText(); }
From source file:com.cognifide.qa.bb.aem.ui.AemDialog.java
License:Apache License
/** * Fills field with data if (and only if) the field's initial value is null. In other words if the * field has already been initialized then it will not be altered. * * @return Returns a hashmap that maps labels to webelements representing tabs. */// w ww .j av a 2s . com private Map<String, WebElement> getTabMap() { List<WebElement> tabs = getAllTabs(); Map<String, WebElement> windowTabs = new HashMap<>(tabs.size()); for (WebElement tab : tabs) { String tabLabel = tab.getText(); windowTabs.put(tabLabel, tab); } return windowTabs; }
From source file:com.cognifide.qa.bb.aem.ui.sidekick.AemSidekick.java
License:Apache License
private Map<String, WebElement> getGroupsByNames() { final Map<String, WebElement> map = new LinkedHashMap<>(); for (WebElement group : componentGroups) { String name = group.getText().trim(); map.put(name, group);// ww w . ja va2s . c om } return map; }
From source file:com.cognifide.qa.bb.aem.ui.sidekick.AemSidekick.java
License:Apache License
private List<String> getComponentNames(String groupName) { final List<String> list = new ArrayList<>(); for (WebElement element : getWebElementsByGroupName(groupName)) { list.add(element.getText()); }//from w w w . j a v a 2s .c om return list; }
From source file:com.cognifide.qa.bb.aem.ui.sidekick.SidekickGrid.java
License:Apache License
/** * Get grid row by row content//w w w. j a v a 2 s . c om * * @param rowContent row of content * @return SidekickGridRow sidekick row */ public SidekickGridRow getGridRow(String rowContent) { for (SidekickGridRow row : gridRows) { List<WebElement> cells = row.getCells(); for (WebElement cell : cells) { if (cell.getText().equals(rowContent)) { return row; } } } throw new IllegalArgumentException("There is no row with content: " + rowContent); }
From source file:com.cognifide.qa.bb.aem.ui.wcm.windows.CreateSiteWindow.java
License:Apache License
/** * Selects chapters on Chapters view// www . jav a2 s . c o m * * @param chapters list of languages * @return this CreateSiteWindow */ public CreateSiteWindow selectChapters(List<String> chapters) { List<WebElement> items = currentWindow .findElements(By.cssSelector(".cq-msm_58chapterPages .x-form-check-wrap")); for (WebElement item : items) { WebElement label = item.findElement(By.tagName("label")); if (!chapters.contains(label.getText())) { item.findElement(By.tagName("input")).click(); } } return this; }
From source file:com.cognifide.qa.bb.utils.WebElementUtils.java
License:Apache License
/** * Checks if WebElement with specified name is present on the specified list and clicks it if * it is on the list.//from w w w . j a v a 2 s.co m * * @param elements list of WebElements within which the specified WebElement is searched. * @param elementName name of the WebElement to be clicked. * @return WebElement that has been clicked. * @throws IllegalArgumentException if element with specified name is not on the list. */ public WebElement clickElementIfExists(final List<WebElement> elements, final String elementName) { for (WebElement element : elements) { if (elementName.equals(element.getText())) { element.click(); return element; } } throw new IllegalArgumentException(String.format("There is no element named %s", elementName)); }
From source file:com.cognifide.qa.bobcumber.steps.common.ComponentSteps.java
License:Apache License
@Then("^Radio Group component has \"([^\"]*)\" item$") public void radioGroupComponentHasItem(String radioText) { WebElement webElement = authorHelper.getComponentScope(scenarioContext.getString(PARSYS_NAME_KEY), DemoComponents.RADIO_GROUP); frameSwitcher.switchTo("$cq"); try {//from www. j a v a2 s . co m assertThat("check radio group value", webElement.getText(), is(radioText)); } finally { frameSwitcher.switchBack(); } }
From source file:com.comcast.dawg.house.ContextMenu.java
License:Apache License
/** * Finds the given menu item and then clicks it * @param cmi The item to click/* w w w . j a v a 2 s .com*/ */ public void clickMenuItem(ContextMenuItem cmi) { List<WebElement> items = menuUI.findElements(By.tagName("a")); for (WebElement item : items) { if (item.getText().equals(cmi.getDisp())) { item.click(); return; } } }
From source file:com.comcast.dawg.house.LoginPageIT.java
License:Apache License
/** * @author Kevin Pearson//from ww w. j a v a2 s . c o m * @throws IOException */ @Test(description = "Tests if a user can input a user name and click enter to log in", groups = "uitest") public void testLogin() throws IOException { String user = "integrationuser"; RemoteWebDriver driver = drivers.get(); driver.get(TestServers.getHouse()); loginWithUserName(driver, user); String expectedNewPageUrl = TestServers.getHouse() + user + "/"; Assert.assertEquals(driver.getCurrentUrl(), expectedNewPageUrl); WebElement userInfo = driver.findElementByClassName(IndexPage.USER_SECTION_CLASS); List<WebElement> spans = userInfo.findElements(By.tagName(Tag.SPAN.toString())); Assert.assertFalse(spans.isEmpty()); WebElement userDisplaySpan = spans.get(0); // the first span should show the user name Assert.assertEquals(userDisplaySpan.getText(), user); }