Skip to content

Instantly share code, notes, and snippets.

@angelovstanton
Created February 20, 2016 10:46
Show Gist options
  • Save angelovstanton/3298648a0f68c4aa7351 to your computer and use it in GitHub Desktop.
Save angelovstanton/3298648a0f68c4aa7351 to your computer and use it in GitHub Desktop.
[TestMethod]
public void JavaScripPopUps()
{
this.driver.Navigate().GoToUrl(
@"http://www.w3schools.com/js/tryit.asp?filename=tryjs_confirm");
this.driver.SwitchTo().Frame("iframeResult");
IWebElement button = driver.FindElement(By.XPath("/html/body/button"));
button.Click();
IAlert a = driver.SwitchTo().Alert();
if (a.Text.Equals("Press a button!"))
{
a.Accept();
}
else
{
a.Dismiss();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment