Example usage for org.openqa.selenium WebElement isEnabled

List of usage examples for org.openqa.selenium WebElement isEnabled

Introduction

In this page you can find the example usage for org.openqa.selenium WebElement isEnabled.

Prototype

boolean isEnabled();

Source Link

Document

Is the element currently enabled or not?

Usage

From source file:org.xwiki.wysiwyg.test.po.EditorElement.java

License:Open Source License

/**
 * Waits for the source text area to have the specified state.
 * /*from w ww .  ja v  a  2s .  co m*/
 * @param enabled whether the source text area should be enabled or disabled
 */
private void waitForSourceTextArea(final boolean enabled) {
    getUtil().waitUntilCondition(new ExpectedCondition<WebElement>() {
        @Override
        public WebElement apply(WebDriver driver) {
            WebElement sourceTextArea = getContainer().findElement(By.className("xPlainTextEditor"));
            return sourceTextArea.isEnabled() == enabled ? sourceTextArea : null;
        }
    });
}

From source file:org.zanata.page.AbstractPage.java

License:Open Source License

private void waitForElementReady(final WebElement element) {
    waitForAMoment().withMessage("Waiting for element to be ready")
            .until((Predicate<WebDriver>) webDriver -> element.isDisplayed() && element.isEnabled());
}

From source file:org.zanata.page.AbstractPage.java

License:Open Source License

private void assertReady(WebElement targetElement) {
    assertThat(targetElement.isDisplayed()).as("displayed").isTrue();
    assertThat(targetElement.isEnabled()).as("enabled").isTrue();
}

From source file:org.zanata.page.administration.TranslationMemoryPage.java

License:Open Source License

public boolean isImportButtonEnabled() {
    WebElement element = existingElement(uploadButton);
    return element.isEnabled();
}

From source file:ru.stqa.selenium.decorated.events.WebDriverListenerTest.java

License:Apache License

@Test
void canFireEventForWebElementIsEnabled() {
    Fixture fixture = new Fixture();

    final WebElement mockedElement = mock(WebElement.class);

    when(fixture.mockedDriver.findElement(By.id("id"))).thenReturn(mockedElement);
    when(mockedElement.isEnabled()).thenReturn(true);

    assertEquals(fixture.driver.findElement(By.id("id")).isEnabled(), true);

    verify(fixture.mockedDriver, times(1)).findElement(By.id("id"));
    verifyNoMoreInteractions(fixture.mockedDriver);
    verify(fixture.listener, times(1)).beforeFindElement(fixture.mockedDriver, By.id("id"));
    verify(fixture.listener, times(1)).afterFindElement(mockedElement, fixture.mockedDriver, By.id("id"));
    verify(mockedElement, times(1)).isEnabled();
    verifyNoMoreInteractions(mockedElement);
    verify(fixture.listener, times(1)).beforeIsEnabled(mockedElement);
    verify(fixture.listener, times(1)).afterIsEnabled(true, mockedElement);
    verifyNoMoreInteractions(fixture.listener);
}

From source file:ru.stqa.selenium.wait.ClientSideImplicitWaitWrapperTest.java

License:Apache License

@Test
public void isEnabledShouldImplicitlyWaitForTheElementToBeVisible() {
    final WebElement mockedElement = mock(WebElement.class);

    when(mockedDriver.findElement(By.name("foo"))).thenReturn(mockedElement);

    when(mockedElement.isEnabled()).thenThrow(ElementNotVisibleException.class)
            .thenThrow(ElementNotVisibleException.class).thenReturn(true);

    boolean selected = driver.findElement(By.name("foo")).isEnabled();

    assertThat(clock.now(), is(200L));/*w w w.  ja va 2 s . com*/
    assertThat(selected, is(true));
    verify(mockedDriver, times(1)).findElement(By.name("foo"));
    verify(mockedElement, times(3)).isEnabled();
}

From source file:ru.stqa.selenium.wait.ClientSideImplicitWaitWrapperTest.java

License:Apache License

@Test
public void isEnabledShouldImplicitlyWaitForTheElementToBeVisibleEvenIfTheElementIsNotEnabled() {
    final WebElement mockedElement = mock(WebElement.class);

    when(mockedDriver.findElement(By.name("foo"))).thenReturn(mockedElement);

    when(mockedElement.isEnabled()).thenThrow(ElementNotVisibleException.class)
            .thenThrow(ElementNotVisibleException.class).thenReturn(false);

    boolean selected = driver.findElement(By.name("foo")).isEnabled();

    assertThat(clock.now(), is(200L));//from w  w w  .  ja  va 2s. c  o  m
    assertThat(selected, is(false));
    verify(mockedDriver, times(1)).findElement(By.name("foo"));
    verify(mockedElement, times(3)).isEnabled();
}

From source file:ru.stqa.selenium.wait.ClientSideImplicitWaitWrapperTest.java

License:Apache License

@Test
public void isEnabledShouldThrowIfTheElementIsNotVisible() {
    final WebElement mockedElement = mock(WebElement.class);

    when(mockedDriver.findElement(By.name("foo"))).thenReturn(mockedElement);

    when(mockedElement.isEnabled()).thenThrow(ElementNotVisibleException.class);

    try {/*from ww w. j a  v a 2 s  .  com*/
        driver.findElement(By.name("foo")).isEnabled();
        fail("Exception expected");
    } catch (Throwable t) {
        assertThat(t, instanceOf(ElementNotVisibleException.class));
    }

    assertThat(clock.now(), is(1000L));
    verify(mockedDriver, times(1)).findElement(By.name("foo"));
    verify(mockedElement, times(11)).isEnabled();
}

From source file:ru.stqa.selenium.wait.ImplicitlyWaitingWebDriverTest.java

License:Apache License

@Test
void isEnabledShouldImplicitlyWaitForTheElementToBeVisible() {
    final WebElement mockedElement = mock(WebElement.class);

    when(mockedDriver.findElement(By.name("foo"))).thenReturn(mockedElement);

    when(mockedElement.isEnabled()).thenThrow(ElementNotVisibleException.class)
            .thenThrow(ElementNotVisibleException.class).thenReturn(true);

    boolean selected = driver.findElement(By.name("foo")).isEnabled();

    assertThat(clock.now(), is(200L));/*w  ww  .  j  av a 2 s .  c  o m*/
    assertThat(selected, is(true));
    verify(mockedDriver, times(1)).findElement(By.name("foo"));
    verify(mockedElement, times(3)).isEnabled();
}

From source file:ru.stqa.selenium.wait.ImplicitlyWaitingWebDriverTest.java

License:Apache License

@Test
void isEnabledShouldImplicitlyWaitForTheElementToBeVisibleEvenIfTheElementIsNotEnabled() {
    final WebElement mockedElement = mock(WebElement.class);

    when(mockedDriver.findElement(By.name("foo"))).thenReturn(mockedElement);

    when(mockedElement.isEnabled()).thenThrow(new ElementNotVisibleException(""))
            .thenThrow(new ElementNotVisibleException("")).thenReturn(false);

    boolean selected = driver.findElement(By.name("foo")).isEnabled();

    assertThat(clock.now(), is(200L));/*from  ww w  . j av a2 s .  com*/
    assertThat(selected, is(false));
    verify(mockedDriver, times(1)).findElement(By.name("foo"));
    verify(mockedElement, times(3)).isEnabled();
}