Appium isDisplayed() wait time issue


I’m testing a certain app which relies on clocks.
When I sql inject data to the devices database & let the sync take place the clock could potentially be off by a minute.

Mainly because I don’t know the current seconds counter on the devices clock & the data I inject just creates an offset.

I’ve two methods on which I deal with this.

I pull the clock text being displayed using bounds as it has no ID;

clock = AndroidDevice.androidDriver.findElementByXPath(“//android.widget.TextView[@bounds=‘[15,404][222,519]’]”).getText();

Then I compare it to the expected time with a threshold of 1 or 2 minutes.
So it just compares to the expected or the expected + 1 minute or the expected + 2 minutes.
This approach works most of the time but I’m not sure if the XPath is best way to implement

Also I check text which changes depending on a countdown.
ie; You have 4 hours left, You have 3 hours and 59 minutes left.

The problem here is the text could be in a few places on the screen as the more relevant text that could appear the further down the screen it is displayed.
I use;

assertTrue(AndroidDevice.androidDriver.findElement(By.xpath(“//android.widget.TextView[@text='”+s+“']”)).isDisplayed() ||
AndroidDevice.androidDriver.findElement(By.xpath(“//android.widget.TextView[@text='”+advisorOffset(s, 1)+“']”)).isDisplayed() ||
AndroidDevice.androidDriver.findElement(By.xpath(“//android.widget.TextView[@text='”+advisorOffset(s, 2)+“']”)).isDisplayed());
But the problem with this is with my gradle tests it seems that .isDisplayed() waits for 120seconds then fails,
not entering the second statement where it could of taken a minute to reach this point of the test.

My tests are never off than more than 2 minutes.

Would there be an approach where it would just check if the text is displayed on the screen at the moment it is executes and doesn’t wait the 120seconds then moves on to the next is displayed +1minute of the expected.