# Wait for an element then return true or false

**URL:** <https://discuss.appium.io/t/wait-for-an-element-then-return-true-or-false/33146>\
**Category:** Support\
**Created:** [February 26, 2021, 9:59pm UTC](https://discuss.appium.io/t/wait-for-an-element-then-return-true-or-false/33146 "2021-02-26T21:59:21Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Perkone](https://discuss.appium.io/user_avatar/discuss.appium.io/perkone/32/8433_2.png) [@Perkone](https://discuss.appium.io/u/Perkone)\
**Post date:** [February 26, 2021, 9:59pm UTC](https://discuss.appium.io/t/wait-for-an-element-then-return-true-or-false/33146/1 "2021-02-26T21:59:21Z")

</div>

Hi,  
I have this method which waits for an element

```
    public void waitForElement(MobileElement element) {
    WebDriverWait wait = new WebDriverWait(driver, 30);
            wait.until(ExpectedConditions.visibilityOf(element));
    }

```

This is work. But I need a method to combine with isDisplayed() for an element if it doesn’t appear to return false or true if it appears.

---

<div class="post-metadata">

**Author:** ![Wasif\_Israr](https://discuss.appium.io/user_avatar/discuss.appium.io/wasif_israr/32/9595_2.png) [@Wasif\_Israr](https://discuss.appium.io/u/Wasif_Israr)\
**Post date:** [July 11, 2023, 1:15pm UTC](https://discuss.appium.io/t/wait-for-an-element-then-return-true-or-false/33146/2 "2023-07-11T13:15:24Z")

</div>

Do this:  
public boolean waitForElement(MobileElement element){  
WebElement elementToWaitFor=new WebDriverWait(driver, 30).until(ExpectedConditions.visibilityOf(element));  
return elementToWaitFor.isDisplayed();

```
}
```
