List of usage examples for org.openqa.selenium WebElement getCssValue
String getCssValue(String propertyName);
From source file:org.callimachusproject.webdriver.helpers.WebBrowserDriver.java
License:Apache License
public void waitUntilModalOpen() { Wait<WebDriver> wait = new WebDriverWait(driver, 240); assertTrue(wait.until(new ExpectedCondition<Boolean>() { public Boolean apply(WebDriver wd) { List<WebElement> modals = wd.findElements(By.cssSelector(".modal.fade.in")); if (modals.isEmpty()) return false; for (WebElement modal : modals) { if (!modal.getCssValue("opacity").equals("1")) return false; }//from w w w.ja v a 2 s . c om return true; } public String toString() { return "modal to open"; } })); }
From source file:org.cybercat.automation.core.Browser.java
License:Apache License
/** * highlight active element with red color */// w w w. j av a 2 s .c om public void highlightElement(WebElement element) { String bg = element.getCssValue("backgroundColor"); try { this.executeScript("arguments[0].style.backgroundColor = '" + "red" + "'", element); Point point = element.getLocation(); Dimension demention = new Dimension(point.x, point.y);// .getSize(); eventManager.notify(new TakeScreenshotEvent(this, EffectType.RESIZ_BY_WIDTH, point.getX() + demention.getWidth(), point.getY() + demention.getHeight())); } catch (Exception e) { e.printStackTrace(); } this.executeScript("arguments[0].style.backgroundColor = '" + bg + "'", element); }
From source file:org.eclipse.che.selenium.pageobject.CheTerminal.java
License:Open Source License
/** * scroll terminal by pressing key 'End' * * @param item is the name of the highlighted item *///www . j a v a2s .com public void moveDownListTerminal(String item) { loader.waitOnClosed(); typeIntoActiveTerminal(Keys.END.toString()); WaitUtils.sleepQuietly(2); WebElement element = seleniumWebDriver .findElement(By.xpath(format("(//span[contains(text(), '%s')])[position()=1]", item))); if (!element.getCssValue("background-color").equals(LINE_HIGHLIGHTED_GREEN)) { typeIntoActiveTerminal(Keys.ARROW_UP.toString()); element = seleniumWebDriver .findElement(By.xpath(format("(//span[contains(text(), '%s')])[position()=1]", item))); WaitUtils.sleepQuietly(2); } new WebDriverWait(seleniumWebDriver, REDRAW_UI_ELEMENTS_TIMEOUT_SEC).until(visibilityOf(element)); WebElement finalElement = element; new WebDriverWait(seleniumWebDriver, REDRAW_UI_ELEMENTS_TIMEOUT_SEC).until( (WebDriver input) -> finalElement.getCssValue("background-color").equals(LINE_HIGHLIGHTED_GREEN)); }
From source file:org.eclipse.che.selenium.pageobject.CheTerminal.java
License:Open Source License
/** * scroll terminal by pressing key 'PageDown' * * @param item is the name of the highlighted item *//*from w w w. j ava 2 s . co m*/ public void movePageDownListTerminal(String item) { loader.waitOnClosed(); typeIntoActiveTerminal(Keys.PAGE_DOWN.toString()); WaitUtils.sleepQuietly(2); WebElement element = seleniumWebDriver .findElement(By.xpath(format("(//span[contains(text(), '%s')])[position()=1]", item))); new WebDriverWait(seleniumWebDriver, REDRAW_UI_ELEMENTS_TIMEOUT_SEC).until(visibilityOf(element)); new WebDriverWait(seleniumWebDriver, REDRAW_UI_ELEMENTS_TIMEOUT_SEC) .until((WebDriver input) -> element.getCssValue("background-color").equals(LINE_HIGHLIGHTED_GREEN)); }
From source file:org.eclipse.che.selenium.pageobject.CheTerminal.java
License:Open Source License
/** * scroll terminal by pressing key 'PageUp' * * @param item is the name of the highlighted item */// www .j a va 2s. c om public void movePageUpListTerminal(String item) { loader.waitOnClosed(); typeIntoActiveTerminal(Keys.PAGE_UP.toString()); WaitUtils.sleepQuietly(2); WebElement element = seleniumWebDriver .findElement(By.xpath(format("(//span[contains(text(), '%s')])[position()=1]", item))); new WebDriverWait(seleniumWebDriver, REDRAW_UI_ELEMENTS_TIMEOUT_SEC).until(visibilityOf(element)); new WebDriverWait(seleniumWebDriver, REDRAW_UI_ELEMENTS_TIMEOUT_SEC) .until((WebDriver input) -> element.getCssValue("background-color").equals(LINE_HIGHLIGHTED_GREEN)); }
From source file:org.eclipse.che.selenium.pageobject.machineperspective.MachineTerminal.java
License:Open Source License
/** * scroll terminal by pressing key 'End' * * @param item is the name of the highlighted item *///from w w w .j ava 2 s . c om public void moveDownListTerminal(String item) { loader.waitOnClosed(); actionsFactory.createAction(seleniumWebDriver).sendKeys(Keys.END.toString()).perform(); WaitUtils.sleepQuietly(2); WebElement element = seleniumWebDriver .findElement(By.xpath(format("(//span[contains(text(), '%s')])[position()=1]", item))); new WebDriverWait(seleniumWebDriver, REDRAW_UI_ELEMENTS_TIMEOUT_SEC).until(visibilityOf(element)); new WebDriverWait(seleniumWebDriver, REDRAW_UI_ELEMENTS_TIMEOUT_SEC) .until((WebDriver input) -> element.getCssValue("background-color").equals(LINE_HIGHLIGHTED_GREEN)); }
From source file:org.eclipse.che.selenium.pageobject.machineperspective.MachineTerminal.java
License:Open Source License
/** * scroll terminal by pressing key 'Home' * * @param item is the name of the highlighted item *///w ww . j a va 2 s. c o m public void moveUpListTerminal(String item) { loader.waitOnClosed(); actionsFactory.createAction(seleniumWebDriver).sendKeys(Keys.HOME.toString()).perform(); WaitUtils.sleepQuietly(2); WebElement element = seleniumWebDriver .findElement(By.xpath(format("(//span[contains(text(), '%s')])[position()=1]", item))); new WebDriverWait(seleniumWebDriver, REDRAW_UI_ELEMENTS_TIMEOUT_SEC).until(visibilityOf(element)); new WebDriverWait(seleniumWebDriver, REDRAW_UI_ELEMENTS_TIMEOUT_SEC) .until((WebDriver input) -> element.getCssValue("background-color").equals(LINE_HIGHLIGHTED_GREEN)); }
From source file:org.jspringbot.keyword.selenium.SeleniumHelper.java
License:Open Source License
public String getCSSValue(String locator, String propertyName) { WebElement el = finder.find(locator); return el.getCssValue(propertyName); }
From source file:org.julianharty.accessibility.automation.Util.java
License:Apache License
/** * Determines if the given {@code WebElement} has a computed CSS * {@code cursor} attribute equal to {@code pointer}. * * @param elem candidate {@code WebElement} to be tested as a decorated link * @return {@code true} if the {@code WebElement} is determined to have a * {@code cursor} attribute equal to {@code pointer}, {@code false} * otherwise/* ww w . j a va2 s. co m*/ */ public static boolean hasPointerCursor(WebElement elem) { String cursor = elem.getCssValue("cursor"); return cursor.equals("pointer"); }
From source file:org.julianharty.accessibility.automation.Util.java
License:Apache License
/** * Determines if the given {@code WebElement} has a CSS background image. * * @param elem candidate {@code WebElement} to be tested as a decorated link * @return {@code true} if the {@code WebElement} is determined to have a CSS * background image, {@code false} otherwise *//*from ww w . j a v a2s . c o m*/ public static boolean hasCSSBackground(WebElement elem) { String cssBackground = elem.getCssValue("background-image"); return !cssBackground.equals("none"); }