How can I replace this implicit wait with an explicit one?
driver = new ChromeDriver(capabilities);
driver.manage().deleteAllCookies();>
Using implicit and Explicit waits.
Though we weigh Explicit wait to be more advisable, you should check for the scenario you are catering for.
For example in your code, you are calling the wait just to get the time for the delete call to complete. Which can be improved without using any wait at all.
Set cookies = driver.manage().getCookies();
for(;cookies.size() != 0;){
driver.manage().deleteAllCookies();
}
**You can use While loop i suppose **
Having said that, to use explicit wait. I have used it for taking actions on the pop up, that I get during the app testing.
WebDriverWait wait = new WebDriverWait(appDriver, 10);
wait.until(ExpectedConditions.alertIsPresent());
appDriver.switchTo().alert().dismiss();
So use no wait if you can verify the condition of execution, and use explicit wait when you know what to wait for. Hope this helps a bit.