Waiting for alert when adding Igtimi account

This commit is contained in:
Steffen Schaefer committed 2017-04-04 08:11:27 +02:00
1 parent 9e1216affc
commit 5ddf50d46f
1 file changed
+19 -1
@@ -1,5 +1,7 @@
package com.sap.sailing.selenium.pages.adminconsole.igtimi;
import org.openqa.selenium.Alert;
import org.openqa.selenium.NoAlertPresentException;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
@@ -35,10 +37,26 @@ public class IgtimiAccountsManagementPanelPO extends PageArea {
return getPO(AddIgtimiAccountDialogPO::new, "AddIgtimiAccountDialog");
}
public void addAccount(String email, String password) {
public void addAccount(String email, String password) throws InterruptedException {
AddIgtimiAccountDialogPO addIgtimiAccountDialog = openAddIgtimiAccountDialog();
addIgtimiAccountDialog.setEmail(email);
addIgtimiAccountDialog.setPassword(password);
addIgtimiAccountDialog.pressOk();
int i = 0;
while (i < DEFAULT_WAIT_TIMEOUT_SECONDS) {
i++;
try {
Alert alert = driver.switchTo().alert();
alert.accept();
break;
} catch (NoAlertPresentException e) {
Thread.sleep(1000);
continue;
}
}
if (i >= DEFAULT_WAIT_TIMEOUT_SECONDS) {
throw new NoAlertPresentException();
}
}
}