Can on help if the internet disconnect wait before throw error

In ios testing
can one help me in java code to wait until connection of internet returned before throw exception of element not found

wow. you have code on some computer where it running and have internet.

now! where you run app:

  • Simulator on same machine where code runs
  • Simulator on other machine
  • real phone with WiFi connection
  • ?

how you check internet connection?

i run app on simulator and real device ios

i check internet by
try {
final URL url = new URL(“”);
final URLConnection conn = url.openConnection();

        return true; 
     catch (IOException e) {
    	 log.error("\n"+"No internet connection on server appium");
			Allure.addAttachment("Internet Connection on server appium", "There is no internet connection on server appium ");
			test.log(Status.FAIL, "There is no internet connection on server appium");
        return false;

the simulator on same device and also the real device connected to same device

all what i need if internet not connected wait until connected and not throw exception of element not found

Maybe easier just wait where it needed for internet connection and continue?

Otherwise you need function that uses By for search elements and will wait first connection with every search and after find element. Last will slow down all.

i mean in the middle of search of elements not before searching , the internet is down >> now i need to wait before throw exception not found element>> i hope you got my point of view

how you looking for element? does try-catch not help you to catch it?

i mean during any step of testing the appium search about element to take action then in the middle of testing , loss of internet connection and test fail, all what i need to wait until connection return before failing the test

it is not possible without creating your own custom search. maybe better right after test fail wait connection and make actions you need?

i will give you example
1-if test step is to click on button a
2-internet connection missed before click on button a
3-appiium throws exception button a not found

all required is to delay the exception of no element found until internet go back

i wish you understand my point of view
if you have any snippet of code to get your solution, i will appreciate it