package Streams;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;

public class Alerts {

    public static void main(String[] args) {
        WebDriver obj = new FirefoxDriver();

        obj.get("https://rahulshettyacademy.com/AutomationPractice/");

        WebElement alertButton= obj.findElement(By.id("alertbtn"));

        alertButton.click();

        // now switch from window to alert for handle.


        obj.switchTo().alert().accept();



        // now click on confirm button
        WebElement confirmButton = obj.findElement(By.id("confirmbtn"));
        confirmButton.click();

        obj.switchTo().alert().dismiss();
    }

}
