The following method can be used to wait until the expected page title appears.
public void waitForPageToLoad(String title){
Integer i = 1;
for(i=1;i<=100;i++) {
if (driver.getTitle().equals(title)) {
break;
}
Thread.sleep(10000);
}
}