Example usage for org.openqa.selenium WebElement getCssValue

List of usage examples for org.openqa.selenium WebElement getCssValue

Introduction

In this page you can find the example usage for org.openqa.selenium WebElement getCssValue.

Prototype

String getCssValue(String propertyName);

Source Link

Document

Get the value of a given CSS property.

Usage

From source file:org.uiautomation.ios.selenium.RenderedWebElementTest.java

License:Apache License

@Test
public void testShouldGetTextDecorationCss() {
    driver.get(pages.javascriptPage);//from w  w  w.j a v  a2 s  .c  o  m

    WebElement element = driver.findElement(By.tagName("a"));
    String height = element.getCssValue("text-decoration");

    assertEquals("underline", height);
}

From source file:org.vaadin.addonhelpers.automated.AbstractWebDriverCase.java

protected void waitForLoading() {
    sleep(1000);/* w ww  .j  a v a2  s . c o m*/
    // driver.manage().timeouts().implicitlyWait(1, TimeUnit.SECONDS);
    (new WebDriverWait(driver, 20)).until(new ExpectedCondition<Boolean>() {
        public Boolean apply(WebDriver d) {
            boolean stopWait = false;
            try {
                WebElement findElement = d.findElement(By.className("v-loading-indicator"));
                String cssValueDisplay = findElement.getCssValue("display");
                if (StringUtils.equals("none", cssValueDisplay)) {
                    stopWait = true;
                }
            } catch (NoSuchElementException e) {
                stopWait = true;
            }
            return stopWait;
        }
    });
}

From source file:org.wso2.ds.ui.integration.test.dashboard.BannerTest.java

License:Open Source License

/**
 * Checks whether the banner is available in view mode.
 *
 * @throws MalformedURLException/*from  w  w w  .  j av  a2 s.c o  m*/
 * @throws XPathExpressionException
 */
private Boolean isBannerPresent() throws MalformedURLException, XPathExpressionException, InterruptedException {
    getDriver().findElement(By.cssSelector("a.ues-dashboard-preview")).click();
    pushWindow();
    WebElement bannerElem = getDriver().findElement(By.cssSelector("[data-banner=true]"));
    String imageUrl = bannerElem.getCssValue("background-image");
    getDriver().close();
    if (imageUrl != null && !imageUrl.isEmpty()) {
        return true;
    }
    return false;
}

From source file:org.wso2.ds.ui.integration.test.dashboard.BannerTest.java

License:Open Source License

/**
 * Checks whether the banner is available in designer mode.
 *
 * @throws MalformedURLException/*from   w  ww  .ja v a 2  s.com*/
 * @throws XPathExpressionException
 */
private Boolean isBannerPresentInDesignerMode() throws MalformedURLException, XPathExpressionException {
    Boolean isBannerPresent = false;
    if (getDriver().isElementPresent(By.className("banner-image"))) {
        WebElement bannerElem = getDriver().findElement(By.className("banner-image"));
        String imageUrl = bannerElem.getCssValue("background-image");
        if (imageUrl != null && !imageUrl.isEmpty()) {
            isBannerPresent = true;
        }
    } else {
        isBannerPresent = false;
    }
    return isBannerPresent;
}

From source file:org.xwiki.flamingo.test.po.PreviewBox.java

License:Open Source License

private String getElementCSSValue(final By locator, String attribute) {
    try {/* ww  w.ja  v  a2  s . c  om*/
        getDriver().switchTo().frame("iframe");
        WebElement element = getDriver().findElement(locator);
        return element.getCssValue(attribute);
    } finally {
        getDriver().switchTo().defaultContent();
    }
}

From source file:org.xwiki.flamingo.test.po.ThemeApplicationWebHomePage.java

License:Open Source License

@Override
protected String getElementCSSValue(final By locator, String attribute) {
    WebElement element = getDriver().findElement(locator);
    return element.getCssValue(attribute);
}

From source file:org.xwiki.test.ui.po.editor.UserPicker.java

License:Open Source License

/**
 * Waits until the suggestions for the current value of the text input are retrieved.
 * /*from   www  .j  a va  2  s.c om*/
 * @return this
 */
public UserPicker waitForSuggestions() {
    getUtil().waitUntilCondition(new ExpectedCondition<Boolean>() {
        public Boolean apply(WebDriver driver) {
            return !textInput.getAttribute("class").contains("loading") && isSuggestListDisplayed(driver);
        }

        private boolean isSuggestListDisplayed(WebDriver driver) {
            WebElement suggestItems = driver.findElement(By.className("suggestItems"));
            // div.suggestItems is added to the document before the suggestions are retrieved. We need to wait for
            // the actual list of suggestions (ul.suggestList).
            WebElement suggestList = suggestItems.findElement(By.className("suggestList"));
            // div.suggestItems fades when closing.
            return suggestList.isDisplayed() && Double.parseDouble(suggestItems.getCssValue("opacity")) == 1;
        }
    });
    return this;
}

From source file:ru.stqa.selenium.decorated.events.WebDriverListenerTest.java

License:Apache License

@Test
void canFireEventForWebElementGetCssValue() {
    Fixture fixture = new Fixture();

    final WebElement mockedElement = mock(WebElement.class);

    when(fixture.mockedDriver.findElement(By.id("id"))).thenReturn(mockedElement);
    when(mockedElement.getCssValue("color")).thenReturn("red");

    assertEquals(fixture.driver.findElement(By.id("id")).getCssValue("color"), "red");

    verify(fixture.mockedDriver, times(1)).findElement(By.id("id"));
    verifyNoMoreInteractions(fixture.mockedDriver);
    verify(fixture.listener, times(1)).beforeFindElement(fixture.mockedDriver, By.id("id"));
    verify(fixture.listener, times(1)).afterFindElement(mockedElement, fixture.mockedDriver, By.id("id"));
    verify(mockedElement, times(1)).getCssValue("color");
    verifyNoMoreInteractions(mockedElement);
    verify(fixture.listener, times(1)).beforeGetCssValue(mockedElement, "color");
    verify(fixture.listener, times(1)).afterGetCssValue("red", mockedElement, "color");
    verifyNoMoreInteractions(fixture.listener);
}

From source file:uk.ac.ebi.atlas.acceptance.selenium.pages.DifferentialExperimentDesignTablePage.java

License:Apache License

public String getLineColor(int rowIndex) {
    List<WebElement> row = getRow(experimentDesignTable, rowIndex);
    WebElement element = row.get(0);
    return element.getCssValue("background-color");
}

From source file:uk.ac.ebi.atlas.acceptance.selenium.pages.HeatmapTablePage.java

License:Apache License

public List<String> getDiffGradientColors() {
    WebElement element = diffHeatmapTableLegend.findElement(By.className("color-gradient"));
    String style = element.getCssValue("background-image");
    return Lists.newArrayList(StringUtils.substringsBetween(style, "rgb(", ")"));
}