Ejemplo n.º 1
0
  @JavascriptEnabled
  @Ignore({ANDROID, HTMLUNIT, OPERA, SELENESE})
  @Test
  public void testGetCssValueShouldReturnStandardizedColour() {
    driver.get(pages.colorPage);

    WebElement element = driver.findElement(By.id("namedColor"));
    String backgroundColour = element.getCssValue("background-color");
    assertEquals("rgba(0, 128, 0, 1)", backgroundColour);

    element = driver.findElement(By.id("rgb"));
    backgroundColour = element.getCssValue("background-color");
    assertEquals("rgba(0, 128, 0, 1)", backgroundColour);
  }
Ejemplo n.º 2
0
  @JavascriptEnabled
  @Ignore({ANDROID, HTMLUNIT, OPERA, SELENESE})
  @Test
  public void testShouldPickUpStyleOfAnElement() {
    driver.get(pages.javascriptPage);

    WebElement element = driver.findElement(By.id("green-parent"));
    String backgroundColour = element.getCssValue("background-color");

    assertEquals("rgba(0, 128, 0, 1)", backgroundColour);

    element = driver.findElement(By.id("red-item"));
    backgroundColour = element.getCssValue("background-color");

    assertEquals("rgba(255, 0, 0, 1)", backgroundColour);
  }
Ejemplo n.º 3
0
  // TODO: This test's value seems dubious at best. The CSS spec does not define how browsers
  // should handle sub-pixel rendering, and every browser seems to be different anyhow:
  // http://ejohn.org/blog/sub-pixel-problems-in-css/
  @JavascriptEnabled
  @Ignore({IE, CHROME, SELENESE, IPHONE, OPERA, ANDROID, SAFARI, OPERA_MOBILE, PHANTOMJS})
  // Reason for Chrome: WebKit bug 28804
  @Test
  public void testShouldHandleNonIntegerPositionAndSize() {
    driver.get(pages.rectanglesPage);

    WebElement r2 = driver.findElement(By.id("r2"));
    String left = r2.getCssValue("left");
    assertTrue("left (\"" + left + "\") should start with \"10.9\".", left.startsWith("10.9"));
    String top = r2.getCssValue("top");
    assertTrue("top (\"" + top + "\") should start with \"10.1\".", top.startsWith("10.1"));
    assertEquals(new Point(11, 10), r2.getLocation());
    String width = r2.getCssValue("width");
    assertTrue("width (\"" + left + "\") should start with \"48.6\".", width.startsWith("48.6"));
    String height = r2.getCssValue("height");
    assertTrue("height (\"" + left + "\") should start with \"49.3\".", height.startsWith("49.3"));
    assertEquals(r2.getSize(), new Dimension(49, 49));
  }
Ejemplo n.º 4
0
  @Test
  public void checkLocationAndSizeOfBingSearchBox() {
    WebDriver d = getDriver();
    d.manage().timeouts().pageLoadTimeout(20, TimeUnit.SECONDS);

    d.get("http://www.bing.com");
    WebElement searchBox = d.findElement(By.cssSelector("input[name*='q']"));

    assertTrue(
        searchBox.getCssValue("color").contains("rgb(0, 0, 0)")
            || searchBox.getCssValue("color").contains("rgba(0, 0, 0, 1)"));
    assertEquals("", searchBox.getAttribute("value"));
    assertEquals("input", searchBox.getTagName());
    assertEquals(true, searchBox.isEnabled());
    assertEquals(true, searchBox.isDisplayed());
    assertTrue(searchBox.getLocation().getX() >= 200);
    assertTrue(searchBox.getLocation().getY() >= 100);
    assertTrue(searchBox.getSize().getWidth() >= 350);
    assertTrue(searchBox.getSize().getHeight() >= 20);
  }
Ejemplo n.º 5
0
  @JavascriptEnabled
  @Ignore({ANDROID, IPHONE, OPERA, SELENESE})
  @Test
  public void testShouldAllowInheritedStylesToBeUsed() {
    driver.get(pages.javascriptPage);

    WebElement element = driver.findElement(By.id("green-item"));
    String backgroundColour = element.getCssValue("background-color");

    // TODO: How should this be standardized? Should it be standardized?
    assertThat(backgroundColour, anyOf(equalTo("transparent"), equalTo("rgba(0, 0, 0, 0)")));
  }
Ejemplo n.º 6
0
  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();

    // 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"));
  }
 @Override
 public String getCssValue(WebElement element, String propertyName) {
   return element.getCssValue(propertyName);
 }