Skip to content

Instantly share code, notes, and snippets.

@stuartf7
Created July 4, 2012 16:13
Show Gist options
  • Save stuartf7/3048097 to your computer and use it in GitHub Desktop.
Save stuartf7/3048097 to your computer and use it in GitHub Desktop.
Some More Selenium Tests
[Test]
public void SearchForTest()
{
IWebElement searchbox = _driver.FindElement(By.Name("q"));
searchbox.SendKeys("Test");
searchbox.SendKeys(Keys.Enter); //send [enter] key to the control.
Assert.AreEqual("Test - Google Search", _driver.Title);
}
[Test]
public void SearchForTestAndFindResult()
{
IWebElement searchbox = _driver.FindElement(By.Name("q"));
searchbox.SendKeys("test");
searchbox.SendKeys(Keys.Enter); //send [enter] key to the control.
Assert.IsNotNull(_driver.FindElement(By.LinkText("Test Central")));
}
[Test]
public void SearchForSelenium()
{
IWebElement searchbox = _driver.FindElement(By.Name("q"));
searchbox.SendKeys("Selenium");
searchbox.Submit(); //submits the form that the control is on.
Assert.AreEqual("Selenium - Google Search", _driver.Title);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment