How to work with Alert using Selenium WebDriver ? - Source Code June 28, 2020 Get link Facebook Twitter Pinterest Email Other Apps package practice; import org.openqa.selenium.Alert; import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.chrome.ChromeDriver; public class AlertExample { public static void main(String[] args) { System.setProperty("webdriver.chrome.driver", "D:\\drivers\\chromedriver.exe"); WebDriver driver = new ChromeDriver(); // To Start Chrome Browser //To Open URL driver.get("https://www.magneticautomation.in/2019/01/alert-example.html"); //For Clicking driver.findElement(By.xpath("//*[@id=\"post-body-5405753133268992336\"]/div/button[3]")).click(); Alert a = driver.switchTo().alert(); //For focusing on Alert //For printing text of Alert System.out.println(a.getText()); //For typing in Alert's input field a.sendKeys("Google"); //a.accept(); // Pressing OK a.dismiss(); // Pressing on Cancel } } Comments aaronnssdJanuary 23, 2021 at 5:25 PMIt is truly a well-researched content and excellent wording. I got so engaged in this material that I couldn’t wait to read. I am impressed with your work and skill. Thanks.responsive lightbox by dfactoryReplyDeleteRepliesReplyseoprofessionalJanuary 27, 2021 at 11:39 PMNice informative content. I enrolled for selenium online training Hyderabad programm and learn many things about this toolReplyDeleteRepliesReplyAdd commentLoad more... Post a Comment
It is truly a well-researched content and excellent wording. I got so engaged in this material that I couldn’t wait to read. I am impressed with your work and skill. Thanks.responsive lightbox by dfactory
ReplyDeleteNice informative content. I enrolled for selenium online training Hyderabad programm and learn many things about this tool
ReplyDelete