Here when we click on the below element on confirm box will appear with OK and Cancel buttons. After click on any of these two buttons another alert will open with OK button.
driver.FindElement(By.XPath("//div[@id='content']/table/tbody/tr[6]/td[3]/input")).Click();
IAlert alert = driver.SwitchTo().Alert(); // Switching to alert
string firstalert = alert.Text; // Trying to get text from the alert
Console.WriteLine(firstalert); // Display the text on Console
alert.Accept(); // Click on OK Button
// alert.Dismiss(); // Click on Cancel Button
IAlert alert1 = driver.SwitchTo().Alert();
string secondalert = alert1.Text;
Console.WriteLine(secondalert);
alert1.Accept();
driver.FindElement(By.XPath("//div[@id='content']/table/tbody/tr[6]/td[3]/input")).Click();
IAlert alert = driver.SwitchTo().Alert(); // Switching to alert
string firstalert = alert.Text; // Trying to get text from the alert
Console.WriteLine(firstalert); // Display the text on Console
alert.Accept(); // Click on OK Button
// alert.Dismiss(); // Click on Cancel Button
IAlert alert1 = driver.SwitchTo().Alert();
string secondalert = alert1.Text;
Console.WriteLine(secondalert);
alert1.Accept();
No comments:
Post a Comment