List of usage examples for org.openqa.selenium WebElement getCssValue
String getCssValue(String propertyName);
From source file:org.nuxeo.ftest.cap.ITMiscLittleThingsTest.java
License:Apache License
@Test public void testRequiredAsterisk() throws UserNotConnectedException { DocumentBasePage page = asPage(DocumentBasePage.class); page.getEditTab();//from w ww. j av a 2s . c o m String labelPattern = "//form[@id='document_edit']//tr[%s]//td[@class='labelColumn']//span"; // title is required WebElement title = driver.findElement(By.xpath(String.format(labelPattern, 1))); assertEquals("Title", title.getText()); String titleStyleClass = title.getAttribute("class"); assertNotNull(titleStyleClass); assertTrue(titleStyleClass.contains("required")); String bgimage = title.getCssValue("background-image"); assertNotNull(bgimage); assertTrue(bgimage.contains("required.gif")); // desc is not required WebElement desc = driver.findElement(By.xpath(String.format(labelPattern, 2))); assertEquals("Description", desc.getText()); String descStyleClass = desc.getAttribute("class"); assertNotNull(descStyleClass); assertFalse(descStyleClass.contains("required")); String descbgimage = desc.getCssValue("background-image"); assertNotNull(descbgimage); assertFalse(descbgimage.contains("required.gif")); }
From source file:org.openlmis.pageobjects.DistributionTab.java
License:Open Source License
public void verifyOverallIndicator(WebElement element, String color) { testWebDriver.sleep(500);//from w w w . j a v a2s .co m assertEquals(colorMap.get(color.toLowerCase()), element.getCssValue("background-color")); }
From source file:org.openlmis.UiUtils.TestCaseHelper.java
License:Open Source License
public void verifyPageNumberSelected(int pageNumber) { WebElement page = testWebDriver.getElementById(String.valueOf(pageNumber)); testWebDriver.waitForElementToAppear(page); AssertJUnit.assertEquals("rgba(96, 172, 175, 1)", page.getCssValue("background-color")); }
From source file:org.openlmis.UiUtils.TestCaseHelper.java
License:Open Source License
public void verifyNextAndLastPageLinksEnabled() { testWebDriver.waitForAjax();/* w w w. j a v a 2 s . c o m*/ WebElement nextPageLink = testWebDriver.getElementById("nextPageLink"); assertEquals(nextPageLink.getCssValue("color"), "rgba(119, 119, 119, 1)"); assertEquals(testWebDriver.getElementById("lastPageLink").getCssValue("color"), "rgba(119, 119, 119, 1)"); }
From source file:org.openlmis.UiUtils.TestCaseHelper.java
License:Open Source License
public void verifyPreviousAndFirstPageLinksDisabled() { testWebDriver.waitForAjax();// w ww. j av a2 s .com WebElement firstPageLink = testWebDriver.getElementById("firstPageLink"); assertEquals(firstPageLink.getCssValue("color"), "rgba(204, 204, 204, 1)"); assertEquals(testWebDriver.getElementById("previousPageLink").getCssValue("color"), "rgba(204, 204, 204, 1)"); }
From source file:org.paxml.selenium.webdriver.PickCssTag.java
License:Open Source License
/** * {@inheritDoc}//ww w . jav a2s . c o m */ @Override protected Object onCommand(Context context) { return handleElements(new IElementHandler() { public Object handle(WebElement ele) { return ele.getCssValue(name); } }); }
From source file:org.richfaces.integration.skin.AbstractSkinTestBase.java
License:Open Source License
protected URL getBackgroundUrl(WebElement element) { String backgroundImage = element.getCssValue("background-image"); Matcher matcher = Pattern.compile("url\\((.*)\\)").matcher(backgroundImage); if (!matcher.matches()) { throw new IllegalArgumentException( String.format("the background-image property '%s' does not match the regexp", backgroundImage)); }/*from w w w.ja v a 2 s . co m*/ String urlString = matcher.group(1); urlString = urlString.replaceAll("(^\"|\"$)", ""); try { return new URL(urlString); } catch (MalformedURLException e) { throw new IllegalStateException(String.format("the url '%s' isn't valid URL", urlString), e); } }
From source file:org.richfaces.tests.metamer.ftest.checker.IconsChecker.java
License:Open Source License
/** * Checks whether icons controlled by CSS work properly (only icons which produce an image) * * @param attribute icon attribute//www . j a v a 2 s .c om * @param icon icon element * @param isHeaderIcon */ public void checkCssImageIcons(A attribute, WebElement icon, boolean isHeaderIcon) { boolean isDisabled = attribute.toString().toLowerCase().contains(DISABLED); // option -> css class for (String cssIcon : cssImageIcons.keySet()) { if (!setAttributeSilently(attribute, cssIcon)) { continue; } String classAtt = icon.getAttribute(CLASS_STRING); assertTrue(classAtt.contains(cssImageIcons.get(cssIcon))); if (cssIcon.equals(TRANSPARENT)) { assertTrue(icon.getCssValue(BG_IMAGE).equals(NONE)); } else { assertTrue(icon.getCssValue(BG_IMAGE).contains(cssIcon)); } boolean containsHeaderStyleClass = classAtt.contains(HEADER_ICON_CLASS); assertTrue(isHeaderIcon ? containsHeaderStyleClass : !containsHeaderStyleClass, "Icon should contain class 'rf-ico-t-hdr' when it is placed in header."); boolean containsDisabledClass = classAtt.contains(DISABLED_CLASS); assertTrue(isDisabled ? containsDisabledClass : !containsDisabledClass, "Icon should contain class 'rf-ico-t-dis' when it is disabled."); // https://issues.jboss.org/browse/RFPL-3718: // checks https://issues.jboss.org/browse/RF-10817 after https://issues.jboss.org/browse/RF-14039 String bgPosition = icon.getCssValue("background-position"); assertTrue(isDisabled ? bgPosition.contains(DISABLED_ICON_POSITION)// disabled image position : isHeaderIcon ? bgPosition.contains(HEADER_ICON_POSITION) : bgPosition.contains(STANDARD_ICON_POSITION), "The icon color/position does not match its state."); } }
From source file:org.richfaces.tests.metamer.ftest.richAccordion.TestAccordion.java
License:Open Source License
@Test public void testHeight() { WebElement accordionRoot = page.getAccordionRootElement(); // height = null assertEquals(accordionRoot.getAttribute("style"), "", "Attribute style should not be present."); // height = 300px accordionAttributes.set(AccordionAttributes.height, "300px"); assertEquals(accordionRoot.getCssValue("height"), "300px", "Attribute height"); }
From source file:org.richfaces.tests.metamer.ftest.richNotify.TestNotifyAttributes.java
License:Open Source License
public static void waitForOpacityChange(final double opacity, final WebElement element) { Graphene.waitGui().withTimeout(3, TimeUnit.SECONDS).until(new ExpectedCondition<Boolean>() { @Override//from w w w.j ava 2 s . c om public Boolean apply(WebDriver from) { return element.getCssValue("opacity") .equals((opacity == 0 ? "0" : (opacity == 1 ? "1" : String.valueOf(opacity)))); } @Override public String toString() { return "opacity change to value '" + opacity + "'. Actual value '" + element.getCssValue("opacity") + "'"; } }); }