Created
January 4, 2012 06:46
-
-
Save tarun3kumar/1558847 to your computer and use it in GitHub Desktop.
Selenium C# test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Text; | |
using System.Text.RegularExpressions; | |
using System.Threading; | |
using NUnit.Framework; | |
using Selenium; | |
namespace SeleniumTests | |
{ | |
[TestFixture] | |
public class NewTest | |
{ | |
private ISelenium selenium; | |
private StringBuilder verificationErrors; | |
[SetUp] | |
public void SetupTest() | |
{ | |
selenium = new DefaultSelenium("localhost", 4444, "*iehta", | |
"http://www.google.com/"); | |
selenium.Start(); | |
verificationErrors = new StringBuilder(); | |
} | |
[TearDown] | |
public void TeardownTest() | |
{ | |
try | |
{ | |
selenium.Stop(); | |
} | |
catch (Exception) | |
{ | |
// Ignore errors if unable to close the browser | |
} | |
Assert.AreEqual("", verificationErrors.ToString()); | |
} | |
[Test] | |
public void TheNewTest() | |
{ | |
selenium.Open("http://www.google.com/"); | |
Assert.AreEqual("Google", selenium.GetTitle()); | |
selenium.Type("q", "Selenium OpenQA"); | |
Assert.AreEqual("Selenium OpenQA", selenium.GetValue("q")); | |
selenium.Click("btnG"); | |
selenium.WaitForPageToLoad("5000"); | |
Assert.IsTrue(selenium.IsTextPresent("www.openqa.org")); | |
Assert.AreEqual("Selenium OpenQA - Google Search", | |
selenium.GetTitle()); | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Text; | |
using System.Text.RegularExpressions; | |
using System.Threading; | |
using NUnit.Framework; | |
using Selenium; | |
namespace SeleniumTests | |
{ | |
[TestFixture] | |
public class NewTest | |
{ | |
private ISelenium selenium; | |
private StringBuilder verificationErrors; | |
[SetUp] | |
public void SetupTest() | |
{ | |
selenium = new DefaultSelenium("localhost", 4444, "*iehta", | |
"http://www.google.com/"); | |
selenium.Start(); | |
verificationErrors = new StringBuilder(); | |
} | |
[TearDown] | |
public void TeardownTest() | |
{ | |
try | |
{ | |
selenium.Stop(); | |
} | |
catch (Exception) | |
{ | |
// Ignore errors if unable to close the browser | |
} | |
Assert.AreEqual("", verificationErrors.ToString()); | |
} | |
[Test] | |
public void TheNewTest() | |
{ | |
selenium.Open("http://www.google.com/"); | |
Assert.AreEqual("Google", selenium.GetTitle()); | |
selenium.Type("q", "Selenium OpenQA"); | |
Assert.AreEqual("Selenium OpenQA", selenium.GetValue("q")); | |
selenium.Click("btnG"); | |
selenium.WaitForPageToLoad("5000"); | |
Assert.IsTrue(selenium.IsTextPresent("www.openqa.org")); | |
Assert.AreEqual("Selenium OpenQA - Google Search", | |
selenium.GetTitle()); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment