private WebElement findElement(final By locator) {
   (new WebDriverWait(driver, 30, 1000))
       .until(ExpectedConditions.presenceOfElementLocated(locator));
   (new WebDriverWait(driver, 30, 1000))
       .until(ExpectedConditions.visibilityOfElementLocated(locator));
   WebElement element = driver.findElement(locator);
   if (element.isEnabled() == false)
     ((JavascriptExecutor) driver).executeScript("arguments[0].disabled = false", element);
   return element;
 }
Ejemplo n.º 2
0
 @Test
 public void testTextInputShouldNotClearWhenDisabled() {
   driver.get(pages.readOnlyPage);
   try {
     WebElement element = driver.findElement(By.id("textInputnotenabled"));
     assertEquals(false, element.isEnabled());
     element.clear();
     fail("Should not have succeeded");
   } catch (InvalidElementStateException e) {
     // This is expected
   }
 }
Ejemplo n.º 3
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);
  }
 @Override
 public boolean isEnabled(WebElement element) {
   return element.isEnabled();
 }
 private boolean isDisabledField(WebElement webElement) {
   return (isAFormElement(webElement) && (!webElement.isEnabled()));
 }
 @Override
 public boolean isEnabled() {
   return webElement.isEnabled();
 }