public WebElement dependency(String value) { for (WebElement element : this.form.findElements(By.name("style"))) { if (value.equals(element.getAttribute("value"))) { return element; } } throw new AssertionError("Dependency not found: " + value); }
@Override public Void execute(SelenideElement proxy, WebElementSource selectField, Object[] args) { String text = (String) args[0]; WebElement element = selectField.getWebElement(); Select select = new Select(element); List<WebElement> options = element.findElements(By.xpath( ".//option[contains(normalize-space(.), " + Quotes.escape(text) + ")]")); if (options.isEmpty()) { throw new NoSuchElementException("Cannot locate option containing text: " + text); } for (WebElement option : options) { setSelected(option); if (!select.isMultiple()) { break; } } return null; }
@Test public void testBannerFunctionalityInDiscoveryPage() { String zoneId = "testzone3"; RestTemplate identityClient = IntegrationTestUtils.getClientCredentialsTemplate( IntegrationTestUtils.getClientCredentialsResource(baseUrl, new String[]{"zones.write", "zones.read", "scim.zones"}, "identity", "identitysecret") ); IdentityZoneConfiguration config = new IdentityZoneConfiguration(); config.setIdpDiscoveryEnabled(true); Banner banner = new Banner(); banner.setText("test banner"); banner.setBackgroundColor("#444"); banner.setTextColor("#111"); config.setBranding(new BrandingInformation()); config.getBranding().setBanner(banner); IntegrationTestUtils.createZoneOrUpdateSubdomain(identityClient, baseUrl, zoneId, zoneId, config); String zoneUrl = baseUrl.replace("localhost",zoneId+".localhost"); webDriver.get(zoneUrl); webDriver.manage().deleteAllCookies(); webDriver.navigate().refresh(); assertEquals("test banner", webDriver.findElement(By.cssSelector(".banner-header span")).getText()); assertEquals("rgba(68, 68, 68, 1)", webDriver.findElement(By.cssSelector(".banner-header")).getCssValue("background-color")); assertEquals("rgba(17, 17, 17, 1)", webDriver.findElement(By.cssSelector(".banner-header span")).getCssValue("color")); String base64Val = "iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAATBJREFUeNqk008og3Ecx/HNnrJSu63kIC5qKRe7KeUiOSulTHJUTrsr0y5ycFaEgyQXElvt5KDYwU0uO2hSUy4KoR7v7/qsfmjPHvzq1e/XU8/39/3zPFHf9yP/WV7jED24nGRbxDFWUAsToM05zyKFLG60d/wmQBxWzwyOlMU1phELEyCmtPeRQRoVbKOM0VYB6q0QW+3IYQpJFFDEYFCAiMqwNY857Ko3SxjGBTbRXb+xMUamcMbWh148YwJvOHSCdyqTAdxZo72ADGwKT98C9CChcxUPQSVYLz50toae4Fy9WcAISl7AiN/RhS1N5RV5rOLxx5eom90pvGAI/VjHMm6bfspK18a1gXvsqM41XDVL052C1Tim56cYd/rR+mdSrXGluxfm5S8Z/HV9CjAAvQZLXoa5mpgAAAAASUVORK5CYII="; banner.setLogo(base64Val); IntegrationTestUtils.createZoneOrUpdateSubdomain(identityClient, baseUrl, zoneId, zoneId, config); webDriver.get(zoneUrl); assertEquals("data:image/png;base64," + base64Val, webDriver.findElement(By.cssSelector(".banner-header img")).getAttribute("src")); assertEquals(2, webDriver.findElement(By.cssSelector(".banner-header")).findElements(By.xpath(".//*")).size()); }
@Override public void clear() { List<WebElement> closeButtons = theField.findElements( By.className( "search-choice-close" ) ); for ( WebElement closeButton : closeButtons ) { closeButton.click(); } }
private Map<String, Column> setColumnHeaders() { List<WebElement> columnElements = dataTableElement.findElements(By.xpath(".//div[contains(@class, 'dataTables_scrollHeadInner')]//thead//th[contains(@class, 'header')]/div")); for ( WebElement columnElement : columnElements ) { Column column = new Column(columnElement); columns.put( column.getName(), column ); } return columns; }
private String getSoftDeletedFeedbackSessionName(int rowId) { return browser.driver.findElement(By.id("tableSoftDeletedFeedbackSessions")) .findElements(By.xpath("tbody/tr")).get(rowId) .findElements(By.xpath("td")).get(1) .getText(); }
public String[] getFieldValuesExcludingId() { String[] allFieldValues = WebElementTransformer.transformToArray( dataContainer.findElements( By.xpath( "//td[contains(@name, 'field-')]" ) ) ); return ArrayUtils.remove( allFieldValues, 0 ); }
public boolean isAllVisibilityOptionsEnabledForNewQuestion() { List<WebElement> visibilityDropdownItems = browser.driver.findElement(By.id("questionTable-" + NEW_QUESTION_NUM)) .findElements(By.cssSelector(".visibility-options-dropdown .dropdown-menu li")); for (WebElement item : visibilityDropdownItems) { if (item.getAttribute("class").contains("hidden")) { return false; } } return true; }
private String getFeedbackSessionCourseId(int rowId) { return browser.driver.findElement(By.id("table-sessions")) .findElements(By.xpath("tbody/tr")).get(rowId) .findElements(By.xpath("td")).get(0) .getText(); }
private String getSoftDeletedFeedbackSessionCourseId(int rowId) { return browser.driver.findElement(By.id("tableSoftDeletedFeedbackSessions")) .findElements(By.xpath("tbody/tr")).get(rowId) .findElements(By.xpath("td")).get(0) .getText(); }
public void clickCopyTableAtRow(int rowIndex) { WebElement row = browser.driver.findElement(By.id("copyTableModal")) .findElements(By.tagName("tr")) .get(rowIndex + 1); click(row); }
/** * Returns the value of the header located at {@code (row, column)} * from the nth(0-index-based) table (which is of type {@code class=table}) in the page. */ public String getHeaderValueFromDataTable(int tableNum, int row, int column) { WebElement tableElement = browser.driver.findElements(By.className("table")).get(tableNum); WebElement trElement = tableElement.findElements(By.tagName("tr")).get(row); WebElement tdElement = trElement.findElements(By.tagName("th")).get(column); return tdElement.getText(); }
/** * Unchecks every course in the course list. */ public void resetCoursesCheckboxes() { WebElement fsCopyModal = browser.driver.findElement(By.id("fsCopyModal")); List<WebElement> coursesCheckBoxes = fsCopyModal.findElements(By.name(Const.ParamsNames.COPIED_COURSES_ID)); for (WebElement e : coursesCheckBoxes) { markCheckBoxAsUnchecked(e); } }
public void deselectUsersInRemindAllForm() { WebElement remindModal = browser.driver.findElement(By.id("remindModal")); List<WebElement> usersToRemind = remindModal.findElements(By.name("usersToRemind")); for (WebElement e : usersToRemind) { markCheckBoxAsUnchecked(e); } }
public void checkCheckboxesInForm(WebElement form, String elementsName) { List<WebElement> formElements = form.findElements(By.name(elementsName)); for (WebElement e : formElements) { markCheckBoxAsChecked(e); } }
/** * Returns the number of rows from the nth(0-index-based) table * (which is of type {@code class=table}) in the page. */ public int getNumberOfRowsFromDataTable(int tableNum) { WebElement tableElement = browser.driver.findElements(By.className("table")).get(tableNum); return tableElement.findElements(By.tagName("tr")).size(); }
public void clickCopyTableRadioButtonAtRow(int rowIndex) { WebElement button = browser.driver.findElement(By.id("copyTableModal")) .findElements(By.tagName("tr")) .get(rowIndex + 1).findElement(By.tagName("input")); click(button); }
public boolean isRadioButtonChecked(int rowIndex) { WebElement button = browser.driver.findElement(By.id("copyTableModal")) .findElements(By.tagName("tr")) .get(rowIndex + 1).findElement(By.tagName("input")); return button.isSelected(); }
public void clickVisibilityOptionForResponseCommentAndSave(String idString, int numOfTheCheckbox) { String idSuffix = idString.substring(18); WebElement commentRow = browser.driver.findElement(By.id(idString)); click(commentRow.findElements(By.tagName("a")).get(1)); WebElement commentEditForm = browser.driver.findElement(By.id("responseCommentEditForm" + idSuffix)); click(commentRow.findElement(By.id("frComment-visibility-options-trigger" + idSuffix))); click(commentRow.findElements(By.cssSelector("input[type='checkbox']")).get(numOfTheCheckbox)); click(commentEditForm.findElement(By.className("col-sm-offset-5")).findElement(By.tagName("a"))); ThreadHelper.waitFor(1000); }
/** * Returns the number of columns from the header in the table * (which is of type {@code class=table}) in the page. */ public int getNumberOfColumnsFromDataTable(int tableNum) { WebElement tableElement = browser.driver.findElements(By.className("table")).get(tableNum); WebElement trElement = tableElement.findElement(By.tagName("tr")); return trElement.findElements(By.tagName("th")).size(); }