Difference between revisions of "Using Selenium in C Sharp"
Jump to navigation
Jump to search
PeterHarding (talk | contribs) (Created page with '=Examples= <pre> * using Microsoft.VisualStudio.TestTools.UnitTesting; using Selenium; [TestClass] public class SeleniumTest { private DefaultSelenium _firefox; [Clas...') |
PeterHarding (talk | contribs) m (moved Using Selenium in C to Using Selenium in C Sharp: It should actually be C#) |
||
(2 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
=Examples= | =Examples= | ||
Windows based Visual Studio Dot.NET examples... | |||
<pre> | <pre> |
Latest revision as of 11:59, 4 January 2012
Examples
Windows based Visual Studio Dot.NET examples...
* using Microsoft.VisualStudio.TestTools.UnitTesting; using Selenium; [TestClass] public class SeleniumTest { private DefaultSelenium _firefox; [ClassInitialize] public void StartSelenium(TestContext testContext) { this._firefox = new DefaultSelenium("localhost", 4444, @"*firefox", "http://localhost:4444"); this._firefox.Start(); } [TestMethod] public void GoogleTest() { bool hasText; this._firefox.Open("http://www.google.com"); this._firefox.Type("name=q", "Dixin"); this._firefox.Click("name=btnG"); this._firefox.WaitForPageToLoad("10000"); hasText = this._firefox.IsTextPresent("Dixin"); Assert.IsTrue(hasText, @"The search result does not contain text ""Dixin""."); } [TestCleanup] public void CloseBrowser() { this._firefox.Close(); } [ClassCleanup] public void StopSelenium() { this._firefox.Stop(); } }