Example usage for org.openqa.selenium WebElement isDisplayed

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

Introduction

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

Prototype

boolean isDisplayed();

Source Link

Document

Is this element displayed or not?

Usage

From source file:io.selendroid.client.waiter.WaitingConditions.java

License:Apache License

public static Callable<Boolean> elementToBeHidden(final WebElement element) {
    return new Callable<Boolean>() {
        public Boolean call() throws Exception {
            try {
                return !element.isDisplayed();
            } catch (StaleElementReferenceException e) {
                return true;
            }/*from www  . j a  v a2  s. c  o  m*/
        }
    };
}

From source file:io.selendroid.nativetests.NativeElementFindingTest.java

License:Apache License

@Test()
public void shouldFindInvisibleElemenById() throws Exception {
    openStartActivity();/*from w  w  w.j av  a 2 s  .  c o  m*/
    WebElement textview = driver().findElement(By.id("visibleTextView"));
    boolean isTextViewDisplayed = textview.isDisplayed();
    driver().findElement(By.id("visibleButtonTest")).click();
    Assert.assertEquals(textview.isDisplayed(), !isTextViewDisplayed);
    Assert.assertEquals(textview.getAttribute("shown"), String.valueOf(!isTextViewDisplayed));
}

From source file:io.selendroid.nativetests.NativeElementFindingTest.java

License:Apache License

@Test()
public void shouldFindInvisibleElemenByText() throws Exception {
    openStartActivity();//from   w  ww.  j  a va  2 s  . c om
    WebElement textview = driver().findElement(By.linkText("Text is sometimes displayed"));
    Assert.assertEquals(textview.isDisplayed(), false);
    driver().findElement(By.id("visibleButtonTest")).click();
    Thread.sleep(1000);
    Assert.assertEquals(textview.isDisplayed(), true);
}

From source file:io.selendroid.nativetests.NativeElementInteractionTest.java

License:Apache License

@Test
public void shouldGetDisplayedStateOfElement() {
    openStartActivity();/*  www  .j ava 2 s  . c o m*/
    WebElement button = driver().findElement(By.id("waitingButtonTest"));
    Assert.assertEquals(button.isDisplayed(), true);
}

From source file:io.selendroid.webviewdrivertests.WebElementInteractionTest.java

License:Apache License

@Test
public void shouldGetDisplayedStateOfElement() {
    givenWebViewWithFormPageLoaded();/*w  ww. j a  v a  2  s  .co  m*/

    WebElement element = driver().findElement(By.id("checky"));
    Assert.assertEquals(element.isDisplayed(), true);
}

From source file:io.tourniquet.pageobjects.PageLoaderTest.java

License:Apache License

@Test
public void testAbstractPage_Click() throws Exception {
    //prepare/*w  w w  .  j a  va  2  s .  c o m*/
    new SeleniumContext(() -> webDriver).init();
    WebElement element = mock(WebElement.class);
    when(webDriver.findElement(By.id("someButton"))).thenReturn(element);
    when(element.isDisplayed()).thenReturn(true);

    //act
    AbstractPage page = PageLoader.loadPage(AbstractPage.class);

    //assert
    assertNotNull(page);
    WebElement e = page.pressButton();
    verify(element).click();
    assertNotNull(e);
    assertEquals(element, e);
    assertEquals("testpage", page.toString());
}

From source file:io.tourniquet.pageobjects.PageLoaderTest.java

License:Apache License

@Test
public void testAbstractPage_SubmitForm() throws Exception {
    //prepare//w ww  .jav  a 2 s .  c o  m
    new SeleniumContext(() -> webDriver).init();
    WebElement element = mock(WebElement.class);
    when(webDriver.findElement(By.id("someForm"))).thenReturn(element);
    when(element.isDisplayed()).thenReturn(true);
    when(element.getTagName()).thenReturn("form");

    //act
    AbstractPage page = PageLoader.loadPage(AbstractPage.class);

    //assert
    assertNotNull(page);
    page.submitForm();
    verify(element).submit();
    assertEquals("testpage", page.toString());
}

From source file:io.tourniquet.pageobjects.PageLoaderTest.java

License:Apache License

@Test
public void testAbstractPage_sendKeys() throws Exception {
    //prepare//from w  ww . j  a  va 2  s.  com
    new SeleniumContext(() -> webDriver).init();
    WebElement element = mock(WebElement.class);
    when(webDriver.findElement(By.id("someInput"))).thenReturn(element);
    when(element.isDisplayed()).thenReturn(true);

    //act
    AbstractPage page = PageLoader.loadPage(AbstractPage.class);

    //assert
    assertNotNull(page);
    AbstractPage fluentPage = page.enterValue("text");
    verify(element).clear();
    verify(element).sendKeys("text");
    assertNotNull(fluentPage);
    assertEquals(page, fluentPage);
    assertEquals("testpage", fluentPage.toString());
}

From source file:io.tourniquet.pageobjects.PageLoaderTest.java

License:Apache License

@Test(expected = IllegalArgumentException.class)
public void testAbstractPage_twoManyArgs() throws Exception {
    //prepare/*from   w w w .  j  a  v a  2  s .c o  m*/
    new SeleniumContext(() -> webDriver).init();
    WebElement element = mock(WebElement.class);
    when(webDriver.findElement(By.id("someInput"))).thenReturn(element);
    when(element.isDisplayed()).thenReturn(true);

    //act
    AbstractPage page = PageLoader.loadPage(AbstractPage.class);

    //assert
    assertNotNull(page);
    //this method is not supported
    page.twoParamsMethod("text", "2ndParam");
}

From source file:io.tourniquet.pageobjects.PageObjectsInjectorTest.java

License:Apache License

@Test
public void testAbstractGroup_Click() throws Exception {
    //prepare//www .  j  a v a  2s  .  c  om
    new SeleniumContext(() -> driver).init();
    WebElement element = mock(WebElement.class);
    when(driver.findElement(By.id("someButton"))).thenReturn(element);
    when(element.isDisplayed()).thenReturn(true);
    GroupWithAbstractSubgroup group = new GroupWithAbstractSubgroup();

    //act
    PageObjectsInjector.injectFields(group);

    //assert
    assertNotNull(group.subgroup);
    WebElement e = group.subgroup.pressButton();
    verify(element).click();
    assertNotNull(e);
    assertEquals(element, e);
    assertEquals("testpage", group.subgroup.toString());
}