Based on the original question and the subsequent comments, I suspect what you're dealing with is a browser pop up window and not an alert. So this won't work
driver.switchTo().alert().accept();
You need to use window handles
Set<String> handles = driver.getWindowHandles();
Iterator<String> windows = handles.iterator();
String parent = windows.next();
String child = windows.next();
driver.switchTo().window(child);
driver.findElement(By.xpath("insert xpath to OK button")).click();
driver.switchTo().window(parent);
//continue with steps on parent window
Note: ensure that you add the required synchronization to the code snippet above