Java Code Examples for org.openqa.selenium.WebElement#getCssValue()
The following examples show how to use
org.openqa.selenium.WebElement#getCssValue() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AssertCssProperty.java From opentest with MIT License | 6 votes |
@Override public void run() { super.run(); By locator = this.readLocatorArgument("locator"); String property = this.readStringArgument("property", null); String expectedValue = this.readStringArgument("value", null); this.waitForAsyncCallsToFinish(); WebElement element = this.getElement(locator); String actualValue = element.getCssValue(property); if (!actualValue.equals(expectedValue)) { throw new RuntimeException(String.format( "Assertion failed for CSS property %s of element %s. Expected value: %s. Actual value: %s.", property, locator, expectedValue, actualValue)); } }
Example 2
Source File: DependencyFilterIT.java From flow with Apache License 2.0 | 6 votes |
@Test public void dependenciesLoadedAsExpectedWithFiltering() { open(); waitUntil(input -> !input.findElements(By.className("dependenciesTest")) .isEmpty()); List<String> testMessages = findElements( By.className("dependenciesTest")).stream() .map(WebElement::getText).collect(Collectors.toList()); boolean found = testMessages.stream() .anyMatch(message -> message.equals("eager.js")); Assert.assertTrue("eager.js should be in the page", found); found = testMessages.stream().anyMatch(message -> message .equals(DependenciesLoadingBaseView.DOM_CHANGE_TEXT)); Assert.assertTrue("Attach a message via JS should be on the page", found); WebElement filteredElement = findElement(By.id("filtered-css")); String color = filteredElement.getCssValue("color"); Assert.assertEquals("rgba(0, 128, 0, 1)", color); }
Example 3
Source File: ExpectedConditions.java From selenium with Apache License 2.0 | 6 votes |
/** * An expectation for checking WebElement with given locator has attribute with a specific value * * @param locator used to find the element * @param attribute used to define css or html attribute * @param value used as expected attribute value * @return Boolean true when element has css or html attribute with the value */ public static ExpectedCondition<Boolean> attributeToBe(final By locator, final String attribute, final String value) { return new ExpectedCondition<Boolean>() { private String currentValue = null; @Override public Boolean apply(WebDriver driver) { WebElement element = driver.findElement(locator); currentValue = element.getAttribute(attribute); if (currentValue == null||currentValue.isEmpty()) { currentValue = element.getCssValue(attribute); } return value.equals(currentValue); } @Override public String toString() { return String.format("element found by %s to have value \"%s\". Current value: \"%s\"", locator, value, currentValue); } }; }
Example 4
Source File: ExpectedConditions.java From selenium with Apache License 2.0 | 6 votes |
/** * An expectation for checking given WebElement has attribute with a specific value * * @param element used to check its parameters * @param attribute used to define css or html attribute * @param value used as expected attribute value * @return Boolean true when element has css or html attribute with the value */ public static ExpectedCondition<Boolean> attributeToBe(final WebElement element, final String attribute, final String value) { return new ExpectedCondition<Boolean>() { private String currentValue = null; @Override public Boolean apply(WebDriver driver) { currentValue = element.getAttribute(attribute); if (currentValue == null || currentValue.isEmpty()) { currentValue = element.getCssValue(attribute); } return value.equals(currentValue); } @Override public String toString() { return String.format(attribute + " to be \"%s\". Current " + attribute + ": \"%s\"", value, currentValue); } }; }
Example 5
Source File: EncapsulateOperation.java From LuckyFrameClient with GNU Affero General Public License v3.0 | 5 votes |
public static String getOperation(WebDriver wd, WebElement we, String operation, String value) { String result = ""; // ��ȡ������ switch (operation) { case "gettext": result = "��ȡ����ֵ�ǡ�" + we.getText() + "��"; LogUtil.APP.info("getText��ȡ����text����...��text����ֵ:{}��",result); break; // ��ȡ��������� case "gettagname": result = "��ȡ����ֵ�ǡ�" + we.getTagName() + "��"; LogUtil.APP.info("getTagName��ȡ����tagname����...��tagname����ֵ:{}��",result); break; case "getattribute": result = "��ȡ����ֵ�ǡ�" + we.getAttribute(value) + "��"; LogUtil.APP.info("getAttribute��ȡ����{}������...��{}����ֵ:{}��",value,value,result); break; case "getcssvalue": result = "��ȡ����ֵ�ǡ�" + we.getCssValue(value) + "��"; LogUtil.APP.info("getCssValue��ȡ����{}������...��{}����ֵ:{}��",value,value,result); break; case "getcaptcha": result = "��ȡ����ֵ�ǡ�" + Ocr.getCAPTCHA(wd, we) + "��"; LogUtil.APP.info("getcaptcha��ȡ��֤��...����֤��ֵ:{}��",result); break; default: break; } return result; }
Example 6
Source File: Utils.java From SWET with MIT License | 5 votes |
public void flash(WebElement element) { String bgcolor = element.getCssValue("backgroundColor"); for (int i = 0; i < 3; i++) { changeColor("rgb(0,200,0)", element); changeColor(bgcolor, element); } }
Example 7
Source File: StaticImageWidgetITCase.java From find with MIT License | 5 votes |
@Test public void testImageElementSrc() { final WebElement webElement = page.getWidgets().get(0); final WebElement staticImageElement = webElement.findElement(By.cssSelector(".static-image")); final String src = staticImageElement.getCssValue("background-image"); assertThat("src is incorrect", "url(\"http://placehold.it/800x300\")".equals(src)); }
Example 8
Source File: AbstractContextInlineIT.java From flow with Apache License 2.0 | 5 votes |
@Test public void inlineDependeciesWithFrontendProtocol() { open(); WebElement templateElement = $(TestBenchElement.class).id("template"); String color = templateElement.getCssValue("color"); Assert.assertEquals("rgba(0, 128, 0, 1)", color); WebElement js = findElement(By.id("js")); Assert.assertEquals("Inlined JS", js.getText()); }
Example 9
Source File: NewQuestionPage.java From mamute with Apache License 2.0 | 5 votes |
public boolean descriptionHintIsVisible() { String descriptionHintId = "question-description-hint"; WebElement hint = byId(descriptionHintId); waitForVisibleElement(hint, 5); String display = hint.getCssValue("display"); return !display.equals("none"); }
Example 10
Source File: NewQuestionPage.java From mamute with Apache License 2.0 | 5 votes |
public boolean titleHintIsVisible() { String titleHintId = "question-title-hint"; WebElement hint = byId(titleHintId); waitForVisibleElement(hint, 5); String display = hint.getCssValue("display"); return !display.equals("none"); }
Example 11
Source File: SeleniumTest.java From gatf with Apache License 2.0 | 5 votes |
private static int getZIndex(WebElement el) { String zindex = el.getCssValue("z-index"); if(zindex!=null) { try { return Integer.parseInt(el.getCssValue("z-index")); } catch (Exception e) { } } return 0; }
Example 12
Source File: ExpectedConditions.java From selenium with Apache License 2.0 | 5 votes |
private static Optional<String> getAttributeOrCssValue(WebElement element, String name) { String value = element.getAttribute(name); if (value == null || value.isEmpty()) { value = element.getCssValue(name); } if (value == null || value.isEmpty()) { return Optional.empty(); } return Optional.of(value); }
Example 13
Source File: SmartWebElement.java From blueocean-plugin with MIT License | 4 votes |
@Override public String getCssValue(String s) { WebElement e = getElement(); return e.getCssValue(s); }
Example 14
Source File: GetCssProperty.java From selenium with Apache License 2.0 | 4 votes |
@Override public String call() { WebElement element = getElement(); return element.getCssValue(propertyName); }