'How to avoid type casting while waiting for mobile element?

As a main type I'm using MobileElement, however I need to wait for element.

For explicit wait I'm using:

WebDriverWait wait = new WebDriverWait(driver, 2);

While my Android driver accepts only MobileELement the Expected conditions library requires type casting because of incompatibility of types.

public MobileElement getElement(By id) {
    return (MobileElement) wait.until(ExpectedConditions.visibilityOfElementLocated(id));
}

Is there any solution to avoid type casting or other library for wait purposes?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source