First switch the control to alert pop then accept or dismiss the alert according to your requirement. Then again switch back to main page to perform other operations.

Below are the steps-

WebDriver driver – new FirefoxDriver();
String mainPage = driver.getWindowHandle(); // get the address of main page
Alert alt = driver.switchTo().alert();  //this will switch the control to alert pop-up 
alt.accept(); // to click on OK or to accept the alert pop-up
//alt.dismiss(); // to click on CANCEL
driver.switchTo().window(mainPage); // switch control to main page