Appium clicks on a not visible WebElement

I have an android appium test for my android app.

My app has a webview with loader at start.

I have a link I want to click.
The link should lead to another web-page.

My android appium clicks the link
but because the loader is on foreground and not the link

It seems that appium already clicked the link but the page didn’t change.

Is there a way to check a webElement is on the foreground? or other property I should wait for before clicking?

here is my code:

MyAndroidDriver myAD;


   myAD.changeToWebContext();
        myAD.changeToIFrame(By.name("braintree-dropin-frame"));
        WebElement element = myAD.waitAndGetElementBy(By.id("choose-payment-method"));
        if (element != null) {
            element.click();
            myAD.changeToDefaultIFrame();
            myAD.changeToIFrame(By.name("braintree-dropin-modal-frame"));
            while (myAD.waitAndGetElementBy(By.className("add-payment-method-link")) == null) {
                myAD.changeToDefaultIFrame();
                myAD.changeToIFrame(By.name("braintree-dropin-frame"));
                myAD.waitAndClickElementBy(By.id("choose-payment-method"));
            }
        }
        myAD.changeToNativeContext();

I would recommend you to use WebDriverWait

usage:
WebDriverWait wait = new WebDriverWait(your driver, timeout);
wait.until(ExpectedConditions.visibilityOf( the element you are looking for ))
try not to use while(condition) loop, thats the reason there is a wait object.
if the object is not located on the current view, “NoSuchElementException” is raised.

That what i did. Worked. How can I mark as “answered”?