List of usage examples for org.openqa.selenium WebElement getCssValue
String getCssValue(String propertyName);
From source file:com.liferay.faces.test.showcase.outputstylesheet.OutputStylesheetGeneralTester.java
License:Open Source License
@Test public void runOutputStylesheetGeneralTest() throws Exception { BrowserDriver browserDriver = getBrowserDriver(); navigateToUseCase(browserDriver, "outputStylesheet", "general"); // Test that both buttons render on the page successfully. WaitingAsserter waitingAsserter = getWaitingAsserter(); String button1Xpath = "(//button[normalize-space(text())='Button'])[1]"; waitingAsserter.assertElementDisplayed(button1Xpath); String button2Xpath = "(//button[normalize-space(text())='Button'])[2]"; waitingAsserter.assertElementDisplayed(button2Xpath); // Test that the first button's opacity is correct. WebElement buttonElement = browserDriver.findElementByXpath(button1Xpath); String buttonOpacity = buttonElement.getCssValue("opacity"); // Since the opacity is a floating point value, it's value may not match .65 exactly. Assert.assertTrue("The button's opacity is not .65, instead it is " + buttonOpacity, (buttonOpacity.contains(".649") || buttonOpacity.contains(".65"))); // Test that the second button's display is block. buttonElement = browserDriver.findElementByXpath(button2Xpath); String buttonDisplay = buttonElement.getCssValue("display"); Assert.assertTrue("The button's display is not block, instead it is " + buttonDisplay, buttonDisplay.contains("block")); }
From source file:com.mgmtp.jfunk.web.util.WebDriverTool.java
License:Apache License
/** * Delegates to {@link #findElement(By)} and then calls * {@link WebElement#getCssValue(String) getAttribute(String)} on the returned element. * * @param by// ww w .j a va 2 s .c o m * the {@link By} used to locate the element * @param propertyName * the name of the CSS property * @return The current, computed value of the property. */ public String getCssValue(final By by, final String propertyName) { WebElement element = findElement(by); return element.getCssValue(propertyName); }
From source file:com.mkl.websuites.internal.command.impl.check.CheckCssCommand.java
License:Apache License
@Override protected void doOperationOnElement(WebElement elem) { cssAttributeName = parameterMap.get(CSS_ATTR_NAME); expectedCssAttributeValue = parameterMap.get(CSS_ATTR_VALUE); actualCssAttributeValue = elem.getCssValue(cssAttributeName); AbstractCheck checkLogic = defineCheckLogic(); checkLogic.runStandardCommand();//from w ww. ja v a 2 s .c om }
From source file:com.nabla.project.fronter.selenium.tests.helper.SeleniumHelper.java
License:Open Source License
public static void testElementStyle(final String id, String expectedResult, final WebDriver driver) { final WebElement message = driver.findElement(By.id(id)); final String width = message.getCssValue("width"); if (null == expectedResult) { expectedResult = "150px"; }/*w ww. j a v a2 s. c om*/ Assert.assertEquals(expectedResult, width); }
From source file:com.osbitools.ws.shared.prj.xui.GenericPrjMgrGuiWebTest.java
License:LGPL
/** * Check project widget with/without first entity created * @param lang Test language//from w ww . ja v a2 s. c om * @param pname Project name * @param fent True when first entity created */ private void checkProjectWidget(String lang, String pname, boolean fent) { checkLangElementById(lang, "LL_SELECT_PROJECT"); WebElement psel = driver.findElement(By.id("project_sel")); assertEquals(pname, psel.getAttribute("value")); List<WebElement> ops = psel.findElements(By.tagName("option")); assertEquals(1, ops.size()); assertEquals(pname, ops.get(0).getText()); checkLangElementById(lang, "LL_NEW"); checkLangElementById(lang, "LL_RENAME"); checkLangElementById(lang, "LL_DELETE"); checkLangElementById(lang, "LL_GIT_PUSH"); checkLangElementById(lang, "LL_LOGOUT"); // Look for new button WebElement btn = driver.findElement(By.className("node-new-btn")); assertNotNull("New Button is not found", btn); WebElement img = btn.findElement(By.tagName("img")); assertNotNull(img); assertEquals("http://localhost:8090/web_test/fr/" + "modules/prj/images/new_entity.png", img.getAttribute("src")); WebElement bname = btn.findElement(By.tagName("a")); assertNotNull(bname); assertEquals(getLabelText(lang, "LL_NEW"), bname.getText()); assertEquals("pointer", bname.getCssValue("cursor")); // Check list of component groups and icons checkComponentList(lang, fent); // Check project controls disabled checkElementVisible("ws_list", fent); checkElementVisible("entity_ctx_ctrl", fent); if (fent) { checkDataSourceList(lang); checkDbConnList(lang); } }
From source file:com.osbitools.ws.shared.xui.DemoGuiWebTest.java
License:LGPL
private void checkDemoPage(String lang) throws InterruptedException { checkElementVisible("page_loader", false); checkElementVisible("login_widget", false); checkElementVisible("webapp_ctx", true); checkElementVisible("error_window", false); checkElementVisible("success_window", true); // Extra check checkWidgetsOnLogin();//from ww w .java 2 s .c o m // Check success message assertEquals("Success message doesn't match", getLabelText(lang, "LL_DEMO_MSG"), driver.findElement(By.id("ok_msg")).getText()); // Click on close button driver.findElement(By.id("success_window")).findElement(By.className("b-close")).click(); Thread.sleep(1000); checkElementVisible("webapp_ctx", true); checkElementVisible("error_window", false); checkElementVisible("success_window", false); // Check color of message WebElement dmsg = driver.findElement(By.className("demo")); assertEquals("demo message color doesn't match", "rgba(128, 128, 128, 1)", dmsg.getCssValue("color")); checkButtonById(lang, "ll_error", true); checkButtonById(lang, "ll_logout", true); // Check & Press error button WebElement err = driver.findElement(By.id("ll_error")); err.click(); Thread.sleep(500); checkErrorWin(lang, "C-DEMO", getLabelText(lang, "LL_INFO_MSG"), getLabelText(lang, "LL_DETAIL_MSG_1") + "\n" + getLabelText(lang, "LL_DETAIL_MSG_2")); }
From source file:com.smash.revolance.ui.model.element.api.Element.java
License:Open Source License
public static String getBg(String tag, WebElement element) { String bg = ""; if (!tag.contentEquals("img")) { bg = element.getCssValue("background-image"); if (bg.contentEquals("none")) { bg = element.getCssValue("background-url"); }//from ww w.j av a2 s .c o m } else { bg = element.getAttribute("src"); } if (bg == null || bg.contentEquals("none")) { bg = ""; } if (!bg.isEmpty()) { //TODO: use standard image format instead of css/uri if (!bg.contains("url") && !bg.contains("http") && !bg.contains(ImageHelper.BASE64_IMAGE_PNG)) { bg = ""; } } return bg; }
From source file:com.vaadin.addon.spreadsheet.elements.SpreadsheetElement.java
License:Open Source License
private boolean isNonCoherentlySelected(WebElement element) { // an element is non-coherently selected if the class attribute // contains "cell-range" return element.getAttribute("class").contains("cell-range") || "solid".equals(element.getCssValue("outline-style")); }
From source file:com.vaadin.tests.components.grid.basicfeatures.server.GridEditorUnbufferedTest.java
License:Apache License
@Test public void testErrorMessageWrapperHidden() { selectMenuPath(EDIT_ITEM_5);//from www .j av a 2s .co m assertEditorOpen(); WebElement editorFooter = getEditor().findElement(By.className("v-grid-editor-footer")); assertTrue("Editor footer should not be visible when there's no error", editorFooter.getCssValue("display").equalsIgnoreCase("none")); }
From source file:com.vaadin.tests.components.gridlayout.GridLayoutExpandRatioTest.java
License:Apache License
@Test public void gridLayoutExpandRatioTest() { openTestURL();/*from w w w . j a va 2s. com*/ GridLayoutElement gridLayout5x5 = $(GridLayoutElement.class).get(0); GridLayoutElement gridLayout4x4 = $(GridLayoutElement.class).get(1); ButtonElement hidingButton = $(ButtonElement.class).get(0); hidingButton.click(); List<WebElement> slots5x5 = gridLayout5x5.findElements(By.className("v-gridlayout-slot")); List<WebElement> slots4x4 = gridLayout4x4.findElements(By.className("v-gridlayout-slot")); assertEquals("Different amount of slots", slots5x5.size(), slots4x4.size()); for (int i = 0; i < slots5x5.size(); i++) { WebElement compared = slots5x5.get(i); WebElement actual = slots4x4.get(i); assertEquals("Different top coordinate for element " + i, compared.getCssValue("top"), actual.getCssValue("top")); assertEquals("Different left coordinate for element " + i, compared.getCssValue("left"), actual.getCssValue("left")); } }