Skip to content

Instantly share code, notes, and snippets.

@nadvolod
Created April 18, 2016 00:02
Show Gist options
  • Save nadvolod/22622da95e405d38482ccf345eb9f479 to your computer and use it in GitHub Desktop.
Save nadvolod/22622da95e405d38482ccf345eb9f479 to your computer and use it in GitHub Desktop.
Simple automated functional test that attempts to interact with an element that does not yet exist on the page
public class UnitTest1
{
private IWebDriver _driver;
[TestInitialize]
public void Setup()
{
//LocalInitialize();
BasicInitialize();
}
private void BasicInitialize()
{
_driver = new FirefoxDriver();
_driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(1));
}
[TestCleanup]
public void Teardown()
{
_driver.Close();
_driver.Quit();
}
[TestMethod]
public void DynamicallyLoadingElementsTestFailure()
{
//go to a url that contains a dynamically loading page element
_driver.Navigate().GoToUrl("https://the-internet.herokuapp.com/dynamic_loading/1");
//click the start button
_driver.FindElement(By.Id("start")).Click();
//find the element that has the text Hello World
var text = _driver.FindElement(By.XPath(".//*[contains(text(),'Hello World!')]"));
//click on the text
text.Click();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment