I am testing a native iOS mobile app using selenium and appium with Java code. As part of my teardown, I have to keep on clicking "back" button until "setting" button appears from where I can logout of the application.
I tried few things using do while but not working. Can anyone help please ?
Try this code may be help you
try {
boolean flag = true;
while(flag) {
WebElement backBtn = driver.findElementByName("back");
backBtn.click();
Thread.sleep(1000);
boolean isFindSettingBtn = driver.findElementsByName("setting").size() !=0;
if(isFindSettingBtn) {
break;
}
}
}catch(Exception e) {
e.printStackTrace();
}