package New;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.Alert;
import org.openqa.selenium.NoAlertPresentException;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.testng.annotations.Test;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.AfterClass;
public class PopUps {
WebDriver driver;
Alert alert;
@Test
public void poupup() {
/* switching to alert
* Alert alert=driver.switchTo().alert();
* accepting the alert
alert.accept();
dismissing
alert.dismiss();
authenticating
alert.authenticateUsing(null);*/
try{
alert=driver.switchTo().alert();
}
catch(NoAlertPresentException ex){
ex.printStackTrace();
}
alert.accept();
alert.dismiss();
alert.authenticateUsing(null);
}
@BeforeClass
public void beforeClass() {
driver = new FirefoxDriver();
driver.manage().window().maximize();
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
}
@AfterClass
public void afterClass() {
driver.quit();
}
}
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.Alert;
import org.openqa.selenium.NoAlertPresentException;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.testng.annotations.Test;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.AfterClass;
public class PopUps {
WebDriver driver;
Alert alert;
@Test
public void poupup() {
/* switching to alert
* Alert alert=driver.switchTo().alert();
* accepting the alert
alert.accept();
dismissing
alert.dismiss();
authenticating
alert.authenticateUsing(null);*/
try{
alert=driver.switchTo().alert();
}
catch(NoAlertPresentException ex){
ex.printStackTrace();
}
alert.accept();
alert.dismiss();
alert.authenticateUsing(null);
}
@BeforeClass
public void beforeClass() {
driver = new FirefoxDriver();
driver.manage().window().maximize();
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
}
@AfterClass
public void afterClass() {
driver.quit();
}
}
No comments:
Post a Comment