How to handle the driver.findElementByName() deprecattion

Look here:

Actually I do not use accessibilityID (only returns cont-desc for me) or xpath.

I use: (where typeSearch is “text” in simpler case)

public WebElement waitForTextwithType(String value, String typeSearch) throws Exception {
    try {
        String query = "new UiSelector()." + typeSearch + "(\"" + value + "\")";
        return fluentWait45.until(webDriver -> ((AndroidDriver) localDriver).findElementByAndroidUIAutomator(query));
    } catch (Exception ex) {
        throw new Exception(String.format(ERROR_MESSAGE_TEXT_NOT_FOUND, value));
    }
}
1 Like