package com.seleniumpractice;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.Alert;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.interactions.Actions;
public class AltertDemo {
public static void main(String[] args) throws InterruptedException {
System.setProperty("webdriver.chrome.driver","C:\\Users\\admin\\Desktop\\Selenium_software\\chromedriver.exe");
WebDriver driver=new ChromeDriver();
driver.get("https://artoftesting.com/sampleSiteForSelenium");
driver.manage().window().maximize();
driver.manage().timeouts().implicitlyWait(20,TimeUnit.SECONDS);
WebElement ele=driver.findElement(By.id("dblClkBtn"));
Actions act=new Actions(driver);
act.doubleClick(ele).perform();
Alert alt=driver.switchTo().alert();
Thread.sleep(2000);
String actualstr=alt.getText();
System.out.println("String value..."+actualstr);
String expStr="Hi! Art Of Testing, Here!";
if(actualstr.equals(expStr)){
alt.accept();
System.out.println("Test case pased");
}
else {
System.out.println("Test case failed");
}
//alt.accept();
//driver.close();
}
}
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.Alert;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.interactions.Actions;
public class AltertDemo {
public static void main(String[] args) throws InterruptedException {
System.setProperty("webdriver.chrome.driver","C:\\Users\\admin\\Desktop\\Selenium_software\\chromedriver.exe");
WebDriver driver=new ChromeDriver();
driver.get("https://artoftesting.com/sampleSiteForSelenium");
driver.manage().window().maximize();
driver.manage().timeouts().implicitlyWait(20,TimeUnit.SECONDS);
WebElement ele=driver.findElement(By.id("dblClkBtn"));
Actions act=new Actions(driver);
act.doubleClick(ele).perform();
Alert alt=driver.switchTo().alert();
Thread.sleep(2000);
String actualstr=alt.getText();
System.out.println("String value..."+actualstr);
String expStr="Hi! Art Of Testing, Here!";
if(actualstr.equals(expStr)){
alt.accept();
System.out.println("Test case pased");
}
else {
System.out.println("Test case failed");
}
//alt.accept();
//driver.close();
}
}
========================================================================
No comments:
Post a Comment