summaryrefslogtreecommitdiff
path: root/src/main/java/com/mavlushechka/a1qa/driverUtils/AlertUtils.java
blob: 8095365a747b8ad491dec2e57bdc2fdb4e6361f4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
package com.mavlushechka.a1qa.driverUtils;

import org.openqa.selenium.Alert;
import org.openqa.selenium.support.ui.ExpectedConditions;

public class AlertUtils {

    private AlertUtils() {
    }

    public static boolean isAlertPresent() {
        return ExpectedConditions.alertIsPresent().apply(WebDriverSingleton.getInstance()) != null;
    }

    public static String getAlertText() {
        return findAlert().getText();
    }

    public static void sendKeysToAlert(String keysToSend) {
        findAlert().sendKeys(keysToSend);
    }

    public static void acceptAlert() {
        findAlert().accept();
    }

    private static Alert findAlert() {
        return WebDriverWaitFactory.createWebDriverWait().until(ExpectedConditions.alertIsPresent());
    }

}