List of usage examples for org.openqa.selenium WebElement getCssValue
String getCssValue(String propertyName);
From source file:de.betterform.conformance.WebDriverTestFunctions.java
License:BSD License
private boolean checkControlHelpHintAlert(String id, String value, String htmlclass) { WebElement webElement = webDriver.findElement(By.id(id)); if (hasHTMlClass(webElement, htmlclass)) { if (!webElement.getCssValue("display").equals("none")) { if (!"".equals(value)) { return value.equalsIgnoreCase(webElement.getText()); }/*from ww w.ja va 2 s . com*/ return true; } } return false; }
From source file:de.betterform.conformance.WebDriverTestFunctions.java
License:BSD License
private boolean hasGrouplayout(WebElement group, String apperance) { boolean validLayout = true; if (WebDriverTestInterface.appearanceFull.equals(apperance)) { if (WebDriverTestInterface.spanTagName.equals(group.getTagName())) { Iterator<WebElement> children = group .findElements(By.className(WebDriverTestInterface.xfControlClass)).iterator(); while (children.hasNext()) { WebElement child = children.next(); if (child.getAttribute("widgetid") != null) { WebElement widget = child .findElement(By.id("widget_" + child.getAttribute("widgetid") + "-value")); validLayout &= "200px".equals(widget.getCssValue("left")); validLayout &= "left".equals(widget.getCssValue("text-align")); }/*from w ww . j a v a 2s . co m*/ validLayout &= WebDriverTestInterface.spanTagName.equals(child.getTagName()); } return validLayout; } } else if (WebDriverTestInterface.appearanceCompact.equals(apperance) || WebDriverTestInterface.appearanceDefault.equals(apperance)) { if (WebDriverTestInterface.spanTagName.equals(group.getTagName())) { Iterator<WebElement> children = group .findElements(By.className(WebDriverTestInterface.xfControlClass)).iterator(); while (children.hasNext()) { WebElement child = children.next(); if (child.getAttribute("widgetid") != null) { WebElement widget = child .findElement(By.id("widget_" + child.getAttribute("widgetid") + "-value")); validLayout &= "start".equals(widget.getCssValue("text-align")); } validLayout &= WebDriverTestInterface.spanTagName.equals(child.getTagName()); } return validLayout; } } else if (WebDriverTestInterface.appearanceHorizontalTable.equals(apperance)) { if (WebDriverTestInterface.tableTagName.equals(group.getTagName())) { final List<WebElement> children = group .findElements(By.tagName(WebDriverTestInterface.tableRowTagName)); if (children.size() == 3) { WebElement labelRow = children.get(1); WebElement valueRow = children.get(2); final List<WebElement> labels = labelRow .findElements(By.tagName(WebDriverTestInterface.tableColTagName)); final List<WebElement> values = valueRow .findElements(By.tagName(WebDriverTestInterface.tableColTagName)); if (labels.size() == values.size()) { for (int i = 0; i < labels.size(); i++) { validLayout &= hasHTMlClass(labels.get(i), "bfHorizontalTableLabel)"); List<WebElement> htmlLabels = labels.get(i) .findElements(By.tagName(WebDriverTestInterface.labelTagName)); validLayout &= (htmlLabels.size() == 1); validLayout &= (hasHTMlClass(htmlLabels.get(0), "bfTableLabel")); //TODO: !!!! } for (int i = 0; i < labels.size(); i++) { validLayout &= hasHTMlClass(values.get(i), "bfHorizontalTableValue)"); //TODO: !!!! } } } } } return false; }
From source file:de.knowwe.uitest.haddock.PanelHaddockUITest.java
License:Open Source License
@Test public void testRightPanelCollapseWatchesOnNarrowWindow() throws InterruptedException { getDriver().manage().window().setSize(NARROW_SIZE); Thread.sleep(500);//from ww w . j a v a 2s .com if (!isRightPanelVisible()) pressRightPanelButton(); assertTrue(isRightPanelVisible()); WebElement watches = getRightPanel().findElement(By.id("watches")); WebElement watchesTitle = watches.findElement(By.className("title")); watchesTitle.click(); Thread.sleep(500); WebElement watchesContent = watches.findElement(By.className("right-panel-content")); assertEquals("Watches shoud be collapsed", watchesContent.getCssValue("display"), "none"); watches.findElement(By.className("title")).click(); Thread.sleep(500); assertThat(watchesContent.getCssValue("display"), is(not("none"))); pressRightPanelButton(); getDriver().manage().window().setSize(STANDARD_SIZE); Thread.sleep(500); }
From source file:de.knowwe.uitest.PanelUITest.java
License:Open Source License
@Test public void testRightPanelCollapseWatches() throws InterruptedException { pressRightPanelButton();//from ww w .jav a 2 s .c om WebElement watches = getRightPanel().findElement(By.id("watches")); watches.findElement(By.className("title")).click(); Thread.sleep(500); WebElement watchesContent = watches.findElement(By.className("right-panel-content")); assertEquals("Watches shoud be collapsed", watchesContent.getCssValue("display"), "none"); watches.findElement(By.className("title")).click(); Thread.sleep(500); assertThat(watchesContent.getCssValue("display"), is(not("none"))); pressRightPanelButton(); }
From source file:info.magnolia.integrationtests.uitest.AbstractMagnoliaUITest.java
License:Open Source License
protected ExpectedCondition<WebElement> applauncherTransitionIsComplete() { final WebElement shellappsViewport = getElement(By.className("v-viewport-shellapps")); return new ExpectedCondition<WebElement>() { @Override/*from www. j av a2s . co m*/ public WebElement apply(WebDriver driver) { return "0px".equals(shellappsViewport.getCssValue("top")) ? shellappsViewport : null; } }; }
From source file:info.magnolia.integrationtests.uitest.SimpleFieldUITest.java
License:Open Source License
@Test public void selectFieldHasOverflowAutoAndHeight() { // GIVEN//from ww w . j av a 2 s .c o m goToDialogShowRoomAndOpenDialogComponent("ftl"); openTabWithCaption("Selections"); waitUntil(tabIsOpen("Selections")); WebElement select = getFormField("Select"); // Simulate a click on the select field so that the suggestion menu pops up and becomes visible. Can't invoke click() method directly // on select because that is a DIV and clicking on it has not the desired effect. WebElement selection = select.findElement(By.className("v-filterselect-input")); selection.click(); // WHEN WebElement suggestMenu = getElement(By.xpath("//div[contains(@class, 'v-filterselect-suggestmenu')]")); // THEN assertEquals("auto", suggestMenu.getCssValue("overflow-y")); assertTrue(StringUtils.isNotBlank(suggestMenu.getCssValue("height"))); }
From source file:jhc.redsniff.webdriver.matchers.ColorMatcher.java
License:Apache License
@Override protected boolean matchesSafely(WebElement item, Description mismatchDescription) { Color actualColor = Color.fromString(item.getCssValue(attributeName)); if (actualColor.equals(expectedColor)) return true; else {/*from w ww . j a va 2 s. co m*/ mismatchDescription.appendText(attributeName + " was " + toString(actualColor)); return false; } }
From source file:jhc.redsniff.webdriver.matchers.CssRenderingMatcher.java
License:Apache License
@Override protected String stateOf(WebElement actual) { return actual.getCssValue(cssAttributeName); }
From source file:nikoladasm.examples.aspark_angularjs_rest.UITest.java
License:Open Source License
private void flash(String color, int interval, int count, WebElement element, WebDriver driver) { JavascriptExecutor js = ((JavascriptExecutor) driver); String bgcolor = element.getCssValue("backgroundColor"); for (int i = 0; i < count; i++) { changeColor(color, interval, element, js); changeColor(bgcolor, interval, element, js); }/* w w w . jav a 2s . c o m*/ }
From source file:org.alfresco.po.share.SharePage.java
License:Open Source License
/** * Get background color of element or color of element (font color) * // w w w .ja v a2 s . co m * @param locator By * @param background if needed to find color of element's background - param must be true * if needed to find color of element itself - param must be false * @return hex * return color in Hex color model */ public String getColor(By locator, boolean background) { WebElement element; String hex = ""; String color; try { element = findAndWait(locator); if (background) color = element.getCssValue("background-color"); else color = element.getCssValue("color"); String[] numbers = color.replace("rgba(", "").replace(")", "").split(","); int number1 = Integer.parseInt(numbers[0]); numbers[1] = numbers[1].trim(); int number2 = Integer.parseInt(numbers[1]); numbers[2] = numbers[2].trim(); int number3 = Integer.parseInt(numbers[2]); hex = String.format("#%02x%02x%02x", number1, number2, number3); } catch (StaleElementReferenceException e) { getColor(locator, background); } catch (TimeoutException e) { if (logger.isTraceEnabled()) { logger.trace("Exceeded time to find " + locator + " locator"); } } return hex; }